Title: [125426] trunk
Revision
125426
Author
[email protected]
Date
2012-08-13 09:49:49 -0700 (Mon, 13 Aug 2012)

Log Message

Web Inspector: get rid of beforeTextChanged
https://bugs.webkit.org/show_bug.cgi?id=93851

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Merged beforeTextChanged and afterTextChanged into a single
onTextChanged event.

* inspector/front-end/CodeMirrorTextEditor.js:
(WebInspector.CodeMirrorTextEditor.prototype.editRange):
(WebInspector.CodeMirrorTextEditor.prototype._onChange):
* inspector/front-end/DefaultTextEditor.js:
(WebInspector.DefaultTextEditor.prototype._enterInternalTextChangeMode):
(WebInspector.DefaultTextEditor.prototype._exitInternalTextChangeMode):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.onTextChanged):
(WebInspector._javascript_SourceFrame.prototype._removeBreakpointsBeforeEditing):
(WebInspector._javascript_SourceFrame.prototype._addBreakpointDecoration):
(WebInspector._javascript_SourceFrame.prototype._removeBreakpointDecoration):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.onTextChanged):
(WebInspector.TextEditorDelegateForSourceFrame.prototype.onTextChanged):
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditorDelegate.prototype.onTextChanged):
* inspector/front-end/UISourceCodeFrame.js:
(WebInspector.UISourceCodeFrame.prototype.onTextChanged):

LayoutTests:

* http/tests/inspector/live-edit-test.js:
(initialize_LiveEditTest.InspectorTest.replaceInSource):
(initialize_LiveEditTest):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125425 => 125426)


--- trunk/LayoutTests/ChangeLog	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/LayoutTests/ChangeLog	2012-08-13 16:49:49 UTC (rev 125426)
@@ -1,3 +1,14 @@
+2012-08-13  Pavel Feldman  <[email protected]>
+
+        Web Inspector: get rid of beforeTextChanged
+        https://bugs.webkit.org/show_bug.cgi?id=93851
+
+        Reviewed by Vsevolod Vlasov.
+
+        * http/tests/inspector/live-edit-test.js:
+        (initialize_LiveEditTest.InspectorTest.replaceInSource):
+        (initialize_LiveEditTest):
+
 2012-08-13  Christophe Dumez  <[email protected]>
 
         [EFL][WK2] Update TestExpectations to make bot green

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


--- trunk/LayoutTests/http/tests/inspector/live-edit-test.js	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/LayoutTests/http/tests/inspector/live-edit-test.js	2012-08-13 16:49:49 UTC (rev 125426)
@@ -3,7 +3,6 @@
 InspectorTest.replaceInSource = function(sourceFrame, string, replacement, callback)
 {
     sourceFrame._textEditor._mainPanel.setReadOnly(false);
-    sourceFrame.beforeTextChanged();
     var oldRange, newRange;
     var lines = sourceFrame._textEditor._textModel._lines;
     for (var i = 0; i < lines.length; ++i) {
@@ -17,7 +16,7 @@
         newRange = new WebInspector.TextRange(i, column, i + lineEndings.length - 1, lastLineLength);
         break;
     }
-    sourceFrame.afterTextChanged(oldRange, newRange);
+    sourceFrame.onTextChanged(oldRange, newRange);
     sourceFrame._textEditor._commitEditing();
 }
 

Modified: trunk/Source/WebCore/ChangeLog (125425 => 125426)


