Created
October 24, 2018 14:41
-
-
Save captainbrosset/476fbadf4f786ad9400717d0b3e44b0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exporting patch: | |
# HG changeset patch | |
# User Patrick Brosset <[email protected]> | |
# Date 1540390759 -7200 | |
# Wed Oct 24 16:19:19 2018 +0200 | |
# Node ID 28252579eb8db33d857061e4db42a15e04a87e45 | |
# Parent 079c7a062b23950449e9ce1ef809ff43026cc259 | |
WIP pref to disable anoncontent highlighters | |
diff --git a/devtools/client/preferences/devtools-client.js b/devtools/client/preferences/devtools-client.js | |
--- a/devtools/client/preferences/devtools-client.js | |
+++ b/devtools/client/preferences/devtools-client.js | |
@@ -51,16 +51,19 @@ pref("devtools.inspector.showAllAnonymou | |
// Enable the CSS shapes highlighter | |
pref("devtools.inspector.shapesHighlighter.enabled", true); | |
// Enable the Font Editor | |
pref("devtools.inspector.fonteditor.enabled", true); | |
// Enable the font highlight-on-hover feature | |
pref("devtools.inspector.fonthighlighter.enabled", true); | |
// Enable tracking of style changes and the Changes panel in the Inspector | |
pref("devtools.inspector.changes.enabled", false); | |
+// Block all highlighters that require injecting content in the anonymous content | |
+// container of the nsCanvasFrame for the document. | |
+pref("devtools.inspector.blockAnonymousContentHighlighters", false); | |
// Flexbox preferences | |
// Enable the Flexbox highlighter and inspector panel in Nightly and DevEdition | |
#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) | |
pref("devtools.inspector.flexboxHighlighter.enabled", true); | |
pref("devtools.flexboxinspector.enabled", true); | |
#else | |
pref("devtools.inspector.flexboxHighlighter.enabled", false); | |
diff --git a/devtools/server/actors/highlighters.js b/devtools/server/actors/highlighters.js | |
--- a/devtools/server/actors/highlighters.js | |
+++ b/devtools/server/actors/highlighters.js | |
@@ -14,16 +14,20 @@ const { highlighterSpec, customHighlight | |
loader.lazyRequireGetter(this, "isWindowIncluded", "devtools/shared/layout/utils", true); | |
loader.lazyRequireGetter(this, "isXUL", "devtools/server/actors/highlighters/utils/markup", true); | |
loader.lazyRequireGetter(this, "SimpleOutlineHighlighter", "devtools/server/actors/highlighters/simple-outline", true); | |
loader.lazyRequireGetter(this, "BoxModelHighlighter", "devtools/server/actors/highlighters/box-model", true); | |
const HIGHLIGHTER_PICKED_TIMER = 1000; | |
const IS_OSX = Services.appinfo.OS === "Darwin"; | |
+const BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS_PREF = | |
+ "devtools.inspector.blockAnonymousContentHighlighters"; | |
+const BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS = | |
+ Services.prefs.getBoolPref(BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS_PREF); | |
/** | |
* The registration mechanism for highlighters provide a quick way to | |
* have modular highlighters, instead of a hard coded list. | |
* It allow us to split highlighers in sub modules, and add them dynamically | |
* using add-on (useful for 3rd party developers, or prototyping) | |
* | |
* Note that currently, highlighters added using add-ons, can only work on | |
@@ -114,29 +118,28 @@ exports.HighlighterActor = protocol.Acto | |
return { | |
actor: this.actorID, | |
}; | |
}, | |
_createHighlighter: function() { | |
this._isPreviousWindowXUL = isXUL(this._targetActor.window); | |
- if (!this._isPreviousWindowXUL) { | |
- this._highlighter = new BoxModelHighlighter(this._highlighterEnv, | |
- this._inspector); | |
+ if (!this._isPreviousWindowXUL && !BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS) { | |
+ this._highlighter = new BoxModelHighlighter(this._highlighterEnv, this._inspector); | |
this._highlighter.on("ready", this._highlighterReady); | |
this._highlighter.on("hide", this._highlighterHidden); | |
} else { | |
this._highlighter = new SimpleOutlineHighlighter(this._highlighterEnv); | |
} | |
}, | |
_destroyHighlighter: function() { | |
if (this._highlighter) { | |
- if (!this._isPreviousWindowXUL) { | |
+ if (!this._isPreviousWindowXUL && !BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS) { | |
this._highlighter.off("ready", this._highlighterReady); | |
this._highlighter.off("hide", this._highlighterHidden); | |
} | |
this._highlighter.destroy(); | |
this._highlighter = null; | |
} | |
}, | |
@@ -447,26 +450,29 @@ exports.CustomHighlighterActor = protoco | |
throw new Error(`${typeName} isn't a valid highlighter class (${list})`); | |
} | |
const constructor = require("./highlighters/" + modulePath)[typeName]; | |
// The assumption is that custom highlighters either need the canvasframe | |
// container to append their elements and thus a non-XUL window or they have | |
// to define a static XULSupported flag that indicates that the highlighter | |
// supports XUL windows. Otherwise, bail out. | |
- if (!isXUL(this._parent.targetActor.window) || constructor.XULSupported) { | |
+ if (!BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS && | |
+ (!isXUL(this._parent.targetActor.window) || constructor.XULSupported)) { | |
this._highlighterEnv = new HighlighterEnvironment(); | |
this._highlighterEnv.initFromTargetActor(parent.targetActor); | |
this._highlighter = new constructor(this._highlighterEnv); | |
if (this._highlighter.on) { | |
this._highlighter.on("highlighter-event", this._onHighlighterEvent.bind(this)); | |
} | |
+ } else if (!BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS) { | |
+ throw new Error(`Custom ${typeName} highlighter cannot be created in a XUL window`); | |
} else { | |
- throw new Error("Custom " + typeName + | |
- "highlighter cannot be created in a XUL window"); | |
+ console.warn(`Because pref ${BLOCK_ANONYMOUS_CONTENT_HIGHLIGHTERS_PREF} is set ` + | |
+ `to true, custom ${typeName} highlighter was not created`); | |
} | |
}, | |
get conn() { | |
return this._parent && this._parent.conn; | |
}, | |
destroy: function() { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment