[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 10/28: Issue 4398 - Fix "view source in a separate window" command

David Prévot taffit at moszumanska.debian.org
Fri Aug 4 21:15:15 UTC 2017


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

taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.

commit 0e60d7ed87081debc22095ab3e10c6cb99f04803
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Mon Sep 12 14:36:09 2016 +0200

    Issue 4398 - Fix "view source in a separate window" command
---
 lib/aardvark.js | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/lib/aardvark.js b/lib/aardvark.js
index e865872..5c4f66d 100644
--- a/lib/aardvark.js
+++ b/lib/aardvark.js
@@ -4,6 +4,8 @@
  * http://mozilla.org/MPL/2.0/.
  */
 
+let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+
 let {Prefs} = require("prefs");
 
 // Make sure to stop selection when we are uninstalled
@@ -696,12 +698,32 @@ let Aardvark = exports.Aardvark =
     if (!elem)
       return false;
 
-    var range = elem.ownerDocument.createRange();
-    range.selectNodeContents(elem);
-    var selection = {rangeCount: 1, getRangeAt: function() {return range}};
-
-    this.window.openDialog("chrome://global/content/viewPartialSource.xul", "_blank", "scrollbars,resizable,chrome,dialog=no",
-                           null, null, selection, "selection");
+    if (Services.vc.compare(Services.appinfo.platformVersion, "43.0") >= 0)
+    {
+      // After https://bugzilla.mozilla.org/show_bug.cgi?id=1134585 landed, pass
+      // a single object as parameter.
+      this.window.openDialog(
+        "chrome://global/content/viewPartialSource.xul",
+        "_blank", "scrollbars,resizable,chrome,dialog=no",
+        {
+          URI: "view-source:data:text/html;charset=utf-8," + encodeURIComponent(elem.outerHTML),
+          drawSelection: false,
+          baseURI: elem.ownerDocument.baseURI
+        }
+      );
+    }
+    else
+    {
+      // Before Gecko 43, use positional parameters and a fake selection object.
+      var range = elem.ownerDocument.createRange();
+      range.selectNodeContents(elem);
+      var selection = {rangeCount: 1, getRangeAt: function() {return range}};
+      this.window.openDialog(
+        "chrome://global/content/viewPartialSource.xul",
+        "_blank", "scrollbars,resizable,chrome,dialog=no",
+        null, null, selection, "selection"
+      );
+    }
     return true;
   },
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git



More information about the Pkg-mozext-commits mailing list