Commit 5e4a452e authored by sergeyv@chromium.org's avatar sergeyv@chromium.org

DevTools: Get rid of redundant default selection during inspectElement

BUG=

Review URL: https://codereview.chromium.org/177653004

git-svn-id: svn://svn.chromium.org/blink/trunk@168503 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 434cbe35
......@@ -35,11 +35,14 @@ function test()
InspectorTest.runTestSuite([
function testRevealElement(next)
{
InspectorTest.addSniffer(WebInspector, "_updateFocusedNode", step2);
InspectorTest.addSniffer(WebInspector.Revealer, "reveal", step2);
evalAndDump("inspect($('#p1'))");
function step2()
function step2(node)
{
if (!(node instanceof WebInspector.DOMNode))
return;
InspectorTest.addResult("Selected node id: '" + WebInspector.panels.elements.selectedDOMNode().getAttribute("id") + "'.");
next();
}
......
......@@ -68,8 +68,7 @@ InspectorTest.selectNodeWithId = function(idValue, callback)
callback = InspectorTest.safeWrap(callback);
function onNodeFound(node)
{
if (node)
WebInspector._updateFocusedNode(node.id);
WebInspector.Revealer.reveal(node);
callback(node);
}
InspectorTest.nodeWithId(idValue, onNodeFound);
......
......@@ -41,8 +41,7 @@ function test()
InspectorTest.findNode(matchFunction, callback);
function callback(node)
{
if (node)
WebInspector._updateFocusedNode(node.id);
WebInspector.Revealer.reveal(node);
next(node);
}
}
......
......@@ -106,7 +106,7 @@ function test()
var childNodes = testNode.children();
for (var i = 0; i < childNodes.length; ++i) {
if (childNodes[i].nodeType() === 8) {
WebInspector._updateFocusedNode(childNodes[i].id);
WebInspector.Revealer.reveal(childNodes[i]);
callback(childNodes[i]);
return;
}
......
......@@ -29,8 +29,7 @@ InspectorTest.selectIdNodeWithId = function(idValue, pseudoType, callback)
callback = InspectorTest.safeWrap(callback);
function onNodeFound(node)
{
if (node)
WebInspector._updateFocusedNode(node.id);
WebInspector.Revealer.reveal(node);
callback(node);
}
......
......@@ -12,10 +12,13 @@ function testFunction()
var test = function()
{
InspectorTest.addSniffer(WebInspector, "inspect", inspect);
InspectorTest.addSniffer(WebInspector, "_updateFocusedNode", updateFocusedNode);
InspectorTest.addSniffer(WebInspector.Revealer, "reveal", updateFocusedNode);
function updateFocusedNode()
function updateFocusedNode(node)
{
if (!(node instanceof WebInspector.DOMNode))
return;
InspectorTest.addResult("Selected node id: '" + WebInspector.panels.elements.selectedDOMNode().getAttribute("id") + "'.");
InspectorTest.completeDebuggerTest();
}
......
......@@ -789,7 +789,6 @@ WebInspector.DOMAgent.Events = {
ChildNodeCountUpdated: "ChildNodeCountUpdated",
UndoRedoRequested: "UndoRedoRequested",
UndoRedoCompleted: "UndoRedoCompleted",
InspectNodeRequested: "InspectNodeRequested"
}
WebInspector.DOMAgent.prototype = {
......@@ -1173,9 +1172,7 @@ WebInspector.DOMAgent.prototype = {
*/
inspectElement: function(nodeId)
{
var node = this._idToDOMNode[nodeId];
if (node)
this.dispatchEventToListeners(WebInspector.DOMAgent.Events.InspectNodeRequested, nodeId);
WebInspector.Revealer.reveal(this.nodeForId(nodeId));
},
/**
......@@ -1183,7 +1180,7 @@ WebInspector.DOMAgent.prototype = {
*/
_inspectNodeRequested: function(nodeId)
{
this.dispatchEventToListeners(WebInspector.DOMAgent.Events.InspectNodeRequested, nodeId);
this.inspectElement(nodeId);
},
/**
......
......@@ -119,9 +119,6 @@ WebInspector.ElementsPanel = function()
WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._documentUpdatedEvent, this);
WebInspector.settings.showShadowDOM.addChangeListener(this._showShadowDOMChanged.bind(this));
if (WebInspector.domAgent.existingDocument())
this._documentUpdated(WebInspector.domAgent.existingDocument());
WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.ModelWasEnabled, this._updateSidebars, this);
}
......@@ -168,7 +165,10 @@ WebInspector.ElementsPanel.prototype = {
this.treeOutline.setVisible(true);
if (!this.treeOutline.rootDOMNode)
WebInspector.domAgent.requestDocument();
if (WebInspector.domAgent.existingDocument())
this._documentUpdated(WebInspector.domAgent.existingDocument());
else
WebInspector.domAgent.requestDocument();
},
willHide: function()
......@@ -188,6 +188,16 @@ WebInspector.ElementsPanel.prototype = {
this._updateTreeOutlineVisibleWidth();
},
omitDefaultSelection: function()
{
this._omitDefaultSelection = true;
},
stopOmittingDefaultSelection: function()
{
delete this._omitDefaultSelection;
},
/**
* @param {!DOMAgent.NodeId} nodeId
* @param {string} pseudoClass
......@@ -312,6 +322,9 @@ WebInspector.ElementsPanel.prototype = {
selectNode.call(this, node);
}
if (this._omitDefaultSelection)
return;
if (this._selectedPathOnReset)
WebInspector.domAgent.pushNodeByPathToFrontend(this._selectedPathOnReset, selectLastSelectedNode.bind(this));
else
......@@ -1350,7 +1363,14 @@ WebInspector.ElementsPanel.DOMNodeRevealer.prototype = {
*/
reveal: function(node)
{
if (node instanceof WebInspector.DOMNode)
/** @type {!WebInspector.ElementsPanel} */ (WebInspector.showPanel("elements")).revealAndSelectNode(node.id);
if (!(node instanceof WebInspector.DOMNode))
return;
if (WebInspector.inspectElementModeController && WebInspector.inspectElementModeController.enabled()) {
InspectorFrontendHost.bringToFront();
WebInspector.inspectElementModeController.disable();
}
/** @type {!WebInspector.ElementsPanel} */ (WebInspector.panel("elements")).revealAndSelectNode(node.id);
}
}
......@@ -283,7 +283,7 @@ WebInspector.ScreencastView.prototype = {
if (event.type === "mousemove")
this.highlightDOMNode(nodeId, this._inspectModeConfig);
else if (event.type === "click")
WebInspector.domAgent.dispatchEventToListeners(WebInspector.DOMAgent.Events.InspectNodeRequested, nodeId);
WebInspector.Revealer.reveal(WebInspector.domAgent.nodeForId(nodeId));
}
},
......
......@@ -343,7 +343,6 @@ WebInspector._doLoadedDoneWithCapabilities = function()
this.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPaused, this);
this.networkLog = new WebInspector.NetworkLog();
this.domAgent = new WebInspector.DOMAgent();
this.domAgent.addEventListener(WebInspector.DOMAgent.Events.InspectNodeRequested, this._inspectNodeRequested, this);
this.workerManager = new WebInspector.WorkerManager(Capabilities.canInspectWorkers);
this.runtimeModel = new WebInspector.RuntimeModel(this.resourceTreeModel);
......@@ -810,14 +809,20 @@ WebInspector.inspect = function(payload, hints)
{
var object = WebInspector.RemoteObject.fromPayload(payload);
if (object.subtype === "node") {
object.pushNodeToFrontend(callback);
var elementsPanel = /** @type {!WebInspector.ElementsPanel} */ WebInspector.panel("elements");
elementsPanel.omitDefaultSelection();
WebInspector.inspectorView.setCurrentPanel(elementsPanel);
function callback(nodeId)
{
WebInspector._updateFocusedNode(nodeId);
elementsPanel.stopOmittingDefaultSelection();
WebInspector.Revealer.reveal(WebInspector.domAgent.nodeForId(nodeId));
InspectorFrontendHost.inspectElementCompleted();
object.release();
}
object.pushNodeToFrontend(callback);
WebInspector.showPanel("elements");
return;
}
......@@ -875,7 +880,13 @@ WebInspector._updateFocusedNode = function(nodeId)
InspectorFrontendHost.bringToFront();
WebInspector.inspectElementModeController.disable();
}
WebInspector.showPanel("elements").revealAndSelectNode(nodeId);
WebInspector.panel("elements").revealAndSelectNode(nodeId);
}
WebInspector.evaluateInConsole = function(expression, showResultOnly)
{
this.showConsole();
this.consoleView.evaluateUsingTextPrompt(expression, showResultOnly);
}
WebInspector.addMainEventListeners = function(doc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment