Title: [131604] trunk
Revision
131604
Author
[email protected]
Date
2012-10-17 08:38:51 -0700 (Wed, 17 Oct 2012)

Log Message

Web Inspector: [Regression] Undoing script changes does not restore breakpoints.
https://bugs.webkit.org/show_bug.cgi?id=99598

Reviewed by Pavel Feldman.

Source/WebCore:

workingCopyChanged now dispatches did/willMergeToVM instead of did/willDivergeFromVM
when change returns uiSourceCode to non dirty state.
Added wasDirty parameter to workingCopyChanged event.

Test: inspector/debugger/live-edit-breakpoints.html

* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptFile.prototype._workingCopyCommitted):
(WebInspector.ResourceScriptFile.prototype._workingCopyChanged):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype.setWorkingCopy):

LayoutTests:

* http/tests/inspector/live-edit-test.js:
(initialize_LiveEditTest.InspectorTest.replaceInSource):
(initialize_LiveEditTest.InspectorTest.commitSource):
(initialize_LiveEditTest.InspectorTest.undoSourceEditing):
(initialize_LiveEditTest):
* inspector/debugger/live-edit-breakpoints-expected.txt: Added.
* inspector/debugger/live-edit-breakpoints.html: Added.
* inspector/debugger/live-edit.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (131603 => 131604)


--- trunk/LayoutTests/ChangeLog	2012-10-17 15:37:33 UTC (rev 131603)
+++ trunk/LayoutTests/ChangeLog	2012-10-17 15:38:51 UTC (rev 131604)
@@ -1,3 +1,19 @@
+2012-10-17  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: [Regression] Undoing script changes does not restore breakpoints.
+        https://bugs.webkit.org/show_bug.cgi?id=99598
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/live-edit-test.js:
+        (initialize_LiveEditTest.InspectorTest.replaceInSource):
+        (initialize_LiveEditTest.InspectorTest.commitSource):
+        (initialize_LiveEditTest.InspectorTest.undoSourceEditing):
+        (initialize_LiveEditTest):
+        * inspector/debugger/live-edit-breakpoints-expected.txt: Added.
+        * inspector/debugger/live-edit-breakpoints.html: Added.
+        * inspector/debugger/live-edit.html:
+
 2012-10-17  Dana Jansens  <[email protected]>
 
         Unreviewed rebaseline for ietestcenter/css3/bordersbackgrounds/border-radius-content-edge-001.htm

Modified: trunk/LayoutTests/http/tests/inspector/live-edit-test.js (131603 => 131604)


--- trunk/LayoutTests/http/tests/inspector/live-edit-test.js	2012-10-17 15:37:33 UTC (rev 131603)
+++ trunk/LayoutTests/http/tests/inspector/live-edit-test.js	2012-10-17 15:38:51 UTC (rev 131604)
@@ -3,21 +3,25 @@
 InspectorTest.replaceInSource = function(sourceFrame, string, replacement)
 {
     sourceFrame._textEditor._mainPanel.setReadOnly(false);
-    var oldRange, newRange;
-    var lines = sourceFrame._textEditor._textModel._lines;
-    for (var i = 0; i < lines.length; ++i) {
-        var column = lines[i].indexOf(string);
+    for (var i = 0; i < sourceFrame._textEditor.linesCount; ++i) {
+        var line = sourceFrame._textEditor.line(i);
+        var column = line.indexOf(string);
         if (column === -1)
             continue;
-        lines[i] = lines[i].replace(string, replacement);
-        var lineEndings = replacement.lineEndings();
-        var lastLineLength = lineEndings[lineEndings.length - 1] - (lineEndings[lineEndings.length - 2] || 0);
-        oldRange = new WebInspector.TextRange(i, column, i, column + string.length);
-        newRange = new WebInspector.TextRange(i, column, i + lineEndings.length - 1, lastLineLength);
+        range = new WebInspector.TextRange(i, column, i, column + string.length);
+        var newRange = sourceFrame._textEditor.editRange(range, replacement);
         break;
     }
-    sourceFrame.onTextChanged(oldRange, newRange);
+}
+
+InspectorTest.commitSource = function(sourceFrame)
+{
     sourceFrame._commitEditing();
 }
 
+InspectorTest.undoSourceEditing = function(sourceFrame)
+{
+    sourceFrame._textEditor._mainPanel.handleUndoRedo(false);
+}
+
 };

Added: trunk/LayoutTests/inspector/debugger/live-edit-breakpoints-expected.txt (0 => 131604)


