Changeset 87383 in webkit
- Timestamp:
- May 26, 2011 7:28:04 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r87382 r87383 1 2011-05-26 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel 6 https://bugs.webkit.org/show_bug.cgi?id=59193 7 8 * inspector/debugger/source-frame.html: 9 1 10 2011-05-26 Philippe Normand <pnormand@igalia.com> 2 11 -
trunk/LayoutTests/inspector/debugger/source-frame.html
r83577 r87383 34 34 function testConsoleMessage(next) 35 35 { 36 InspectorTest.addSniffer(WebInspector. SourceFrame.prototype, "addMessage", didAddMessage);36 InspectorTest.addSniffer(WebInspector.Resource.prototype, "addMessage", didAddMessage); 37 37 InspectorTest.evaluateInPage("addErrorToConsole()"); 38 38 -
trunk/Source/WebCore/ChangeLog
r87374 r87383 1 2011-05-26 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel 6 https://bugs.webkit.org/show_bug.cgi?id=59193 7 8 * inspector/front-end/NetworkItemView.js: 9 (WebInspector.NetworkItemView): 10 (WebInspector.NetworkItemView._contentViewForResource): 11 * inspector/front-end/NetworkPanel.js: 12 (WebInspector.NetworkPanel.prototype._refreshResource): 13 * inspector/front-end/Resource.js: 14 (WebInspector.Resource.prototype.get messages): 15 (WebInspector.Resource.prototype.addMessage): 16 (WebInspector.Resource.prototype.set errors): 17 (WebInspector.Resource.prototype.set warnings): 18 (WebInspector.Resource.prototype.clearErrorsAndWarnings): 19 * inspector/front-end/ResourceTreeModel.js: 20 (WebInspector.ResourceTreeModel.prototype._consoleMessageAdded): 21 * inspector/front-end/ResourceView.js: 22 (WebInspector.ResourceView.hasTextContent): 23 (WebInspector.ResourceView.nonSourceViewForResource): 24 (WebInspector.ResourceSourceFrame): 25 (WebInspector.ResourceSourceFrame.mimeTypeForResource): 26 (WebInspector.ResourceSourceFrame.prototype.requestContent): 27 (WebInspector.ResourceSourceFrame.prototype.suggestedFileName): 28 (WebInspector.EditableResourceSourceFrame): 29 (WebInspector.EditableResourceSourceFrame.prototype.doubleClick): 30 (WebInspector.EditableResourceSourceFrame.prototype.editContent): 31 (WebInspector.EditableResourceSourceFrame.prototype.cancelEditing): 32 (WebInspector.EditableResourceSourceFrame.prototype.afterTextChanged): 33 (WebInspector.EditableResourceSourceFrame.prototype._clearIncrementalUpdateTimer): 34 (WebInspector.ResourceRevisionSourceFrame): 35 (WebInspector.ResourceRevisionSourceFrame.prototype.requestContent): 36 * inspector/front-end/ResourcesPanel.js: 37 (WebInspector.ResourcesPanel.prototype.showResource): 38 (WebInspector.ResourcesPanel.prototype._showResourceView): 39 (WebInspector.ResourcesPanel.prototype._resourceViewForResource): 40 (WebInspector.ResourcesPanel.prototype._showRevisionView): 41 (WebInspector.ResourcesPanel.prototype._sourceViewForRevision): 42 (WebInspector.ResourcesPanel.prototype.searchCanceled): 43 (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision): 44 (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision.getParent): 45 (WebInspector.FrameResourceTreeElement): 46 (WebInspector.FrameResourceTreeElement.prototype.onattach): 47 (WebInspector.FrameResourceTreeElement.prototype._updateErrorsAndWarningsBubbles): 48 (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsCleared): 49 (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsMessageAdded): 50 (WebInspector.FrameResourceTreeElement.prototype._appendRevision): 51 (WebInspector.FrameResourceTreeElement.prototype.sourceView): 52 (WebInspector.FrameResourceTreeElement.prototype._createSourceView): 53 (WebInspector.FrameResourceTreeElement.prototype._recreateSourceView): 54 (WebInspector.ResourceRevisionTreeElement): 55 (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent): 56 (WebInspector.ResourceRevisionTreeElement.prototype.sourceView): 57 1 58 2011-05-26 Andreas Kling <kling@webkit.org> 2 59 -
trunk/Source/WebCore/inspector/front-end/NetworkItemView.js
r84492 r87383 36 36 37 37 this._headersView = new WebInspector.ResourceHeadersView(resource); 38 // Do not store reference to content view - it can be recreated.39 var contentView = WebInspector.ResourceView.resourceViewForResource(resource);40 41 38 this._tabbedPane = new WebInspector.TabbedPane(this.element); 42 39 this._tabbedPane.appendTab("headers", WebInspector.UIString("Headers"), this._headersView); 43 40 44 if (contentView.hasContent()) { 45 // Reusing this view, so hide it at first. 46 contentView.visible = false; 41 var contentView = WebInspector.NetworkItemView._contentViewForResource(resource); 42 if (contentView.hasContent()) 47 43 this._tabbedPane.appendTab("content", WebInspector.UIString("Content"), contentView); 48 }49 44 50 45 if (resource.type === WebInspector.Resource.Type.XHR && resource.content) { … … 67 62 68 63 this._tabbedPane.addEventListener("tab-selected", this._tabSelected, this); 64 } 65 66 WebInspector.NetworkItemView._contentViewForResource = function(resource) 67 { 68 if (WebInspector.ResourceView.hasTextContent(resource)) 69 return new WebInspector.ResourceSourceFrame(resource) 70 return WebInspector.ResourceView.nonSourceViewForResource(resource); 69 71 } 70 72 -
trunk/Source/WebCore/inspector/front-end/NetworkPanel.js
r86959 r87383 792 792 this._staleResources.push(resource); 793 793 this._scheduleRefresh(); 794 795 var oldView = WebInspector.ResourceView.existingResourceViewForResource(resource);796 if (!oldView)797 return;798 799 if (WebInspector.ResourceView.resourceViewTypeMatchesResource(resource))800 return;801 802 var newView = WebInspector.ResourceView.recreateResourceView(resource);803 if (this.visibleView === oldView)804 this.visibleView = newView;805 794 }, 806 795 -
trunk/Source/WebCore/inspector/front-end/Resource.js
r87073 r87383 694 694 }, 695 695 696 get messages() 697 { 698 return this._messages || []; 699 }, 700 701 addMessage: function(msg) 702 { 703 if (!msg.isErrorOrWarning() || !msg.message) 704 return; 705 706 if (!this._messages) 707 this._messages = []; 708 this._messages.push(msg); 709 this.dispatchEventToListeners("errors-warnings-message-added", msg); 710 }, 711 696 712 get errors() 697 713 { … … 702 718 { 703 719 this._errors = x; 704 this.dispatchEventToListeners("errors-warnings-updated");705 720 }, 706 721 … … 713 728 { 714 729 this._warnings = x; 715 this.dispatchEventToListeners("errors-warnings-updated");716 730 }, 717 731 718 732 clearErrorsAndWarnings: function() 719 733 { 734 this._messages = []; 720 735 this._warnings = 0; 721 736 this._errors = 0; 722 this.dispatchEventToListeners("errors-warnings- updated");737 this.dispatchEventToListeners("errors-warnings-cleared"); 723 738 }, 724 739 -
trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js
r86760 r87383 232 232 break; 233 233 } 234 235 var view = WebInspector.ResourceView.resourceViewForResource(resource); 236 if (view.addMessage && msg.isErrorOrWarning() && msg.message) 237 view.addMessage(msg); 234 resource.addMessage(msg); 238 235 }, 239 236 -
trunk/Source/WebCore/inspector/front-end/ResourceView.js
r86552 r87383 44 44 WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype; 45 45 46 WebInspector.ResourceView. createResourceView= function(resource)46 WebInspector.ResourceView.hasTextContent = function(resource) 47 47 { 48 48 switch (resource.category) { … … 51 51 case WebInspector.resourceCategories.xhr: 52 52 case WebInspector.resourceCategories.stylesheets: 53 return new WebInspector.ResourceSourceFrame(resource); 53 return true; 54 default: 55 return false; 56 } 57 } 58 59 WebInspector.ResourceView.nonSourceViewForResource = function(resource) 60 { 61 switch (resource.category) { 54 62 case WebInspector.resourceCategories.images: 55 63 return new WebInspector.ImageView(resource); … … 61 69 } 62 70 63 WebInspector.ResourceView.resourceViewTypeMatchesResource = function(resource)64 {65 var resourceView = resource._resourceView;66 switch (resource.category) {67 case WebInspector.resourceCategories.documents:68 case WebInspector.resourceCategories.scripts:69 case WebInspector.resourceCategories.xhr:70 case WebInspector.resourceCategories.stylesheets:71 return resourceView.__proto__ === WebInspector.ResourceSourceFrame.prototype;72 case WebInspector.resourceCategories.images:73 return resourceView.__proto__ === WebInspector.ImageView.prototype;74 case WebInspector.resourceCategories.fonts:75 return resourceView.__proto__ === WebInspector.FontView.prototype;76 default:77 return resourceView.__proto__ === WebInspector.ResourceView.prototype;78 }79 }80 81 WebInspector.ResourceView.resourceViewForResource = function(resource)82 {83 if (!resource)84 return null;85 if (!resource._resourceView)86 resource._resourceView = WebInspector.ResourceView.createResourceView(resource);87 return resource._resourceView;88 }89 90 WebInspector.ResourceView.recreateResourceView = function(resource)91 {92 var newView = WebInspector.ResourceView.createResourceView(resource);93 94 var oldView = resource._resourceView;95 var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;96 var scrollTop = oldView.scrollTop;97 98 resource._resourceView.detach();99 delete resource._resourceView;100 101 resource._resourceView = newView;102 103 if (oldViewParentNode)104 newView.show(oldViewParentNode);105 if (scrollTop)106 newView.scrollTop = scrollTop;107 108 return newView;109 }110 111 WebInspector.ResourceView.existingResourceViewForResource = function(resource)112 {113 if (!resource)114 return null;115 return resource._resourceView;116 }117 118 119 71 WebInspector.ResourceSourceFrame = function(resource) 120 72 { 121 WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate( ), resource.url);73 WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(resource), resource.url); 122 74 this._resource = resource; 123 75 } … … 131 83 } 132 84 85 WebInspector.ResourceSourceFrame.mimeTypeForResource = function(resource) { 86 return WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[resource.type] || resource.mimeType; 87 } 88 133 89 WebInspector.ResourceSourceFrame.prototype = { 134 90 get resource() … … 137 93 }, 138 94 95 requestContent: function(callback) 96 { 97 function contentLoaded(text) 98 { 99 var mimeType = WebInspector.ResourceSourceFrame.mimeTypeForResource(this.resource); 100 callback(mimeType, text); 101 } 102 103 this.resource.requestContent(contentLoaded.bind(this)); 104 }, 105 106 suggestedFileName: function() 107 { 108 return this.resource.displayName; 109 } 110 } 111 112 WebInspector.ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype; 113 114 WebInspector.EditableResourceSourceFrame = function(resource) 115 { 116 WebInspector.ResourceSourceFrame.call(this, resource); 117 } 118 119 WebInspector.EditableResourceSourceFrame.prototype = { 139 120 doubleClick: function(lineNumber) 140 121 { 141 if (!this. _resource.isEditable())122 if (!this.resource.isEditable()) 142 123 return; 143 124 … … 153 134 this._clearIncrementalUpdateTimer(); 154 135 var majorChange = true; 155 this. _resource.setContent(newText, majorChange, callback);136 this.resource.setContent(newText, majorChange, callback); 156 137 }, 157 138 … … 160 141 this._clearIncrementalUpdateTimer(); 161 142 const majorChange = false; 162 this. _resource.setContent(this._viewerState.textModelContent, majorChange);143 this.resource.setContent(this._viewerState.textModelContent, majorChange); 163 144 WebInspector.SourceFrame.prototype.cancelEditing.call(this); 164 145 }, … … 169 150 { 170 151 var majorChange = false; 171 this. _resource.setContent(this._textModel.text, majorChange, function() {});152 this.resource.setContent(this._textModel.text, majorChange, function() {}); 172 153 } 173 154 const updateTimeout = 200; … … 181 162 delete this._incrementalUpdateTimer; 182 163 }, 183 184 requestContent: function(callback)185 {186 function contentLoaded(text)187 {188 var mimeType = WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType;189 callback(mimeType, text);190 }191 this._resource.requestContent(contentLoaded.bind(this));192 },193 194 suggestedFileName: function()195 {196 return this._resource.displayName;197 }198 164 } 199 165 200 WebInspector. ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;166 WebInspector.EditableResourceSourceFrame.prototype.__proto__ = WebInspector.ResourceSourceFrame.prototype; 201 167 202 WebInspector.Re visionSourceFrame = function(revision)168 WebInspector.ResourceRevisionSourceFrame = function(revision) 203 169 { 204 WebInspector. SourceFrame.call(this, new WebInspector.SourceFrameDelegate(), revision.resource.url);170 WebInspector.ResourceSourceFrame.call(this, revision.resource); 205 171 this._revision = revision; 206 172 } 207 173 208 WebInspector.Re visionSourceFrame.prototype = {174 WebInspector.ResourceRevisionSourceFrame.prototype = { 209 175 get resource() 210 176 { 211 177 return this._revision.resource; 212 },213 214 doubleClick: function(lineNumber)215 {216 178 }, 217 179 … … 220 182 function contentLoaded(text) 221 183 { 222 var mimeType = WebInspector.ResourceSourceFrame. DefaultMIMETypeForResourceType[this._revision.resource.type] || this._revision.resource.mimeType;184 var mimeType = WebInspector.ResourceSourceFrame.mimeTypeForResource(this.resource); 223 185 callback(mimeType, text); 224 186 } 187 225 188 this._revision.requestContent(contentLoaded.bind(this)); 226 189 }, 227 228 suggestedFileName: function()229 {230 return this._revision.resource.displayName;231 }232 190 } 233 191 234 WebInspector.Re visionSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;192 WebInspector.ResourceRevisionSourceFrame.prototype.__proto__ = WebInspector.ResourceSourceFrame.prototype; -
trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js
r86745 r87383 364 364 365 365 if (line !== undefined) { 366 var view = WebInspector.ResourceView.resourceViewForResource(resource);366 var view = this._resourceViewForResource(resource); 367 367 if (view.highlightLine) 368 368 view.highlightLine(line); … … 373 373 _showResourceView: function(resource) 374 374 { 375 var view = WebInspector.ResourceView.resourceViewForResource(resource); 376 // FIXME: This could be removed once we stop caching SourceFrames. 375 var view = this._resourceViewForResource(resource); 376 if (!view) { 377 this.visibleView.hide(); 378 return; 379 } 377 380 if (view.searchCanceled) 378 381 view.searchCanceled(); … … 381 384 }, 382 385 386 _resourceViewForResource: function(resource) 387 { 388 if (WebInspector.ResourceView.hasTextContent(resource)) { 389 var treeElement = this._findTreeElementForResource(resource); 390 if (!treeElement) 391 return null; 392 return treeElement.sourceView(); 393 } 394 return WebInspector.ResourceView.nonSourceViewForResource(resource); 395 }, 396 383 397 _showRevisionView: function(revision) 384 398 { 385 if (!revision._view) 386 revision._view = new WebInspector.RevisionSourceFrame(revision); 387 var view = revision._view; 399 var view = this._sourceViewForRevision(revision); 388 400 this._fetchAndApplyDiffMarkup(view, revision.resource, revision); 389 401 this._innerShowView(view); 402 }, 403 404 _sourceViewForRevision: function(revision) 405 { 406 var treeElement = this._findTreeElementForRevision(revision); 407 return treeElement.sourceView(); 390 408 }, 391 409 … … 789 807 searchCanceled: function() 790 808 { 809 function callback(resourceTreeElement) 810 { 811 resourceTreeElement._updateErrorsAndWarningsBubbles(); 812 } 813 791 814 WebInspector.searchController.updateSearchMatchesCount(0, this); 792 815 this._resetSearchResults(); 816 this._forAllResourceTreeElements(callback); 793 817 }, 794 818 … … 835 859 836 860 return this.sidebarTree.findTreeElement(resource, isAncestor, getParent); 861 }, 862 863 _findTreeElementForRevision: function(revision) 864 { 865 function isAncestor(ancestor, object) 866 { 867 return false; 868 } 869 870 function getParent(object) 871 { 872 return null; 873 } 874 875 return this.sidebarTree.findTreeElement(revision, isAncestor, getParent); 837 876 }, 838 877 … … 1148 1187 WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource, resource.displayName, ["resource-sidebar-tree-item", "resources-category-" + resource.category.name]); 1149 1188 this._resource = resource; 1150 this._resource.addEventListener("errors-warnings-updated", this._errorsWarningsUpdated, this); 1189 this._resource.addEventListener("errors-warnings-cleared", this._errorsWarningsCleared, this); 1190 this._resource.addEventListener("errors-warnings-message-added", this._errorsWarningsMessageAdded, this); 1151 1191 this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._revisionAdded, this); 1152 1192 this.tooltip = resource.url; … … 1192 1232 this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false); 1193 1233 this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true); 1234 1235 this._updateErrorsAndWarningsBubbles(); 1194 1236 }, 1195 1237 … … 1278 1320 }, 1279 1321 1280 _errorsWarningsUpdated: function() 1281 { 1282 // FIXME: move to the SourceFrame. 1283 if (!this._resource.warnings && !this._resource.errors) { 1284 var view = WebInspector.ResourceView.existingResourceViewForResource(this._resource); 1285 if (view && view.clearMessages) 1286 view.clearMessages(); 1287 } 1288 1322 _updateErrorsAndWarningsBubbles: function() 1323 { 1289 1324 if (this._storagePanel.currentQuery) 1290 1325 return; … … 1301 1336 this._bubbleElement.addStyleClass("error"); 1302 1337 }, 1338 1339 _errorsWarningsCleared: function() 1340 { 1341 // FIXME: move to the SourceFrame. 1342 if (this._sourceView) 1343 this._sourceView.clearMessages(); 1344 1345 this._updateErrorsAndWarningsBubbles(); 1346 }, 1347 1348 _errorsWarningsMessageAdded: function(event) 1349 { 1350 var msg = event.data; 1351 1352 if (this._sourceView) 1353 this._sourceView.addMessage(msg); 1354 1355 this._updateErrorsAndWarningsBubbles(); 1356 }, 1303 1357 1304 1358 _populateRevisions: function() … … 1316 1370 { 1317 1371 this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._storagePanel, revision), 0); 1318 var oldView = WebInspector.ResourceView.existingResourceViewForResource(this._resource);1372 var oldView = this._sourceView; 1319 1373 if (oldView) { 1320 var newView = WebInspector.ResourceView.recreateResourceView(this._resource); 1374 // This is needed when resource content was changed from scripts panel. 1375 var newView = this._recreateSourceView(); 1321 1376 if (oldView === this._storagePanel.visibleView) 1322 1377 this._storagePanel._showResourceView(this._resource); 1323 1378 } 1324 } 1379 }, 1380 1381 sourceView: function() 1382 { 1383 if (!this._sourceView) { 1384 this._sourceView = this._createSourceView(); 1385 if (this._resource.messages) { 1386 for (var i = 0; i < this._resource.messages.length; i++) 1387 this._sourceView.addMessage(this._resource.messages[i]); 1388 } 1389 } 1390 return this._sourceView; 1391 }, 1392 1393 _createSourceView: function() 1394 { 1395 return new WebInspector.EditableResourceSourceFrame(this._resource); 1396 }, 1397 1398 _recreateSourceView: function() 1399 { 1400 var oldView = this._sourceView; 1401 var newView = this._createSourceView(); 1402 1403 var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null; 1404 var scrollTop = oldView.scrollTop; 1405 1406 this._sourceView.detach(); 1407 this._sourceView = newView; 1408 1409 if (oldViewParentNode) 1410 newView.show(oldViewParentNode); 1411 if (scrollTop) 1412 newView.scrollTop = scrollTop; 1413 1414 return newView; 1415 } 1325 1416 } 1326 1417 … … 1452 1543 { 1453 1544 var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : WebInspector.UIString("(original)"); 1454 WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["resource-sidebar-tree-item", "resources-category-" + revision.resource.category.name]);1545 WebInspector.BaseStorageTreeElement.call(this, storagePanel, revision, title, ["resource-sidebar-tree-item", "resources-category-" + revision.resource.category.name]); 1455 1546 if (revision.timestamp) 1456 1547 this.tooltip = revision.timestamp.toLocaleString(); … … 1503 1594 1504 1595 contextMenu.show(event); 1596 }, 1597 1598 sourceView: function() 1599 { 1600 if (!this._sourceView) 1601 this._sourceView = new WebInspector.ResourceRevisionSourceFrame(this._revision); 1602 return this._sourceView; 1505 1603 } 1506 1604 }
Note: See TracChangeset
for help on using the changeset viewer.