[patch] for per-domain settings

Leo Savernik l.savernik at aon.at
Sun Oct 20 21:01:16 BST 2002


http://bugs.kde.org/attachment.cgi?id=229&action=view
first patch, khtml side only 

This patch modifies khtml_settings.{cc,h} and ecma/kjs_window.cpp so that 
khtml 
correctly reads and interprets global as well as per-domain settings. 

I introduced a new KPerDomainSettings struct which contains all per-domain 
settings. One object is directly embedded in KHTMLSettingsPrivate serving as 
default (global domain) whereas the others are inserted into the domainPolicy 
map as specified by the configuration. 

setup_per_domain_policy serves as a KPerDomainSettings constructor for the 
legacy keys JavaScriptAdvice, ECMADomainSettings and JavaDomainSettings. It 
returns an existing domain policy or creates a new one by inheriting from the 
global domain. 

readDomainSettings reads the settings of the given domain from the config file 
and writes them into the relevant domain policy. The global domain policy will 
also be set from this method, when the global parameter is true. This method 
takes care of inheriting from the global domain or in case of the global 
domain, using the hardcoded default, if the key does not exist. That means 
that 
all domain policies are fully initialized after reading and all values 
computed. No more inheriting needs to be done when a domain policy is queried 
later on. 

init now uses readDomainSettings to initialize the global domain as well as 
all 
domains given under the new key DomainSettings. It also handles legacy keys, 
but I still haven't tested them, so don't trust that code yet. DomainSettings 
is a simple string list, containing nothing but domain names. 

I extended lookup_hostname_policy to return KPerDomainSettings references 
instead of simple boolean values. The handling remains the same, though I 
optimized lookup a bit by using iterators wherever possible. 

The new getters are: 
KJSWindowVVVPolicy windowVVVPolicy(const QString &hostname=QString::null) 
const 

where VVV is one of Open, Resize, Move, Focus, Status. 
They simply return the requested member from the appropriate domain policy. 

I also adapted the implementations for isJavaEnabled, isJavaScriptEnabled, 
isPluginsEnabled and noticed that they'd better be const, but refrained from 
changing it for not breaking BC. 

Well, within kjs_window.cpp I inserted the relevant queries to the settings 
object. The code's obvious so no need to dwell upon it. 

Btw, I also implemented per-domain handling of isJavaEnabled and 
isPluginsEnabled; it would have been harder to ignore than to implement ;-) 

I used enums for the policies and each enum contains a KJSWindowVVVInherit=-1. 
This value is nowhere needed now and intended to be used within the kcontrol 
module. 

A little problem are the bitfields in KPerDomainSettings. g++ insists that 
bitfields are signed, thus returning -1 for 3 in KJSWindowOpenPolicy, for 
example. I inserted a small hack to circumvent this (the other locations 
happen 
to work fine because I always test for equality to 0). If anyone has a cleaner 
idea, please tell me. 

This patch is not intended to be included within KDE, and serves merely a 
draft 
ready to be commented upon.

mfg
	Leo





More information about the kfm-devel mailing list