Title: [183713] trunk/Source/WebInspectorUI
Revision
183713
Author
[email protected]
Date
2015-05-02 02:36:12 -0700 (Sat, 02 May 2015)

Log Message

Web Inspector: REGRESSION: Resources section doesn't update after changes are made to a local file
https://bugs.webkit.org/show_bug.cgi?id=144512

The content view was being associated with the wrong represented object. This caused the code to use
the old main resource when showing the frame again.

Reviewed by Joseph Pecoraro.

* UserInterface/Base/Main.js:
(WebInspector._frameWasAdded.delayedWork):
(WebInspector._frameWasAdded):
With the changes in ResourceSidebarPanel, we need to delay showing the frame.

* UserInterface/Views/ContentBrowserTabContentView.js:
(WebInspector.ContentBrowserTabContentView.prototype.showRepresentedObject):
Avoid restoring state by calling cancelRestoringState(). Not fully related to this bug,
but it was preventing testing the cases.

* UserInterface/Views/ContentViewContainer.js:
(WebInspector.ContentViewContainer.prototype.contentViewForRepresentedObject):
This fixes the bug. Don't associate the content view with the Frame, associate it with
the Resource that we actually show.

* UserInterface/Views/NavigationSidebarPanel.js:
(WebInspector.NavigationSidebarPanel.prototype.cancelRestoringState): Added.

* UserInterface/Views/ResourceSidebarPanel.js:
(WebInspector.ResourceSidebarPanel): Remove unused _waitingForInitialMainFrame.
(WebInspector.ResourceSidebarPanel.prototype.treeElementForRepresentedObject):
(WebInspector.ResourceSidebarPanel.prototype._mainResourceDidChange):
(WebInspector.ResourceSidebarPanel.prototype._mainFrameDidChange):
(WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange.delayedWork):
(WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange):
Clean up how we show the main frame in the sidebar. This was a two step mess before.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (183712 => 183713)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-05-02 06:09:47 UTC (rev 183712)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-05-02 09:36:12 UTC (rev 183713)
@@ -1,3 +1,40 @@
+2015-05-02  Timothy Hatcher  <[email protected]>
+
+        Web Inspector: REGRESSION: Resources section doesn't update after changes are made to a local file
+        https://bugs.webkit.org/show_bug.cgi?id=144512
+
+        The content view was being associated with the wrong represented object. This caused the code to use
+        the old main resource when showing the frame again.
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector._frameWasAdded.delayedWork):
+        (WebInspector._frameWasAdded):
+        With the changes in ResourceSidebarPanel, we need to delay showing the frame.
+
+        * UserInterface/Views/ContentBrowserTabContentView.js:
+        (WebInspector.ContentBrowserTabContentView.prototype.showRepresentedObject):
+        Avoid restoring state by calling cancelRestoringState(). Not fully related to this bug,
+        but it was preventing testing the cases.
+
+        * UserInterface/Views/ContentViewContainer.js:
+        (WebInspector.ContentViewContainer.prototype.contentViewForRepresentedObject):
+        This fixes the bug. Don't associate the content view with the Frame, associate it with
+        the Resource that we actually show.
+
+        * UserInterface/Views/NavigationSidebarPanel.js:
+        (WebInspector.NavigationSidebarPanel.prototype.cancelRestoringState): Added.
+
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WebInspector.ResourceSidebarPanel): Remove unused _waitingForInitialMainFrame.
+        (WebInspector.ResourceSidebarPanel.prototype.treeElementForRepresentedObject):
+        (WebInspector.ResourceSidebarPanel.prototype._mainResourceDidChange):
+        (WebInspector.ResourceSidebarPanel.prototype._mainFrameDidChange):
+        (WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange.delayedWork):
+        (WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange):
+        Clean up how we show the main frame in the sidebar. This was a two step mess before.
+
 2015-04-29  Timothy Hatcher  <[email protected]>
 
         Web Inspector: Remove FrameContentView.js

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (183712 => 183713)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-05-02 06:09:47 UTC (rev 183712)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-05-02 09:36:12 UTC (rev 183713)
@@ -1092,7 +1092,14 @@
     if (frame.id !== this._frameIdentifierToShowSourceCodeWhenAvailable)
         return;
 
-    this.showSourceCodeForFrame(frame.id);
+    function delayedWork()
+    {
+        this.showSourceCodeForFrame(frame.id);
+    }
+
+    // Delay showing the frame since FrameWasAdded is called before MainFrameChanged.
+    // Calling showSourceCodeForFrame before MainFrameChanged will show the frame then close it.
+    setTimeout(delayedWork.bind(this));
 };
 
 WebInspector._mainFrameDidChange = function(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js (183712 => 183713)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js	2015-05-02 06:09:47 UTC (rev 183712)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js	2015-05-02 09:36:12 UTC (rev 183713)
@@ -180,6 +180,8 @@
 
     showRepresentedObject: function(representedObject, cookie)
     {
+        if (this.navigationSidebarPanel)
+            this.navigationSidebarPanel.cancelRestoringState();
         this.contentBrowser.showContentViewForRepresentedObject(representedObject, cookie);
     },
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js (183712 => 183713)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js	2015-05-02 06:09:47 UTC (rev 183712)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js	2015-05-02 09:36:12 UTC (rev 183713)
@@ -114,6 +114,11 @@
         if (!contentView)
             return null;
 
+        // The representedObject can change in the constructor for ContentView. Remember the
+        // contentViews on the real representedObject and not the one originally supplied.
+        // The main case for this is a Frame being passed in and the main Resource being used.
+        representedObject = contentView.representedObject;
+
         // Remember this content view for future calls.
         if (!representedObject.__contentViews)
             representedObject.__contentViews = [];

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js (183712 => 183713)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js	2015-05-02 06:09:47 UTC (rev 183712)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js	2015-05-02 09:36:12 UTC (rev 183713)
@@ -139,6 +139,15 @@
         return this._restoringState;
     }
 