--- trunk/Source/WebCore/ChangeLog	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/Source/WebCore/ChangeLog	2012-08-13 16:49:49 UTC (rev 125426)
@@ -1,3 +1,32 @@
+2012-08-13  Pavel Feldman  <[email protected]>
+
+        Web Inspector: get rid of beforeTextChanged
+        https://bugs.webkit.org/show_bug.cgi?id=93851
+
+        Reviewed by Vsevolod Vlasov.
+
+        Merged beforeTextChanged and afterTextChanged into a single
+        onTextChanged event.
+
+        * inspector/front-end/CodeMirrorTextEditor.js:
+        (WebInspector.CodeMirrorTextEditor.prototype.editRange):
+        (WebInspector.CodeMirrorTextEditor.prototype._onChange):
+        * inspector/front-end/DefaultTextEditor.js:
+        (WebInspector.DefaultTextEditor.prototype._enterInternalTextChangeMode):
+        (WebInspector.DefaultTextEditor.prototype._exitInternalTextChangeMode):
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.onTextChanged):
+        (WebInspector._javascript_SourceFrame.prototype._removeBreakpointsBeforeEditing):
+        (WebInspector._javascript_SourceFrame.prototype._addBreakpointDecoration):
+        (WebInspector._javascript_SourceFrame.prototype._removeBreakpointDecoration):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.onTextChanged):
+        (WebInspector.TextEditorDelegateForSourceFrame.prototype.onTextChanged):
+        * inspector/front-end/TextEditor.js:
+        (WebInspector.TextEditorDelegate.prototype.onTextChanged):
+        * inspector/front-end/UISourceCodeFrame.js:
+        (WebInspector.UISourceCodeFrame.prototype.onTextChanged):
+
 2012-08-13  Bruno de Oliveira Abinader  <[email protected]>
 
         [css] Remove "default" switch case from CSS primitive value mappings

Modified: trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js (125425 => 125426)


--- trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js	2012-08-13 16:49:49 UTC (rev 125426)
@@ -180,22 +180,17 @@
      */
     editRange: function(range, text)
     {
-        this._delegate.beforeTextChanged();
-
         var pos = this._toPos(range);
         this._codeMirror.replaceRange(text, pos.start, pos.end);
         var newRange = this._toRange(pos.start, this._codeMirror.posFromIndex(this._codeMirror.indexFromPos(pos.start) + text.length));
-
-        this._delegate.afterTextChanged(range, newRange);
-
+        this._delegate.onTextChanged(range, newRange);
         return newRange;
     },
 
     _onChange: function()
     {
-        this._delegate.beforeTextChanged();
         var newRange = this.range();
-        this._delegate.afterTextChanged(this._lastRange, newRange);
+        this._delegate.onTextChanged(this._lastRange, newRange);
         this._lastRange = newRange;
     },
 

Modified: trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js (125425 => 125426)


--- trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js	2012-08-13 16:49:49 UTC (rev 125426)
@@ -251,7 +251,6 @@
     _enterInternalTextChangeMode: function()
     {
         this._internalTextChangeMode = true;
-        this._delegate.beforeTextChanged();
     },
 
     /**
@@ -261,7 +260,7 @@
     _exitInternalTextChangeMode: function(oldRange, newRange)
     {
         this._internalTextChangeMode = false;
-        this._delegate.afterTextChanged(oldRange, newRange);
+        this._delegate.onTextChanged(oldRange, newRange);
     },
 
     _updatePanelOffsets: function()

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (125425 => 125426)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-08-13 16:49:49 UTC (rev 125426)
@@ -147,19 +147,14 @@
         contextMenu.appendApplicableItems(this._javaScriptSource);
     },
 
-    afterTextChanged: function(oldRange, newRange)
+    onTextChanged: function(oldRange, newRange)
     {
-        WebInspector.SourceFrame.prototype.afterTextChanged.call(this, oldRange, newRange);
+        WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, newRange);
+        this._removeBreakpointsBeforeEditing();
         this._javaScriptSource.setWorkingCopy(this._textEditor.text());
         this._restoreBreakpointsAfterEditing();
     },
 
-    beforeTextChanged: function()
-    {
-        WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
-        this._removeBreakpointsBeforeEditing();
-    },
-
     _didEditContent: function(error)
     {
         delete this._isCommittingEditing;
@@ -174,16 +169,23 @@
 
     _removeBreakpointsBeforeEditing: function()
     {
-        if (!this._javaScriptSource.isDirty() || this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()) {
+        var supportsBreakpointsOnEdit = this._javaScriptSource.supportsEnabledBreakpointsWhileEditing();
+        if (!this._javaScriptSource.isDirty() || supportsBreakpointsOnEdit) {
             // Disable all breakpoints in the model, store them as muted breakpoints.
             var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource);
             var lineNumbers = {};
+            this._preserveDecorations = true;
             for (var i = 0; i < breakpointLocations.length; ++i) {
                 var breakpoint = breakpointLocations[i].breakpoint;
                 breakpointLocations[i].breakpoint.remove();
-                // Re-adding decoration only.
-                this._addBreakpointDecoration(breakpointLocations[i].uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), true);
             }
+            delete this._preserveDecorations;
+
+            for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
+                var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
+                if (breakpointDecoration)
+                    this._addBreakpointDecoration(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled, !supportsBreakpointsOnEdit);
+            }
             this.clearExecutionLine();
         }
     },
@@ -337,7 +339,7 @@
 
         this.textEditor.beginUpdates();
         this.textEditor.addDecoration(lineNumber, "webkit-breakpoint");
-        if (!enabled || (mutedWhileEditing && !this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()))
+        if (!enabled || mutedWhileEditing)
             this.textEditor.addDecoration(lineNumber, "webkit-breakpoint-disabled");
         else
             this.textEditor.removeDecoration(lineNumber, "webkit-breakpoint-disabled");
@@ -350,6 +352,8 @@
 
     _removeBreakpointDecoration: function(lineNumber)
     {
+        if (this._preserveDecorations)
+            return;
         this.textEditor.removeAttribute(lineNumber, "breakpoint");
         this.textEditor.beginUpdates();
         this.textEditor.removeDecoration(lineNumber, "webkit-breakpoint");

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (125425 => 125426)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-08-13 16:49:49 UTC (rev 125426)
@@ -273,17 +273,13 @@
         this._innerSetSelectionIfNeeded();
     },
 
-    beforeTextChanged: function()
+    onTextChanged: function(oldRange, newRange)
     {
         if (!this._isReplacing)
             WebInspector.searchController.cancelSearch();
         this.clearMessages();
     },
 
-    afterTextChanged: function(oldRange, newRange)
-    {
-    },
-
     /**
      * @param {?string} content
      * @param {boolean} contentEncoded
@@ -645,16 +641,11 @@
 }
 
 WebInspector.TextEditorDelegateForSourceFrame.prototype = {
-    beforeTextChanged: function()
+    onTextChanged: function(oldRange, newRange)
     {
-        this._sourceFrame.beforeTextChanged();
+        this._sourceFrame.onTextChanged(oldRange, newRange);
     },
 
-    afterTextChanged: function(oldRange, newRange)
-    {
-        this._sourceFrame.afterTextChanged(oldRange, newRange);
-    },
-
     commitEditing: function()
     {
         this._sourceFrame.commitEditing(this._sourceFrame._textEditor.text());

Modified: trunk/Source/WebCore/inspector/front-end/TextEditor.js (125425 => 125426)


--- trunk/Source/WebCore/inspector/front-end/TextEditor.js	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/Source/WebCore/inspector/front-end/TextEditor.js	2012-08-13 16:49:49 UTC (rev 125426)
@@ -187,13 +187,11 @@
 }
 
 WebInspector.TextEditorDelegate.prototype = {
-    beforeTextChanged: function() { },
-
     /**
      * @param {WebInspector.TextRange} oldRange
      * @param {WebInspector.TextRange} newRange
      */
-    afterTextChanged: function(oldRange, newRange) { },
+    onTextChanged: function(oldRange, newRange) { },
 
     commitEditing: function() { },
 

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js (125425 => 125426)


--- trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js	2012-08-13 16:47:53 UTC (rev 125425)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js	2012-08-13 16:49:49 UTC (rev 125426)
@@ -59,7 +59,7 @@
         this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));
     },
 
-    afterTextChanged: function(oldRange, newRange)
+    onTextChanged: function(oldRange, newRange)
     {
         this._uiSourceCode.setWorkingCopy(this._textEditor.text());
     },
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to