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

Unified Diff: lib/aardvark.js

Issue 29366556: Issue 2879 - Make "view source in separate window" command work again (Closed) Base URL: https://hg.adblockplus.org/elemhidehelper
Patch Set: Created Dec. 1, 2016, 11:03 a.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 | lib/child/commands.js » ('j') | 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
@@ -324,47 +324,31 @@ let Aardvark = exports.Aardvark =
{
sourceBox.showPopup(anchor, x, y, "tooltip", "topleft", "topleft");
Aardvark.viewSourceTimer = null;
}, 500, Ci.nsITimer.TYPE_ONE_SHOT);
});
return true;
},
- viewSourceWindow: function(elem)
+ viewSourceWindow: function()
{
- if (!elem)
- return false;
-
- if (Services.vc.compare(Services.appinfo.platformVersion, "43.0") >= 0)
+ sendMessageWithResponse("ElemHideHelper:GetHTML", null, data =>
{
- // 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),
+ URI: "view-source:data:text/html;charset=utf-8," +
+ encodeURIComponent(data.html),
drawSelection: false,
saroyanm 2016/12/05 18:02:51 Nit: not aligned with the line above.
Wladimir Palant 2016/12/08 13:04:16 It shouldn't be - the line above is indented to in
saroyanm 2016/12/20 14:32:04 Acknowledged.
- baseURI: elem.ownerDocument.baseURI
+ baseURI: data.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)
{
let type = node.type;
if (type == "element")
{
@@ -438,8 +422,16 @@ let Aardvark = exports.Aardvark =
return true;
}
}
// Makes sure event handlers like Aardvark.onKeyPress always have the correct
// this pointer set.
for (let method of ["onKeyPress", "onMouseMove", "onTabSelect"])
Aardvark[method] = Aardvark[method].bind(Aardvark);
+
+if (Services.vc.compare(Services.appinfo.platformVersion, "43.0") < 0)
+{
+ // View source window expected the actual node before
+ // https://bugzil.la/1134585 landed, we don't have it so disable the command.
+ let index = Aardvark.commands.indexOf("viewSourceWindow");
+ Aardvark.commands.splice(index, 1);
+}
« no previous file with comments | « no previous file | lib/child/commands.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld