From 5ca294eae0235103208a7e665bf34f064d1ecffd Mon Sep 17 00:00:00 2001 From: Matteo Ferretti Date: Mon, 24 Apr 2017 18:57:57 +0200 Subject: [PATCH] Bug 1359028 - added encodeURIComponent and fixed css class typo; r=pbro The patch of bug 1353005 removed by mistake a leading dot in a css class, and the `encodeURIComponent` calls (so the # in the color definition was considered the hash part in the url). Also, it appears autoland rejected the last commit from Bug 1353005, so this patch includes those changes as well. MozReview-Commit-ID: 2aVW3hYHhSr --- .../actors/highlighters/simple-outline.js | 21 +++++++++++-------- .../actors/highlighters/utils/markup.js | 16 +------------- devtools/server/actors/inspector.js | 17 +++------------ devtools/server/actors/stylesheets.js | 2 +- devtools/shared/layout/utils.js | 12 +++++------ 5 files changed, 23 insertions(+), 45 deletions(-) diff --git a/devtools/server/actors/highlighters/simple-outline.js b/devtools/server/actors/highlighters/simple-outline.js index 52b7cad749e4..3ef064b7306f 100644 --- a/devtools/server/actors/highlighters/simple-outline.js +++ b/devtools/server/actors/highlighters/simple-outline.js @@ -5,21 +5,24 @@ "use strict"; const { - installHelperSheet, isNodeValid, addPseudoClassLock, removePseudoClassLock } = require("./utils/markup"); +const { loadSheet } = require("devtools/shared/layout/utils"); + // SimpleOutlineHighlighter's stylesheet const HIGHLIGHTED_PSEUDO_CLASS = ":-moz-devtools-highlighted"; -const SIMPLE_OUTLINE_SHEET = `.__fx-devtools-hide-shortcut__ { - visibility: hidden !important - } - ${HIGHLIGHTED_PSEUDO_CLASS} { - outline: 2px dashed #F06!important; - outline-offset: -2px!important - }`; +const SIMPLE_OUTLINE_SHEET = "data:text/css;charset=utf-8," + encodeURIComponent(` + .__fx-devtools-hide-shortcut__ { + visibility: hidden !important + } + ${HIGHLIGHTED_PSEUDO_CLASS} { + outline: 2px dashed #F06!important; + outline-offset: -2px!important + }`); + /** * The SimpleOutlineHighlighter is a class that has the same API than the * BoxModelHighlighter, but adds a pseudo-class on the target element itself @@ -48,7 +51,7 @@ SimpleOutlineHighlighter.prototype = { if (isNodeValid(node) && (!this.currentNode || node !== this.currentNode)) { this.hide(); this.currentNode = node; - installHelperSheet(node.ownerGlobal, SIMPLE_OUTLINE_SHEET); + loadSheet(node.ownerGlobal, SIMPLE_OUTLINE_SHEET); addPseudoClassLock(node, HIGHLIGHTED_PSEUDO_CLASS); } return true; diff --git a/devtools/server/actors/highlighters/utils/markup.js b/devtools/server/actors/highlighters/utils/markup.js index 997501491741..019d5f2b1634 100644 --- a/devtools/server/actors/highlighters/utils/markup.js +++ b/devtools/server/actors/highlighters/utils/markup.js @@ -101,20 +101,6 @@ function isXUL(window) { } exports.isXUL = isXUL; -/** - * Inject a helper stylesheet in the window. - */ -var installedHelperSheets = new WeakSet(); - -function installHelperSheet(win, url = STYLESHEET_URI, type = "agent") { - if (installedHelperSheets.has(win.document)) { - return; - } - loadSheet(win, url, type); - installedHelperSheets.add(win.document); -} -exports.installHelperSheet = installHelperSheet; - /** * Returns true if a DOM node is "valid", where "valid" means that the node isn't a dead * object wrapper, is still attached to a document, and is of a given type. @@ -275,7 +261,7 @@ CanvasFrameAnonymousContentHelper.prototype = { //