mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 817558 - [inspector] When the selection is deleted, we should select the parent, and make sure the breadcrumbs are updated, r=paul
This commit is contained in:
parent
644d5fd0a2
commit
f521eb1167
@ -83,7 +83,6 @@ HTMLBreadcrumbs.prototype = {
|
||||
this.update = this.update.bind(this);
|
||||
this.updateSelectors = this.updateSelectors.bind(this);
|
||||
this.selection.on("new-node", this.update);
|
||||
this.selection.on("detached", this.update);
|
||||
this.selection.on("pseudoclass", this.updateSelectors);
|
||||
this.selection.on("attribute-changed", this.updateSelectors);
|
||||
this.update();
|
||||
@ -296,7 +295,6 @@ HTMLBreadcrumbs.prototype = {
|
||||
});
|
||||
|
||||
this.selection.off("new-node", this.update);
|
||||
this.selection.off("detached", this.update);
|
||||
this.selection.off("pseudoclass", this.updateSelectors);
|
||||
this.selection.off("attribute-changed", this.updateSelectors);
|
||||
|
||||
|
@ -133,7 +133,6 @@ Highlighter.prototype = {
|
||||
|
||||
this.selection.on("new-node", this.highlight);
|
||||
this.selection.on("new-node", this.updateInfobar);
|
||||
this.selection.on("detached", this.highlight);
|
||||
this.selection.on("pseudoclass", this.updateInfobar);
|
||||
this.selection.on("attribute-changed", this.updateInfobar);
|
||||
|
||||
@ -168,7 +167,6 @@ Highlighter.prototype = {
|
||||
|
||||
this.selection.off("new-node", this.highlight);
|
||||
this.selection.off("new-node", this.updateInfobar);
|
||||
this.selection.off("detached", this.highlight);
|
||||
this.selection.off("pseudoclass", this.updateInfobar);
|
||||
this.selection.off("attribute-changed", this.updateInfobar);
|
||||
|
||||
|
@ -68,6 +68,8 @@ InspectorPanel.prototype = {
|
||||
this._selection = new Selection();
|
||||
this.onNewSelection = this.onNewSelection.bind(this);
|
||||
this.selection.on("new-node", this.onNewSelection);
|
||||
this.onDetached = this.onDetached.bind(this);
|
||||
this.selection.on("detached", this.onDetached);
|
||||
|
||||
this.breadcrumbs = new HTMLBreadcrumbs(this);
|
||||
|
||||
@ -280,6 +282,15 @@ InspectorPanel.prototype = {
|
||||
this.cancelLayoutChange();
|
||||
},
|
||||
|
||||
/**
|
||||
* When a node is deleted, select its parent node.
|
||||
*/
|
||||
onDetached: function InspectorPanel_onDetached(event, parentNode) {
|
||||
this.cancelLayoutChange();
|
||||
this.breadcrumbs.cutAfter(this.breadcrumbs.indexOf(parentNode));
|
||||
this.selection.setNode(parentNode, "detached");
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy the inspector.
|
||||
*/
|
||||
@ -315,6 +326,7 @@ InspectorPanel.prototype = {
|
||||
this.nodemenu.removeEventListener("popuphiding", this._resetNodeMenu, true);
|
||||
this.breadcrumbs.destroy();
|
||||
this.selection.off("new-node", this.onNewSelection);
|
||||
this.selection.off("detached", this.onDetached);
|
||||
this._destroyMarkup();
|
||||
this._selection.destroy();
|
||||
this._selection = null;
|
||||
|
@ -70,12 +70,14 @@ Selection.prototype = {
|
||||
_onMutations: function(mutations) {
|
||||
let attributeChange = 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()) {
|
||||
parentNode = m.target;
|
||||
detached = true;
|
||||
}
|
||||
}
|
||||
@ -84,7 +86,7 @@ Selection.prototype = {
|
||||
if (attributeChange)
|
||||
this.emit("attribute-changed");
|
||||
if (detached)
|
||||
this.emit("detached");
|
||||
this.emit("detached", parentNode);
|
||||
},
|
||||
|
||||
_attachEvents: function SN__attachEvents() {
|
||||
|
@ -35,6 +35,7 @@ _BROWSER_FILES = \
|
||||
browser_inspector_highlighter_autohide.js \
|
||||
browser_inspector_changes.js \
|
||||
browser_inspector_bug_674871.js \
|
||||
browser_inspector_bug_817558_delete_node.js \
|
||||
head.js \
|
||||
helpers.js \
|
||||
$(NULL)
|
||||
|
@ -0,0 +1,50 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
//ignoreAllUncaughtExceptions();
|
||||
|
||||
let node, iframe, inspector;
|
||||
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function onload() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", onload, true);
|
||||
waitForFocus(setupTest, content);
|
||||
}, true);
|
||||
|
||||
content.location = "http://mochi.test:8888/browser/browser/devtools/inspector/test/browser_inspector_destroyselection.html";
|
||||
|
||||
function setupTest()
|
||||
{
|
||||
iframe = content.document.querySelector("iframe");
|
||||
node = iframe.contentDocument.querySelector("span");
|
||||
openInspector(runTests);
|
||||
}
|
||||
|
||||
function runTests(aInspector)
|
||||
{
|
||||
inspector = aInspector;
|
||||
inspector.selection.setNode(node);
|
||||
|
||||
let parentNode = node.parentNode;
|
||||
parentNode.removeChild(node);
|
||||
|
||||
let tmp = {};
|
||||
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm", tmp);
|
||||
ok(!tmp.LayoutHelpers.isNodeConnected(node), "Node considered as disconnected.");
|
||||
executeSoon(function() {
|
||||
is(inspector.selection.node, parentNode, "parent of selection got selected");
|
||||
|
||||
finishUp();
|
||||
});
|
||||
}
|
||||
|
||||
function finishUp() {
|
||||
node = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ LayoutView.prototype = {
|
||||
this.update = this.update.bind(this);
|
||||
this.onNewNode = this.onNewNode.bind(this);
|
||||
this.onHighlighterLocked = this.onHighlighterLocked.bind(this);
|
||||
this.inspector.selection.on("detached", this.onNewNode);
|
||||
this.inspector.selection.on("new-node", this.onNewNode);
|
||||
this.inspector.sidebar.on("layoutview-selected", this.onNewNode);
|
||||
if (this.inspector.highlighter) {
|
||||
@ -101,7 +100,6 @@ LayoutView.prototype = {
|
||||
destroy: function LV_destroy() {
|
||||
this.inspector.sidebar.off("layoutview-selected", this.onNewNode);
|
||||
this.inspector.selection.off("new-node", this.onNewNode);
|
||||
this.inspector.selection.off("detached", this.onNewNode);
|
||||
if (this.browser) {
|
||||
this.browser.removeEventListener("MozAfterPaint", this.update, true);
|
||||
}
|
||||
|
@ -181,7 +181,6 @@ TiltVisualizer.prototype = {
|
||||
if (panel) {
|
||||
this.inspector = panel;
|
||||
this.inspector.selection.on("new-node", this.onNewNodeFromInspector);
|
||||
this.inspector.selection.on("detached", this.onNewNodeFromInspector);
|
||||
this.onNewNodeFromInspector();
|
||||
}
|
||||
}
|
||||
@ -196,7 +195,6 @@ TiltVisualizer.prototype = {
|
||||
|
||||
if (this.inspector) {
|
||||
this.inspector.selection.off("new-node", this.onNewNodeFromInspector);
|
||||
this.inspector.selection.off("detached", this.onNewNodeFromInspector);
|
||||
this.inspector = null;
|
||||
}
|
||||
|
||||
@ -217,7 +215,6 @@ TiltVisualizer.prototype = {
|
||||
if (toolbox.target.tab === this._browserTab) {
|
||||
this.inspector = panel;
|
||||
this.inspector.selection.on("new-node", this.onNewNodeFromInspector);
|
||||
this.inspector.selection.on("detached", this.onNewNodeFromInspector);
|
||||
this.onNewNodeFromTilt();
|
||||
}
|
||||
},
|
||||
@ -231,7 +228,6 @@ TiltVisualizer.prototype = {
|
||||
this.inspector) {
|
||||
if (this.inspector.selection) {
|
||||
this.inspector.selection.off("new-node", this.onNewNodeFromInspector);
|
||||
this.inspector.selection.off("detached", this.onNewNodeFromInspector);
|
||||
}
|
||||
this.inspector = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user