bug 451187 — <preferences> element should work outside of a <prefwindow>
authorDaniel Brooks <db48x@db48x.net>
Thu, 09 Oct 2008 18:14:17 -0500
changeset 20231 3fe2918df5333703987b30634ea54d2a90354c6c
parent 20229 6251e69516c9280e9e057c106f5cd6178aedecbd
child 20232 d85c83763479773c880bf09e86db6f1f82761416
push idunknown
push userunknown
push dateunknown
bugs451187
milestone1.9.1b2pre
bug 451187 — <preferences> element should work outside of a <prefwindow>
toolkit/content/widgets/preferences.xml
--- a/toolkit/content/widgets/preferences.xml
+++ b/toolkit/content/widgets/preferences.xml
@@ -68,16 +68,32 @@
       </field>
       <field name="defaultBranch">
         this.service.getDefaultBranch("");
       </field>
       <field name="rootBranchInternal">
         Components.classes["@mozilla.org/preferences-service;1"]
                   .getService(Components.interfaces.nsIPrefBranchInternal);
       </field>
+      <property name="type" readonly="true">
+        <getter>
+          <![CDATA[
+            var doc = document.documentElement;
+            return doc.type || "";
+          ]]>
+        </getter>
+      </property>
+      <property name="instantApply" readonly="true">
+        <getter>
+          <![CDATA[
+            var doc = document.documentElement;
+            return doc.instantApply || this.rootBranch.getBoolPref("browser.preferences.instantApply");
+          ]]>
+        </getter>
+      </property>
     </implementation>
   </binding>
 
   <binding id="preference">
     <implementation>
       <constructor>
       <![CDATA[
         // if the element has been inserted without the name attribute set,
@@ -85,17 +101,17 @@
         if (!this.name)
           return;
 
         this.preferences.rootBranchInternal
             .addObserver(this.name, this.preferences, false);
         // In non-instant apply mode, we must try and use the last saved state
         // from any previous opens of a child dialog instead of the value from
         // preferences, to pick up any edits a user may have made. 
-        if (document.documentElement.type == "child" && 
+        if (this.preferences.type == "child" && 
             !this.instantApply && window.opener) {
           var pdoc = window.opener.document;
 
           // Try to find a preference element for the same preference.
           var preference = null;
           var parentPreferences = pdoc.getElementsByTagName("preferences");
           for (var k = 0; (k < parentPreferences.length && !preference); ++k) {
             var parentPrefs = parentPreferences[k]
@@ -114,17 +130,17 @@
       </constructor>
       <destructor>
         this.preferences.rootBranchInternal
             .removeObserver(this.name, this.preferences);
       </destructor>
       
       <property name="instantApply">
         <getter>
-          return this.getAttribute("instantApply") == "true" || document.documentElement.instantApply;
+          return this.getAttribute("instantApply") == "true" || this.preferences.instantApply;
         </getter>
       </property>
 
       <property name="preferences" onget="return this.parentNode"/>
       <property name="name" onget="return this.getAttribute('name');">
         <setter>
           if (val == this.name)
             return val;