Web Inspector: Inspect Element doesn't always highlight the correct element when...
authorjonowells@apple.com <jonowells@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Aug 2014 00:56:44 +0000 (00:56 +0000)
committerjonowells@apple.com <jonowells@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Aug 2014 00:56:44 +0000 (00:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135995

Reviewed by Joseph Pecoraro.

Change so if an element is inspected via the Inspect Element context menu, selected
node restoration is disallowed until the main resource in the main frame changes.
This way an attempt by a sub-frame will not change the highlighted element in the
Main Frame's DOM tree unexpectedly.

* UserInterface/Controllers/DOMTreeManager.js:
(WebInspector.DOMTreeManager):
(WebInspector.DOMTreeManager.prototype._mainResourceDidChange):
(WebInspector.DOMTreeManager.prototype.inspectElement):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172662 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js

index c3b3fd1..b641b61 100644 (file)
@@ -1,3 +1,20 @@
+2014-08-15  Jono Wells  <jonowells@apple.com>
+
+        Web Inspector: Inspect Element doesn't always highlight the correct element when inspector is closed before inspecting
+        https://bugs.webkit.org/show_bug.cgi?id=135995
+
+        Reviewed by Joseph Pecoraro.
+
+        Change so if an element is inspected via the Inspect Element context menu, selected
+        node restoration is disallowed until the main resource in the main frame changes.
+        This way an attempt by a sub-frame will not change the highlighted element in the
+        Main Frame's DOM tree unexpectedly.
+
+        * UserInterface/Controllers/DOMTreeManager.js:
+        (WebInspector.DOMTreeManager):
+        (WebInspector.DOMTreeManager.prototype._mainResourceDidChange):
+        (WebInspector.DOMTreeManager.prototype.inspectElement):
+
 2014-08-15  Brian J. Burg  <burg@cs.washington.edu>
 
         Web Inspector: rewrite CodeGeneratorInspector to be modular and testable
index b557806..53aa2c1 100644 (file)
@@ -37,6 +37,8 @@ WebInspector.DOMTreeManager = function() {
     this._flows = new Map;
     this._contentNodesToFlowsMap = new Map;
     this._restoreSelectedNodeIsAllowed = true;
+
+    WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
 };
 
 WebInspector.Object.addConstructorFunctions(WebInspector.DOMTreeManager);
@@ -271,8 +273,6 @@ WebInspector.DOMTreeManager.prototype = {
 
     inspectElement: function(nodeId)
     {
-        this._restoreSelectedNodeIsAllowed = true;
-
         var node = this._idToDOMNode[nodeId];
         if (node)
             this.dispatchEventToListeners(WebInspector.DOMTreeManager.Event.DOMNodeWasInspected, {node: node});
@@ -711,6 +711,14 @@ WebInspector.DOMTreeManager.prototype = {
 
             return result;
         }
+    },
+
+    // Private
+
+    _mainResourceDidChange: function(event)
+    {
+        if (event.target.isMainFrame())
+            this._restoreSelectedNodeIsAllowed = true;
     }
 };