Title: [152990] branches/safari-537-branch/Source/WebInspectorUI
Revision
152990
Author
[email protected]
Date
2013-07-22 13:56:30 -0700 (Mon, 22 Jul 2013)

Log Message

Merged r152651.  <rdar://problem/14406853>

Modified Paths

Diff

Modified: branches/safari-537-branch/Source/WebInspectorUI/ChangeLog (152989 => 152990)


--- branches/safari-537-branch/Source/WebInspectorUI/ChangeLog	2013-07-22 20:54:46 UTC (rev 152989)
+++ branches/safari-537-branch/Source/WebInspectorUI/ChangeLog	2013-07-22 20:56:30 UTC (rev 152990)
@@ -1,3 +1,20 @@
+2013-07-22  Lucas Forschler  <[email protected]>
+
+        Merge r152651
+
+    2013-07-15  Timothy Hatcher  <[email protected]>
+
+            Properly handle style text changes while the color popover is open.
+
+            https://bugs.webkit.org/show_bug.cgi?id=118575
+
+            Reviewed by Joseph Pecoraro.
+
+            * UserInterface/CSSStyleDeclarationTextEditor.js:
+            (WebInspector.CSSStyleDeclarationTextEditor.prototype._colorSwatchClicked.updateCodeMirror):
+            The original text marker might have been cleared by a style update, in this case we need to
+            find the new color text marker so we know the right range for the new style color text.
+
 2013-07-15  Lucas Forschler  <[email protected]>
 
         Merge r152652

Modified: branches/safari-537-branch/Source/WebInspectorUI/UserInterface/CSSStyleDeclarationTextEditor.js (152989 => 152990)


--- branches/safari-537-branch/Source/WebInspectorUI/UserInterface/CSSStyleDeclarationTextEditor.js	2013-07-22 20:54:46 UTC (rev 152989)
+++ branches/safari-537-branch/Source/WebInspectorUI/UserInterface/CSSStyleDeclarationTextEditor.js	2013-07-22 20:56:30 UTC (rev 152990)
@@ -678,22 +678,52 @@
 
         function updateCodeMirror(newColorText)
         {
-            this._codeMirror.operation(function() 
+            function update()
             {
+                // The original text marker might have been cleared by a style update,
+                // in this case we need to find the new color text marker so we know
+                // the right range for the new style color text.
+                if (!colorTextMarker || !colorTextMarker.find()) {
+                    colorTextMarker = null;
+
+                    var marks = this._codeMirror.findMarksAt(range.from);
+                    if (!marks.length)
+                        return;
+
+                    for (var i = 0; i < marks.length; ++i) {
+                        var mark = marks[i];
+                        if (!mark.__markedColor)
+                            continue;
+                        colorTextMarker = mark;
+                        break;
+                    }
+                }
+
+                if (!colorTextMarker)
+                    return;
+
+                // Sometimes we still might find a stale text marker with findMarksAt.
+                var newRange = colorTextMarker.find();
+                if (!newRange)
+                    return;
+
+                range = newRange;
+
                 colorTextMarker.clear();
 
                 this._codeMirror.replaceRange(newColorText, range.from, range.to);
 
                 // The color's text format could have changed, so we need to update the "range" 
                 // variable to anticipate a different "range.to" property.
-                var to = {line: range.from.line, ch: range.from.ch + newColorText.length};
-                range.to = to;
+                range.to.ch = range.from.ch + newColorText.length;
 
-                colorTextMarker = this._codeMirror.markText(range.from, to);
+                colorTextMarker = this._codeMirror.markText(range.from, range.to);
                 colorTextMarker.__markedColor = true;
 
                 swatch.__colorTextMarker = colorTextMarker;
-            }.bind(this));
+            }
+
+            this._codeMirror.operation(update.bind(this));
         }
 
         if (event.shiftKey) {
@@ -710,7 +740,6 @@
             this._ignoreCodeMirrorContentDidChangeEvent = true;
             updateCodeMirror.call(this, newColorText);
             delete this._ignoreCodeMirrorContentDidChangeEvent;
-
         } else {
             this._colorPickerPopover = new WebInspector.Popover(this);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to