+    cancelRestoringState()
+    {
+        if (!this._finalAttemptToRestoreViewStateTimeout)
+            return;
+
+        clearTimeout(this._finalAttemptToRestoreViewStateTimeout);
+        this._finalAttemptToRestoreViewStateTimeout = undefined;
+    }
+
     createContentTreeOutline(dontHideByDefault, suppressFiltering)
     {
         var contentTreeOutlineElement = document.createElement("ol");

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (183712 => 183713)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js	2015-05-02 06:09:47 UTC (rev 183712)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js	2015-05-02 09:36:12 UTC (rev 183713)
@@ -33,7 +33,7 @@
 
         this.filterBar.placeholder = WebInspector.UIString("Filter Resource List");
 
-        this._waitingForInitialMainFrame = true;
+        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
 
         WebInspector.frameResourceManager.addEventListener(WebInspector.FrameResourceManager.Event.MainFrameDidChange, this._mainFrameDidChange, this);
 
@@ -110,8 +110,10 @@
             return treeElement;
 
         // Only special case Script objects.
-        if (!(representedObject instanceof WebInspector.Script))
+        if (!(representedObject instanceof WebInspector.Script)) {
+            console.error("Didn't find a TreeElement for representedObject", representedObject);
             return null;
+        }
 
         // If the Script has a URL we should have found it earlier.
         if (representedObject.url) {
@@ -139,21 +141,36 @@
 
     // Private
 
+    _mainResourceDidChange(event)
+    {
+        if (!event.target.isMainFrame())
+            return;
+
+        this._mainFrameMainResourceDidChange(event.target);
+    }
+
     _mainFrameDidChange(event)
     {
+        this._mainFrameMainResourceDidChange(WebInspector.frameResourceManager.mainFrame);
+    }
+
+    _mainFrameMainResourceDidChange(mainFrame)
+    {
+        this.contentBrowser.contentViewContainer.closeAllContentViews();
+
         if (this._mainFrameTreeElement) {
-            this._mainFrameTreeElement.frame.removeEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainFrameMainResourceDidChange, this);
             this.contentTreeOutline.removeChild(this._mainFrameTreeElement);
             this._mainFrameTreeElement = null;
         }
 
-        var newFrame = WebInspector.frameResourceManager.mainFrame;
-        if (newFrame) {
-            newFrame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainFrameMainResourceDidChange, this);
-            this._mainFrameTreeElement = new WebInspector.FrameTreeElement(newFrame);
-            this.contentTreeOutline.insertChild(this._mainFrameTreeElement, 0);
+        if (!mainFrame)
+            return;
 
-            // Select a tree element by default. Allow onselect if we aren't showing a content view.
+        this._mainFrameTreeElement = new WebInspector.FrameTreeElement(mainFrame);
+        this.contentTreeOutline.insertChild(this._mainFrameTreeElement, 0);
+
+        function delayedWork()
+        {
             if (!this.contentTreeOutline.selectedTreeElement) {
                 var currentContentView = this.contentBrowser.currentContentView;
                 var treeElement = currentContentView ? this.treeElementForRepresentedObject(currentContentView.representedObject) : null;
@@ -163,40 +180,11 @@
             }
         }
 
-        // The navigation path needs update when the main frame changes, since all resources are under the main frame.
-        this.contentBrowser.updateHierarchicalPathForCurrentContentView();
-
-        // We only care about the first time the main frame changes.
-        if (!this._waitingForInitialMainFrame)
-            return;
-
-        // Only if there is a main frame.
-        if (!newFrame)
-            return;
-
-        this._waitingForInitialMainFrame = false;
+        // Cookie restoration will attempt to re-select the resource we were showing.
+        // Give it time to do that before selecting the main frame resource.
+        setTimeout(delayedWork.bind(this));
     }
 
-    _mainFrameMainResourceDidChange(event)
-    {
-        this.contentBrowser.contentViewContainer.closeAllContentViews();
-
-        function delayedWork()
-        {
-            // Show the main frame since there is no content view showing.
-            // Cookie restoration will attempt to re-select the resource we were showing.
-            if (!this.contentBrowser.currentContentView) {
-                // NOTE: This selection, during provisional loading, won't be saved, so it is
-                // safe to do and not-clobber cookie restoration.
-                this.showDefaultContentViewForTreeElement(this._mainFrameTreeElement);
-            }
-        }
-
-        // Delay this work because other listeners of this event might not have fired yet. So selecting the main frame
-        // before those listeners do their work might cause the content of the old page to show instead of the new page.
-        setTimeout(delayedWork.bind(this), 0);
-    }
-
     _scriptWasAdded(event)
     {
         var script = event.data.script;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to