[Pkg-mozext-commits] [tabmixplus] 18/23: Update compatibility with TreeStyleTab extension version 0.16.2016021602

David Prévot taffit at moszumanska.debian.org
Wed Feb 17 18:34:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 74103a6d337808822461076d0936b9902103ee51
Author: onemen <tabmix.onemen at gmail.com>
Date:   Tue Feb 16 19:06:45 2016 +0200

    Update compatibility with TreeStyleTab extension version 0.16.2016021602
---
 chrome/content/extensions/extensions.js | 86 +++++++++++++++++++++------------
 modules/Places.jsm                      | 23 ++++++---
 2 files changed, 70 insertions(+), 39 deletions(-)

diff --git a/chrome/content/extensions/extensions.js b/chrome/content/extensions/extensions.js
index 347754c..5e94150 100644
--- a/chrome/content/extensions/extensions.js
+++ b/chrome/content/extensions/extensions.js
@@ -569,7 +569,8 @@ TMP_extensionsCompatibility.treeStyleTab = {
   errorMsg: "Error in Tabmix when trying to load compatible functions with TreeStyleTab extension",
 
   preInit: function() {
-    if (typeof TreeStyleTabWindowHelper.overrideExtensionsPreInit == "function") {
+    let tstHelper = TreeStyleTabWindowHelper;
+    if (typeof tstHelper.overrideExtensionsPreInit == "function") {
       // overrideExtensionsPreInit look for 'gBrowser.restoreTab' in tablib.init
       tablib._init = tablib.init;
       tablib.init = function() {
@@ -580,6 +581,26 @@ TMP_extensionsCompatibility.treeStyleTab = {
          */
       };
     }
+
+    // run our initialization function before TreeStyleTab functions:
+    // preInit and onBeforeBrowserInit
+    if (typeof tstHelper.preInit == "function") {
+      Tabmix.originalFunctions.tstHelper_preInit = tstHelper.preInit;
+      tstHelper.preInit = function() {
+        TMP_eventListener._onLoad("DOMContentLoaded");
+        let method = Tabmix.originalFunctions.tstHelper_preInit;
+        method.apply(this, arguments);
+      };
+    }
+
+    if (typeof tstHelper.onBeforeBrowserInit == "function") {
+      Tabmix.originalFunctions.tstHelper_onBeforeBrowserInit = tstHelper.onBeforeBrowserInit;
+      tstHelper.onBeforeBrowserInit = function() {
+        TMP_eventListener._onLoad("load");
+        let method = Tabmix.originalFunctions.tstHelper_onBeforeBrowserInit;
+        method.apply(this, arguments);
+      };
+    }
   },
 
   onContentLoaded: function() {
@@ -689,36 +710,39 @@ TMP_extensionsCompatibility.treeStyleTab = {
   },
 
   onWindowLoaded: function() {
-    /**
-     *  TST have eval to TMP_Bookmark.openGroup
-     *  we replace TMP_Bookmark.openGroup with TMP_Places.openGroup at Tabmix 0.3.8.2pre.090830
-     *  we also replace call to TreeStyleTabService.openGroupBookmarkBehavior();
-     *  with aOpenGroupBookmarkBehavior that we pass from PlacesUIUtils._openTabset
-     *  we only call this functiom from browserWindow so we don't need to call it for
-     *  other places windows
-     */
-    Tabmix.changeCode(TMP_Places, "TMP_Places.openGroup")._replace(
-      'var tabs = gBrowser.visibleTabs;',
-      'let TSTOpenGroupBookmarkBehavior = arguments.length > 3 && arguments[3] ||\n' +
-      '        TreeStyleTabService.openGroupBookmarkBehavior();\n' +
-      '    $&'
-    )._replace(
-      'index = prevTab._tPos + 1;',
-      '  index = gBrowser.treeStyleTab.getNextSiblingTab(gBrowser.treeStyleTab.getRootTab(prevTab));' +
-      '  if (tabToSelect == aTab) index = gBrowser.treeStyleTab.getNextSiblingTab(index);' +
-      '    index = index ? index._tPos : (prevTab._tPos + 1);'
-    )._replace(
-      'prevTab = aTab;',
-      '  $&' +
-      '  if (tabToSelect == aTab && TSTOpenGroupBookmarkBehavior & TreeStyleTabService.kGROUP_BOOKMARK_SUBTREE) {' +
-      '    TreeStyleTabService.readyToOpenChildTab(tabToSelect, true, gBrowser.treeStyleTab.getNextSiblingTab(tabToSelect));' +
-      '  }'
-    )._replace(
-      /(\})(\)?)$/,
-      '  if (TSTOpenGroupBookmarkBehavior & TreeStyleTabService.kGROUP_BOOKMARK_SUBTREE)' +
-      '    TreeStyleTabService.stopToOpenChildTab(tabToSelect);' +
-      '$1$2'
-    ).toCode();
+    // we don't need this hack since treestyletab version 0.16.2016021602
+    if (typeof PlacesUIUtils.__treestyletab__openTabset != "function") {
+      /**
+       *  TST have eval to TMP_Bookmark.openGroup
+       *  we replace TMP_Bookmark.openGroup with TMP_Places.openGroup at Tabmix 0.3.8.2pre.090830
+       *  we also replace call to TreeStyleTabService.openGroupBookmarkBehavior();
+       *  with aOpenGroupBookmarkBehavior that we pass from PlacesUIUtils._openTabset
+       *  we only call this functiom from browserWindow so we don't need to call it for
+       *  other places windows
+       */
+      Tabmix.changeCode(TMP_Places, "TMP_Places.openGroup")._replace(
+        'var tabs = gBrowser.visibleTabs;',
+        'let TSTOpenGroupBookmarkBehavior = arguments.length > 3 && arguments[3] ||\n' +
+        '        TreeStyleTabService.openGroupBookmarkBehavior();\n' +
+        '    $&'
+      )._replace(
+        'index = prevTab._tPos + 1;',
+        '  index = gBrowser.treeStyleTab.getNextSiblingTab(gBrowser.treeStyleTab.getRootTab(prevTab));' +
+        '  if (tabToSelect == aTab) index = gBrowser.treeStyleTab.getNextSiblingTab(index);' +
+        '    index = index ? index._tPos : (prevTab._tPos + 1);'
+      )._replace(
+        'prevTab = aTab;',
+        '  $&' +
+        '  if (tabToSelect == aTab && TSTOpenGroupBookmarkBehavior & TreeStyleTabService.kGROUP_BOOKMARK_SUBTREE) {' +
+        '    TreeStyleTabService.readyToOpenChildTab(tabToSelect, true, gBrowser.treeStyleTab.getNextSiblingTab(tabToSelect));' +
+        '  }'
+      )._replace(
+        /(\})(\)?)$/,
+        '  if (TSTOpenGroupBookmarkBehavior & TreeStyleTabService.kGROUP_BOOKMARK_SUBTREE)' +
+        '    TreeStyleTabService.stopToOpenChildTab(tabToSelect);' +
+        '$1$2'
+      ).toCode();
+    }
 
     if (Services.prefs.getBoolPref("extensions.treestyletab.compatibility.TMP")) {
       // Added 2010-04-10
diff --git a/modules/Places.jsm b/modules/Places.jsm
index 35ef528..17baaa1 100644
--- a/modules/Places.jsm
+++ b/modules/Places.jsm
@@ -89,10 +89,9 @@ var PlacesUtilsInternal = {
       PlacesUIUtils["tabmix_" + aFn] = PlacesUIUtils[aFn];
     });
 
-    var treeStyleTab = "TreeStyleTabBookmarksService" in aWindow;
-    function updateOpenTabset() {
+    function updateOpenTabset(fnName, treeStyleTab) {
       let openGroup = "    browserWindow.TMP_Places.openGroup(urls, ids, where$1);";
-      Tabmix.changeCode(PlacesUIUtils, "PlacesUIUtils._openTabset")._replace(
+      Tabmix.changeCode(PlacesUIUtils, "PlacesUIUtils." + fnName)._replace(
         'urls = []',
         'behavior, $&', {check: treeStyleTab}
       )._replace(
@@ -117,20 +116,26 @@ var PlacesUtilsInternal = {
         openGroup.replace("$1", treeStyleTab ? ", behavior" : "")
       ).toCode();
     }
-    if (treeStyleTab) {
+    var treeStyleTabInstalled = "TreeStyleTabBookmarksService" in aWindow;
+    if (treeStyleTabInstalled &&
+        typeof PlacesUIUtils.__treestyletab__openTabset == "function") {
+      updateOpenTabset("__treestyletab__openTabset");
+    } else if (treeStyleTabInstalled) {
       // wait until TreeStyleTab changed PlacesUIUtils._openTabset
       let timer = this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
       this.__index = 0;
       timer.initWithCallback(function() {
-        if (++this.__index > 10 || PlacesUIUtils._openTabset.toString().indexOf("GroupBookmarkBehavior") > -1) {
+        let str = PlacesUIUtils._openTabset.toString();
+        if (++this.__index > 10 || str.indexOf("TreeStyleTabBookmarksService") > -1 ||
+            str.indexOf("GroupBookmarkBehavior") > -1) {
           timer.cancel();
           this._timer = null;
           this.__index = null;
-          updateOpenTabset();
+          updateOpenTabset("_openTabset", true);
         }
       }.bind(this), 50, Ci.nsITimer.TYPE_REPEATING_SLACK);
     } else { // TreeStyleTab not installed
-      updateOpenTabset();
+      updateOpenTabset("_openTabset");
 
       Tabmix.changeCode(PlacesUIUtils, "PlacesUIUtils.openURINodesInTabs")._replace(
         'push({uri: aNodes[i].uri,',
@@ -151,7 +156,9 @@ var PlacesUtilsInternal = {
       ).toCode();
     }
 
-    Tabmix.changeCode(PlacesUIUtils, "PlacesUIUtils.openNodeWithEvent")._replace(
+    let fnName = treeStyleTabInstalled && PlacesUIUtils.__treestyletab__openNodeWithEvent ?
+        "__treestyletab__openNodeWithEvent" : "openNodeWithEvent";
+    Tabmix.changeCode(PlacesUIUtils, "PlacesUIUtils." + fnName)._replace(
       /window.whereToOpenLink\(aEvent[,\s\w]*\)/, '{where: $&, event: aEvent}'
     ).toCode();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list