--- trunk/LayoutTests/inspector/debugger/live-edit-breakpoints-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/live-edit-breakpoints-expected.txt	2012-10-17 15:38:51 UTC (rev 131604)
@@ -0,0 +1,133 @@
+Tests live edit feature.
+
+Debugger was enabled.
+
+Running: testEditUndo
+Setting breakpoint:
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Editing source:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Undoing source editing:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Finally removing breakpoint:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    Dumping breakpoint storage
+    Dumping breakpoint locations
+
+Running: testEditCommit
+Setting breakpoint:
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Editing source:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Committing edited source:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Finally removing breakpoint:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    Dumping breakpoint storage
+    Dumping breakpoint locations
+
+Running: testEditCommitFailEditCommit
+Setting breakpoint:
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Editing source:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Committing edited source:
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Editing source again so that live edit could succeed:
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Committing edited source again:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Finally removing breakpoint:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    Dumping breakpoint storage
+    Dumping breakpoint locations
+
+Running: testEditCommitFailUndoCommit
+Setting breakpoint:
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Editing source:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = true)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Committing edited source:
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Undoing source editing:
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: true
+Committing edited source again:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    TextEditor.addBreakpoint(lineNumber = 2, disabled = false)
+    Dumping breakpoint storage
+        edit-me.js:2, enabled:true
+    Dumping breakpoint locations
+        url: edit-me.js, lineNumber: 2, isTemporary: false
+Finally removing breakpoint:
+    TextEditor.removeBreakpoint(lineNumber = 2)
+    Dumping breakpoint storage
+    Dumping breakpoint locations
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/inspector/debugger/live-edit-breakpoints-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/debugger/live-edit-breakpoints.html (0 => 131604)


