Web Inspector: Styles sidebar: Uncommenting CSS rules of pseudo-elements doesn't...
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 21:56:50 +0000 (21:56 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Dec 2016 21:56:50 +0000 (21:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165831
<rdar://problem/29652688>

Reviewed by Matt Baker.

* UserInterface/Views/CSSStyleDeclarationTextEditor.js:
(WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties):
Call _resetContent() when toggling all properties to ensure properties have text markers.

(WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCommentCheckboxChanged):
(WebInspector.CSSStyleDeclarationTextEditor.prototype._uncommentProperty): Added.
This method is the opposite of _commentProperty. Introduce it to minimize code duplication.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js

index 6be2574..bb17713 100644 (file)
@@ -1,3 +1,19 @@
+2016-12-22  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Styles sidebar: Uncommenting CSS rules of pseudo-elements doesn't work
+        https://bugs.webkit.org/show_bug.cgi?id=165831
+        <rdar://problem/29652688>
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Views/CSSStyleDeclarationTextEditor.js:
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype.uncommentAllProperties):
+        Call _resetContent() when toggling all properties to ensure properties have text markers.
+
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype._propertyCommentCheckboxChanged):
+        (WebInspector.CSSStyleDeclarationTextEditor.prototype._uncommentProperty): Added.
+        This method is the opposite of _commentProperty. Introduce it to minimize code duplication.
+
 2016-12-21  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Uncommenting CSS properties doesn't work for inline styles
index bbb876a..9c80658 100644 (file)
@@ -309,12 +309,10 @@ WebInspector.CSSStyleDeclarationTextEditor = class CSSStyleDeclarationTextEditor
             if (!properties.length)
                 return false;
 
-            for (var property of properties) {
-                if (property._commentRange) {
-                    this._uncommentRange(property._commentRange);
-                    property._commentRange = null;
-                }
-            }
+            this._resetContent();
+
+            for (let property of properties)
+                this._uncommentProperty(property);
 
             return true;
         }
@@ -1272,9 +1270,6 @@ WebInspector.CSSStyleDeclarationTextEditor = class CSSStyleDeclarationTextEditor
         if (!range)
             return;
 
-        property._commentRange = range;
-        property._commentRange.to.ch += 6; // Number of characters added by comments.
-
         var text = this._codeMirror.getRange(range.from, range.to);
 
         function update()
@@ -1291,14 +1286,19 @@ WebInspector.CSSStyleDeclarationTextEditor = class CSSStyleDeclarationTextEditor
 
     _propertyCommentCheckboxChanged(event)
     {
-        var commentTextMarker = event.target.__commentTextMarker;
-        console.assert(commentTextMarker);
-        if (!commentTextMarker)
+        this._uncommentProperty(event.target);
+    }
+
+    _uncommentProperty(property)
+    {
+        let textMarker = property.__propertyTextMarker;
+        console.assert(textMarker);
+        if (!textMarker)
             return;
 
-        // Check if the comment has been removed already, like from double-clicking
-        // the checkbox and calling event listener multiple times.
-        var range = commentTextMarker.find();
+        // Check if the property has been removed already, like from double-clicking
+        // the checkbox and calling this event listener multiple times.
+        let range = textMarker.find();
         if (!range)
             return;