Changeset 157269 in webkit


Ignore:
Timestamp:
Oct 10, 2013 4:20:56 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: content views and managers should save/restore view state.
https://bugs.webkit.org/show_bug.cgi?id=122546

To restore the same content view and sidebars when re-opening the
inspector, a cookie is saved whenever a new content view is shown
in the main content browser. Previously, this cookie was created
and restored using navigation sidebar-specific logic. This has two
major flaws: non-default sidebars for a represented object are not
restored correctly; and it centralizes storage of view-specific
state such as subview selections.

This patch adds ContentView methods for saving a key for the
view's represented object, and saving/restoring any view-specific
state as the view is shown. The 'type' field of the cookie
specifies the manager which deserializes the cookie into a
represented object.

Patch by Brian J. Burg <Brian Burg> on 2013-10-10
Reviewed by Timothy Hatcher.

  • UserInterface/ApplicationCacheFrameContentView.js:

(WebInspector.ApplicationCacheFrameContentView):
(WebInspector.ApplicationCacheFrameContentView.prototype.saveToCookie):
(WebInspector.ApplicationCacheFrameContentView.prototype._maybeUpdate):
(WebInspector.ApplicationCacheFrameContentView.prototype._updateStatus):
(WebInspector.ApplicationCacheFrameContentView.prototype.updateStatus):
(WebInspector.ApplicationCacheFrameContentView.prototype._updateCallback):

  • UserInterface/ApplicationCacheManager.js:

(WebInspector.ApplicationCacheManager.prototype.networkStateUpdated):
(WebInspector.ApplicationCacheManager.prototype.applicationCacheStatusUpdated):
(WebInspector.ApplicationCacheManager.prototype.):
(WebInspector.ApplicationCacheManager.prototype.requestApplicationCache):
(WebInspector.ApplicationCacheManager.prototype.objectForCookie):
(WebInspector.ApplicationCacheManager.prototype._manifestForFrameLoaded):
(WebInspector.ApplicationCacheManager.prototype._framesWithManifestsLoaded):
(WebInspector.ApplicationCacheManager.prototype._frameManifestUpdated):

  • UserInterface/BackForwardEntry.js:

(WebInspector.BackForwardEntry):
(WebInspector.BackForwardEntry.prototype._restoreFromCookie):

  • UserInterface/ContentBrowser.js:

(WebInspector.ContentBrowser.prototype.showContentViewForRepresentedObject):
(WebInspector.ContentBrowser.prototype.showContentView):

  • UserInterface/ContentView.js:

(WebInspector.ContentView.prototype.saveToCookie):
(WebInspector.ContentView.prototype.restoreFromCookie):

  • UserInterface/ContentViewContainer.js:

(WebInspector.ContentViewContainer.prototype.showContentView):

  • UserInterface/CookieStorageContentView.js:

(WebInspector.CookieStorageContentView.prototype.update):
(WebInspector.CookieStorageContentView.prototype.saveToCookie):
(WebInspector.CookieStorageContentView.prototype._rebuildTable):
(WebInspector.CookieStorageContentView.prototype._filterCookies):

  • UserInterface/DOMStorageContentView.js:

(WebInspector.DOMStorageContentView.prototype.saveToCookie):

  • UserInterface/DatabaseContentView.js:

(WebInspector.DatabaseContentView.prototype.saveToCookie):
(WebInspector.DatabaseContentView.prototype._messagesClicked):

  • UserInterface/DatabaseTableContentView.js:

(WebInspector.DatabaseTableContentView):
(WebInspector.DatabaseTableContentView.prototype.saveToCookie):

  • UserInterface/FrameContentView.js:

(WebInspector.FrameContentView.prototype.saveToCookie):
(WebInspector.FrameContentView.prototype.restoreFromCookie):

  • UserInterface/FrameResourceManager.js:

(WebInspector.FrameResourceManager.prototype.objectForCookie):

  • UserInterface/InstrumentSidebarPanel.js:

(WebInspector.InstrumentSidebarPanel):
(WebInspector.InstrumentSidebarPanel.prototype.showTimeline):
(WebInspector.InstrumentSidebarPanel.prototype.shown):
(WebInspector.InstrumentSidebarPanel.prototype._timelinesTreeElementSelected):

  • UserInterface/Main.js:

(WebInspector.loaded):
(WebInspector.contentLoaded):
(WebInspector.openURL):
(WebInspector._updateCurrentContentViewCookie):
(WebInspector._showContentViewForCookie.lastAttemptToRestoreFromCookie):
(WebInspector._showContentViewForCookie):
(WebInspector._resolveAndShowPendingContentViewCookie.delayedWork):
(WebInspector._resolveAndShowPendingContentViewCookie):
(WebInspector.elementDragStart):
(WebInspector.elementDragEnd):
(WebInspector.createMessageTextView):
(WebInspector.linkifyStringAsFragment):

  • UserInterface/NavigationSidebarPanel.js:
  • UserInterface/ResourceClusterContentView.js:

(WebInspector.ResourceClusterContentView.prototype.saveToCookie):
(WebInspector.ResourceClusterContentView.prototype.restoreFromCookie):

  • UserInterface/ResourceSidebarPanel.js:

(WebInspector.ResourceSidebarPanel.prototype.showSourceCode):
(WebInspector.ResourceSidebarPanel.prototype._mainFrameDidChange):
(WebInspector.ResourceSidebarPanel.prototype._domStorageObjectWasAdded):
(WebInspector.ResourceSidebarPanel.prototype._databaseWasAdded):
(WebInspector.ResourceSidebarPanel.prototype._cookieStorageObjectWasAdded):
(WebInspector.ResourceSidebarPanel.prototype._frameManifestAdded):

  • UserInterface/ScriptContentView.js:

(WebInspector.ScriptContentView.prototype.saveToCookie):
(WebInspector.ScriptContentView.prototype.restoreFromCookie):

  • UserInterface/StorageManager.js:

(WebInspector.StorageManager.prototype.findMatchingObjectInArray):
(WebInspector.StorageManager.prototype.objectForCookie):

  • UserInterface/TimelineManager.js:

(WebInspector.TimelineManager):
(WebInspector.TimelineManager.prototype.get timelines):
(WebInspector.TimelineManager.prototype.objectForCookie):

  • UserInterface/TimelinesContentView.js:

(WebInspector.TimelinesContentView.prototype.saveToCookie):
(WebInspector.TimelinesContentView.prototype.restoreFromCookie):
(WebInspector.TimelinesContentView.prototype._makeColumnScopeBar):