--- trunk/LayoutTests/inspector/debugger/live-edit-breakpoints.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/live-edit-breakpoints.html	2012-10-17 15:38:51 UTC (rev 131604)
@@ -0,0 +1,248 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+function test()
+{
+    var panel = WebInspector.showPanel("scripts");  
+
+    function pathToFileName(path)
+    {
+        return path.substring(path.lastIndexOf("/") + 1);
+    }
+
+    function dumpBreakpointStorageAndLocations()
+    {
+        var breakpointManager = WebInspector.breakpointManager;
+        var breakpoints = breakpointManager._storage._setting.get();
+        InspectorTest.addResult("    Dumping breakpoint storage");
+        for (var i = 0; i < breakpoints.length; ++i) {
+            var url = 
+            InspectorTest.addResult("        " + pathToFileName(breakpoints[i].sourceFileId) + ":" + breakpoints[i].lineNumber + ", enabled:" + breakpoints[i].enabled);
+        }
+
+        var breakpointManager = WebInspector.breakpointManager;
+        locations = breakpointManager.allBreakpointLocations();
+        InspectorTest.addResult("    Dumping breakpoint locations");
+        for (var i = 0; i < locations.length; ++i) {
+            var uiLocation = locations[i].uiLocation;
+            var uiSourceCode = uiLocation.uiSourceCode;
+            InspectorTest.addResult("        url: " + pathToFileName(uiSourceCode.url) + ", lineNumber: " + uiLocation.lineNumber + ", isTemporary: " + !!uiSourceCode.isTemporary);
+        }
+    }
+
+    function addBreakpointSniffer(lineNumber, disabled)
+    {
+        InspectorTest.addResult("    TextEditor.addBreakpoint(lineNumber = " + lineNumber + ", disabled = " + disabled + ")");
+    }
+
+    function removeBreakpointSniffer(lineNumber)
+    {
+        InspectorTest.addResult("    TextEditor.removeBreakpoint(lineNumber = " + lineNumber + ")");
+    }
+
+    WebInspector.breakpointManager._storage._breakpoints = {};
+    InspectorTest.addSniffer(WebInspector.DefaultTextEditor.prototype, "addBreakpoint", addBreakpointSniffer, true);
+    InspectorTest.addSniffer(WebInspector.DefaultTextEditor.prototype, "removeBreakpoint", removeBreakpointSniffer, true);
+
+    InspectorTest.runDebuggerTestSuite([
+        function testEditUndo(next)
+        {
+            var _javascript_SourceFrame, uiSourceCode, scriptFile;
+
+            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+
+            function didShowScriptSource(sourceFrame)
+            {
+                _javascript_SourceFrame = sourceFrame;
+                uiSourceCode = sourceFrame._uiSourceCode;
+                scriptFile = sourceFrame._uiSourceCode.scriptFile();
+                
+                InspectorTest.addResult("Setting breakpoint:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolved);
+                InspectorTest.setBreakpoint(sourceFrame, 2, "", true);
+            }
+
+            function breakpointResolved()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Editing source:");
+                InspectorTest.replaceInSource(_javascript_SourceFrame, "}", "}//");
+
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Undoing source editing:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolvedAgain);
+                InspectorTest.undoSourceEditing(_javascript_SourceFrame);
+            }
+
+            function breakpointResolvedAgain()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Finally removing breakpoint:");
+                InspectorTest.removeBreakpoint(_javascript_SourceFrame, 2);
+
+                dumpBreakpointStorageAndLocations();
+                next();
+            }
+        },
+
+        function testEditCommit(next)
+        {
+            var _javascript_SourceFrame, uiSourceCode, scriptFile;
+
+            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+
+            function didShowScriptSource(sourceFrame)
+            {
+                _javascript_SourceFrame = sourceFrame;
+                uiSourceCode = sourceFrame._uiSourceCode;
+                scriptFile = sourceFrame._uiSourceCode.scriptFile();
+                
+                InspectorTest.addResult("Setting breakpoint:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolved);
+                InspectorTest.setBreakpoint(sourceFrame, 2, "", true);
+            }
+
+            function breakpointResolved()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Editing source:");
+                InspectorTest.replaceInSource(_javascript_SourceFrame, "}", "}//");
+
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Committing edited source:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolvedAgain);
+                InspectorTest.commitSource(_javascript_SourceFrame);
+            }
+
+            function breakpointResolvedAgain()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Finally removing breakpoint:");
+                InspectorTest.removeBreakpoint(_javascript_SourceFrame, 2);
+
+                dumpBreakpointStorageAndLocations();
+                next();
+            }
+        },
+
+        function testEditCommitFailEditCommit(next)
+        {
+            var _javascript_SourceFrame, uiSourceCode, scriptFile;
+
+            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+
+            function didShowScriptSource(sourceFrame)
+            {
+                _javascript_SourceFrame = sourceFrame;
+                uiSourceCode = sourceFrame._uiSourceCode;
+                scriptFile = sourceFrame._uiSourceCode.scriptFile();
+                
+                InspectorTest.addResult("Setting breakpoint:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolved);
+                InspectorTest.setBreakpoint(sourceFrame, 2, "", true);
+            }
+
+            function breakpointResolved()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Editing source:");
+                InspectorTest.replaceInSource(_javascript_SourceFrame, "}", "//}");
+
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Committing edited source:");
+                InspectorTest.addSniffer(WebInspector.debuggerModel, "_didEditScriptSource", commitFailed);
+                InspectorTest.commitSource(_javascript_SourceFrame);
+            }
+
+            function commitFailed(error)
+            {
+                InspectorTest.assertTrue(!!error, "Commit should have failed.");
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Editing source again so that live edit could succeed:");
+                InspectorTest.replaceInSource(_javascript_SourceFrame, "//}", "}//");
+
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Committing edited source again:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolvedAgain);
+                InspectorTest.commitSource(_javascript_SourceFrame);
+            }
+
+            function breakpointResolvedAgain()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Finally removing breakpoint:");
+                InspectorTest.removeBreakpoint(_javascript_SourceFrame, 2);
+
+                dumpBreakpointStorageAndLocations();
+                next();
+            }
+        },
+
+        function testEditCommitFailUndoCommit(next)
+        {
+            var _javascript_SourceFrame, uiSourceCode, scriptFile;
+
+            InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+
+            function didShowScriptSource(sourceFrame)
+            {
+                _javascript_SourceFrame = sourceFrame;
+                uiSourceCode = sourceFrame._uiSourceCode;
+                scriptFile = sourceFrame._uiSourceCode.scriptFile();
+                
+                InspectorTest.addResult("Setting breakpoint:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolved);
+                InspectorTest.setBreakpoint(sourceFrame, 2, "", true);
+            }
+
+            function breakpointResolved()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Editing source:");
+                InspectorTest.replaceInSource(_javascript_SourceFrame, "}", "//}");
+
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Committing edited source:");
+                InspectorTest.addSniffer(WebInspector.debuggerModel, "_didEditScriptSource", commitFailed);
+                InspectorTest.commitSource(_javascript_SourceFrame);
+            }
+
+            function commitFailed(error)
+            {
+                InspectorTest.assertTrue(!!error, "Commit should have failed.");
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Undoing source editing:");
+                InspectorTest.undoSourceEditing(_javascript_SourceFrame);
+
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Committing edited source again:");
+                InspectorTest.addSniffer(WebInspector.BreakpointManager.Breakpoint.prototype, "_addResolvedLocation", breakpointResolvedAgain);
+                InspectorTest.commitSource(_javascript_SourceFrame);
+            }
+
+            function breakpointResolvedAgain()
+            {
+                dumpBreakpointStorageAndLocations();
+                InspectorTest.addResult("Finally removing breakpoint:");
+                InspectorTest.removeBreakpoint(_javascript_SourceFrame, 2);
+
+                dumpBreakpointStorageAndLocations();
+                next();
+            }
+        },
+    ]);
+};
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>Tests live edit feature.</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/live-edit-breakpoints.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/LayoutTests/inspector/debugger/live-edit.html (131603 => 131604)


