Web Inspector: Styles: clicking on property that soon to be discarded shouldn't start...
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2019 08:34:15 +0000 (08:34 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2019 08:34:15 +0000 (08:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193218
<rdar://problem/47098303>

Reviewed by Devin Rousso.

* UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleMouseDown):
A style property may get removed on blur event, so propertyElement may get removed from the DOM right when mousedown event happens.

(WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleWindowClick):
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleClick):
(WI.SpreadsheetCSSStyleDeclarationSection.prototype._stopSelection):

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

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

index 84f0901..6f13654 100644 (file)
@@ -1,3 +1,19 @@
+2019-01-09  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Styles: clicking on property that soon to be discarded shouldn't start selection
+        https://bugs.webkit.org/show_bug.cgi?id=193218
+        <rdar://problem/47098303>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/SpreadsheetCSSStyleDeclarationSection.js:
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleMouseDown):
+        A style property may get removed on blur event, so propertyElement may get removed from the DOM right when mousedown event happens.
+
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleWindowClick):
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype._handleClick):
+        (WI.SpreadsheetCSSStyleDeclarationSection.prototype._stopSelection):
+
 2019-01-08  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Styles: Undo reverts all changes at once
index d4f7dbc..6fa142d 100644 (file)
@@ -407,8 +407,11 @@ WI.SpreadsheetCSSStyleDeclarationSection = class SpreadsheetCSSStyleDeclarationS
         else
             this._propertiesEditor.deselectProperties();
 
-        this._mouseDownIndex = propertyIndex;
-        this._element.classList.add("selecting");
+        if (propertyElement.parentNode) {
+            this._mouseDownIndex = propertyIndex;
+            this._element.classList.add("selecting");
+        } else
+            this._stopSelection();
     }
 
     _handleWindowClick(event)
@@ -417,15 +420,13 @@ WI.SpreadsheetCSSStyleDeclarationSection = class SpreadsheetCSSStyleDeclarationS
             // Don't start editing name/value if there's selection.
             event.stop();
         }
-
-        this._isMousePressed = false;
-        this._mouseDownIndex = NaN;
-
-        this._element.classList.remove("selecting");
+        this._stopSelection();
     }
 
     _handleClick(event)
     {
+        this._stopSelection();
+
         if (this._wasEditing || this._propertiesEditor.hasSelectedProperties())
             return;
 
@@ -451,6 +452,13 @@ WI.SpreadsheetCSSStyleDeclarationSection = class SpreadsheetCSSStyleDeclarationS
         }
     }
 
+    _stopSelection()
+    {
+        this._isMousePressed = false;
+        this._mouseDownIndex = NaN;
+        this._element.classList.remove("selecting");
+    }
+
     _highlightNodesWithSelector()
     {
         if (!this._style.ownerRule) {