From 0d6084bbcdefeebf235ab010ba06399ae3aff3fc Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 1 Oct 2013 11:20:36 -0400 Subject: [PATCH] Backed out changeset 09cca9f32103 (bug 848731) for mochitest-bc failures. --- browser/devtools/inspector/breadcrumbs.js | 9 +- browser/devtools/inspector/inspector-panel.js | 4 +- browser/devtools/inspector/selection.js | 58 +++--- browser/devtools/inspector/test/browser.ini | 2 - ..._bug_848731_reset_selection_on_delete.html | 14 -- ...or_bug_848731_reset_selection_on_delete.js | 140 -------------- browser/devtools/markupview/markup-view.js | 171 ++++++++++-------- 7 files changed, 125 insertions(+), 273 deletions(-) delete mode 100644 browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html delete mode 100644 browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js diff --git a/browser/devtools/inspector/breadcrumbs.js b/browser/devtools/inspector/breadcrumbs.js index 49d27717061..25910863027 100644 --- a/browser/devtools/inspector/breadcrumbs.js +++ b/browser/devtools/inspector/breadcrumbs.js @@ -102,7 +102,6 @@ HTMLBreadcrumbs.prototype = { this.selection.on("new-node-front", this.update); this.selection.on("pseudoclass", this.updateSelectors); this.selection.on("attribute-changed", this.updateSelectors); - this.inspector.on("markupmutation", this.update); this.update(); }, @@ -350,7 +349,6 @@ HTMLBreadcrumbs.prototype = { this.selection.off("new-node-front", this.update); this.selection.off("pseudoclass", this.updateSelectors); this.selection.off("attribute-changed", this.updateSelectors); - this.inspector.off("markupmutation", this.update); this.container.removeEventListener("underflow", this.onscrollboxreflow, false); this.container.removeEventListener("overflow", this.onscrollboxreflow, false); @@ -613,7 +611,7 @@ HTMLBreadcrumbs.prototype = { /** * Update the breadcrumbs display when a new node is selected. */ - update: function BC_update(reason) + update: function BC_update() { this.inspector.hideNodeMenu(); @@ -634,8 +632,7 @@ HTMLBreadcrumbs.prototype = { let idx = this.indexOf(this.selection.nodeFront); // Is the node already displayed in the breadcrumbs? - // (and there are no mutations that need re-display of the crumbs) - if (idx > -1 && reason !== "markupmutation") { + if (idx > -1) { // Yes. We select it. this.setCursor(idx); } else { @@ -669,7 +666,7 @@ HTMLBreadcrumbs.prototype = { doneUpdating(this.selection.nodeFront); this.selectionGuardEnd(err); }); - } + }, } XPCOMUtils.defineLazyGetter(this, "DOMUtils", function () { diff --git a/browser/devtools/inspector/inspector-panel.js b/browser/devtools/inspector/inspector-panel.js index 459bf8172a8..91cd2ee0290 100644 --- a/browser/devtools/inspector/inspector-panel.js +++ b/browser/devtools/inspector/inspector-panel.js @@ -432,9 +432,7 @@ InspectorPanel.prototype = { }, /** - * When a node is deleted, select its parent node or the defaultNode if no - * parent is found (may happen when deleting an iframe inside which the - * node was selected). + * When a node is deleted, select its parent node. */ onDetached: function InspectorPanel_onDetached(event, parentNode) { this.cancelLayoutChange(); diff --git a/browser/devtools/inspector/selection.js b/browser/devtools/inspector/selection.js index dd01dd9d571..929df15deda 100644 --- a/browser/devtools/inspector/selection.js +++ b/browser/devtools/inspector/selection.js @@ -4,8 +4,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - const {Cu, Ci} = require("chrome"); let EventEmitter = require("devtools/shared/event-emitter"); @@ -78,38 +76,32 @@ Selection.prototype = { let pseudoChange = false; let detached = false; let parentNode = null; - for (let m of mutations) { if (!attributeChange && m.type == "attributes") { attributeChange = true; } if (m.type == "childList") { - if (!detached && !this.isConnected()) { - if (this.isNode()) { - parentNode = m.target; - } + if (!detached && this.isNode() && !this.isConnected()) { + parentNode = m.target; detached = true; } } - if (m.type == "pseudoClassLock") { + if (m.type == "pseudoClassLock"){ pseudoChange = true; } } - // Fire our events depending on what changed in the mutations array - if (attributeChange) { + if (attributeChange) this.emit("attribute-changed"); - } - if (pseudoChange) { + if (pseudoChange) this.emit("pseudoclass"); - } if (detached) { this.emit("detached", parentNode ? parentNode.rawNode() : null); this.emit("detached-front", parentNode); } }, - destroy: function() { + destroy: function SN_destroy() { this.setNode(null); this.setWalker(null); }, @@ -125,7 +117,7 @@ Selection.prototype = { }, // Not remote-safe - setNode: function(value, reason="unknown") { + setNode: function SN_setNode(value, reason="unknown") { if (value) { value = this._walker.frontForRawNode(value); } @@ -176,13 +168,13 @@ Selection.prototype = { return this._nodeFront; }, - isRoot: function() { + isRoot: function SN_isRootNode() { return this.isNode() && this.isConnected() && this._nodeFront.isDocumentElement; }, - isNode: function() { + isNode: function SN_isNode() { if (!this._nodeFront) { return false; } @@ -196,11 +188,11 @@ Selection.prototype = { return true; }, - isLocal: function() { + isLocal: function SN_nsLocal() { return !!this._node; }, - isConnected: function() { + isConnected: function SN_isConnected() { let node = this._nodeFront; if (!node || !node.actorID) { return false; @@ -228,58 +220,58 @@ Selection.prototype = { return false; }, - isHTMLNode: function() { + isHTMLNode: function SN_isHTMLNode() { let xhtml_ns = "http://www.w3.org/1999/xhtml"; return this.isNode() && this.node.namespaceURI == xhtml_ns; }, // Node type - isElementNode: function() { + isElementNode: function SN_isElementNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ELEMENT_NODE; }, - isAttributeNode: function() { + isAttributeNode: function SN_isAttributeNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ATTRIBUTE_NODE; }, - isTextNode: function() { + isTextNode: function SN_isTextNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.TEXT_NODE; }, - isCDATANode: function() { + isCDATANode: function SN_isCDATANode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.CDATA_SECTION_NODE; }, - isEntityRefNode: function() { + isEntityRefNode: function SN_isEntityRefNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ENTITY_REFERENCE_NODE; }, - isEntityNode: function() { + isEntityNode: function SN_isEntityNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.ENTITY_NODE; }, - isProcessingInstructionNode: function() { + isProcessingInstructionNode: function SN_isProcessingInstructionNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.PROCESSING_INSTRUCTION_NODE; }, - isCommentNode: function() { + isCommentNode: function SN_isCommentNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.PROCESSING_INSTRUCTION_NODE; }, - isDocumentNode: function() { + isDocumentNode: function SN_isDocumentNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.DOCUMENT_NODE; }, - isDocumentTypeNode: function() { + isDocumentTypeNode: function SN_isDocumentTypeNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.DOCUMENT_TYPE_NODE; }, - isDocumentFragmentNode: function() { + isDocumentFragmentNode: function SN_isDocumentFragmentNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE; }, - isNotationNode: function() { + isNotationNode: function SN_isNotationNode() { return this.isNode() && this.nodeFront.nodeType == Ci.nsIDOMNode.NOTATION_NODE; }, -}; +} diff --git a/browser/devtools/inspector/test/browser.ini b/browser/devtools/inspector/test/browser.ini index d1e0e183078..8533417c904 100644 --- a/browser/devtools/inspector/test/browser.ini +++ b/browser/devtools/inspector/test/browser.ini @@ -16,8 +16,6 @@ support-files = head.js [browser_inspector_bug_831693_search_suggestions.html] [browser_inspector_bug_835722_infobar_reappears.js] [browser_inspector_bug_840156_destroy_after_navigation.js] -[browser_inspector_bug_848731_reset_selection_on_delete.js] -[browser_inspector_bug_848731_reset_selection_on_delete.html] [browser_inspector_changes.js] [browser_inspector_cmd_inspect.html] [browser_inspector_cmd_inspect.js] diff --git a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html b/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html deleted file mode 100644 index c91281867e9..00000000000 --- a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - node delete - reset selection - test - - - - - - diff --git a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js b/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js deleted file mode 100644 index 69cffa1e30f..00000000000 --- a/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.js +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// Test that when nodes are being deleted in the page, the current selection -// and therefore the markup view, css rule view, computed view, font view, -// box model view, and breadcrumbs, reset accordingly to show the right node - -const TEST_PAGE = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_bug_848731_reset_selection_on_delete.html"; - -function test() { - let inspector, toolbox; - - waitForExplicitFinish(); - - // Create a tab, load test HTML, wait for load and start the tests - gBrowser.selectedTab = gBrowser.addTab(); - gBrowser.selectedBrowser.addEventListener("load", function onload() { - gBrowser.selectedBrowser.removeEventListener("load", onload, true); - waitForFocus(function() { - openInspector((aInspector, aToolbox) => { - inspector = aInspector; - toolbox = aToolbox; - startTests(); - }); - }, content); - }, true); - content.location = TEST_PAGE; - - function startTests() { - testManuallyDeleteSelectedNode(); - } - - function getContainerForRawNode(rawNode) { - let front = inspector.markup.walker.frontForRawNode(rawNode); - let container = inspector.markup.getContainer(front); - return container; - } - - // 1 - select a node, right click, hit delete, verify that its parent is selected - // and that all other tools are fine - function testManuallyDeleteSelectedNode() { - // Select our div - let div = content.document.getElementById("deleteManually"); - inspector.selection.setNode(div); - inspector.once("inspector-updated", () => { - is(inspector.selection.node, div); - - // Get the node container in the markup view - let container = getContainerForRawNode(div); - - // Simulate right-click - EventUtils.synthesizeMouse(container.tagLine, 2, 2, - {type: "contextmenu", button: 2}, inspector.panelWin); - - // And react to the popup shown event - let contextMenu = inspector.panelDoc.getElementById("inspectorPopupSet"); - contextMenu.addEventListener("popupshown", function contextShown() { - contextMenu.removeEventListener("popupshown", contextShown, false); - - // Click on the delete sub-menu item - inspector.panelDoc.getElementById("node-menu-delete").click(); - - // Once updated, make sure eveything is in place, and move on - inspector.once("inspector-updated", () => { - let parent = content.document.getElementById("deleteChildren"); - assertNodeSelectedAndPanelsUpdated(parent, "ul#deleteChildren"); - testAutomaticallyDeleteSelectedNode(); - }); - }, false); - }); - } - - // 2 - select a node, delete it via javascript, verify the same things as 1 - function testAutomaticallyDeleteSelectedNode() { - // Select our second div - let div = content.document.getElementById("deleteAutomatically"); - inspector.selection.setNode(div); - inspector.once("inspector-updated", () => { - is(inspector.selection.node, div); - - // Now remove that div via javascript - let parent = content.document.getElementById("deleteChildren"); - parent.removeChild(div); - - // Once updated, make sure eveything is in place, and move on - inspector.once("inspector-updated", () => { - assertNodeSelectedAndPanelsUpdated(parent, "ul#deleteChildren"); - testDeleteSelectedNodeContainerFrame(); - }); - }); - } - - // 3 - select a node inside an iframe, delete the iframe via javascript, verify that the default node is selected - // and that all other tools are fine - function testDeleteSelectedNodeContainerFrame() { - // Select our third test element, inside the iframe - let iframe = content.document.getElementById("deleteIframe"); - let div = iframe.contentDocument.getElementById("deleteInIframe"); - inspector.selection.setNode(div); - inspector.once("inspector-updated", () => { - is(inspector.selection.node, div); - - // Now remove that parent iframe via javascript - let parent = content.document.body; - parent.removeChild(iframe); - - // Once updated, make sure eveything is in place, and move on - inspector.once("inspector-updated", () => { - assertNodeSelectedAndPanelsUpdated(parent, "body"); - endTests(); - }); - }); - } - - function endTests() { - executeSoon(() => { - toolbox.destroy(); - toolbox = inspector = null; - gBrowser.removeCurrentTab(); - finish(); - }); - } - - function assertNodeSelectedAndPanelsUpdated(node, crumbLabel) { - // Right node selected? - is(inspector.selection.nodeFront, getNodeFront(node), - "The right node is selected"); - - // breadcrumbs updated? - let breadcrumbs = inspector.panelDoc.getElementById("inspector-breadcrumbs"); - is(breadcrumbs.querySelector("button[checked=true]").textContent, crumbLabel, - "The right breadcrumb is selected"); - - // Highlighter is shown? - ok(!inspector.highlighter.isHidden(), "The highlighter is shown"); - } -} diff --git a/browser/devtools/markupview/markup-view.js b/browser/devtools/markupview/markup-view.js index 07278a6dcff..c11e499cd10 100644 --- a/browser/devtools/markupview/markup-view.js +++ b/browser/devtools/markupview/markup-view.js @@ -28,9 +28,7 @@ Cu.import("resource://gre/modules/Services.jsm"); loader.lazyGetter(this, "DOMParser", function() { return Cc["@mozilla.org/xmlextras/domparser;1"].createInstance(Ci.nsIDOMParser); }); -loader.lazyGetter(this, "AutocompletePopup", () => { - return require("devtools/shared/autocomplete-popup").AutocompletePopup -}); +loader.lazyGetter(this, "AutocompletePopup", () => require("devtools/shared/autocomplete-popup").AutocompletePopup); /** * Vocabulary for the purposes of this file: @@ -50,7 +48,8 @@ loader.lazyGetter(this, "AutocompletePopup", () => { * @param iframe aFrame * An iframe in which the caller has kindly loaded markup-view.xhtml. */ -function MarkupView(aInspector, aFrame, aControllerWindow) { +function MarkupView(aInspector, aFrame, aControllerWindow) +{ this._inspector = aInspector; this.walker = this._inspector.walker; this._frame = aFrame; @@ -102,7 +101,8 @@ exports.MarkupView = MarkupView; MarkupView.prototype = { _selectedContainer: null, - template: function(aName, aDest, aOptions={stack: "markup-view.xhtml"}) { + template: function MT_template(aName, aDest, aOptions={stack: "markup-view.xhtml"}) + { let node = this.doc.getElementById("template-" + aName).cloneNode(true); node.removeAttribute("id"); template(node, aDest, aOptions); @@ -113,7 +113,8 @@ MarkupView.prototype = { * Get the MarkupContainer object for a given node, or undefined if * none exists. */ - getContainer: function(aNode) { + getContainer: function MT_getContainer(aNode) + { return this._containers.get(aNode); }, @@ -147,7 +148,8 @@ MarkupView.prototype = { /** * Highlight the inspector selected node. */ - _onNewSelection: function() { + _onNewSelection: function MT__onNewSelection() + { let done = this._inspector.updating("markup-view"); if (this._inspector.selection.isNode()) { this.showNode(this._inspector.selection.nodeFront, true).then(() => { @@ -164,7 +166,8 @@ MarkupView.prototype = { * Create a TreeWalker to find the next/previous * node for selection. */ - _selectionWalker: function(aStart) { + _selectionWalker: function MT__seletionWalker(aStart) + { let walker = this.doc.createTreeWalker( aStart || this._elt, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, @@ -184,7 +187,8 @@ MarkupView.prototype = { /** * Key handling. */ - _onKeyDown: function(aEvent) { + _onKeyDown: function MT__KeyDown(aEvent) + { let handled = true; // Ignore keystrokes that originated in editors. @@ -282,7 +286,8 @@ MarkupView.prototype = { * Delete a node from the DOM. * This is an undoable action. */ - deleteNode: function(aNode) { + deleteNode: function MC__deleteNode(aNode) + { if (aNode.isDocumentElement || aNode.nodeType == Ci.nsIDOMNode.DOCUMENT_TYPE_NODE) { return; @@ -310,7 +315,7 @@ MarkupView.prototype = { /** * If an editable item is focused, select its container. */ - _onFocus: function(aEvent) { + _onFocus: function MC__onFocus(aEvent) { let parent = aEvent.target; while (!parent.container) { parent = parent.parentNode; @@ -329,7 +334,8 @@ MarkupView.prototype = { * @param aIgnoreFocus aIgnoreFocus * If falsy, keyboard focus will be moved to the container too. */ - navigate: function(aContainer, aIgnoreFocus) { + navigate: function MT__navigate(aContainer, aIgnoreFocus) + { if (!aContainer) { return; } @@ -356,7 +362,8 @@ MarkupView.prototype = { * Whether the newly imported node should be flashed * @returns MarkupContainer The MarkupContainer object for this element. */ - importNode: function(aNode, aFlashNode) { + importNode: function MT_importNode(aNode, aFlashNode) + { if (!aNode) { return null; } @@ -388,7 +395,8 @@ MarkupView.prototype = { /** * Mutation observer used for included nodes. */ - _mutationObserver: function(aMutations) { + _mutationObserver: function MT__mutationObserver(aMutations) + { for (let mutation of aMutations) { let type = mutation.type; let target = mutation.target; @@ -429,7 +437,8 @@ MarkupView.prototype = { * Given a list of mutations returned by the mutation observer, flash the * corresponding containers to attract attention. */ - _flashMutatedNodes: function(aMutations) { + _flashMutatedNodes: function MT_flashMutatedNodes(aMutations) + { let addedOrEditedContainers = new Set(); let removedContainers = new Set(); @@ -472,7 +481,8 @@ MarkupView.prototype = { * Make sure the given node's parents are expanded and the * node is scrolled on to screen. */ - showNode: function(aNode, centered) { + showNode: function MT_showNode(aNode, centered) + { let container = this.importNode(aNode); let parent = aNode; while ((parent = parent.parentNode())) { @@ -491,7 +501,8 @@ MarkupView.prototype = { /** * Expand the container's children. */ - _expandContainer: function(aContainer) { + _expandContainer: function MT__expandContainer(aContainer) + { return this._updateChildren(aContainer, {expand: true}).then(() => { aContainer.expanded = true; }); @@ -500,7 +511,8 @@ MarkupView.prototype = { /** * Expand the node's children. */ - expandNode: function(aNode) { + expandNode: function MT_expandNode(aNode) + { let container = this._containers.get(aNode); this._expandContainer(container); }, @@ -510,7 +522,8 @@ MarkupView.prototype = { * * @param aContainer The container to expand. */ - _expandAll: function(aContainer) { + _expandAll: function MT_expandAll(aContainer) + { return this._expandContainer(aContainer).then(() => { let child = aContainer.children.firstChild; let promises = []; @@ -528,7 +541,8 @@ MarkupView.prototype = { * @param aContainer The node to expand, or null * to start from the top. */ - expandAll: function(aNode) { + expandAll: function MT_expandAll(aNode) + { aNode = aNode || this._rootNode; return this._expandAll(this._containers.get(aNode)); }, @@ -536,12 +550,14 @@ MarkupView.prototype = { /** * Collapse the node's children. */ - collapseNode: function(aNode) { + collapseNode: function MT_collapseNode(aNode) + { let container = this._containers.get(aNode); container.expanded = false; }, - setNodeExpanded: function(aNode, aExpanded) { + setNodeExpanded: function(aNode, aExpanded) + { if (aExpanded) { this.expandNode(aNode); } else { @@ -552,7 +568,8 @@ MarkupView.prototype = { /** * Mark the given node selected. */ - markNodeAsSelected: function(aNode) { + markNodeAsSelected: function MT_markNodeAsSelected(aNode) + { let container = this._containers.get(aNode); if (this._selectedContainer === container) { return false; @@ -572,7 +589,8 @@ MarkupView.prototype = { * Make sure that every ancestor of the selection are updated * and included in the list of visible children. */ - _ensureVisible: function(node) { + _ensureVisible: function(node) + { while (node) { let container = this._containers.get(node); let parent = node.parentNode(); @@ -590,7 +608,8 @@ MarkupView.prototype = { /** * Unmark selected node (no node selected). */ - unmarkSelectedNode: function() { + unmarkSelectedNode: function MT_unmarkSelectedNode() + { if (this._selectedContainer) { this._selectedContainer.selected = false; this._selectedContainer = null; @@ -600,7 +619,8 @@ MarkupView.prototype = { /** * Called when the markup panel initiates a change on a node. */ - nodeChanged: function(aNode) { + nodeChanged: function MT_nodeChanged(aNode) + { if (aNode === this._inspector.selection.nodeFront) { this._inspector.change("markupview"); } @@ -647,7 +667,8 @@ MarkupView.prototype = { * @return a promise that will be resolved when the children are ready * (which may be immediately). */ - _updateChildren: function(aContainer, options) { + _updateChildren: function(aContainer, options) + { let expand = options && options.expand; let flash = options && options.flash; @@ -751,7 +772,8 @@ MarkupView.prototype = { /** * Return a list of the children to display for this container. */ - _getVisibleChildren: function(aContainer, aCentered) { + _getVisibleChildren: function MV__getVisibleChildren(aContainer, aCentered) + { let maxChildren = aContainer.maxChildren || this.maxChildren; if (maxChildren == -1) { maxChildren = undefined; @@ -766,7 +788,8 @@ MarkupView.prototype = { /** * Tear down the markup panel. */ - destroy: function() { + destroy: function MT_destroy() + { gDevTools.off("pref-changed", this._handlePrefChange); this.undo.destroy(); @@ -779,23 +802,18 @@ MarkupView.prototype = { delete this._boundFocus; if (this._boundUpdatePreview) { - this._frame.contentWindow.removeEventListener("scroll", - this._boundUpdatePreview, true); + this._frame.contentWindow.removeEventListener("scroll", this._boundUpdatePreview, true); delete this._boundUpdatePreview; } if (this._boundResizePreview) { - this._frame.contentWindow.removeEventListener("resize", - this._boundResizePreview, true); - this._frame.contentWindow.removeEventListener("overflow", - this._boundResizePreview, true); - this._frame.contentWindow.removeEventListener("underflow", - this._boundResizePreview, true); + this._frame.contentWindow.removeEventListener("resize", this._boundResizePreview, true); + this._frame.contentWindow.removeEventListener("overflow", this._boundResizePreview, true); + this._frame.contentWindow.removeEventListener("underflow", this._boundResizePreview, true); delete this._boundResizePreview; } - this._frame.contentWindow.removeEventListener("keydown", - this._boundKeyDown, false); + this._frame.contentWindow.removeEventListener("keydown", this._boundKeyDown, false); delete this._boundKeyDown; this._inspector.selection.off("new-node-front", this._boundOnNewSelection); @@ -812,7 +830,8 @@ MarkupView.prototype = { /** * Initialize the preview panel. */ - _initPreview: function() { + _initPreview: function MT_initPreview() + { if (!Services.prefs.getBoolPref("devtools.inspector.markupPreview")) { return; } @@ -826,23 +845,21 @@ MarkupView.prototype = { this._previewWidth = this._preview.getBoundingClientRect().width; this._boundResizePreview = this._resizePreview.bind(this); - this._frame.contentWindow.addEventListener("resize", - this._boundResizePreview, true); - this._frame.contentWindow.addEventListener("overflow", - this._boundResizePreview, true); - this._frame.contentWindow.addEventListener("underflow", - this._boundResizePreview, true); + this._frame.contentWindow.addEventListener("resize", this._boundResizePreview, true); + this._frame.contentWindow.addEventListener("overflow", this._boundResizePreview, true); + this._frame.contentWindow.addEventListener("underflow", this._boundResizePreview, true); this._boundUpdatePreview = this._updatePreview.bind(this); - this._frame.contentWindow.addEventListener("scroll", - this._boundUpdatePreview, true); + this._frame.contentWindow.addEventListener("scroll", this._boundUpdatePreview, true); this._updatePreview(); }, + /** * Move the preview viewbox. */ - _updatePreview: function() { + _updatePreview: function MT_updatePreview() + { let win = this._frame.contentWindow; if (win.scrollMaxY == 0) { @@ -859,8 +876,7 @@ MarkupView.prototype = { let scrollTo if (height >= win.innerHeight) { scrollTo = -(height - win.innerHeight) * (win.scrollY / win.scrollMaxY); - this._previewBar.setAttribute("style", "height:" + height + - "px;transform:translateY(" + scrollTo + "px)"); + this._previewBar.setAttribute("style", "height:" + height + "px;transform:translateY(" + scrollTo + "px)"); } else { this._previewBar.setAttribute("style", "height:100%"); } @@ -870,14 +886,14 @@ MarkupView.prototype = { let height = ~~(win.innerHeight * ratio) + "px"; let top = ~~(win.scrollY * ratio) + "px"; - this._viewbox.setAttribute("style", "height:" + height + - ";transform: translateY(" + top + ")"); + this._viewbox.setAttribute("style", "height:" + height + ";transform: translateY(" + top + ")"); }, /** * Hide the preview while resizing, to avoid slowness. */ - _resizePreview: function() { + _resizePreview: function MT_resizePreview() + { let win = this._frame.contentWindow; this._previewBar.classList.add("hide"); win.clearTimeout(this._resizePreviewTimeout); @@ -1106,14 +1122,12 @@ MarkupContainer.prototype = { this.highlighter.classList.add("theme-bg-darker"); } if (this.closeTagLine) { - this.closeTagLine.querySelector(".highlighter").classList.add( - "theme-bg-darker"); + this.closeTagLine.querySelector(".highlighter").classList.add("theme-bg-darker"); } } else { this.highlighter.classList.remove("theme-bg-darker"); if (this.closeTagLine) { - this.closeTagLine.querySelector(".highlighter").classList.remove( - "theme-bg-darker"); + this.closeTagLine.querySelector(".highlighter").classList.remove("theme-bg-darker"); } } }, @@ -1190,7 +1204,8 @@ RootContainer.prototype = { /** * Creates an editor for simple nodes. */ -function GenericEditor(aContainer, aNode) { +function GenericEditor(aContainer, aNode) +{ this.elt = aContainer.doc.createElement("span"); this.elt.className = "editor"; this.elt.textContent = aNode.nodeName; @@ -1202,7 +1217,8 @@ function GenericEditor(aContainer, aNode) { * @param MarkupContainer aContainer The container owning this editor. * @param DOMNode aNode The node being edited. */ -function DoctypeEditor(aContainer, aNode) { +function DoctypeEditor(aContainer, aNode) +{ this.elt = aContainer.doc.createElement("span"); this.elt.className = "editor comment"; this.elt.textContent = '", "text/html").body.childNodes[0] || - parse("
", "text/html").body.childNodes[0] || - parse("
", "text/html").body.childNodes[0]; + let el = DOMParser.parseFromString("
", "text/html").body.childNodes[0] || + DOMParser.parseFromString("
", "text/html").body.childNodes[0] || + DOMParser.parseFromString("
", "text/html").body.childNodes[0]; let div = doc.createElement("div"); let attributes = [];