--- trunk/LayoutTests/inspector/debugger/live-edit.html	2012-10-17 15:37:33 UTC (rev 131603)
+++ trunk/LayoutTests/inspector/debugger/live-edit.html	2012-10-17 15:38:51 UTC (rev 131604)
@@ -126,6 +126,8 @@
     {
         InspectorTest.addSniffer(WebInspector.debuggerModel, "_didEditScriptSource", callback);
         InspectorTest.replaceInSource(sourceFrame, string, replacement);
+        InspectorTest.commitSource(sourceFrame);
+        
     }
 };
 

Modified: trunk/Source/WebCore/ChangeLog (131603 => 131604)


--- trunk/Source/WebCore/ChangeLog	2012-10-17 15:37:33 UTC (rev 131603)
+++ trunk/Source/WebCore/ChangeLog	2012-10-17 15:38:51 UTC (rev 131604)
@@ -1,3 +1,22 @@
+2012-10-17  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: [Regression] Undoing script changes does not restore breakpoints.
+        https://bugs.webkit.org/show_bug.cgi?id=99598
+
+        Reviewed by Pavel Feldman.
+
+        workingCopyChanged now dispatches did/willMergeToVM instead of did/willDivergeFromVM
+        when change returns uiSourceCode to non dirty state.
+        Added wasDirty parameter to workingCopyChanged event.
+
+        Test: inspector/debugger/live-edit-breakpoints.html
+
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptFile.prototype._workingCopyCommitted):
+        (WebInspector.ResourceScriptFile.prototype._workingCopyChanged):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode.prototype.setWorkingCopy):
+
 2012-10-17  Simon Hausmann  <[email protected]>
 
         [Qt] Avoid re-creating CSSGrammar.cpp with each (incremental) build

Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (131603 => 131604)


--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-10-17 15:37:33 UTC (rev 131603)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-10-17 15:38:51 UTC (rev 131604)
@@ -323,6 +323,7 @@
         function innerCallback(error)
         {
             if (error) {
+                this._hasDivergedFromVM = true;
                 WebInspector.showErrorMessage(error);
                 return;
             }
@@ -342,12 +343,18 @@
 
     _workingCopyChanged: function(event)
     {
-        this._isDivergingFromVM = true;
-        this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillDivergeFromVM, this._uiSourceCode);
-        this._hasDivergedFromVM = true;
-        this._resourceScriptMapping._hasDivergedFromVM(this._uiSourceCode);
-        this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._uiSourceCode);
-        delete this._isDivergingFromVM;
+        var wasDirty = /** @type {boolean} */ event.data.wasDirty;
+        if (!wasDirty && this._uiSourceCode.isDirty() && !this._hasDivergedFromVM) {
+            this._isDivergingFromVM = true;
+            this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillDivergeFromVM, this._uiSourceCode);
+            this._resourceScriptMapping._hasDivergedFromVM(this._uiSourceCode);
+            this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._uiSourceCode);
+            delete this._isDivergingFromVM;
+        } else if (wasDirty && !this._uiSourceCode.isDirty() && !this._hasDivergedFromVM) {
+            this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillMergeToVM, this._uiSourceCode);
+            this._resourceScriptMapping._hasMergedToVM(this._uiSourceCode);
+            this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidMergeToVM, this._uiSourceCode);
+        }
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (131603 => 131604)


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-10-17 15:37:33 UTC (rev 131603)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-10-17 15:38:51 UTC (rev 131604)
@@ -304,13 +304,14 @@
      */
     setWorkingCopy: function(newWorkingCopy)
     {
+        var wasDirty = this.isDirty();        
         this._mimeType = this.canonicalMimeType();
         var oldWorkingCopy = this._workingCopy;
         if (this._content === newWorkingCopy)
             delete this._workingCopy;
         else
             this._workingCopy = newWorkingCopy;
-        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy()});
+        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy(), wasDirty: wasDirty});
     },
 
     /**
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to