Location:
trunk/Source/WebInspectorUI
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r157241 r157269  
     12013-10-10  Brian J. Burg  <burg@cs.washington.edu>
     2
     3        Web Inspector: content views and managers should save/restore view state.
     4        https://bugs.webkit.org/show_bug.cgi?id=122546
     5
     6        To restore the same content view and sidebars when re-opening the
     7        inspector, a cookie is saved whenever a new content view is shown
     8        in the main content browser. Previously, this cookie was created
     9        and restored using navigation sidebar-specific logic. This has two
     10        major flaws: non-default sidebars for a represented object are not
     11        restored correctly; and it centralizes storage of view-specific
     12        state such as subview selections.
     13
     14        This patch adds ContentView methods for saving a key for the
     15        view's represented object, and saving/restoring any view-specific
     16        state as the view is shown. The 'type' field of the cookie
     17        specifies the manager which deserializes the cookie into a
     18        represented object.
     19
     20        Reviewed by Timothy Hatcher.
     21
     22        * UserInterface/ApplicationCacheFrameContentView.js:
     23        (WebInspector.ApplicationCacheFrameContentView):
     24        (WebInspector.ApplicationCacheFrameContentView.prototype.saveToCookie):
     25        (WebInspector.ApplicationCacheFrameContentView.prototype._maybeUpdate):
     26        (WebInspector.ApplicationCacheFrameContentView.prototype._updateStatus):
     27        (WebInspector.ApplicationCacheFrameContentView.prototype.updateStatus):
     28        (WebInspector.ApplicationCacheFrameContentView.prototype._updateCallback):
     29        * UserInterface/ApplicationCacheManager.js:
     30        (WebInspector.ApplicationCacheManager.prototype.networkStateUpdated):
     31        (WebInspector.ApplicationCacheManager.prototype.applicationCacheStatusUpdated):
     32        (WebInspector.ApplicationCacheManager.prototype.):
     33        (WebInspector.ApplicationCacheManager.prototype.requestApplicationCache):
     34        (WebInspector.ApplicationCacheManager.prototype.objectForCookie):
     35        (WebInspector.ApplicationCacheManager.prototype._manifestForFrameLoaded):
     36        (WebInspector.ApplicationCacheManager.prototype._framesWithManifestsLoaded):
     37        (WebInspector.ApplicationCacheManager.prototype._frameManifestUpdated):
     38        * UserInterface/BackForwardEntry.js:
     39        (WebInspector.BackForwardEntry):
     40        (WebInspector.BackForwardEntry.prototype._restoreFromCookie):
     41        * UserInterface/ContentBrowser.js:
     42        (WebInspector.ContentBrowser.prototype.showContentViewForRepresentedObject):
     43        (WebInspector.ContentBrowser.prototype.showContentView):
     44        * UserInterface/ContentView.js:
     45        (WebInspector.ContentView.prototype.saveToCookie):
     46        (WebInspector.ContentView.prototype.restoreFromCookie):
     47        * UserInterface/ContentViewContainer.js:
     48        (WebInspector.ContentViewContainer.prototype.showContentView):
     49        * UserInterface/CookieStorageContentView.js:
     50        (WebInspector.CookieStorageContentView.prototype.update):
     51        (WebInspector.CookieStorageContentView.prototype.saveToCookie):
     52        (WebInspector.CookieStorageContentView.prototype._rebuildTable):
     53        (WebInspector.CookieStorageContentView.prototype._filterCookies):
     54        * UserInterface/DOMStorageContentView.js:
     55        (WebInspector.DOMStorageContentView.prototype.saveToCookie):
     56        * UserInterface/DatabaseContentView.js:
     57        (WebInspector.DatabaseContentView.prototype.saveToCookie):
     58        (WebInspector.DatabaseContentView.prototype._messagesClicked):
     59        * UserInterface/DatabaseTableContentView.js:
     60        (WebInspector.DatabaseTableContentView):
     61        (WebInspector.DatabaseTableContentView.prototype.saveToCookie):
     62        * UserInterface/FrameContentView.js:
     63        (WebInspector.FrameContentView.prototype.saveToCookie):
     64        (WebInspector.FrameContentView.prototype.restoreFromCookie):
     65        * UserInterface/FrameResourceManager.js:
     66        (WebInspector.FrameResourceManager.prototype.objectForCookie):
     67        * UserInterface/InstrumentSidebarPanel.js:
     68        (WebInspector.InstrumentSidebarPanel):
     69        (WebInspector.InstrumentSidebarPanel.prototype.showTimeline):
     70        (WebInspector.InstrumentSidebarPanel.prototype.shown):
     71        (WebInspector.InstrumentSidebarPanel.prototype._timelinesTreeElementSelected):
     72        * UserInterface/Main.js:
     73        (WebInspector.loaded):
     74        (WebInspector.contentLoaded):
     75        (WebInspector.openURL):
     76        (WebInspector._updateCurrentContentViewCookie):
     77        (WebInspector._showContentViewForCookie.lastAttemptToRestoreFromCookie):
     78        (WebInspector._showContentViewForCookie):
     79        (WebInspector._resolveAndShowPendingContentViewCookie.delayedWork):
     80        (WebInspector._resolveAndShowPendingContentViewCookie):
     81        (WebInspector.elementDragStart):
     82        (WebInspector.elementDragEnd):
     83        (WebInspector.createMessageTextView):
     84        (WebInspector.linkifyStringAsFragment):
     85        * UserInterface/NavigationSidebarPanel.js:
     86        * UserInterface/ResourceClusterContentView.js:
     87        (WebInspector.ResourceClusterContentView.prototype.saveToCookie):
     88        (WebInspector.ResourceClusterContentView.prototype.restoreFromCookie):
     89        * UserInterface/ResourceSidebarPanel.js:
     90        (WebInspector.ResourceSidebarPanel.prototype.showSourceCode):
     91        (WebInspector.ResourceSidebarPanel.prototype._mainFrameDidChange):
     92        (WebInspector.ResourceSidebarPanel.prototype._domStorageObjectWasAdded):
     93        (WebInspector.ResourceSidebarPanel.prototype._databaseWasAdded):
     94        (WebInspector.ResourceSidebarPanel.prototype._cookieStorageObjectWasAdded):
     95        (WebInspector.ResourceSidebarPanel.prototype._frameManifestAdded):
     96        * UserInterface/ScriptContentView.js:
     97        (WebInspector.ScriptContentView.prototype.saveToCookie):
     98        (WebInspector.ScriptContentView.prototype.restoreFromCookie):
     99        * UserInterface/StorageManager.js:
     100        (WebInspector.StorageManager.prototype.findMatchingObjectInArray):
     101        (WebInspector.StorageManager.prototype.objectForCookie):
     102        * UserInterface/TimelineManager.js:
     103        (WebInspector.TimelineManager):
     104        (WebInspector.TimelineManager.prototype.get timelines):
     105        (WebInspector.TimelineManager.prototype.objectForCookie):
     106        * UserInterface/TimelinesContentView.js:
     107        (WebInspector.TimelinesContentView.prototype.saveToCookie):
     108        (WebInspector.TimelinesContentView.prototype.restoreFromCookie):
     109        (WebInspector.TimelinesContentView.prototype._makeColumnScopeBar):
     110
    11112013-10-10  Mark Rowe  <mrowe@apple.com>
    2112
     
    251361        can be incorrect depending on the sort order and the number of nodes. To fix this, we now manually
    252362        set "even" and "odd" CSS classes on those nodes when they're sorted such that we have a chance
    253         to style them as intended. 
     363        to style them as intended.
    254364
    255365        * UserInterface/LayerTreeDataGrid.js:
     
    180219122013-07-22  Diego Pino Garcia  <dpino@igalia.com>
    18031913
    1804         Web Inspector: When right-clicking on a DataGrid column, show editing 
     1914        Web Inspector: When right-clicking on a DataGrid column, show editing
    18051915        menu option as "Edit <columnName>" instead of just "Edit"
    18061916        https://bugs.webkit.org/show_bug.cgi?id=118970
     
    207821882013-06-27  James Craig  <james@cookiecrook.com>
    20792189
    2080         Web Inspector: AX: Add container ARIA roles (toolbar, main, labeled regions, etc.) 
     2190        Web Inspector: AX: Add container ARIA roles (toolbar, main, labeled regions, etc.)
    20812191        so the layout is more discoverable to screen reader users
    20822192        https://bugs.webkit.org/show_bug.cgi?id=118104
     
    21092219        Main console log area (div.console-messages) is now an ARIA live region (role="log")
    21102220        so screen readers speak plain text updates.
    2111        
     2221
    21122222        Also added contextual labels (e.g. input/output) but speech output verification of
    21132223        those is currently blocked by http://webkit.org/b/118096
  • trunk/Source/WebInspectorUI/UserInterface/ApplicationCacheFrameContentView.js

    r155241 r157269  
    4646
    4747    this._markDirty();
    48    
     48
    4949    var status = representedObject.status;
    5050    this.updateStatus(status);
     
    7272        if (this.dataGrid)
    7373            this.dataGrid.updateLayout();
     74    },
     75
     76    saveToCookie: function(cookie)
     77    {
     78        cookie.type = WebInspector.ContentViewCookieType.ApplicationCache;
     79        cookie.frame = this.representedObject.frame.url;
     80        cookie.manifest = this.representedObject.manifest.manifestURL;
    7481    },
    7582
     
    8592        if (!this.visible || !this._viewDirty)
    8693            return;
    87        
     94
    8895        this._update();
    8996        this._viewDirty = false;
     
    100107        if (frameManifest !== this.representedObject)
    101108            return;
    102        
     109
    103110        console.assert(frameManifest instanceof WebInspector.ApplicationCacheFrame);
    104        
     111
    105112        this.updateStatus(frameManifest.status);
    106113    },
     
    113120        var oldStatus = this._status;
    114121        this._status = status;
    115        
     122
    116123        if (this.visible && this._status === WebInspector.ApplicationCacheManager.Status.Idle && (oldStatus === WebInspector.ApplicationCacheManager.Status.UpdateReady || !this._resources))
    117124            this._markDirty();
     
    136143            delete this._size;
    137144            delete this._resources;
    138            
     145
    139146            this._emptyView.classList.remove("hidden");
    140            
     147
    141148            if (this._dataGrid)
    142149                this._dataGrid.element.classList.add("hidden");
     
    157164        this._dataGrid.autoSizeColumns(20, 80);
    158165        this._dataGrid.element.classList.remove("hidden");
    159        
     166
    160167        this._emptyView.classList.add("hidden");
    161168    },
  • trunk/Source/WebInspectorUI/UserInterface/ApplicationCacheManager.js

    r151453 r157269  
    7070    {
    7171        this._online = isNowOnline;
    72        
     72
    7373        this.dispatchEventToListeners(WebInspector.ApplicationCacheManager.Event.NetworkStateUpdated, {online: this._online});
    7474    },
     
    8484        if (!frame)
    8585            return;
    86        
     86
    8787        this._frameManifestUpdated(frame, manifestURL, status);
    8888    },
     
    9696                return;
    9797            }
    98            
     98
    9999            callback(applicationCache);
    100100        }
    101        
     101
    102102        ApplicationCacheAgent.getApplicationCacheForFrame(frame.id, callbackWrapper);
     103    },
     104
     105    objectForCookie: function(cookie, matchOnTypeAlone)
     106    {
     107        console.assert(cookie.type && cookie.type === WebInspector.ContentViewCookieType.ApplicationCache);
     108
     109        for (var i = 0; i < this._applicationCacheObjects.length; ++i) {
     110            var object = this._applicationCacheObjects[i];
     111            if (object.frame.url === cookie.frame && object.manifest.manifestURL === cookie.manifest)
     112                return object;
     113        }
     114
     115        return matchOnTypeAlone && this._applicationCacheObjects.length ? this._applicationCacheObjects[0] : null;
    103116    },
    104117
     
    134147        if (!frame)
    135148            return;
    136        
     149
    137150        if (!manifestURL)
    138151            this._frameManifestRemoved(frame);
    139152    },
    140    
     153
    141154    _framesWithManifestsLoaded: function(error, framesWithManifests)
    142155    {
    143156        if (error)
    144157            return;
    145        
     158
    146159        for (var i = 0; i < framesWithManifests.length; ++i) {
    147160            var frame = WebInspector.frameResourceManager.frameForIdentifier(framesWithManifests[i].frameId);
     
    152165        }
    153166    },
    154    
     167
    155168    _frameManifestUpdated: function(frame, manifestURL, status)
    156169    {
     
    171184        if (manifestFrame)
    172185            manifestFrame.status = status;
    173        
     186
    174187        if (!this._applicationCacheObjects[frame.id]) {
    175188            var cacheManifest = new WebInspector.ApplicationCacheManifest(manifestURL);
     
    178191            this.dispatchEventToListeners(WebInspector.ApplicationCacheManager.Event.FrameManifestAdded, {frameManifest: this._applicationCacheObjects[frame.id]});
    179192        }
    180        
     193
    181194        if (statusChanged)
    182195            this.dispatchEventToListeners(WebInspector.ApplicationCacheManager.Event.FrameManifestStatusChanged, {frameManifest: this._applicationCacheObjects[frame.id]});
    183196    },
    184    
     197
    185198    _frameManifestRemoved: function(frame)
    186199    {
  • trunk/Source/WebInspectorUI/UserInterface/BackForwardEntry.js

    r156809 r157269  
    2525 */
    2626
    27 WebInspector.BackForwardEntry = function(contentView, cookie, restoreCallback)
     27WebInspector.BackForwardEntry = function(contentView, cookie)
    2828{
    2929    WebInspector.Object.call(this);
     
    3232    this._cookie = cookie || {};
    3333    this._scrollPositions = [];
    34     this._restoreCallback = restoreCallback;
     34
     35    contentView.saveToCookie(this._cookie);
    3536};
    3637
     
    7475    {
    7576        this._restoreScrollPositions();
    76 
    77         if (this._restoreCallback && typeof this._restoreCallback === "function")
    78             this._restoreCallback.call(null, this.contentView, this.cookie);
     77        this.contentView.restoreFromCookie(this.cookie);
    7978    },
    8079
  • trunk/Source/WebInspectorUI/UserInterface/ContentBrowser.js

    r156809 r157269  
    153153    },
    154154
    155     showContentViewForRepresentedObject: function(representedObject)
    156     {
    157         return this._contentViewContainer.showContentViewForRepresentedObject(representedObject);
    158     },
    159 
    160     showContentView: function(contentView, cookie, restoreCallback)
    161     {
    162         return this._contentViewContainer.showContentView(contentView, cookie, restoreCallback);
     155    showContentViewForRepresentedObject: function(representedObject, cookie)
     156    {
     157        var contentView = this.contentViewForRepresentedObject(representedObject);
     158        return this._contentViewContainer.showContentView(contentView, cookie);
     159    },
     160
     161    showContentView: function(contentView, cookie)
     162    {
     163        return this._contentViewContainer.showContentView(contentView, cookie);
    163164    },
    164165
  • trunk/Source/WebInspectorUI/UserInterface/ContentView.js

    r153928 r157269  
    234234    },
    235235
     236    saveToCookie: function(cookie)
     237    {
     238        // Implemented by subclasses.
     239    },
     240
     241    restoreFromCookie: function(cookie)
     242    {
     243        // Implemented by subclasses.
     244    },
     245
    236246    canGoBack: function()
    237247    {
  • trunk/Source/WebInspectorUI/UserInterface/ContentViewContainer.js

    r156809 r157269  
    134134    },
    135135
    136     showContentView: function(contentView, cookie, restoreCallback)
     136    showContentView: function(contentView, cookie)
    137137    {
    138138        console.assert(contentView instanceof WebInspector.ContentView);
     
    147147
    148148        var currentEntry = this.currentBackForwardEntry;
    149         var provisionalEntry = new WebInspector.BackForwardEntry(contentView, cookie, restoreCallback);
     149        var provisionalEntry = new WebInspector.BackForwardEntry(contentView, cookie);
    150150        // Don't do anything if we would have added an identical back/forward list entry.
    151151        if (currentEntry && currentEntry.contentView === contentView && Object.shallowEqual(provisionalEntry.cookie, currentEntry.cookie))
  • trunk/Source/WebInspectorUI/UserInterface/CookieStorageContentView.js

    r151453 r157269  
    5050            this._rebuildTable();
    5151        }
    52    
     52
    5353        PageAgent.getCookies(callback.bind(this));
    5454    },
     
    5858        if (this._dataGrid)
    5959            this._dataGrid.updateLayout();
     60    },
     61
     62    saveToCookie: function(cookie)
     63    {
     64        cookie.type = WebInspector.ContentViewCookieType.CookieStorage;
     65        cookie.host = this.representedObject.host;
    6066    },
    6167
     
    109115            this._dataGrid.updateLayout();
    110116        }
    111        
     117
    112118        console.assert(this._dataGrid);
    113119        this._dataGrid.removeChildren();
     
    137143            node.cookie = cookie;
    138144            node.selectable = true;
    139            
     145
    140146            this._dataGrid.appendChild(node);
    141147        }
     
    171177            }
    172178        }
    173        
     179
    174180        return filteredCookies;
    175181    },
    176    
     182
    177183    _sortCookies: function(cookies)
    178184    {
  • trunk/Source/WebInspectorUI/UserInterface/DOMStorageContentView.js

    r153817 r157269  
    4646    },
    4747
     48    saveToCookie: function(cookie)
     49    {
     50        cookie.type = WebInspector.ContentViewCookieType.DOMStorage;
     51        cookie.isLocalStorage = this.representedObject.isLocalStorage();
     52        cookie.host = this.representedObject.host;
     53    },
     54
    4855    itemsCleared: function()
    4956    {
  • trunk/Source/WebInspectorUI/UserInterface/DatabaseContentView.js

    r155241 r157269  
    5151    constructor: WebInspector.DatabaseContentView,
    5252
     53    // Public
     54
    5355    shown: function()
    5456    {
     
    6870    },
    6971
    70     _messagesClicked: function()
     72    saveToCookie: function(cookie)
    7173    {
    72         this.prompt.focus();
     74        cookie.type = WebInspector.ContentViewCookieType.Database;
     75        cookie.host = this.representedObject.host;
     76        cookie.name = this.representedObject.name;
    7377    },
    74    
     78
    7579    consolePromptCompletionsNeeded: function(prompt, defaultCompletions, base, prefix, suffix)
    7680    {
     
    102106    {
    103107        this.database.executeSQL(query, this._queryFinished.bind(this, query), this._queryError.bind(this, query));
     108    },
     109
     110    // Private
     111
     112    _messagesClicked: function()
     113    {
     114        this.prompt.focus();
    104115    },
    105116
  • trunk/Source/WebInspectorUI/UserInterface/DatabaseTableContentView.js

    r151453 r157269  
    2727{
    2828    WebInspector.ContentView.call(this, representedObject);
    29    
     29
    3030    this.element.classList.add(WebInspector.DatabaseTableContentView.StyleClassName);
    31    
     31
    3232    this.update();
    3333};
     
    4949        if (this._dataGrid)
    5050            this._dataGrid.updateLayout();
     51    },
     52
     53    saveToCookie: function(cookie)
     54    {
     55        cookie.type = WebInspector.ContentViewCookieType.DatabaseTable;
     56        cookie.host = this.representedObject.host;
     57        cookie.name = this.representedObject.name;
     58        cookie.database = this.representedObject.database.name;
    5159    },
    5260
  • trunk/Source/WebInspectorUI/UserInterface/FrameContentView.js

    r151453 r157269  
    9696    },
    9797
     98    saveToCookie: function(cookie)
     99    {
     100        cookie.type = WebInspector.ContentViewCookieType.Resource;
     101        cookie.subview = this._currentContentViewSetting.value;
     102        if (!this.representedObject.isMainFrame())
     103            cookie.url = this.representedObject.url;
     104    },
     105
     106    restoreFromCookie: function(cookie)
     107    {
     108        var shownView = this._showContentViewForIdentifier(cookie.subview);
     109        if ("lineNumber" in cookie && "columnNumber" in cookie)
     110            this.showSourceCode(new WebInspector.SourceCodePosition(cookie.lineNumber, cookie.columnNumber));
     111    },
     112
    98113    showResource: function()
    99114    {
  • trunk/Source/WebInspectorUI/UserInterface/FrameResourceManager.js

    r156284 r157269  
    8181    },
    8282
     83
     84    objectForCookie: function(cookie)
     85    {
     86        var representedObject = cookie.url ? this.resourceForURL(cookie.url) : this.mainFrame;
     87
     88        if (!representedObject)
     89            representedObject = this.mainFrame;
     90
     91        if (representedObject instanceof WebInspector.Resource && representedObject.isMainResource())
     92            representedObject = representedObject.parentFrame;
     93
     94        return representedObject;
     95    },
     96
    8397    frameDidNavigate: function(framePayload)
    8498    {
  • trunk/Source/WebInspectorUI/UserInterface/InstrumentSidebarPanel.js

    r153928 r157269  
    5656    this._timelinesTreeOutline.allowsRepeatSelection = true;
    5757
    58     this._timelinesObject = new WebInspector.TimelinesObject;
    59 
    60     this._timelinesTreeElement = new WebInspector.GeneralTreeElement(WebInspector.InstrumentSidebarPanel.StopwatchIconStyleClass, WebInspector.UIString("Timelines"), null, this._timelinesObject);
     58    this._timelinesTreeElement = new WebInspector.GeneralTreeElement(WebInspector.InstrumentSidebarPanel.StopwatchIconStyleClass, WebInspector.UIString("Timelines"), null, WebInspector.timelineManager.timelines);
    6159
    6260    var networkTimelineTreeElement = new WebInspector.GeneralTreeElement(WebInspector.InstrumentSidebarPanel.NetworkIconStyleClass, WebInspector.UIString("Network Requests"), null, WebInspector.TimelineRecord.Type.Network);
     
    175173    showTimeline: function()
    176174    {
    177         WebInspector.contentBrowser.showContentViewForRepresentedObject(this._timelinesObject);
     175        WebInspector.contentBrowser.showContentViewForRepresentedObject(WebInspector.timelineManager.timelines);
    178176    },
    179177
     
    185183
    186184        treeElementToSelect.select(true, true);
    187     },
    188 
    189     cookieForContentView: function(contentView)
    190     {
    191         if (contentView instanceof WebInspector.TimelinesContentView)
    192             return {timeline: true};
    193         return null;
    194     },
    195 
    196     showContentViewForCookie: function(contentViewCookie)
    197     {
    198         if (!contentViewCookie)
    199             return;
    200 
    201         if (contentViewCookie.timeline)
    202             this.showTimeline();
    203185    },
    204186
     
    218200    shown: function()
    219201    {
    220         // Reselect the selected tree element to cause the content view to be shown as well. <rdar://problem/10854727>
    221         var selectedTreeElement = this._timelinesTreeOutline.selectedTreeElement;
    222         if (selectedTreeElement)
    223             selectedTreeElement.select(true, true);
    224 
     202        // Delegate to TimelinesContentView to select the default record type.
     203        WebInspector.contentBrowser.showContentViewForRepresentedObject(WebInspector.timelineManager.timelines);
    225204        WebInspector.NavigationSidebarPanel.prototype.shown.call(this);
    226205    },
     
    238217            selectedTreeElement.deselect();
    239218
    240         var contentView = WebInspector.contentBrowser.contentViewForRepresentedObject(this._timelinesObject);
     219        var contentView = WebInspector.contentBrowser.contentViewForRepresentedObject(WebInspector.timelineManager.timelines);
    241220        contentView.showTimelineForRecordType(treeElement.representedObject);
    242221        WebInspector.contentBrowser.showContentView(contentView);
  • trunk/Source/WebInspectorUI/UserInterface/Main.js

    r156923 r157269  
    3030};
    3131
     32WebInspector.ContentViewCookieType = {
     33    ApplicationCache: "application-cache",
     34    CookieStorage: "cookie-storage",
     35    Database: "database",
     36    DatabaseTable: "database-table",
     37    DOMStorage: "dom-storage",
     38    Resource: "resource", // includes Frame too.
     39    Timelines: "timelines",
     40
     41};
     42
    3243WebInspector.loaded = function()
    3344{
     
    94105    WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
    95106
     107    // These listeners are for events that could resolve a pending content view cookie.
     108    this.applicationCacheManager.addEventListener(WebInspector.ApplicationCacheManager.Event.FrameManifestAdded, this._resolveAndShowPendingContentViewCookie, this);
     109    this.frameResourceManager.addEventListener(WebInspector.FrameResourceManager.Event.MainFrameDidChange, this._resolveAndShowPendingContentViewCookie, this);
     110    this.storageManager.addEventListener(WebInspector.StorageManager.Event.DatabaseWasAdded, this._resolveAndShowPendingContentViewCookie, this);
     111    this.storageManager.addEventListener(WebInspector.StorageManager.Event.CookieStorageObjectWasAdded, this._resolveAndShowPendingContentViewCookie, this);
     112    this.storageManager.addEventListener(WebInspector.StorageManager.Event.DOMStorageObjectWasAdded, this._resolveAndShowPendingContentViewCookie, this);
     113
    96114    document.addEventListener("DOMContentLoaded", this.contentLoaded.bind(this));
    97115
     
    155173    this.toolbar.addEventListener(WebInspector.Toolbar.Event.DisplayModeDidChange, this._toolbarDisplayModeDidChange, this);
    156174    this.toolbar.addEventListener(WebInspector.Toolbar.Event.SizeModeDidChange, this._toolbarSizeModeDidChange, this);
    157    
     175
    158176    var contentElement = document.getElementById("content");
    159177    contentElement.setAttribute("role", "main");
     
    284302            // The console does not have a sidebar, so handle its special cookie here.
    285303            this.showFullHeightConsole();
    286         } else {
    287             var responsibleSidebarPanel = this.navigationSidebar.findSidebarPanel(this._lastContentViewResponsibleSidebarPanelSetting.value);
    288             if (responsibleSidebarPanel)
    289                 responsibleSidebarPanel.showContentViewForCookie(this._lastContentCookieSetting.value);
    290         }
     304        } else
     305            this._showContentViewForCookie(this._lastContentCookieSetting.value);
    291306    }
    292307
     
    492507        return;
    493508    }
    494    
     509
    495510    var parsedURL = parseURL(url);
    496511    if (parsedURL.scheme === WebInspector.ProfileType.ProfileScheme) {
    497512        var profileType = parsedURL.host.toUpperCase();
    498513        var profileTitle = parsedURL.path;
    499        
    500         // The path of of the profile URL starts with a slash, remove it, so 
     514
     515        // The path of of the profile URL starts with a slash, remove it, so
    501516        // we can get the actual title.
    502517        console.assert(profileTitle[0] === '/');
     
    10121027        return;
    10131028
    1014     var cookie = responsibleSidebarPanel.cookieForContentView(currentContentView);
    1015 
     1029    var cookie = {};
     1030    currentContentView.saveToCookie(cookie);
    10161031    this._lastContentViewResponsibleSidebarPanelSetting.value = responsibleSidebarPanel.identifier;
    10171032    this._lastContentCookieSetting.value = cookie;
     
    11091124}
    11101125
     1126WebInspector._showContentViewForCookie = function(cookie)
     1127{
     1128    if (!cookie || !cookie.type)
     1129        return null;
     1130
     1131    this._pendingContentViewCookie = cookie;
     1132    var shownContentView = this._resolveAndShowPendingContentViewCookie();
     1133
     1134    // At this point, we assume no storage objects or views have been created yet.
     1135    // If the cookie requests these views, they will be shown when the storage object
     1136    // is added (if it matches exactly), or any view of the same type (after a timeout).
     1137    if (!shownContentView) {
     1138        if (this._lastAttemptCookieCheckingTimeout)
     1139            clearTimeout(this._lastAttemptCookieCheckingTimeout);
     1140
     1141        var lastAttemptToRestoreFromCookie = function() {
     1142            delete this._lastAttemptCookieCheckingTimeout;
     1143            this._resolveAndShowPendingContentViewCookie(true);
     1144        };
     1145
     1146        // When the specific storage item wasn't found we want to relax the check to show the first item with the
     1147        // same type. There is no good time to naturally declare the cookie wasn't found, so we do that on a timeout.
     1148        this._lastAttemptCookieCheckingTimeout = setTimeout(lastAttemptToRestoreFromCookie.bind(this), 500);
     1149    }
     1150
     1151    return shownContentView;
     1152}
     1153
     1154WebInspector._resolveAndShowPendingContentViewCookie = function(matchOnTypeAlone)
     1155{
     1156    var cookie = this._pendingContentViewCookie;
     1157    if (!cookie)
     1158        return false;
     1159
     1160    var representedObject = null;
     1161
     1162    if (cookie.type === WebInspector.ContentViewCookieType.Resource)
     1163        representedObject = this.frameResourceManager.objectForCookie(cookie);
     1164
     1165    if (cookie.type === WebInspector.ContentViewCookieType.Timelines)
     1166        representedObject = this.timelineManager.objectForCookie(cookie);
     1167
     1168    if (cookie.type === WebInspector.ContentViewCookieType.CookieStorage || cookie.type === WebInspector.ContentViewCookieType.Database  || cookie.type === WebInspector.ContentViewCookieType.DatabaseTable || cookie.type === WebInspector.ContentViewCookieType.DOMStorage)
     1169        representedObject = this.storageManager.objectForCookie(cookie, matchOnTypeAlone);
     1170
     1171    if (cookie.type === WebInspector.ContentViewCookieType.ApplicationCache)
     1172        representedObject = this.applicationCacheManager.objectForCookie(cookie, matchOnTypeAlone);
     1173
     1174    if (!representedObject)
     1175        return false;
     1176
     1177    // If we reached this point, then we should be able to create and/or display a content view based on the cookie.
     1178    delete this._pendingContentViewCookie;
     1179    if (this._lastAttemptCookieCheckingTimeout)
     1180        clearTimeout(this._lastAttemptCookieCheckingTimeout);
     1181
     1182    // Delay this work because other listeners of the originating event might not have fired yet.
     1183    // So displaying the content view before those listeners do their work might cause the
     1184    // dependent view states (navigation sidebar tree elements, path components) to be wrong.
     1185    function delayedWork()
     1186    {
     1187        this.contentBrowser.showContentViewForRepresentedObject(representedObject, cookie);
     1188    }
     1189    setTimeout(delayedWork.bind(this), 0);
     1190    return true;
     1191}
     1192
    11111193WebInspector._initializeWebSocketIfNeeded = function()
    11121194{
     
    13881470    if (WebInspector._elementDraggingEventListener || WebInspector._elementEndDraggingEventListener)
    13891471        WebInspector.elementDragEnd(event);
    1390    
     1472
    13911473    if (element) {
    13921474        // Install glass pane
    13931475        if (WebInspector._elementDraggingGlassPane)
    13941476            WebInspector._elementDraggingGlassPane.parentElement.removeChild(WebInspector._elementDraggingGlassPane);
    1395        
     1477
    13961478        var glassPane = document.createElement("div");
    13971479        glassPane.style.cssText = "position:absolute;top:0;bottom:0;left:0;right:0;opacity:0;z-index:1";
     
    14001482        WebInspector._elementDraggingGlassPane = glassPane;
    14011483    }
    1402    
     1484
    14031485    WebInspector._elementDraggingEventListener = dividerDrag;
    14041486    WebInspector._elementEndDraggingEventListener = elementDragEnd;
    1405    
     1487
    14061488    var targetDocument = event.target.ownerDocument;
    14071489
     
    14091491    WebInspector._elementDraggingEventTarget.addEventListener("mousemove", dividerDrag, true);
    14101492    WebInspector._elementDraggingEventTarget.addEventListener("mouseup", elementDragEnd, true);
    1411    
     1493
    14121494    targetDocument.body.style.cursor = cursor;
    1413    
     1495
    14141496    event.preventDefault();
    14151497}
     
    14191501    WebInspector._elementDraggingEventTarget.removeEventListener("mousemove", WebInspector._elementDraggingEventListener, true);
    14201502    WebInspector._elementDraggingEventTarget.removeEventListener("mouseup", WebInspector._elementEndDraggingEventListener, true);
    1421    
     1503
    14221504    event.target.ownerDocument.body.style.removeProperty("cursor");
    1423    
     1505
    14241506    if (WebInspector._elementDraggingGlassPane)
    14251507        WebInspector._elementDraggingGlassPane.parentElement.removeChild(WebInspector._elementDraggingGlassPane);
    1426    
     1508
    14271509    delete WebInspector._elementDraggingGlassPane;
    14281510    delete WebInspector._elementDraggingEventTarget;
    14291511    delete WebInspector._elementDraggingEventListener;
    14301512    delete WebInspector._elementEndDraggingEventListener;
    1431    
     1513
    14321514    event.preventDefault();
    14331515}
     
    14411523
    14421524    messageElement.textContent = message;
    1443    
     1525
    14441526    return messageElement;
    14451527}
     
    15931675            urlNode.lineNumber = lineNumber;
    15941676
    1595         return urlNode; 
    1596     }
    1597    
     1677        return urlNode;
     1678    }
     1679
    15981680    return WebInspector.linkifyStringAsFragmentWithCustomLinkifier(string, linkifier);
    15991681}
  • trunk/Source/WebInspectorUI/UserInterface/NavigationSidebarPanel.js

    r155241 r157269  
    172172    },
    173173
    174     cookieForContentView: function(contentView)
    175     {
    176         // Implemented by subclasses.
    177         return null;
    178     },
    179 
    180     showContentViewForCookie: function(contentViewCookie)
    181     {
    182         // Implemented by subclasses.
    183     },
    184 
    185174    showContentViewForCurrentSelection: function()
    186175    {
  • trunk/Source/WebInspectorUI/UserInterface/ResourceClusterContentView.js

    r151453 r157269  
    141141    },
    142142
     143    saveToCookie: function(cookie)
     144    {
     145        cookie.type = WebInspector.ContentViewCookieType.Resource;
     146        cookie.url = this.representedObject.url;
     147        cookie.subview = this._currentContentViewSetting.value;
     148    },
     149
     150    restoreFromCookie: function(cookie)
     151    {
     152        if ("lineNumber" in cookie && "columnNumber" in cookie)
     153            return this.showResponse(new WebInspector.SourceCodePosition(cookie.lineNumber, cookie.columnNumber));
     154
     155        this._showContentViewForIdentifier(cookie.subview);
     156    },
     157
    143158    showRequest: function()
    144159    {
  • trunk/Source/WebInspectorUI/UserInterface/ResourceSidebarPanel.js

    r156809 r157269  
    8989};
    9090
    91 WebInspector.ResourceSidebarPanel.ResourceContentViewCookieType = "resource";
    92 WebInspector.ResourceSidebarPanel.CookieStorageContentViewCookieType = "cookie-storage";
    93 WebInspector.ResourceSidebarPanel.DatabaseContentViewCookieType = "database";
    94 WebInspector.ResourceSidebarPanel.DatabaseTableContentViewCookieType = "database-table";
    95 WebInspector.ResourceSidebarPanel.DOMStorageContentViewCookieType = "dom-storage";
    96 WebInspector.ResourceSidebarPanel.ApplicationCacheContentViewCookieType = "application-cache";
    97 
    9891WebInspector.ResourceSidebarPanel.prototype = {
    9992    constructor: WebInspector.ResourceSidebarPanel,
     
    10497    {
    10598        return this._searchContentTreeOutline;
    106     },
    107 
    108     cookieForContentView: function(contentView)
    109     {
    110         console.assert(contentView instanceof WebInspector.FrameContentView || contentView instanceof WebInspector.ResourceClusterContentView || contentView instanceof WebInspector.ScriptContentView || contentView instanceof WebInspector.CookieStorageContentView || contentView instanceof WebInspector.DOMStorageContentView || contentView instanceof WebInspector.DatabaseTableContentView || contentView instanceof WebInspector.DatabaseContentView || contentView instanceof WebInspector.ApplicationCacheFrameContentView);
    111 
    112         var representedObject = contentView.representedObject;
    113 
    114         // The main frame does not need a URL, an empty cookie is enough.
    115         if (representedObject instanceof WebInspector.Frame && representedObject.isMainFrame())
    116             return {type: WebInspector.ResourceSidebarPanel.ResourceContentViewCookieType};
    117 
    118         // If it has a URL, return a cookie with the frame/resource/script URL represented by the content view.
    119         if (representedObject.url) {
    120             console.assert(representedObject instanceof WebInspector.Frame || representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.Script);
    121             return {type: WebInspector.ResourceSidebarPanel.ResourceContentViewCookieType, url: contentView.representedObject.url};
    122         }
    123 
    124         var cookie = {};
    125 
    126         if (representedObject instanceof WebInspector.CookieStorageObject) {
    127             cookie.type = WebInspector.ResourceSidebarPanel.CookieStorageContentViewCookieType;
    128             cookie.host = representedObject.host;
    129         } else if (representedObject instanceof WebInspector.DatabaseObject) {
    130             cookie.type = WebInspector.ResourceSidebarPanel.DatabaseContentViewCookieType;
    131             cookie.host = representedObject.host;
    132             cookie.name = representedObject.name;
    133         } else if (representedObject instanceof WebInspector.DatabaseTableObject) {
    134             cookie.type = WebInspector.ResourceSidebarPanel.DatabaseTableContentViewCookieType;
    135             cookie.host = representedObject.database.host;
    136             cookie.database = representedObject.database.name;
    137             cookie.name = representedObject.name;
    138         } else if (representedObject instanceof WebInspector.DOMStorageObject) {
    139             cookie.type = WebInspector.ResourceSidebarPanel.DOMStorageContentViewCookieType;
    140             cookie.isLocalStorage = representedObject.isLocalStorage();
    141             cookie.host = representedObject.host;
    142         } else if (representedObject instanceof WebInspector.ApplicationCacheFrame) {
    143             cookie.type = WebInspector.ResourceSidebarPanel.ApplicationCacheContentViewCookieType;
    144             cookie.frame = representedObject.frame.url;
    145             cookie.manifest = representedObject.manifest.manifestURL;
    146         } else if (representedObject instanceof WebInspector.Script) {
    147             // If the Script does not have a URL, then there is not much more we can do to make a cookie.
    148             // The URL case is handled above, do nothing here to prevent triggering the "Unknown" error below.
    149             console.assert(!representedObject.url);
    150         } else {
    151             console.error("Unknown represented object.");
    152         }
    153 
    154         return cookie;
    155     },
    156 
    157     showContentViewForCookie: function(contentViewCookie)
    158     {
    159         if (!contentViewCookie || !contentViewCookie.type)
    160             return;
    161 
    162         this._contentViewCookieToShowWhenAvailable = contentViewCookie;
    163 
    164         if (contentViewCookie.type === WebInspector.ResourceSidebarPanel.ResourceContentViewCookieType) {
    165             // We can't show anything until we have the main frame in the sidebar. Otherwise the path components in the navigation bar would be missing.
    166             if (!this._mainFrameTreeElement) {
    167                 this._contentViewCookieToShowWhenAvailable = contentViewCookie;
    168                 return;
    169             }
    170 
    171             var representedObject = contentViewCookie.url ? WebInspector.frameResourceManager.resourceForURL(contentViewCookie.url) : WebInspector.frameResourceManager.mainFrame;
    172             if (!representedObject)
    173                 representedObject = WebInspector.frameResourceManager.mainFrame;
    174 
    175             if (!representedObject)
    176                 return;
    177 
    178             if (representedObject instanceof WebInspector.Resource && representedObject.isMainResource())
    179                 representedObject = representedObject.parentFrame;
    180 
    181             this.treeElementForRepresentedObject(representedObject).revealAndSelect(true, true);
    182 
    183             return;
    184         }
    185 
    186         // It must be a storage cookie.
    187 
    188         function finalizeCookieChecking()
    189         {
    190             // Walk all the tree elements and match them based on type alone. So if you were looking at cookies
    191             // on one site, and later open the inspector on another site, the new site's cookies will show.
    192             var currentTreeElement = this.contentTreeOutline.children[0];
    193             while (currentTreeElement && !currentTreeElement.root) {
    194                 if (this._checkStorageTreeElementAgainstPendingContentViewCookie(currentTreeElement, true))
    195                     break;
    196                 currentTreeElement = currentTreeElement.traverseNextTreeElement(false, null, false);
    197             }
    198 
    199             delete this._contentViewCookieToShowWhenAvailable;
    200             delete this._finalizeCookieCheckingTimeout;
    201         }
    202 
    203         if (this._finalizeCookieCheckingTimeout)
    204             clearTimeout(this._finalizeCookieCheckingTimeout);
    205 
    206         // When the specific storage item wasn't found we want to relax the check to show the first item with the
    207         // same type. There is no good time to naturally declare the cookie wasn't found, so we do that on a timeout.
    208         this._finalizeCookieCheckingTimeout = setTimeout(finalizeCookieChecking.bind(this), 500);
    20999    },
    210100
     
    264154        var cookie = {lineNumber: positionToReveal.lineNumber, columnNumber: positionToReveal.columnNumber};
    265155
    266         var restoreCallback = function(contentView, savedCookie) {
    267             var lineNumber = savedCookie.lineNumber;
    268             var columnNumber = savedCookie.columnNumber;
    269             var position = new WebInspector.SourceCodePosition(lineNumber, columnNumber);
    270 
    271             if (contentView instanceof WebInspector.FrameContentView)
    272                 contentView.showSourceCode(position)
    273             else if (contentView instanceof WebInspector.ResourceClusterContentView)
    274                 contentView.showResponse(position)
    275             else if (contentView instanceof WebInspector.ScriptContentView)
    276                 contentView.revealPosition(position)
    277         };
    278 
    279         WebInspector.contentBrowser.showContentView(newContentView, cookie, restoreCallback);
     156        WebInspector.contentBrowser.showContentView(newContentView, cookie);
    280157    },
    281158
     
    619496            if (this._frameIdentifierToShowSourceCodeWhenAvailable)
    620497                this.showSourceCodeForFrame(this._frameIdentifierToShowSourceCodeWhenAvailable, true);
    621             else if (this._contentViewCookieToShowWhenAvailable) {
    622                 this.showContentViewForCookie(this._contentViewCookieToShowWhenAvailable);
    623 
    624                 // The cookie is only useful until the main frame loads.
    625                 delete this._contentViewCookieToShowWhenAvailable;
    626             }
    627498        }
    628499
     
    765636    },
    766637
    767     _checkStorageTreeElementAgainstPendingContentViewCookie: function(treeElement, matchOnTypeAlone)
    768     {
    769         var contentViewCookie = this._contentViewCookieToShowWhenAvailable;
    770         if (!contentViewCookie || !contentViewCookie.type)
    771             return false;
    772 
    773         if (contentViewCookie.type === WebInspector.ResourceSidebarPanel.ResourceContentViewCookieType)
    774             return;
    775 
    776         var representedObject = treeElement.representedObject;
    777 
    778         switch (contentViewCookie.type) {
    779         case WebInspector.ResourceSidebarPanel.CookieStorageContentViewCookieType:
    780             if (!(representedObject instanceof WebInspector.CookieStorageObject))
    781                 return;
    782             if (!matchOnTypeAlone && representedObject.host !== contentViewCookie.host)
    783                 return false;
    784             break;
    785 
    786         case WebInspector.ResourceSidebarPanel.DatabaseContentViewCookieType:
    787             if (!(representedObject instanceof WebInspector.DatabaseObject))
    788                 return false;
    789             if (!matchOnTypeAlone && representedObject.host !== contentViewCookie.host)
    790                 return false;
    791             if (!matchOnTypeAlone && representedObject.name !== contentViewCookie.name)
    792                 return false;
    793             break;
    794 
    795         case WebInspector.ResourceSidebarPanel.DatabaseTableContentViewCookieType:
    796             // FIXME: This isn't easy to implement like the others since DatabaseTreeElement
    797             // populates the tables instead of ResourceSidebarPanel. Just select the database.
    798             if (!(representedObject instanceof WebInspector.DatabaseObject))
    799                 return false;
    800             if (!matchOnTypeAlone && representedObject.host !== contentViewCookie.host)
    801                 return false;
    802             if (!matchOnTypeAlone && representedObject.name !== contentViewCookie.database)
    803                 return false;
    804             return;
    805 
    806         case WebInspector.ResourceSidebarPanel.DOMStorageContentViewCookieType:
    807             if (!(representedObject instanceof WebInspector.DOMStorageObject))
    808                 return false;
    809             if (!matchOnTypeAlone && representedObject.host !== contentViewCookie.host)
    810                 return false;
    811             if (!matchOnTypeAlone && representedObject.isLocalStorage() !== contentViewCookie.isLocalStorage)
    812                 return false;
    813             break;
    814 
    815         case WebInspector.ResourceSidebarPanel.ApplicationCacheContentViewCookieType:
    816             if (!(representedObject instanceof WebInspector.ApplicationCacheFrame))
    817                 return;
    818             if (!matchOnTypeAlone && representedObject.frame.url !== contentViewCookie.frame)
    819                 return;
    820             if (!matchOnTypeAlone && representedObject.manifest.manifestURL !== contentViewCookie.manifest)
    821                 return false;
    822             break;
    823 
    824         default:
    825             console.assert("Unknown content view cookie type.");
    826             return false;
    827         }
    828 
    829         // If we got here, then the tree element was a match to the content view cookie.
    830         // Selecting the tree element will cause the content view to show.
    831         treeElement.revealAndSelect(true, true);
    832 
    833         return true;
    834     },
    835 
    836638    _domStorageObjectWasAdded: function(event)
    837639    {
     
    843645        else
    844646            this._sessionStorageRootTreeElement = this._addStorageChild(storageElement, this._sessionStorageRootTreeElement, WebInspector.UIString("Session Storage"));
    845 
    846         this._checkStorageTreeElementAgainstPendingContentViewCookie(storageElement);
    847647    },
    848648
     
    867667        var databaseElement = new WebInspector.DatabaseTreeElement(database);
    868668        this._databaseHostTreeElementMap[database.host].appendChild(databaseElement);
    869 
    870         this._checkStorageTreeElementAgainstPendingContentViewCookie(databaseElement);
    871669    },
    872670
     
    884682        var cookieElement = new WebInspector.CookieStorageTreeElement(event.data.cookieStorage);
    885683        this._cookieStorageRootTreeElement = this._addStorageChild(cookieElement, this._cookieStorageRootTreeElement, WebInspector.UIString("Cookies"));
    886 
    887         this._checkStorageTreeElementAgainstPendingContentViewCookie(cookieElement);
    888684    },
    889685
     
    902698        var frameCacheElement = new WebInspector.ApplicationCacheFrameTreeElement(frameManifest);
    903699        this._applicationCacheURLTreeElementMap[manifestURL].appendChild(frameCacheElement);
    904 
    905         this._checkStorageTreeElementAgainstPendingContentViewCookie(frameCacheElement);
    906700    },
    907701
  • trunk/Source/WebInspectorUI/UserInterface/ScriptContentView.js

    r153894 r157269  
    108108    },
    109109
     110    saveToCookie: function(cookie)
     111    {
     112        cookie.type = WebInspector.ContentViewCookieType.Resource;
     113        cookie.url = this.representedObject.url;
     114    },
     115
     116    restoreFromCookie: function(cookie)
     117    {
     118        if ("lineNumber" in cookie && "columnNumber" in cookie)
     119            this.revealPosition(new WebInspector.SourceCodePosition(cookie.lineNumber, cookie.columnNumber));
     120    },
     121
    110122    get supportsSave()
    111123    {
  • trunk/Source/WebInspectorUI/UserInterface/StorageManager.js

    r153817 r157269  
    148148    },
    149149
     150    objectForCookie: function(cookie, matchOnTypeAlone)
     151    {
     152        console.assert(cookie.type);
     153
     154        var findMatchingObjectInArray = function (array, matchesFunction) {
     155            for (var i = 0; i < array.length; ++i)
     156                if (matchesFunction.call(null, array[i]))
     157                    return array[i];
     158
     159            return matchOnTypeAlone && array.length ? array[0] : null;
     160        };
     161
     162        if (cookie.type === WebInspector.ContentViewCookieType.CookieStorage) {
     163            if (this._cookieStorageObjects[cookie.host])
     164                return this._cookieStorageObjects[cookie.host];
     165
     166            if (!matchOnTypeAlone)
     167                return null;
     168
     169            // If we just want any cookie storage object, use the first one.
     170            for (var key in this._cookieStorageObjects)
     171                return this._cookieStorageObjects[key];
     172
     173            return null;
     174        }
     175
     176        if (cookie.type === WebInspector.ContentViewCookieType.DOMStorage) {
     177            return findMatchingObjectInArray(this._domStorageObjects, function(object) {
     178                return object.host === cookie.host && object.isLocalStorage() === cookie.isLocalStorage;
     179            });
     180        }
     181
     182        if (cookie.type === WebInspector.ContentViewCookieType.Database) {
     183            return findMatchingObjectInArray(this._databaseObjects, function(object) {
     184                return object.host === cookie.host && object.name === cookie.name;
     185            });
     186        }
     187
     188        // FIXME: This isn't easy to implement like the others since DatabaseTreeElement
     189        // creates database table objects, and they aren't known by StorageManager. Just
     190        // display the database instead.
     191        if (cookie.type === WebInspector.ContentViewCookieType.DatabaseTable) {
     192            return findMatchingObjectInArray(this._databaseObjects, function(object) {
     193                return object.host === cookie.host && object.database === cookie.name;
     194            });
     195        }
     196
     197        console.assert("Unknown content view cookie: ", cookie);
     198        return null;
     199    },
     200
    150201    // Private
    151202
  • trunk/Source/WebInspectorUI/UserInterface/TimelineManager.js

    r155924 r157269  
    3737    this._loadEventTime = NaN;
    3838    this._eventMarkers = [];
     39    this._timelinesObject = new WebInspector.TimelinesObject;
    3940};
    4041
     
    7475    {
    7576        return this._records;
     77    },
     78
     79    get timelines()
     80    {
     81        return this._timelinesObject;
    7682    },
    7783
     
    294300    },
    295301
     302    objectForCookie: function(cookie)
     303    {
     304        return this.timelines;
     305    },
     306
    296307    // Private
    297308
  • trunk/Source/WebInspectorUI/UserInterface/TimelinesContentView.js

    r155241 r157269  
    336336    },
    337337
     338    saveToCookie: function(cookie)
     339    {
     340        cookie.type = WebInspector.ContentViewCookieType.Timelines;
     341        cookie.timeline = this._currentRecordTypeSetting.value;
     342    },
     343
     344    restoreFromCookie: function(cookie)
     345    {
     346        this.showTimelineForRecordType(cookie.timeline);
     347    },
     348
    338349    timelineOverviewRecordsWithType: function(type)
    339350    {
     
    448459            this._currentDataGrid.scrollToLastRow();
    449460    },
    450    
     461
    451462    _updateCalculatorBoundsForPendingRecordsAndEventMarkers: function()
    452463    {
     
    686697
    687698        scopeBarItems.unshift(new WebInspector.ScopeBarItem(prefix + "type-all", WebInspector.UIString("All"), true));
    688        
     699
    689700        return new WebInspector.ScopeBar(prefix + "scope-bar", scopeBarItems, scopeBarItems[0]);
    690701    },
     
    708719            return this._createDataGridNodeForRecord(record);
    709720        }, this);
    710        
     721
    711722        dataGrid.removeChildren();
    712723        nodes.sort(this._sortComparator.bind(this)).forEach(function(node) {
     
    715726
    716727        delete this._pendingRefreshGridNodes[recordType];
    717        
     728
    718729        this._updateOffscreenRows();
    719730    },
Note: See TracChangeset for help on using the changeset viewer.