Changeset 147099 in webkit
- Timestamp:
- Mar 28, 2013 5:34:16 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r147097 r147099 1 2013-03-28 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Simplify ResourceScriptFile so that it stores hasDiverged state in it. 4 https://bugs.webkit.org/show_bug.cgi?id=113489 5 6 Reviewed by Pavel Feldman. 7 8 ResourceScriptFile._hasDiverged is the one flag that shows whether we have diverged from VM. 9 It's values is based both on dirty flag on uiSourceCode and information about live edit failures stored in _lastLiveEditFailed field. 10 Removed willMerge/Diverge events from ScriptFile. 11 JavaScriptSourceFrame now uses isMergingToVM/DivergingFromVM methods on ScriptFile. 12 to determine whether breakpointAdded/Removed events should be ignored. 13 Introduced muted state on JavaScriptSourceFrame to determine whether it should ignore user attempts to set/remove breakpoints. 14 15 * inspector/front-end/JavaScriptSourceFrame.js: 16 (WebInspector.JavaScriptSourceFrame): 17 (WebInspector.JavaScriptSourceFrame.prototype._didMergeToVM): 18 (WebInspector.JavaScriptSourceFrame.prototype._didDivergeFromVM): 19 (WebInspector.JavaScriptSourceFrame.prototype._muteBreakpointsWhileEditing): 20 (WebInspector.JavaScriptSourceFrame.prototype._restoreBreakpointsAfterEditing): 21 (WebInspector.JavaScriptSourceFrame.prototype._addBreakpointDecoration): 22 (WebInspector.JavaScriptSourceFrame.prototype._removeBreakpointDecoration): 23 (WebInspector.JavaScriptSourceFrame.prototype._shouldIgnoreExternalBreakpointEvents): 24 (WebInspector.JavaScriptSourceFrame.prototype._breakpointAdded): 25 (WebInspector.JavaScriptSourceFrame.prototype._breakpointRemoved): 26 (WebInspector.JavaScriptSourceFrame.prototype._updateScriptFile): 27 (WebInspector.JavaScriptSourceFrame.prototype.onTextEditorContentLoaded): 28 * inspector/front-end/LiveEditSupport.js: 29 (WebInspector.LiveEditScriptFile.prototype.isMergingToVM): 30 * inspector/front-end/ResourceScriptMapping.js: 31 (WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation): 32 (WebInspector.ScriptFile.prototype.isMergingToVM): 33 (WebInspector.ResourceScriptFile): 34 (WebInspector.ResourceScriptFile.prototype._workingCopyCommitted): 35 (WebInspector.ResourceScriptFile.prototype._isDiverged): 36 (WebInspector.ResourceScriptFile.prototype._workingCopyChanged): 37 (WebInspector.ResourceScriptFile.prototype._update): 38 (WebInspector.ResourceScriptFile.prototype._divergeFromVM): 39 (WebInspector.ResourceScriptFile.prototype._mergeToVM): 40 (WebInspector.ResourceScriptFile.prototype.hasDivergedFromVM): 41 (WebInspector.ResourceScriptFile.prototype.isMergingToVM): 42 * inspector/front-end/ScriptSnippetModel.js: 43 (WebInspector.SnippetScriptFile.prototype.isMergingToVM): 44 1 45 2013-03-25 Andrey Kosyakov <caseq@chromium.org> 2 46 -
trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
r146903 r147099 59 59 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this); 60 60 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SourceMappingChanged, this._onSourceMappingChanged, this); 61 61 62 62 this._updateScriptFile(); 63 63 } … … 130 130 }, 131 131 132 _ willMergeToVM: function()132 _didMergeToVM: function() 133 133 { 134 134 if (this._supportsEnabledBreakpointsWhileEditing()) 135 135 return; 136 this._ preserveDecorations = true;137 }, 138 139 _did MergeToVM: function()136 this._restoreBreakpointsAfterEditing(); 137 }, 138 139 _didDivergeFromVM: function() 140 140 { 141 141 if (this._supportsEnabledBreakpointsWhileEditing()) 142 142 return; 143 delete this._preserveDecorations;144 this._restoreBreakpointsAfterEditing();145 },146 147 _willDivergeFromVM: function()148 {149 if (this._supportsEnabledBreakpointsWhileEditing())150 return;151 this._preserveDecorations = true;152 },153 154 _didDivergeFromVM: function()155 {156 if (this._supportsEnabledBreakpointsWhileEditing())157 return;158 delete this._preserveDecorations;159 143 this._muteBreakpointsWhileEditing(); 160 144 }, … … 162 146 _muteBreakpointsWhileEditing: function() 163 147 { 148 if (this._muted) 149 return; 164 150 for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) { 165 151 var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint"); … … 169 155 this._addBreakpointDecoration(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled, true); 170 156 } 157 this._muted = true; 171 158 }, 172 159 … … 178 165 _restoreBreakpointsAfterEditing: function() 179 166 { 167 delete this._muted; 180 168 var breakpoints = {}; 181 169 // Save and remove muted breakpoint decorations. … … 312 300 _addBreakpointDecoration: function(lineNumber, condition, enabled, mutedWhileEditing) 313 301 { 314 if (this._preserveDecorations)315 return;316 302 var breakpoint = { 317 303 condition: condition, 318 304 enabled: enabled 319 305 }; 306 320 307 this.textEditor.setAttribute(lineNumber, "breakpoint", breakpoint); 321 308 … … 326 313 _removeBreakpointDecoration: function(lineNumber) 327 314 { 328 if (this._preserveDecorations)329 return;330 315 this.textEditor.removeAttribute(lineNumber, "breakpoint"); 331 316 this.textEditor.removeBreakpoint(lineNumber); … … 431 416 }, 432 417 418 /** 419 * @return {boolean} 420 */ 421 _shouldIgnoreExternalBreakpointEvents: function() 422 { 423 if (this._supportsEnabledBreakpointsWhileEditing()) 424 return false; 425 if (this._muted) 426 return true; 427 return this._scriptFile && (this._scriptFile.isDivergingFromVM() || this._scriptFile.isMergingToVM()); 428 }, 429 433 430 _breakpointAdded: function(event) 434 431 { 435 432 var uiLocation = /** @type {WebInspector.UILocation} */ (event.data.uiLocation); 436 437 433 if (uiLocation.uiSourceCode !== this._uiSourceCode) 434 return; 435 if (this._shouldIgnoreExternalBreakpointEvents()) 438 436 return; 439 437 … … 447 445 var uiLocation = /** @type {WebInspector.UILocation} */ (event.data.uiLocation); 448 446 if (uiLocation.uiSourceCode !== this._uiSourceCode) 447 return; 448 if (this._shouldIgnoreExternalBreakpointEvents()) 449 449 return; 450 450 … … 485 485 { 486 486 if (this._scriptFile) { 487 this._scriptFile.removeEventListener(WebInspector.ScriptFile.Events.WillMergeToVM, this._willMergeToVM, this);488 487 this._scriptFile.removeEventListener(WebInspector.ScriptFile.Events.DidMergeToVM, this._didMergeToVM, this); 489 this._scriptFile.removeEventListener(WebInspector.ScriptFile.Events.WillDivergeFromVM, this._willDivergeFromVM, this);490 488 this._scriptFile.removeEventListener(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._didDivergeFromVM, this); 491 489 } 492 490 this._scriptFile = this._uiSourceCode.scriptFile(); 493 491 if (this._scriptFile) { 494 this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.WillMergeToVM, this._willMergeToVM, this);495 492 this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidMergeToVM, this._didMergeToVM, this); 496 this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.WillDivergeFromVM, this._willDivergeFromVM, this);497 493 this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._didDivergeFromVM, this); 498 494 } … … 505 501 506 502 var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode); 507 for (var i = 0; i < breakpointLocations.length; ++i) { 508 var breakpoint = breakpointLocations[i].breakpoint; 509 this._addBreakpointDecoration(breakpointLocations[i].uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), false); 510 } 503 for (var i = 0; i < breakpointLocations.length; ++i) 504 this._breakpointAdded({data:breakpointLocations[i]}); 511 505 512 506 var messages = this._uiSourceCode.consoleMessages(); … … 522 516 _handleGutterClick: function(event) 523 517 { 524 if (this._ uiSourceCode.isDirty() && !this._supportsEnabledBreakpointsWhileEditing())518 if (this._muted) 525 519 return; 526 520 … … 553 547 toggleBreakpointOnCurrentLine: function() 554 548 { 555 if (this._ uiSourceCode.isDirty() && !this._supportsEnabledBreakpointsWhileEditing())549 if (this._muted) 556 550 return; 557 551 -
trunk/Source/WebCore/inspector/front-end/LiveEditSupport.js
r142269 r147099 127 127 }, 128 128 129 /** 130 * @return {boolean} 131 */ 132 isMergingToVM: function() 133 { 134 return false; 135 }, 136 129 137 __proto__: WebInspector.Object.prototype 130 138 } -
trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js
r146983 r147099 55 55 if (!uiSourceCode) 56 56 return null; 57 if (uiSourceCode.scriptFile() && uiSourceCode.scriptFile().hasDivergedFromVM()) 57 var scriptFile = uiSourceCode.scriptFile(); 58 if (scriptFile && ((scriptFile.hasDivergedFromVM() && !scriptFile.isMergingToVM()) || scriptFile.isDivergingFromVM())) 58 59 return null; 59 60 return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0); … … 243 244 244 245 WebInspector.ScriptFile.Events = { 245 WillMergeToVM: "WillMergeToVM",246 246 DidMergeToVM: "DidMergeToVM", 247 WillDivergeFromVM: "WillDivergeFromVM",248 247 DidDivergeFromVM: "DidDivergeFromVM", 249 248 } … … 259 258 */ 260 259 isDivergingFromVM: function() { return false; }, 260 261 /** 262 * @return {boolean} 263 */ 264 isMergingToVM: function() { return false; }, 261 265 } 262 266 … … 273 277 this._resourceScriptMapping = resourceScriptMapping; 274 278 this._uiSourceCode = uiSourceCode; 279 275 280 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this); 276 281 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this); 277 this._ maybeDirtyChanged(false);282 this._update(); 278 283 } 279 284 … … 287 292 { 288 293 if (error) { 289 this._ hasDivergedFromVM= true;294 this._lastLiveEditFailed = true; 290 295 WebInspector.showErrorMessage(error); 291 296 return; 292 297 } 293 294 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillMergeToVM, this); 295 delete this._hasDivergedFromVM; 296 this._resourceScriptMapping._hasMergedToVM(this._uiSourceCode); 297 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidMergeToVM, this); 298 299 delete this._lastLiveEditFailed; 300 this._mergeToVM(); 298 301 } 299 302 300 303 var rawLocation = /** @type {WebInspector.DebuggerModel.Location} */ (this._uiSourceCode.uiLocationToRawLocation(0, 0)); 301 304 if (!rawLocation) … … 305 308 }, 306 309 310 _isDiverged: function() 311 { 312 if (this._uiSourceCode.isDirty()) 313 return true; 314 return this._lastLiveEditFailed; 315 }, 316 307 317 _workingCopyChanged: function(event) 308 318 { 309 var wasDirty = /** @type {boolean} */ (event.data.wasDirty); 310 this._maybeDirtyChanged(wasDirty); 311 }, 312 313 _maybeDirtyChanged: function(wasDirty) 314 { 315 if (!wasDirty && this._uiSourceCode.isDirty() && !this._hasDivergedFromVM) { 316 this._isDivergingFromVM = true; 317 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillDivergeFromVM, this._uiSourceCode); 318 this._resourceScriptMapping._hasDivergedFromVM(this._uiSourceCode); 319 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._uiSourceCode); 320 delete this._isDivergingFromVM; 321 } else if (wasDirty && !this._uiSourceCode.isDirty() && !this._hasDivergedFromVM) { 322 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillMergeToVM, this._uiSourceCode); 323 this._resourceScriptMapping._hasMergedToVM(this._uiSourceCode); 324 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidMergeToVM, this._uiSourceCode); 325 } 319 this._update(); 320 }, 321 322 _update: function() 323 { 324 if (this._isDiverged() && !this._hasDivergedFromVM) 325 this._divergeFromVM(); 326 else if (!this._isDiverged() && this._hasDivergedFromVM) 327 this._mergeToVM(); 328 }, 329 330 _divergeFromVM: function() 331 { 332 this._isDivergingFromVM = true; 333 this._resourceScriptMapping._hasDivergedFromVM(this._uiSourceCode); 334 delete this._isDivergingFromVM; 335 this._hasDivergedFromVM = true; 336 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._uiSourceCode); 337 }, 338 339 _mergeToVM: function() 340 { 341 delete this._hasDivergedFromVM; 342 this._isMergingToVM = true; 343 this._resourceScriptMapping._hasMergedToVM(this._uiSourceCode); 344 delete this._isMergingToVM; 345 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidMergeToVM, this._uiSourceCode); 326 346 }, 327 347 … … 331 351 hasDivergedFromVM: function() 332 352 { 333 return this._ uiSourceCode.isDirty() || this._hasDivergedFromVM;353 return this._hasDivergedFromVM; 334 354 }, 335 355 … … 340 360 { 341 361 return this._isDivergingFromVM; 362 }, 363 364 /** 365 * @return {boolean} 366 */ 367 isMergingToVM: function() 368 { 369 return this._isMergingToVM; 342 370 }, 343 371 -
trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js
r146983 r147099 435 435 436 436 /** 437 * @return {boolean} 438 */ 439 isMergingToVM: function() 440 { 441 return false; 442 }, 443 444 /** 437 445 * @param {boolean} isDivergingFromVM 438 446 */
Note: See TracChangeset
for help on using the changeset viewer.