Changeset 117799 in webkit
- Timestamp:
- May 21, 2012 10:27:37 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r117792 r117799 1 2012-05-21 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: refactor revision history to not include resource itself. 4 https://bugs.webkit.org/show_bug.cgi?id=87026 5 6 Reviewed by Vsevolod Vlasov. 7 8 * http/tests/inspector/network/network-request-revision-content.html: 9 * inspector/styles/styles-history-expected.txt: 10 * inspector/styles/styles-history.html: 11 1 12 2012-05-21 Stephen Chenney <schenney@chromium.org> 2 13 -
trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html
r114116 r117799 24 24 } 25 25 26 function step3( )26 function step3(content) 27 27 { 28 28 InspectorTest.addResult(resource.url); 29 InspectorTest.addResult( resource.content);29 InspectorTest.addResult(content); 30 30 InspectorTest.completeTest(); 31 31 } -
trunk/LayoutTests/inspector/styles/styles-history-expected.txt
r111677 r117799 6 6 Running: testSetResourceContentMinor 7 7 History length: 0 8 Item <tip>:9 body {10 margin: 10px;11 padding: 10px;12 }13 14 8 15 9 Running: testSetResourceContentMajor 16 10 History length: 1 17 11 Item 0: 18 body {19 margin: 10px;20 padding: 10px;21 }22 23 Item <tip>:24 12 body { 25 13 margin: 20px; … … 31 19 Item 0: 32 20 body { 33 margin: 10px;34 padding: 10px;35 }36 37 Item <tip>:38 body {39 21 margin: 20px; 40 22 padding: 10px; … … 45 27 Item 0: 46 28 body { 47 margin: 10px;48 padding: 10px;49 }50 51 Item 1:52 body {53 29 margin: 20px; 54 30 padding: 10px; 55 31 } 56 Item <tip>:32 Item 1: 57 33 body { 58 34 margin:30px; -
trunk/LayoutTests/inspector/styles/styles-history.html
r111677 r117799 97 97 { 98 98 InspectorTest.addResult("History length: " + styleResource.history.length); 99 for (var i = 0; i < styleResource.history.length; ++i) 100 styleResource.history[i].requestContent(dumpRevision.bind(this, i, null)); 101 styleResource.requestContent(dumpRevision.bind(this, "<tip>", next)); 99 for (var i = 0; i < styleResource.history.length; ++i) { 100 InspectorTest.addResult("Item " + i + ":"); 101 InspectorTest.addResult(styleResource.history[i].content); 102 } 103 next(); 102 104 } 103 105 return result; 104 }105 106 function dumpRevision(index, next, content)107 {108 InspectorTest.addResult("Item " + index + ":");109 InspectorTest.addResult(content);110 if (next)111 next();112 106 } 113 107 } -
trunk/Source/WebCore/ChangeLog
r117798 r117799 1 2012-05-21 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: refactor revision history to not include resource itself. 4 https://bugs.webkit.org/show_bug.cgi?id=87026 5 6 Reviewed by Vsevolod Vlasov. 7 8 This change makes resource contain pure revisions, it stops updating Resources upon free flow editing. 9 10 * inspector/front-end/JavaScriptSource.js: 11 (WebInspector.JavaScriptSource.prototype.setFormatted.didGetContent.didFormatContent): 12 (WebInspector.JavaScriptSource.prototype.setFormatted.didGetContent): 13 (WebInspector.JavaScriptSource.prototype.setFormatted): 14 * inspector/front-end/JavaScriptSourceFrame.js: 15 (WebInspector.JavaScriptSourceFrame.prototype.commitEditing): 16 (WebInspector.JavaScriptSourceFrame.prototype._onContentChanged): 17 (WebInspector.JavaScriptSourceFrame.prototype._didEditContent): 18 * inspector/front-end/Resource.js: 19 (WebInspector.Resource.prototype.addRevision): 20 (WebInspector.Resource.prototype._innerRequestContent.callback): 21 (WebInspector.Resource.prototype._innerRequestContent): 22 (WebInspector.Resource.prototype.revertToOriginal): 23 (WebInspector.ResourceRevision.prototype.revertToThis): 24 (WebInspector.ResourceRevision.prototype.requestContent): 25 (WebInspector.ResourceRevision.prototype.searchInContent): 26 (WebInspector.ResourceRevision.prototype._persistRevision): 27 * inspector/front-end/RevisionHistoryView.js: 28 (WebInspector.RevisionHistoryView): 29 (WebInspector.RevisionHistoryView.prototype._revisionAdded): 30 (WebInspector.RevisionHistoryTreeElement): 31 * inspector/front-end/ScriptSnippetModel.js: 32 (WebInspector.ScriptSnippetModel.prototype.setScriptSnippetContent): 33 * inspector/front-end/StylesPanel.js: 34 (WebInspector.StyleSourceFrame.prototype.commitEditing): 35 (WebInspector.StyleSourceFrame.prototype._didEditContent): 36 (WebInspector.StyleSourceFrame.prototype._onContentChanged): 37 * inspector/front-end/UISourceCode.js: 38 (WebInspector.UISourceCode.prototype._revisionAdded): 39 (WebInspector.UISourceCode.prototype.contentChanged): 40 (WebInspector.UISourceCode.prototype.commitWorkingCopy): 41 * inspector/front-end/inspector.js: 42 (WebInspector._doLoadedDoneWithCapabilities.get if): 43 1 44 2012-05-21 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 45 -
trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js
r117781 r117799 103 103 if (!formatted) { 104 104 this._togglingFormatter = true; 105 this.contentChanged(content || "" );105 this.contentChanged(content || "", mimeType); 106 106 delete this._togglingFormatter; 107 107 this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping(); … … 122 122 { 123 123 this._togglingFormatter = true; 124 this.contentChanged(formattedContent );124 this.contentChanged(formattedContent, mimeType); 125 125 delete this._togglingFormatter; 126 126 this._formatterMapping = formatterMapping; -
trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
r117781 r117799 93 93 commitEditing: function(text) 94 94 { 95 this._ editingContent= true;95 this._isCommittingEditing = true; 96 96 this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this)); 97 97 }, … … 102 102 _onContentChanged: function(event) 103 103 { 104 if (this._editingContent) 105 return; 106 var oldContent = /** @type {string} */ event.data.oldContent; 104 if (this._isCommittingEditing) 105 return; 107 106 var content = /** @type {string} */ event.data.content; 108 107 … … 177 176 _didEditContent: function(error) 178 177 { 179 delete this._ editingContent;178 delete this._isCommittingEditing; 180 179 181 180 if (error) { -
trunk/Source/WebCore/inspector/front-end/Resource.js
r117750 r117799 115 115 116 116 /** 117 * @param {WebInspector.Resource } resource117 * @param {WebInspector.ResourceRevision} revision 118 118 */ 119 WebInspector.Resource.persistRevision = function(re source)119 WebInspector.Resource.persistRevision = function(revision) 120 120 { 121 121 if (!window.localStorage) 122 122 return; 123 123 124 var resource = revision.resource; 124 125 var url = resource.url; 125 126 var loaderId = resource.loaderId; 126 var timestamp = re source._contentTimestamp.getTime();127 var timestamp = revision.timestamp.getTime(); 127 128 var key = "resource-history|" + url + "|" + loaderId + "|" + timestamp; 128 var content = re source._content;129 var content = revision._content; 129 130 130 131 var registry = WebInspector.Resource._resourceRevisionRegistry(); … … 302 303 303 304 /** 304 * @return {Date}305 */306 get contentTimestamp()307 {308 return this._contentTimestamp;309 },310 311 /**312 305 * @return {boolean} 313 306 */ … … 337 330 338 331 /** 339 * @param {string} newContent332 * @param {string} content 340 333 * @param {Date=} timestamp 341 334 * @param {boolean=} restoringHistory 342 335 */ 343 addRevision: function(newContent, timestamp, restoringHistory) 344 { 345 var revision = new WebInspector.ResourceRevision(this, this._content, this._contentTimestamp); 336 addRevision: function(content, timestamp, restoringHistory) 337 { 338 if (this.history.length) { 339 var lastRevision = this.history[this.history.length - 1]; 340 if (lastRevision._content === content) 341 return; 342 } 343 var revision = new WebInspector.ResourceRevision(this, content, timestamp || new Date()); 346 344 this.history.push(revision); 347 348 this._content = newContent;349 this._contentTimestamp = timestamp || new Date();350 345 351 346 this.dispatchEventToListeners(WebInspector.Resource.Events.RevisionAdded, revision); 352 347 if (!restoringHistory) 353 this._persistRevision(); 354 WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted, { resource: this, content: newContent }); 355 }, 356 357 _persistRevision: function() 358 { 359 WebInspector.Resource.persistRevision(this); 348 revision._persistRevision(); 349 WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted, { resource: this, content: content }); 360 350 }, 361 351 … … 459 449 this._content = error ? null : content; 460 450 this._contentEncoded = contentEncoded; 461 this._originalContent = content;462 451 var callbacks = this._pendingContentCallbacks.slice(); 463 452 for (var i = 0; i < callbacks.length; ++i) … … 467 456 } 468 457 PageAgent.getResourceContent(this.frameId, this.url, callback.bind(this)); 458 }, 459 460 revertToOriginal: function() 461 { 462 function revert(content) 463 { 464 this.setContent(content, true, function() {}); 465 } 466 this.requestContent(revert.bind(this)); 469 467 } 470 468 } … … 477 475 * @param {WebInspector.Resource} resource 478 476 * @param {?string|undefined} content 479 * @param { number} timestamp477 * @param {Date} timestamp 480 478 */ 481 479 WebInspector.ResourceRevision = function(resource, content, timestamp) … … 496 494 497 495 /** 498 * @return { number}496 * @return {Date} 499 497 */ 500 498 get timestamp() … … 516 514 { 517 515 if (this._resource._content !== content) 518 this._resource.setContent(content, true );516 this._resource.setContent(content, true, function() {}); 519 517 } 520 518 this.requestContent(revert.bind(this)); … … 542 540 requestContent: function(callback) 543 541 { 544 if (typeof this._content === "string") { 545 callback(this._content, false, this.resource.mimeType); 546 return; 547 } 548 549 // If we are here, this is initial revision. First, look up content fetched over the wire. 550 if (typeof this.resource._originalContent === "string") { 551 this._content = this._resource._originalContent; 552 callback(this._content, false, this.resource.mimeType); 553 return; 554 } 555 556 /** 557 * @param {?Protocol.Error} error 558 * @param {string} content 559 * @param {boolean} contentEncoded 560 */ 561 function callbackWrapper(error, content, contentEncoded) 562 { 563 callback(error ? null : content, contentEncoded, this.resource.mimeType); 564 } 565 566 PageAgent.getResourceContent(this._resource.frameId, this._resource.url, callbackWrapper.bind(this)); 542 callback(this._content || "", false, this.resource.mimeType); 567 543 }, 568 544 … … 576 552 { 577 553 callback([]); 554 }, 555 556 _persistRevision: function() 557 { 558 WebInspector.Resource.persistRevision(this); 578 559 } 579 560 } -
trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js
r117750 r117799 51 51 } else { 52 52 var olElement = this.element.createChild("ol"); 53 vartreeOutline = new TreeOutline(olElement);53 this._treeOutline = new TreeOutline(olElement); 54 54 revisionCount = this._resource.history.length; 55 56 var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource);57 historyItem.selectable = false;58 treeOutline.appendChild(historyItem);59 55 60 56 for (var i = revisionCount - 1; i >= 0; --i) { 61 57 var revision = this._resource.history[i]; 62 historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource, i); 63 historyItem.selectable = false; 64 treeOutline.appendChild(historyItem); 65 } 58 var historyItem = new WebInspector.RevisionHistoryTreeElement(revision, this._resource.history[i - 1]); 59 this._treeOutline.appendChild(historyItem); 60 } 61 62 var baseItem = new TreeElement("", null, false); 63 baseItem.selectable = false; 64 this._treeOutline.appendChild(baseItem); 65 66 var revertToOriginal = baseItem.listItemElement.createChild("span", "revision-history-link"); 67 revertToOriginal.textContent = WebInspector.UIString("revert to original"); 68 revertToOriginal.addEventListener("click", this._resource.revertToOriginal.bind(this._resource)); 66 69 } 67 70 … … 98 101 99 102 WebInspector.RevisionHistoryView.prototype = { 100 _revisionAdded: function() 101 { 102 WebInspector.RevisionHistoryView.showHistory(this._uiSourceCode); 103 _revisionAdded: function(event) 104 { 105 if (this._resource.history.length === 1) { 106 WebInspector.RevisionHistoryView.showHistory(this._uiSourceCode); 107 return; 108 } 109 var historyLength = this._resource.history.length; 110 var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource.history[historyLength - 1], this._resource.history[historyLength - 2]); 111 this._treeOutline.insertChild(historyItem, 0); 103 112 }, 104 113 … … 116 125 * @constructor 117 126 * @extends {TreeElement} 118 * @param {WebInspector.Resource} resource 119 * @param {number=} revisionOrdinal 120 */ 121 WebInspector.RevisionHistoryTreeElement = function(resource, revisionOrdinal) 122 { 123 this._resource = resource; 124 127 * @param {WebInspector.ResourceRevision} revision 128 * @param {WebInspector.ResourceRevision=} baseRevision 129 */ 130 WebInspector.RevisionHistoryTreeElement = function(revision, baseRevision) 131 { 125 132 var titleElement = document.createElement("span"); 126 if (isNaN(revisionOrdinal)) { 127 this._revision = resource; 128 this._baseRevision = resource.history[resource.history.length - 1]; 129 130 titleElement.textContent = resource.contentTimestamp.toLocaleTimeString(); 131 } else { 132 this._revision = resource.history[revisionOrdinal]; 133 this._baseRevision = resource.history[revisionOrdinal - 1]; 134 135 titleElement.textContent = revisionOrdinal ? resource.history[revisionOrdinal].timestamp.toLocaleTimeString() : WebInspector.UIString("(original)"); 136 function revert() 137 { 138 this._revision.revertToThis(); 139 } 140 141 var revertElement = titleElement.createChild("span", "revision-history-link"); 142 revertElement.textContent = WebInspector.UIString("revert to this"); 143 revertElement.addEventListener("click", revert.bind(this), false); 144 } 145 TreeElement.call(this, titleElement, null, revisionOrdinal !== 0); 133 titleElement.textContent = revision.timestamp.toLocaleTimeString(); 134 135 TreeElement.call(this, titleElement, null, true); 136 this.selectable = false; 137 138 this._revision = revision; 139 this._baseRevision = baseRevision; 140 141 var revertElement = titleElement.createChild("span", "revision-history-link"); 142 revertElement.textContent = WebInspector.UIString("revert to this"); 143 revertElement.addEventListener("click", this._revision.revertToThis.bind(this._revision), false); 146 144 } 147 145 … … 154 152 155 153 this.childrenListElement.addStyleClass("source-code"); 156 this._baseRevision.requestContent(step1.bind(this)); 154 if (this._baseRevision) 155 this._baseRevision.requestContent(step1.bind(this)); 156 else 157 this._revision.resource.requestContent(step1.bind(this)); 157 158 158 159 function step1(baseContent) -
trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js
r117781 r117799 114 114 var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId); 115 115 snippet.content = newContent; 116 snippetJavaScriptSource.contentChanged(newContent );116 snippetJavaScriptSource.contentChanged(newContent, "text/javascript"); 117 117 }, 118 118 -
trunk/Source/WebCore/inspector/front-end/StylesPanel.js
r117781 r117799 146 146 commitEditing: function(text) 147 147 { 148 this._isCommittingEditing = true; 148 149 this._styleSource.commitWorkingCopy(this._didEditContent.bind(this)); 149 150 }, … … 160 161 return; 161 162 } 163 delete this._isCommittingEditing; 162 164 }, 163 165 … … 174 176 _onContentChanged: function(event) 175 177 { 176 this.setContent(this._styleSource.resource().content, false, "text/stylesheet"); 178 if (!this._isCommittingEditing) 179 this.setContent(this._styleSource.content() || "", false, "text/css"); 177 180 }, 178 181 -
trunk/Source/WebCore/inspector/front-end/UISourceCode.js
r117781 r117799 137 137 _revisionAdded: function(event) 138 138 { 139 this.contentChanged(this.resource().content || ""); 139 var revision = /** @type {WebInspector.ResourceRevision} */ event.data; 140 this.contentChanged(revision.content || "", this._resource.canonicalMimeType()); 140 141 }, 141 142 142 143 /** 143 144 * @param {string} newContent 144 */ 145 contentChanged: function(newContent) 145 * @param {string} mimeType 146 */ 147 contentChanged: function(newContent, mimeType) 146 148 { 147 149 if (this._committingWorkingCopy) 148 150 return; 149 151 150 var oldContent = this._contentLoaded ? this._content : undefined;151 152 this._content = newContent; 153 this._mimeType = mimeType; 154 this._contentLoaded = true; 152 155 delete this._workingCopy; 153 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, { oldContent: oldContent,content: newContent});156 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {content: newContent}); 154 157 }, 155 158 … … 205 208 delete this._committingWorkingCopy; 206 209 if (!error) 207 this.contentChanged(newContent );210 this.contentChanged(newContent, this._mimeType); 208 211 callback(error); 209 212 } -
trunk/Source/WebCore/inspector/front-end/inspector.js
r117746 r117799 417 417 this.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this.debuggerModel); 418 418 419 WebInspector.CSSCompletions.requestCSSNameCompletions(); 420 419 421 this.drawer = new WebInspector.Drawer(); 420 422 this.consoleView = new WebInspector.ConsoleView(WebInspector.WorkerManager.isWorkerFrontend()); … … 445 447 this._requestZoom(); 446 448 447 WebInspector.CSSCompletions.requestCSSNameCompletions();448 449 this._createPanels(); 449 450 this._createGlobalStatusBarItems();
Note: See TracChangeset
for help on using the changeset viewer.