mozilla-kde.patch
changeset 994 9fc447b00040
parent 985 038d048a3940
child 999 932b3ad009d5
--- a/mozilla-kde.patch	Sun Sep 17 10:06:24 2017 +0200
+++ b/mozilla-kde.patch	Wed Sep 20 21:52:01 2017 +0200
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent  172cd661ceed38b3161c6246f6729f4d8370dce3
+# Parent  faadbf89d1cb02eefec4c5dfd3ab86bc20d815d5
 Description: Add KDE integration to Firefox (toolkit parts)
 Author: Wolfgang Rosenauer <wolfgang@rosenauer.org>
 Author: Lubos Lunak <lunak@suse.com>
@@ -9,7 +9,7 @@
 diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp
 --- a/modules/libpref/Preferences.cpp
 +++ b/modules/libpref/Preferences.cpp
-@@ -32,16 +32,17 @@
+@@ -33,16 +33,17 @@
  #include "nsIZipReader.h"
  #include "nsPrefBranch.h"
  #include "nsXPIDLString.h"
@@ -27,7 +27,7 @@
  #include "prefread.h"
  #include "prefapi_private_data.h"
  
-@@ -1219,16 +1220,34 @@ pref_LoadPrefsInDir(nsIFile* aDir, char 
+@@ -1435,16 +1436,34 @@ pref_LoadPrefsInDir(nsIFile* aDir, char 
  
  static nsresult pref_LoadPrefsInDirList(const char *listId)
  {
@@ -62,7 +62,7 @@
      return NS_OK;
  
    bool hasMore;
-@@ -1244,17 +1263,17 @@ static nsresult pref_LoadPrefsInDirList(
+@@ -1460,17 +1479,17 @@ static nsresult pref_LoadPrefsInDirList(
  
      nsAutoCString leaf;
      path->GetNativeLeafName(leaf);
@@ -81,7 +81,7 @@
  {
    nsZipItemPtr<char> manifest(jarReader, name, true);
    NS_ENSURE_TRUE(manifest.Buffer(), NS_ERROR_NOT_AVAILABLE);
-@@ -1348,24 +1367,36 @@ static nsresult pref_InitInitialObjects(
+@@ -1566,24 +1585,36 @@ pref_InitInitialObjects()
    /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
    static const char* specialFiles[] = {
  #if defined(XP_MACOSX)
@@ -706,7 +706,7 @@
 new file mode 100644
 --- /dev/null
 +++ b/toolkit/content/widgets/preferences-kde.xml
-@@ -0,0 +1,1380 @@
+@@ -0,0 +1,1409 @@
 +<?xml version="1.0"?>
 +
 +<!DOCTYPE bindings [
@@ -742,19 +742,19 @@
 +      <method name="_constructAfterChildren">
 +      <body>
 +      <![CDATA[
-+      // This method will be called after each one of the child
++      // This method will be called after the last of the child
 +      // <preference> elements is constructed. Its purpose is to propagate
-+      // the values to the associated form elements
++      // the values to the associated form elements. Sometimes the code for
++      // some <preference> initializers depend on other <preference> elements
++      // being initialized so we wait and call updateElements on all of them
++      // once the last one has been constructed. See bugs 997570 and 992185.
 +
 +      var elements = this.getElementsByTagName("preference");
 +      for (let element of elements) {
-+        if (!element._constructed) {
-+          return;
-+        }
-+      }
-+      for (let element of elements) {
 +        element.updateElements();
 +      }
++
++      this._constructAfterChildrenCalled = true;
 +      ]]>
 +      </body>
 +      </method>
@@ -821,6 +821,25 @@
 +          ]]>
 +        </getter>
 +      </property>
++
++      <!-- We want to call _constructAfterChildren after all child
++           <preference> elements have been constructed. To do this, we get
++           and store the node list of all child <preference> elements in the
++           constructor, and maintain a count which is incremented in the
++           constructor of <preference>. _constructAfterChildren is called
++           when the count matches the length of the list. -->
++      <field name="_constructedChildrenCount">0</field>
++      <field name="_preferenceChildren">null</field>
++      <!-- Some <preference> elements are added dynamically after
++           _constructAfterChildren has already been called - we want to
++           avoid looping over all of them again in this case so we remember
++           if we already called it. -->
++      <field name="_constructAfterChildrenCalled">false</field>
++      <constructor>
++      <![CDATA[
++        this._preferenceChildren = this.getElementsByTagName("preference");
++      ]]>
++      </constructor>
 +    </implementation>
 +  </binding>
 +
@@ -828,8 +847,6 @@
 +    <implementation>
 +      <constructor>
 +      <![CDATA[
-+        this._constructed = true;
-+
 +        // if the element has been inserted without the name attribute set,
 +        // we have nothing to do here
 +        if (!this.name)
@@ -862,9 +879,21 @@
 +
 +          // Don't use the value setter here, we don't want updateElements to be prematurely fired.
 +          this._value = preference ? preference.value : this.valueFromPreferences;
-+        } else
++        } else {
 +          this._value = this.valueFromPreferences;
-+        this.preferences._constructAfterChildren();
++        }
++        if (this.preferences._constructAfterChildrenCalled) {
++          // This <preference> was added after _constructAfterChildren() was already called.
++          // We can directly call updateElements().
++          this.updateElements();
++          return;
++        }
++        this.preferences._constructedChildrenCount++;
++        if (this.preferences._constructedChildrenCount ==
++            this.preferences._preferenceChildren.length) {
++          // This is the last <preference>, time to updateElements() on all of them.
++          this.preferences._constructAfterChildren();
++        }
 +      ]]>
 +      </constructor>
 +      <destructor>
@@ -2090,7 +2119,7 @@
 diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js
 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
 +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
-@@ -625,17 +625,17 @@ nsUnknownContentTypeDialog.prototype = {
+@@ -628,17 +628,17 @@ nsUnknownContentTypeDialog.prototype = {
        else
          typeString = mimeInfo.MIMEType;
      }
@@ -2109,7 +2138,7 @@
    },
  
    // Returns true if opening the default application makes sense.
-@@ -799,17 +799,17 @@ nsUnknownContentTypeDialog.prototype = {
+@@ -802,17 +802,17 @@ nsUnknownContentTypeDialog.prototype = {
        switch (this.dialogElement("openHandler").selectedIndex) {
        case 0:
          // No app need be specified in this case.
@@ -2128,15 +2157,15 @@
      this.mDialog.document.documentElement.getButton("accept").disabled = !ok;
    },
  
-@@ -1066,30 +1066,56 @@ nsUnknownContentTypeDialog.prototype = {
+@@ -1067,30 +1067,57 @@ nsUnknownContentTypeDialog.prototype = {
+ 
+       if (params.handlerApp &&
            params.handlerApp.executable &&
            params.handlerApp.executable.isFile()) {
          // Remember the file they chose to run.
          this.chosenApp = params.handlerApp;
        }
-     }
-     else {
- #if MOZ_WIDGET_GTK == 3
+     } else if ("@mozilla.org/applicationchooser;1" in Components.classes) {
 -      var nsIApplicationChooser = Components.interfaces.nsIApplicationChooser;
 -      var appChooser = Components.classes["@mozilla.org/applicationchooser;1"]
 -                                 .createInstance(nsIApplicationChooser);
@@ -2147,7 +2176,8 @@
 -           contentTypeDialogObj.chosenApp = aResult.QueryInterface(Components.interfaces.nsILocalHandlerApp);
 +      // handle the KDE case which is implemented in the filepicker
 +      // therefore falling back to Gtk2 like behaviour if KDE is running
-+      // FIXME this should be better handled in the nsIApplicationChooser interface
++      // FIXME this should be better handled in the nsIApplicationChooser
++      // interface
 +      var env = Components.classes["@mozilla.org/process/environment;1"]
 +                          .getService(Components.interfaces.nsIEnvironment);
 +      if (env.get('KDE_FULL_SESSION') == "true")
@@ -2190,7 +2220,7 @@
 +        // The finishChooseApp is called from appChooserCallback
 +        return;
 +      }
- #else
+     } else {
        var nsIFilePicker = Components.interfaces.nsIFilePicker;
        var fp = Components.classes["@mozilla.org/filepicker;1"]
                           .createInstance(nsIFilePicker);