From 828b754804f8d9108b854bcd2c624262451707b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Sat, 24 Sep 2011 12:22:48 +0200 Subject: [PATCH] Backed out changeset f1409901573a --- browser/devtools/highlighter/inspector.js | 46 +---------------- .../devtools/styleinspector/CssHtmlTree.jsm | 3 +- .../styleinspector/StyleInspector.jsm | 49 +++---------------- .../browser_styleinspector_webconsole.js | 16 ++++-- browser/devtools/webconsole/HUDService.jsm | 2 +- .../chrome/browser/styleinspector.properties | 6 --- 6 files changed, 22 insertions(+), 100 deletions(-) diff --git a/browser/devtools/highlighter/inspector.js b/browser/devtools/highlighter/inspector.js index 7857b339aad9..709b53017ae4 100644 --- a/browser/devtools/highlighter/inspector.js +++ b/browser/devtools/highlighter/inspector.js @@ -208,6 +208,7 @@ Highlighter.prototype = { aParent.appendChild(closeButton); }, + /** * Destroy the nodes. */ @@ -839,26 +840,6 @@ var InspectorUI = { */ initTools: function IUI_initTools() { - // Style inspector - if (Services.prefs.getBoolPref("devtools.styleinspector.enabled") && - !this.toolRegistered("styleinspector")) { - let stylePanel = this.StyleInspector.createPanel(true); - this.registerTool({ - id: "styleinspector", - label: InspectorUI.StyleInspector.l10n("style.highlighter.button.label"), - tooltiptext: InspectorUI.StyleInspector.l10n("style.highlighter.button.tooltip"), - accesskey: InspectorUI.StyleInspector.l10n("style.highlighter.accesskey"), - context: stylePanel, - get isOpen() stylePanel.isOpen(), - onSelect: stylePanel.selectNode, - show: stylePanel.showTool, - hide: stylePanel.hideTool, - dim: stylePanel.dimTool, - panel: stylePanel, - unregister: stylePanel.destroy, - }); - this.stylePanel = stylePanel; - } }, /** @@ -985,7 +966,6 @@ var InspectorUI = { this.treePanel.hidePopup(); delete this.treePanel; - delete this.stylePanel; }, /** @@ -1002,7 +982,6 @@ var InspectorUI = { document.getElementById("inspector-inspect-toolbutton").checked = true; this.attachPageListeners(); this.inspecting = true; - this.toolsDim(true); this.highlighter.veilContainer.removeAttribute("locked"); }, @@ -1021,7 +1000,6 @@ var InspectorUI = { document.getElementById("inspector-inspect-toolbutton").checked = false; this.detachPageListeners(); this.inspecting = false; - this.toolsDim(false); if (this.highlighter.node) { this.select(this.highlighter.node, true, true, !aPreventScroll); } else { @@ -1181,12 +1159,10 @@ var InspectorUI = { this.ioBox.toggleObject(node); } else { if (this.inspecting) { - this.toolsSelect(); this.stopInspecting(true); } else { this.select(node, true, false); this.highlighter.highlightNode(node); - this.toolsSelect(); } } } @@ -1655,7 +1631,6 @@ var InspectorUI = { * onSelect: object.method, * show: object.method, called to show the tool when button is pressed. * hide: object.method, called to hide the tool when button is pressed. - * dim: object.method, called to disable a tool during highlighting. * unregister: object.method, called when tool should be destroyed. * panel: myTool.panel * } @@ -1818,19 +1793,6 @@ var InspectorUI = { }); }, - /** - * Dim or undim each tool in the tools collection - * @param aState true = dim, false = undim - */ - toolsDim: function IUI_toolsDim(aState) - { - this.toolsDo(function IUI_toolsOnSelect(aTool) { - if (aTool.isOpen && "dim" in aTool) { - aTool.dim.call(aTool.context, aState); - } - }); - }, - /** * Loop through all registered tools and pass each into the provided function * @param aFunction The function to which each tool is to be passed @@ -2098,9 +2060,3 @@ XPCOMUtils.defineLazyGetter(InspectorUI, "strings", function () { createBundle("chrome://browser/locale/inspector.properties"); }); -XPCOMUtils.defineLazyGetter(InspectorUI, "StyleInspector", function () { - var obj = {}; - Cu.import("resource:///modules/devtools/StyleInspector.jsm", obj); - return obj.StyleInspector; -}); - diff --git a/browser/devtools/styleinspector/CssHtmlTree.jsm b/browser/devtools/styleinspector/CssHtmlTree.jsm index 7cf71d4c24f4..5e2a5dcc6ac6 100644 --- a/browser/devtools/styleinspector/CssHtmlTree.jsm +++ b/browser/devtools/styleinspector/CssHtmlTree.jsm @@ -21,10 +21,9 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Joe Walker (jwalker@mozilla.com) (Original Author) + * Joe Walker (jwalker@mozilla.com) (original author) * Mihai Șucan * Michael Ratcliffe - * Rob Campbell * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or diff --git a/browser/devtools/styleinspector/StyleInspector.jsm b/browser/devtools/styleinspector/StyleInspector.jsm index 230a13253d6c..34888f89b158 100644 --- a/browser/devtools/styleinspector/StyleInspector.jsm +++ b/browser/devtools/styleinspector/StyleInspector.jsm @@ -21,8 +21,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Mike Ratcliffe (Original Author) - * Rob Campbell + * Mike Ratcliffe * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -110,6 +109,8 @@ var StyleInspector = { let iframeReady = false; function SI_iframeOnload() { iframe.removeEventListener("load", SI_iframeOnload, true); + panel.cssLogic = new CssLogic(); + panel.cssHtmlTree = new CssHtmlTree(iframe, panel.cssLogic, panel); iframeReady = true; if (panelReady) { SI_popupShown.call(panel); @@ -123,10 +124,6 @@ var StyleInspector = { function SI_popupShown() { panelReady = true; if (iframeReady) { - if (!this.cssLogic) { - this.cssLogic = new CssLogic(); - this.cssHtmlTree = new CssHtmlTree(iframe, this.cssLogic, this); - } let selectedNode = this.selectedNode || null; this.cssLogic.highlight(selectedNode); this.cssHtmlTree.highlight(selectedNode); @@ -165,9 +162,12 @@ var StyleInspector = { panel.selectNode = function SI_selectNode(aNode) { this.selectedNode = aNode; - if (this.isOpen() && !this.hasAttribute("dimmed")) { + if (this.isOpen()) { this.cssLogic.highlight(aNode); this.cssHtmlTree.highlight(aNode); + } else { + let win = Services.wm.getMostRecentWindow("navigator:browser"); + this.openPopup(win.gBrowser.selectedBrowser, "end_before", 0, 0, false, false); } }; @@ -176,10 +176,6 @@ var StyleInspector = { */ panel.destroy = function SI_destroy() { - if (!this.cssLogic) - return; - if (this.isOpen()) - this.hideTool(); this.cssLogic = null; this.cssHtmlTree = null; this.removeEventListener("popupshown", SI_popupShown); @@ -188,37 +184,6 @@ var StyleInspector = { Services.obs.notifyObservers(null, "StyleInspector-closed", null); }; - /** - * Dim or undim a panel by setting or removing a dimmed attribute. - * - * @param aState - * true = dim, false = undim - */ - panel.dimTool = function SI_dimTool(aState) - { - if (!this.isOpen()) - return; - - if (aState) { - this.setAttribute("dimmed", "true"); - } else if (this.hasAttribute("dimmed")) { - this.removeAttribute("dimmed"); - } - }; - - panel.showTool = function SI_showTool(aSelection) - { - this.selectNode(aSelection); - let win = Services.wm.getMostRecentWindow("navigator:browser"); - this.openPopup(win.gBrowser.selectedBrowser, "end_before", 0, 0, - false, false); - }; - - panel.hideTool = function SI_hideTool() - { - this.hidePopup(); - }; - /** * Is the Style Inspector initialized? * @returns {Boolean} true or false diff --git a/browser/devtools/styleinspector/test/browser/browser_styleinspector_webconsole.js b/browser/devtools/styleinspector/test/browser/browser_styleinspector_webconsole.js index a68f8915eacb..aab2e2116307 100644 --- a/browser/devtools/styleinspector/test/browser/browser_styleinspector_webconsole.js +++ b/browser/devtools/styleinspector/test/browser/browser_styleinspector_webconsole.js @@ -174,18 +174,26 @@ function styleInspectorClosedFromConsole1() { Services.obs.removeObserver(styleInspectorClosedFromConsole1, "StyleInspector-closed", false); - info("Style Inspector 1 and 2 closed"); + info("Style Inspector 1 closed"); + Services.obs.addObserver(styleInspectorClosedFromConsole2, + "StyleInspector-closed", false); +} + +function styleInspectorClosedFromConsole2() +{ + Services.obs.removeObserver(styleInspectorClosedFromConsole2, + "StyleInspector-closed", false); + info("Style Inspector 2 closed"); executeSoon(cleanUp); } function cleanUp() { - let panels = document.querySelector("panel[hudToolId]"); - ok(!panels, + let popupSet = document.getElementById("mainPopupSet"); + ok(!popupSet.lastChild.hasAttribute("hudToolId"), "all style inspector panels are now detached and ready for garbage collection"); info("cleaning up"); - doc = hudBox = stylePanels = jsterm = null; finishTest(); } diff --git a/browser/devtools/webconsole/HUDService.jsm b/browser/devtools/webconsole/HUDService.jsm index 6956922f8c3c..394ac1f4d54d 100644 --- a/browser/devtools/webconsole/HUDService.jsm +++ b/browser/devtools/webconsole/HUDService.jsm @@ -4438,7 +4438,7 @@ function JSTermHelper(aJSTerm) if (!errstr) { let stylePanel = StyleInspector.createPanel(); stylePanel.setAttribute("hudToolId", aJSTerm.hudId); - stylePanel.showTool(aNode); + stylePanel.selectNode(aNode); } else { aJSTerm.writeOutput(errstr + "\n", CATEGORY_OUTPUT, SEVERITY_ERROR); } diff --git a/browser/locales/en-US/chrome/browser/styleinspector.properties b/browser/locales/en-US/chrome/browser/styleinspector.properties index 22d1bae9ad33..1c4292b6043f 100644 --- a/browser/locales/en-US/chrome/browser/styleinspector.properties +++ b/browser/locales/en-US/chrome/browser/styleinspector.properties @@ -41,9 +41,3 @@ group.Positioning_and_Page_Flow=Positioning and Page Flow group.Borders=Borders group.Lists=Lists group.Effects_and_Other=Effects and Other - -# LOCALIZATION NOTE (style.highlighter.button): These strings are used inside -# html tree of the highlighter for the style inspector button -style.highlighter.button.label=Style -style.highlighter.accesskey=S -style.highlighter.button.tooltip=Inspect element styles