Changeset 72654 in webkit


Ignore:
Timestamp:
Nov 24, 2010 2:28:27 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2010-11-24 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: add "Locally modified" group into the resource panel.
https://bugs.webkit.org/show_bug.cgi?id=50005

  • English.lproj/localizedStrings.js:
  • inspector/front-end/ResourcesPanel.js: (WebInspector.ResourcesPanel): (WebInspector.ResourcesPanel.prototype.reset): (WebInspector.ResourcesPanel.prototype.addLocallyModifiedRevision): (WebInspector.ResourcesPanel.prototype._innerShowView): (WebInspector.BaseStorageTreeElement.prototype.set titleText): (WebInspector.LocallyModifiedResourceTreeElement): (WebInspector.LocallyModifiedResourceTreeElement.prototype.onselect): (WebInspector.LocallyModifiedResourceTreeElement.prototype.gcRevisions): (WebInspector.LocallyModifiedRevisionTreeElement): (WebInspector.LocallyModifiedRevisionTreeElement.prototype.onattach): (WebInspector.LocallyModifiedRevisionTreeElement.prototype.onselect): (WebInspector.LocallyModifiedRevisionTreeElement.prototype._ondragstart):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r72652 r72654  
     12010-11-24  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: add "Locally modified" group into the resource panel.
     6        https://bugs.webkit.org/show_bug.cgi?id=50005
     7
     8        * English.lproj/localizedStrings.js:
     9        * inspector/front-end/ResourcesPanel.js:
     10        (WebInspector.ResourcesPanel):
     11        (WebInspector.ResourcesPanel.prototype.reset):
     12        (WebInspector.ResourcesPanel.prototype.addLocallyModifiedRevision):
     13        (WebInspector.ResourcesPanel.prototype._innerShowView):
     14        (WebInspector.BaseStorageTreeElement.prototype.set titleText):
     15        (WebInspector.LocallyModifiedResourceTreeElement):
     16        (WebInspector.LocallyModifiedResourceTreeElement.prototype.onselect):
     17        (WebInspector.LocallyModifiedResourceTreeElement.prototype.gcRevisions):
     18        (WebInspector.LocallyModifiedRevisionTreeElement):
     19        (WebInspector.LocallyModifiedRevisionTreeElement.prototype.onattach):
     20        (WebInspector.LocallyModifiedRevisionTreeElement.prototype.onselect):
     21        (WebInspector.LocallyModifiedRevisionTreeElement.prototype._ondragstart):
     22
    1232010-11-24  Pavel Feldman  <pfeldman@chromium.org>
    224
  • trunk/WebCore/inspector/front-end/ResourcesPanel.js

    r72090 r72654  
    5757    this.sidebarTree.appendChild(this.applicationCacheListTreeElement);
    5858
     59    this.locallyModifiedListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Locally Modified"), "LocallyModified", "frame-storage-tree-item");
     60    this.sidebarTree.appendChild(this.locallyModifiedListTreeElement);
     61    this.locallyModifiedListTreeElement.hidden = true;
     62
    5963    if (Preferences.fileSystemEnabled) {
    6064        this.fileSystemListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("File System"), "FileSystem", "file-system-storage-tree-item");
     
    6266        this.fileSystemListTreeElement.expand();
    6367    }
    64        
     68
    6569    this.storageViews = document.createElement("div");
    6670    this.storageViews.id = "storage-views";
     
    7579    this._origins = {};
    7680    this._domains = {};
     81    this._locallyModifiedResources = {};
    7782
    7883    this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false);
     
    148153
    149154        this._cookieViews = {};
    150        
     155        this._locallyModifiedResources = {};
    151156        this._fileSystemView = null;
    152157       
     
    159164        this.cookieListTreeElement.removeChildren();
    160165        this.applicationCacheListTreeElement.removeChildren();
     166        this.locallyModifiedListTreeElement.removeChildren();
    161167        if (Preferences.fileSystemEnabled)
    162168            this.fileSystemListTreeElement.removeChildren();
     
    307313        else
    308314            this.sessionStorageListTreeElement.appendChild(domStorageTreeElement);
     315    },
     316
     317    addLocallyModifiedRevision: function(url, resourceType, content)
     318    {
     319        this.locallyModifiedListTreeElement.hidden = false;
     320
     321        var newRevision = new WebInspector.LocallyModifiedRevisionTreeElement(this, url, resourceType, content);
     322        var lastRevision = this._locallyModifiedResources[url];
     323        this._locallyModifiedResources[url] = newRevision;
     324
     325        if (lastRevision)
     326            lastRevision.becomeLogEntry(newRevision);
     327        else
     328            this.locallyModifiedListTreeElement.appendChild(newRevision);
    309329    },
    310330
     
    458478    {
    459479        if (this.visibleView)
    460             this.visibleView.hide();
     480            this.visibleView.detach();
    461481
    462482        view.show(this.storageViews);
     
    814834    {
    815835        this._titleText = titleText;
    816         this.titleElement.textContent = this._titleText;
     836        if (this.titleElement)
     837            this.titleElement.textContent = this._titleText;
    817838    },
    818839
     
    11821203WebInspector.ApplicationCacheTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
    11831204
     1205WebInspector.LocallyModifiedRevisionTreeElement = function(storagePanel, url, resourceType, content)
     1206{
     1207    var resource = new WebInspector.Resource(null, url);
     1208    resource.type = resourceType;
     1209    resource.content = content;
     1210
     1211    var timestamp = new Date();
     1212    WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, resource.displayName, "resource-sidebar-tree-item resources-category-" + resource.category.name);
     1213    this.tooltip = resource.url;
     1214    this.timestamp = timestamp;
     1215    this._resource = resource;
     1216}
     1217
     1218WebInspector.LocallyModifiedRevisionTreeElement.prototype = {
     1219    becomeLogEntry: function(newRevision)
     1220    {
     1221        var oldChildren = this.children.slice();
     1222        var oldExpanded = this.expanded;
     1223        var oldIndex = this.parent.children.indexOf(this);
     1224
     1225        this.removeChildren();
     1226        this.titleText = this.timestamp.toLocaleTimeString();
     1227        this.toLocaleString();
     1228        this.hasChildren = false;
     1229
     1230        this.parent.insertChild(newRevision, oldIndex);
     1231        this.parent.removeChild(this);
     1232
     1233        const oneMinute = 1000 * 60;
     1234        if (newRevision.timestamp - this.timestamp > oneMinute)
     1235            newRevision.appendChild(this);
     1236
     1237        for (var i = 0; i < oldChildren.length; ++i)
     1238            newRevision.appendChild(oldChildren[i]);
     1239        if (oldExpanded)
     1240            newRevision.expand();
     1241    },
     1242
     1243    onattach: function()
     1244    {
     1245        WebInspector.BaseStorageTreeElement.prototype.onattach.call(this);
     1246        this.listItemElement.draggable = true;
     1247        this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false);
     1248    },
     1249
     1250    onselect: function()
     1251    {
     1252        WebInspector.BaseStorageTreeElement.prototype.onselect.call(this);
     1253        this._storagePanel._showResourceView(this._resource);
     1254    },
     1255
     1256    _ondragstart: function(event)
     1257    {
     1258        event.dataTransfer.setData("text/plain", this._resource.content);
     1259        event.dataTransfer.effectAllowed = "copy";
     1260        return true;
     1261    }
     1262}
     1263WebInspector.LocallyModifiedRevisionTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype;
     1264
    11841265WebInspector.FileSystemTreeElement = function(storagePanel, origin)
    11851266{
Note: See TracChangeset for help on using the changeset viewer.