Web Inspector: Styles Redesign: adding a property before or after the first one appen...
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 07:01:29 +0000 (07:01 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 07:01:29 +0000 (07:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180321
<rdar://problem/35816402>

Reviewed by Timothy Hatcher.

* UserInterface/Models/CSSStyleDeclaration.js:
(WI.CSSStyleDeclaration.prototype._rangeAfterPropertyAtIndex):
* UserInterface/Models/TextRange.js:
(WI.TextRange.prototype.collapseToStart):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js
Source/WebInspectorUI/UserInterface/Models/TextRange.js

index 966557a..0784181 100644 (file)
@@ -1,3 +1,16 @@
+2017-12-05  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Styles Redesign: adding a property before or after the first one appends it to the end
+        https://bugs.webkit.org/show_bug.cgi?id=180321
+        <rdar://problem/35816402>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/CSSStyleDeclaration.js:
+        (WI.CSSStyleDeclaration.prototype._rangeAfterPropertyAtIndex):
+        * UserInterface/Models/TextRange.js:
+        (WI.TextRange.prototype.collapseToStart):
+
 2017-12-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Empty Message View in Network Tab has padding at top
index 09541d0..6325133 100644 (file)
@@ -418,13 +418,14 @@ WI.CSSStyleDeclaration = class CSSStyleDeclaration extends WI.Object
 
     _rangeAfterPropertyAtIndex(index)
     {
-        if (index > 0) {
-            let property = this.allVisibleProperties[index];
-            if (property && property.styleSheetTextRange)
-                return property.styleSheetTextRange.collapseToEnd();
-        }
+        if (index < 0)
+            return this._styleSheetTextRange.collapseToStart();
+
+        if (index >= this.allVisibleProperties.length)
+            return this._styleSheetTextRange.collapseToEnd();
 
-        return this._styleSheetTextRange.collapseToEnd();
+        let property = this.allVisibleProperties[index];
+        return property.styleSheetTextRange.collapseToEnd();
     }
 };
 
index 8c45d72..73d75d7 100644 (file)
@@ -128,6 +128,12 @@ WI.TextRange = class TextRange
         return new WI.TextRange(startLine, startColumn, endLine, endColumn);
     }
 
+    collapseToStart()
+    {
+        console.assert(!isNaN(this._startLine), "TextRange needs line/column data.");
+        return new WI.TextRange(this._startLine, this._startColumn, this._startLine, this._startColumn);
+    }
+
     collapseToEnd()
     {
         console.assert(!isNaN(this._endLine), "TextRange needs line/column data.");