Bug 1324565 - Remove dependency to sdk/page-mod from inspector highlighter. r=pbro draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 19 Dec 2016 11:07:11 -0800
changeset 451435 8d295ab88ecac386b24d58a961b2641a8b34beda
parent 450924 863c2b61bd27bb6099104933134d3be7c052551a
child 540026 087f5f65361df1760f982ae2e3a616f3a03abc10
push id39177
push userbmo:poirot.alex@gmail.com
push dateTue, 20 Dec 2016 10:13:47 +0000
reviewerspbro
bugs1324565
milestone53.0a1
Bug 1324565 - Remove dependency to sdk/page-mod from inspector highlighter. r=pbro MozReview-Commit-ID: 5oZI4mkDFqJ
devtools/server/actors/highlighters/utils/markup.js
--- a/devtools/server/actors/highlighters/utils/markup.js
+++ b/devtools/server/actors/highlighters/utils/markup.js
@@ -281,18 +281,26 @@ CanvasFrameAnonymousContentHelper.protot
     if (isXUL(this.highlighterEnv.window)) {
       return;
     }
 
     // For now highlighters.css is injected in content as a ua sheet because
     // <style scoped> doesn't work inside anonymous content (see bug 1086532).
     // If it did, highlighters.css would be injected as an anonymous content
     // node using CanvasFrameAnonymousContentHelper instead.
-    installHelperSheet(this.highlighterEnv.window,
-      "@import url('" + STYLESHEET_URI + "');");
+    if (!installedHelperSheets.has(doc)) {
+      installedHelperSheets.set(doc, true);
+      let source = "@import url('" + STYLESHEET_URI + "');";
+      let url = "data:text/css;charset=utf-8," + encodeURIComponent(source);
+      let winUtils = this.highlighterEnv.window
+                         .QueryInterface(Ci.nsIInterfaceRequestor)
+                         .getInterface(Ci.nsIDOMWindowUtils);
+      winUtils.loadSheetUsingURIString(url, winUtils.AGENT_SHEET);
+    }
+
     let node = this.nodeBuilder();
 
     // It was stated that hidden documents don't accept
     // `insertAnonymousContent` calls yet. That doesn't seems the case anymore,
     // at least on desktop. Therefore, removing the code that was dealing with
     // that scenario, fixes when we're adding anonymous content in a tab that
     // is not the active one (see bug 1260043 and bug 1260044)
     this._content = doc.insertAnonymousContent(node);