Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/aardvark.js

Issue 29352667: Issue 4398 - Fix "view source in a separate window" command (Closed) Base URL: https://hg.adblockplus.org/elemhidehelper
Patch Set: Created Sept. 12, 2016, 12:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/aardvark.js
===================================================================
--- a/lib/aardvark.js
+++ b/lib/aardvark.js
@@ -1,14 +1,16 @@
/*
* This Source Code is subject to the terms of the Mozilla Public License
* version 2.0 (the "License"). You can obtain a copy of the License at
* 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
onShutdown.add(() => Aardvark.quit());
// To be replaced when selection starts
function E(id) {return null;}
@@ -691,22 +693,42 @@ let Aardvark = exports.Aardvark =
return true;
},
viewSourceWindow: function(elem)
{
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),
kzar 2016/09/13 09:49:26 How come URI, drawSelection and baseURI are added
Wladimir Palant 2016/09/13 10:32:08 You have to look at the changes introduced in http
kzar 2016/09/13 12:06:50 That makes sense, thanks for explaining. (I tried
+ 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;
},
getOuterHtmlFormatted: function(node, container)
{
var type = null;
switch (node.nodeType)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld