Changeset 83969 in webkit
- Timestamp:
- Apr 15, 2011 7:08:31 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r83968 r83969 1 2011-04-15 Pavel Feldman <pfeldman@google.com> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: make resource revisions use dedicated type (not Resource clone). 6 https://bugs.webkit.org/show_bug.cgi?id=58659 7 8 * inspector/front-end/CSSStyleModel.js: 9 (WebInspector.CSSStyleModel.prototype.setStyleSheetText): 10 * inspector/front-end/Resource.js: 11 (WebInspector.Resource.prototype.addRevision): 12 (WebInspector.Resource.prototype._innerRequestContent.onResourceContent): 13 (WebInspector.Resource.prototype._innerRequestContent): 14 (WebInspector.ResourceRevision): 15 (WebInspector.ResourceRevision.prototype.get resource): 16 (WebInspector.ResourceRevision.prototype.get timestamp): 17 (WebInspector.ResourceRevision.prototype.get content): 18 (WebInspector.ResourceRevision.prototype.revertToThis): 19 (WebInspector.ResourceRevision.prototype.requestContent.mycallback): 20 (WebInspector.ResourceRevision.prototype.requestContent): 21 * inspector/front-end/ResourceView.js: 22 (WebInspector.ResourceView.resourceViewTypeMatchesResource): 23 (WebInspector.ResourceView.resourceViewForResource): 24 (WebInspector.ResourceView.recreateResourceView): 25 (WebInspector.ResourceView.existingResourceViewForResource): 26 (WebInspector.RevisionSourceFrame): 27 (WebInspector.RevisionSourceFrame.prototype.get resource): 28 (WebInspector.RevisionSourceFrame.prototype.isContentEditable): 29 (WebInspector.RevisionSourceFrame.prototype.requestContent): 30 * inspector/front-end/ResourcesPanel.js: 31 (WebInspector.ResourcesPanel.prototype._showResourceView): 32 (WebInspector.ResourcesPanel.prototype._showRevisionView): 33 (WebInspector.ResourcesPanel.prototype._fetchAndApplyDiffMarkup.step1): 34 (WebInspector.ResourcesPanel.prototype._fetchAndApplyDiffMarkup.step2): 35 (WebInspector.ResourcesPanel.prototype._fetchAndApplyDiffMarkup): 36 (WebInspector.ResourceRevisionTreeElement): 37 (WebInspector.ResourceRevisionTreeElement.prototype.get itemURL): 38 (WebInspector.ResourceRevisionTreeElement.prototype.onselect): 39 (WebInspector.ResourceRevisionTreeElement.prototype._ondragstart): 40 (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent): 41 * inspector/front-end/SourceFrame.js: 42 (WebInspector.SourceFrame.prototype._ensureContentLoaded): 43 (WebInspector.SourceFrame.prototype.requestContent): 44 (WebInspector.SourceFrame.prototype.commitEditing.didEditContent): 45 (WebInspector.SourceFrame.prototype.commitEditing): 46 1 47 2011-04-15 Alexander Pavlov <apavlov@chromium.org> 2 48 -
trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js
r83962 r83969 188 188 { 189 189 if (!error) 190 this._fireStyleSheetChanged( this.id, majorChange);190 this._fireStyleSheetChanged(styleSheetId, majorChange); 191 191 192 192 if (userCallback) -
trunk/Source/WebCore/inspector/front-end/Resource.js
r83962 r83969 724 724 addRevision: function(newContent) 725 725 { 726 var revisionResource = new WebInspector.Resource(null, this.url); 727 revisionResource.frameId = this.frameId; 728 revisionResource.loaderId = this.loaderId; 729 revisionResource.documentURL = this.documentURL; 730 revisionResource.type = this.type; 731 revisionResource.loader = this.loader; 732 revisionResource.timestamp = this.timestamp; 733 revisionResource._content = this._content; 734 revisionResource._actualResource = this; 735 736 if (this.finished) 737 revisionResource.finished = true; 738 else { 739 function finished() 740 { 741 this.removeEventListener("finished", finished); 742 revisionResource.finished = true; 743 } 744 this.addEventListener("finished", finished.bind(this)); 745 } 746 747 if (!this._baseRevision) 748 this._baseRevision = revisionResource; 749 else 750 revisionResource._baseRevision = this._baseRevision; 726 var revision = new WebInspector.ResourceRevision(this, this._content, this._contentTimestamp); 727 this.history.push(revision); 751 728 752 729 this._content = newContent; 753 this.timestamp = new Date(); 754 755 this.history.push(revisionResource); 756 this.dispatchEventToListeners(WebInspector.Resource.Events.RevisionAdded, revisionResource); 757 }, 758 759 revertToThis: function() 760 { 761 if (!this._actualResource) 762 return; 763 764 function callback(content) 765 { 766 if (content) 767 this._actualResource.setContent(content, true); 768 } 769 this.requestContent(callback.bind(this)); 770 }, 771 772 get baseRevision() 773 { 774 return this._baseRevision; 730 this._contentTimestamp = new Date(); 731 732 this.dispatchEventToListeners(WebInspector.Resource.Events.RevisionAdded, revision); 775 733 }, 776 734 … … 831 789 { 832 790 this._content = data; 791 this._originalContent = data; 833 792 var callbacks = this._pendingContentCallbacks.slice(); 834 793 for (var i = 0; i < callbacks.length; ++i) … … 843 802 WebInspector.Resource.prototype.__proto__ = WebInspector.Object.prototype; 844 803 804 WebInspector.ResourceRevision = function(resource, content, timestamp) 805 { 806 this._resource = resource; 807 this._content = content; 808 this._timestamp = timestamp; 809 } 810 811 WebInspector.ResourceRevision.prototype = { 812 get resource() 813 { 814 return this._resource; 815 }, 816 817 get timestamp() 818 { 819 return this._timestamp; 820 }, 821 822 get content() 823 { 824 return this._content; 825 }, 826 827 revertToThis: function() 828 { 829 function revert(content) 830 { 831 this._resource.setContent(content, true); 832 } 833 this.requestContent(revert.bind(this)); 834 }, 835 836 requestContent: function(callback) 837 { 838 if (typeof this._content === "string") { 839 callback(this._content); 840 return; 841 } 842 843 // If we are here, this is initial revision. First, look up content fetched over the wire. 844 if (typeof this.resource._originalContent === "string") { 845 this._content = this._resource._originalContent; 846 callback(this._content); 847 return; 848 } 849 850 // If unsuccessful, request the content. 851 function mycallback(content) 852 { 853 this._content = content; 854 callback(content); 855 } 856 WebInspector.networkManager.requestContent(this._resource, false, mycallback.bind(this)); 857 } 858 } 845 859 846 860 WebInspector.ResourceDomainModelBinding = function() -
trunk/Source/WebCore/inspector/front-end/ResourceView.js
r83962 r83969 63 63 WebInspector.ResourceView.resourceViewTypeMatchesResource = function(resource) 64 64 { 65 var resourceView = resource._resource sView;65 var resourceView = resource._resourceView; 66 66 switch (resource.category) { 67 67 case WebInspector.resourceCategories.documents: … … 83 83 if (!resource) 84 84 return null; 85 if (!resource._resource sView)86 resource._resource sView = WebInspector.ResourceView.createResourceView(resource);87 return resource._resource sView;85 if (!resource._resourceView) 86 resource._resourceView = WebInspector.ResourceView.createResourceView(resource); 87 return resource._resourceView; 88 88 } 89 89 … … 92 92 var newView = WebInspector.ResourceView.createResourceView(resource); 93 93 94 var oldView = resource._resource sView;94 var oldView = resource._resourceView; 95 95 var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null; 96 96 var scrollTop = oldView.scrollTop; 97 97 98 resource._resource sView.detach();99 delete resource._resource sView;100 101 resource._resource sView = newView;98 resource._resourceView.detach(); 99 delete resource._resourceView; 100 101 resource._resourceView = newView; 102 102 103 103 if (oldViewParentNode) … … 113 113 if (!resource) 114 114 return null; 115 return resource._resource sView;115 return resource._resourceView; 116 116 } 117 117 … … 167 167 }, 168 168 169 _requestContent: function(callback)169 requestContent: function(callback) 170 170 { 171 171 function contentLoaded(text) … … 179 179 180 180 WebInspector.ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype; 181 182 WebInspector.RevisionSourceFrame = function(revision) 183 { 184 WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(), revision.resource.url); 185 this._revision = revision; 186 } 187 188 WebInspector.RevisionSourceFrame.prototype = { 189 get resource() 190 { 191 return this._revision.resource; 192 }, 193 194 isContentEditable: function() 195 { 196 return false; 197 }, 198 199 requestContent: function(callback) 200 { 201 function contentLoaded(text) 202 { 203 var mimeType = WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[this._revision.resource.type] || this._revision.resource.mimeType; 204 callback(mimeType, text); 205 } 206 this._revision.requestContent(contentLoaded.bind(this)); 207 } 208 } 209 210 WebInspector.RevisionSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype; -
trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js
r83962 r83969 404 404 { 405 405 var view = WebInspector.ResourceView.resourceViewForResource(resource); 406 407 // Consider rendering diff markup here. 408 if (resource.baseRevision && view instanceof WebInspector.SourceFrame) { 409 function callback(baseContent) 410 { 411 if (baseContent) 412 this._applyDiffMarkup(view, baseContent, resource.content); 413 } 414 resource.baseRevision.requestContent(callback.bind(this)); 415 } 406 this._fetchAndApplyDiffMarkup(view, resource); 416 407 this._innerShowView(view); 408 }, 409 410 _showRevisionView: function(revision) 411 { 412 if (!revision._view) 413 revision._view = new WebInspector.RevisionSourceFrame(revision); 414 var view = revision._view; 415 this._fetchAndApplyDiffMarkup(view, revision.resource, revision); 416 this._innerShowView(view); 417 }, 418 419 _fetchAndApplyDiffMarkup: function(view, resource, revision) 420 { 421 var baseRevision = resource.history[0]; 422 if (!baseRevision) 423 return; 424 if (!(view instanceof WebInspector.SourceFrame)) 425 return; 426 427 baseRevision.requestContent(step1.bind(this)); 428 429 function step1(baseContent) 430 { 431 (revision ? revision : resource).requestContent(step2.bind(this, baseContent)); 432 } 433 434 function step2(baseContent, revisionContent) 435 { 436 this._applyDiffMarkup(view, baseContent, revisionContent); 437 } 417 438 }, 418 439 … … 1253 1274 { 1254 1275 var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : WebInspector.UIString("(original)"); 1255 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["resource-sidebar-tree-item", "resources-category-" + revision. category.name]);1276 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["resource-sidebar-tree-item", "resources-category-" + revision.resource.category.name]); 1256 1277 if (revision.timestamp) 1257 1278 this.tooltip = revision.timestamp.toLocaleString(); 1258 this._re source= revision;1279 this._revision = revision; 1259 1280 } 1260 1281 1261 1282 WebInspector.ResourceRevisionTreeElement.prototype = { 1283 get itemURL() 1284 { 1285 return this._revision.resource.url; 1286 }, 1287 1262 1288 onattach: function() 1263 1289 { … … 1271 1297 { 1272 1298 WebInspector.BaseStorageTreeElement.prototype.onselect.call(this); 1273 this._storagePanel._showRe sourceView(this._resource);1299 this._storagePanel._showRevisionView(this._revision); 1274 1300 }, 1275 1301 1276 1302 _ondragstart: function(event) 1277 1303 { 1278 event.dataTransfer.setData("text/plain", this._resource.content); 1279 event.dataTransfer.effectAllowed = "copy"; 1280 return true; 1304 if (this._revision.content) { 1305 event.dataTransfer.setData("text/plain", this._revision.content); 1306 event.dataTransfer.effectAllowed = "copy"; 1307 return true; 1308 } 1281 1309 }, 1282 1310 … … 1284 1312 { 1285 1313 var contextMenu = new WebInspector.ContextMenu(); 1286 contextMenu.appendItem(WebInspector.UIString("Revert to this revision"), this._re source.revertToThis.bind(this._resource));1314 contextMenu.appendItem(WebInspector.UIString("Revert to this revision"), this._revision.revertToThis.bind(this._revision)); 1287 1315 contextMenu.show(event); 1288 1316 } -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r83951 r83969 120 120 if (!this._contentRequested) { 121 121 this._contentRequested = true; 122 this. _requestContent(this._initializeTextViewer.bind(this));123 } 124 }, 125 126 _requestContent: function(callback)122 this.requestContent(this._initializeTextViewer.bind(this)); 123 } 124 }, 125 126 requestContent: function(callback) 127 127 { 128 128 this._delegate.requestContent(callback); … … 904 904 { 905 905 if (error) { 906 WebInspector.log(error.data[0], WebInspector.ConsoleMessage.MessageLevel.Error); 907 WebInspector.showConsole(); 906 if (error.data && error.data[0]) { 907 WebInspector.log(error.data[0], WebInspector.ConsoleMessage.MessageLevel.Error); 908 WebInspector.showConsole(); 909 } 908 910 callback(error); 909 911 return;
Note: See TracChangeset
for help on using the changeset viewer.