Web Inspector: [CodeMirror] bug with LineWidgets
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2013 15:47:32 +0000 (15:47 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2013 15:47:32 +0000 (15:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111978

Patch by Andrey Lushnikov <lushnikov@chromium.org> on 2013-03-13
Reviewed by Vsevolod Vlasov.

Implement CodeMirrorTextEditor.beginUpdates and
CodeMirrorTextEditor.endUpdates and surround decoration creation
with the beginUpdates/endUpdates calls.

No new tests.

* inspector/front-end/CodeMirrorTextEditor.js:
(WebInspector.CodeMirrorTextEditor):
(WebInspector.CodeMirrorTextEditor.prototype.beginUpdates):
(WebInspector.CodeMirrorTextEditor.prototype.endUpdates):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.addMessageToSource):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@145723 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js
Source/WebCore/inspector/front-end/SourceFrame.js

index b8f5f1a..f0e8d2d 100644 (file)
@@ -1,3 +1,23 @@
+2013-03-13  Andrey Lushnikov  <lushnikov@chromium.org>
+
+        Web Inspector: [CodeMirror] bug with LineWidgets
+        https://bugs.webkit.org/show_bug.cgi?id=111978
+
+        Reviewed by Vsevolod Vlasov.
+
+        Implement CodeMirrorTextEditor.beginUpdates and
+        CodeMirrorTextEditor.endUpdates and surround decoration creation
+        with the beginUpdates/endUpdates calls.
+
+        No new tests.
+
+        * inspector/front-end/CodeMirrorTextEditor.js:
+        (WebInspector.CodeMirrorTextEditor):
+        (WebInspector.CodeMirrorTextEditor.prototype.beginUpdates):
+        (WebInspector.CodeMirrorTextEditor.prototype.endUpdates):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.addMessageToSource):
+
 2013-03-13  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: get rid of hiddenPanels filter
index 69720a6..4a4bbfa 100644 (file)
@@ -77,6 +77,7 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate)
     this.element.firstChild.addStyleClass("source-code");
     this.element.firstChild.addStyleClass("fill");
     this._elementToWidget = new Map();
+    this._nestedUpdatesCounter = 0;
 }
 
 WebInspector.CodeMirrorTextEditor.prototype = {
@@ -122,9 +123,16 @@ WebInspector.CodeMirrorTextEditor.prototype = {
         this._codeMirror.focus();
     },
 
-    beginUpdates: function() { },
+    beginUpdates: function()
+    {
+        ++this._nestedUpdatesCounter;
+    },
 
-    endUpdates: function() { },
+    endUpdates: function()
+    {
+        if (!--this._nestedUpdatesCounter);
+            this._codeMirror.refresh();
+    },
 
     /**
      * @param {number} lineNumber
index 21b54e2..94d114b 100644 (file)
@@ -511,14 +511,6 @@ WebInspector.SourceFrame.prototype = {
         if (lineNumber < 0)
             lineNumber = 0;
 
-        var messageBubbleElement = this._messageBubbles[lineNumber];
-        if (!messageBubbleElement || messageBubbleElement.nodeType !== Node.ELEMENT_NODE || !messageBubbleElement.hasStyleClass("webkit-html-message-bubble")) {
-            messageBubbleElement = document.createElement("div");
-            messageBubbleElement.className = "webkit-html-message-bubble";
-            this._messageBubbles[lineNumber] = messageBubbleElement;
-            this._textEditor.addDecoration(lineNumber, messageBubbleElement);
-        }
-
         var rowMessages = this._rowMessages[lineNumber];
         if (!rowMessages) {
             rowMessages = [];
@@ -536,6 +528,15 @@ WebInspector.SourceFrame.prototype = {
         var rowMessage = { consoleMessage: msg };
         rowMessages.push(rowMessage);
 
+        this._textEditor.beginUpdates();
+        var messageBubbleElement = this._messageBubbles[lineNumber];
+        if (!messageBubbleElement) {
+            messageBubbleElement = document.createElement("div");
+            messageBubbleElement.className = "webkit-html-message-bubble";
+            this._messageBubbles[lineNumber] = messageBubbleElement;
+            this._textEditor.addDecoration(lineNumber, messageBubbleElement);
+        }
+
         var imageURL;
         switch (msg.level) {
             case WebInspector.ConsoleMessage.MessageLevel.Error:
@@ -562,6 +563,7 @@ WebInspector.SourceFrame.prototype = {
         rowMessage.element = messageLineElement;
         rowMessage.repeatCount = msg.totalRepeatCount;
         this._updateMessageRepeatCount(rowMessage);
+        this._textEditor.endUpdates();
     },
 
     _updateMessageRepeatCount: function(rowMessage)