Changeset 183713 in webkit


Ignore:
Timestamp:
May 2, 2015 2:36:12 AM (9 years ago)
Author:
timothy@apple.com
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.

Location:
trunk/Source/WebInspectorUI
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r183671 r183713  
     12015-05-02  Timothy Hatcher  <timothy@apple.com>
     2
     3        Web Inspector: REGRESSION: Resources section doesn't update after changes are made to a local file
     4        https://bugs.webkit.org/show_bug.cgi?id=144512
     5
     6        The content view was being associated with the wrong represented object. This caused the code to use
     7        the old main resource when showing the frame again.
     8
     9        Reviewed by Joseph Pecoraro.
     10
     11        * UserInterface/Base/Main.js:
     12        (WebInspector._frameWasAdded.delayedWork):
     13        (WebInspector._frameWasAdded):
     14        With the changes in ResourceSidebarPanel, we need to delay showing the frame.
     15
     16        * UserInterface/Views/ContentBrowserTabContentView.js:
     17        (WebInspector.ContentBrowserTabContentView.prototype.showRepresentedObject):
     18        Avoid restoring state by calling cancelRestoringState(). Not fully related to this bug,
     19        but it was preventing testing the cases.
     20
     21        * UserInterface/Views/ContentViewContainer.js:
     22        (WebInspector.ContentViewContainer.prototype.contentViewForRepresentedObject):
     23        This fixes the bug. Don't associate the content view with the Frame, associate it with
     24        the Resource that we actually show.
     25
     26        * UserInterface/Views/NavigationSidebarPanel.js:
     27        (WebInspector.NavigationSidebarPanel.prototype.cancelRestoringState): Added.
     28
     29        * UserInterface/Views/ResourceSidebarPanel.js:
     30        (WebInspector.ResourceSidebarPanel): Remove unused _waitingForInitialMainFrame.
     31        (WebInspector.ResourceSidebarPanel.prototype.treeElementForRepresentedObject):
     32        (WebInspector.ResourceSidebarPanel.prototype._mainResourceDidChange):
     33        (WebInspector.ResourceSidebarPanel.prototype._mainFrameDidChange):
     34        (WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange.delayedWork):
     35        (WebInspector.ResourceSidebarPanel.prototype._mainFrameMainResourceDidChange):
     36        Clean up how we show the main frame in the sidebar. This was a two step mess before.
     37
    1382015-04-29  Timothy Hatcher  <timothy@apple.com>
    239
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r183642 r183713  
    10931093        return;
    10941094
    1095     this.showSourceCodeForFrame(frame.id);
     1095    function delayedWork()
     1096    {
     1097        this.showSourceCodeForFrame(frame.id);
     1098    }
     1099
     1100    // Delay showing the frame since FrameWasAdded is called before MainFrameChanged.
     1101    // Calling showSourceCodeForFrame before MainFrameChanged will show the frame then close it.
     1102    setTimeout(delayedWork.bind(this));
    10961103};
    10971104
  • trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js

    r183642 r183713  
    181181    showRepresentedObject: function(representedObject, cookie)
    182182    {
     183        if (this.navigationSidebarPanel)
     184            this.navigationSidebarPanel.cancelRestoringState();
    183185        this.contentBrowser.showContentViewForRepresentedObject(representedObject, cookie);
    184186    },
  • trunk/Source/WebInspectorUI/UserInterface/Views/ContentViewContainer.js

    r183422 r183713  
    115115            return null;
    116116
     117        // The representedObject can change in the constructor for ContentView. Remember the
     118        // contentViews on the real representedObject and not the one originally supplied.
     119        // The main case for this is a Frame being passed in and the main Resource being used.
     120        representedObject = contentView.representedObject;
     121
    117122        // Remember this content view for future calls.
    118123        if (!representedObject.__contentViews)
  • trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js

    r183579 r183713  
    140140    }
    141141
     142    cancelRestoringState()
     143    {
     144        if (!this._finalAttemptToRestoreViewStateTimeout)
     145            return;
     146
     147        clearTimeout(this._finalAttemptToRestoreViewStateTimeout);
     148        this._finalAttemptToRestoreViewStateTimeout = undefined;
     149    }
     150
    142151    createContentTreeOutline(dontHideByDefault, suppressFiltering)
    143152    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js

    r183671 r183713  
    3434        this.filterBar.placeholder = WebInspector.UIString("Filter Resource List");
    3535
    36         this._waitingForInitialMainFrame = true;
     36        WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
    3737
    3838        WebInspector.frameResourceManager.addEventListener(WebInspector.FrameResourceManager.Event.MainFrameDidChange, this._mainFrameDidChange, this);
     
    111111
    112112        // Only special case Script objects.
    113         if (!(representedObject instanceof WebInspector.Script))
     113        if (!(representedObject instanceof WebInspector.Script)) {
     114            console.error("Didn't find a TreeElement for representedObject", representedObject);
    114115            return null;
     116        }
    115117
    116118        // If the Script has a URL we should have found it earlier.
     
    140142    // Private
    141143
     144    _mainResourceDidChange(event)
     145    {
     146        if (!event.target.isMainFrame())
     147            return;
     148
     149        this._mainFrameMainResourceDidChange(event.target);
     150    }
     151
    142152    _mainFrameDidChange(event)
    143153    {
     154        this._mainFrameMainResourceDidChange(WebInspector.frameResourceManager.mainFrame);
     155    }
     156
     157    _mainFrameMainResourceDidChange(mainFrame)
     158    {
     159        this.contentBrowser.contentViewContainer.closeAllContentViews();
     160
    144161        if (this._mainFrameTreeElement) {
    145             this._mainFrameTreeElement.frame.removeEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainFrameMainResourceDidChange, this);
    146162            this.contentTreeOutline.removeChild(this._mainFrameTreeElement);
    147163            this._mainFrameTreeElement = null;
    148164        }
    149165
    150         var newFrame = WebInspector.frameResourceManager.mainFrame;
    151         if (newFrame) {
    152             newFrame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainFrameMainResourceDidChange, this);
    153             this._mainFrameTreeElement = new WebInspector.FrameTreeElement(newFrame);
    154             this.contentTreeOutline.insertChild(this._mainFrameTreeElement, 0);
    155 
    156             // Select a tree element by default. Allow onselect if we aren't showing a content view.
     166        if (!mainFrame)
     167            return;
     168
     169        this._mainFrameTreeElement = new WebInspector.FrameTreeElement(mainFrame);
     170        this.contentTreeOutline.insertChild(this._mainFrameTreeElement, 0);
     171
     172        function delayedWork()
     173        {
    157174            if (!this.contentTreeOutline.selectedTreeElement) {
    158175                var currentContentView = this.contentBrowser.currentContentView;
     
    164181        }
    165182
    166         // The navigation path needs update when the main frame changes, since all resources are under the main frame.
    167         this.contentBrowser.updateHierarchicalPathForCurrentContentView();
    168 
    169         // We only care about the first time the main frame changes.
    170         if (!this._waitingForInitialMainFrame)
    171             return;
    172 
    173         // Only if there is a main frame.
    174         if (!newFrame)
    175             return;
    176 
    177         this._waitingForInitialMainFrame = false;
    178     }
    179 
    180     _mainFrameMainResourceDidChange(event)
    181     {
    182         this.contentBrowser.contentViewContainer.closeAllContentViews();
    183 
    184         function delayedWork()
    185         {
    186             // Show the main frame since there is no content view showing.
    187             // Cookie restoration will attempt to re-select the resource we were showing.
    188             if (!this.contentBrowser.currentContentView) {
    189                 // NOTE: This selection, during provisional loading, won't be saved, so it is
    190                 // safe to do and not-clobber cookie restoration.
    191                 this.showDefaultContentViewForTreeElement(this._mainFrameTreeElement);
    192             }
    193         }
    194 
    195         // Delay this work because other listeners of this event might not have fired yet. So selecting the main frame
    196         // before those listeners do their work might cause the content of the old page to show instead of the new page.
    197         setTimeout(delayedWork.bind(this), 0);
     183        // Cookie restoration will attempt to re-select the resource we were showing.
     184        // Give it time to do that before selecting the main frame resource.
     185        setTimeout(delayedWork.bind(this));
    198186    }
    199187
Note: See TracChangeset for help on using the changeset viewer.