Skip to content

Commit 5d4be2c

Browse files
committed
Markup view temp patch
1 parent a94c45b commit 5d4be2c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

lib/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const { ConsoleOverlay } = require("./console-overlay.js");
1616
const { InspectorOverlay } = require("./inspector-overlay.js");
1717
const { FireQueryToolboxOverlay } = require("./firequery-toolbox-overlay.js");
1818

19+
// Platform patch (should be removed as soon as it's built-in).
20+
const MarkupViewPatch = require("./markup-view-patch.js");
21+
1922
// Localization files. All strings in the UI should be loaded from these
2023
// files, so the entire extension can be localized into other languages.
2124
Locale.registerStringBundle("chrome://firequery/locale/firequery.properties");
@@ -45,6 +48,9 @@ function onUnload(reason) {
4548
ToolboxChrome.unregisterPanelOverlay(InspectorOverlay);
4649
ToolboxChrome.unregisterPanelOverlay(ConsoleOverlay);
4750

51+
// Unapply temporary patches
52+
MarkupViewPatch.shutdown();
53+
4854
// xxxHonza: needs FBSDK update
4955
// ToolboxChrome.shutdown(reason);
5056
}

lib/markup-view-patch.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* See license.txt for terms of usage */
2+
3+
"use strict";
4+
5+
module.metadata = {
6+
"stability": "experimental"
7+
};
8+
9+
// Add-on SDK
10+
const { Cu, Ci } = require("chrome");
11+
12+
// Firebug SDK
13+
const { Trace, TraceError } = require("firebug.sdk/lib/core/trace.js").get(module.id);
14+
15+
// DevTools
16+
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
17+
const { MarkupView } = devtools["require"]("devtools/markupview/markup-view");
18+
19+
// Patching MarkupView
20+
// xxxHonza: Bug 1036949 - New API: MarkupView customization
21+
let originalTemplate = MarkupView.prototype.template;
22+
MarkupView.prototype.template = function(aName, aDest, aOptions) {
23+
let node = originalTemplate.apply(this, arguments);
24+
//this._inspector.emit("markupview-render", node, aName, aDest, aOptions);
25+
return node;
26+
}
27+
28+
function shutdown() {
29+
MarkupView.prototype.template = originalTemplate;
30+
31+
// xxxHonza: iterate also all existing instances
32+
// and un-patch
33+
}
34+
35+
// Exports from this module
36+
exports.shutdown = shutdown;

0 commit comments

Comments
 (0)