Title: [246816] trunk/Source/WebInspectorUI
Revision
246816
Author
[email protected]
Date
2019-06-25 16:40:14 -0700 (Tue, 25 Jun 2019)

Log Message

REGRESSION(r246621): Web Inspector: Styles: property may get removed when editing after deleting value
https://bugs.webkit.org/show_bug.cgi?id=199143
<rdar://problem/52042815>

Reviewed by Matt Baker.

r246621 affected when WI.CSSStyleDeclaration.Event.PropertiesChanged event is fired, which caused
SpreadsheetCSSStyleDeclarationEditor to possibly enter a state when `focused` property is
incorrectly set to false.

* UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
(WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyRemoved): Removed.
(WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyWillRemove): Added.
Renamed from "removed" to "willRemove" since we need to call it before the property DOM element
is detached from the document.

* UserInterface/Views/SpreadsheetStyleProperty.js:
(WI.SpreadsheetStyleProperty.prototype.remove):
Don't set focused to false when the removed property wasn't focused.
This code need to exist because removing focused element from the DOM doesn't trigger blur event.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (246815 => 246816)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-06-25 23:38:03 UTC (rev 246815)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-06-25 23:40:14 UTC (rev 246816)
@@ -1,3 +1,26 @@
+2019-06-25  Nikita Vasilyev  <[email protected]>
+
+        REGRESSION(r246621): Web Inspector: Styles: property may get removed when editing after deleting value
+        https://bugs.webkit.org/show_bug.cgi?id=199143
+        <rdar://problem/52042815>
+
+        Reviewed by Matt Baker.
+
+        r246621 affected when WI.CSSStyleDeclaration.Event.PropertiesChanged event is fired, which caused
+        SpreadsheetCSSStyleDeclarationEditor to possibly enter a state when `focused` property is
+        incorrectly set to false.
+
+        * UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js:
+        (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyRemoved): Removed.
+        (WI.SpreadsheetCSSStyleDeclarationEditor.prototype.spreadsheetStylePropertyWillRemove): Added.
+        Renamed from "removed" to "willRemove" since we need to call it before the property DOM element
+        is detached from the document.
+
+        * UserInterface/Views/SpreadsheetStyleProperty.js:
+        (WI.SpreadsheetStyleProperty.prototype.remove):
+        Don't set focused to false when the removed property wasn't focused.
+        This code need to exist because removing focused element from the DOM doesn't trigger blur event.
+
 2019-06-25  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Implement console.timeLog

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js (246815 => 246816)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js	2019-06-25 23:38:03 UTC (rev 246815)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetCSSStyleDeclarationEditor.js	2019-06-25 23:40:14 UTC (rev 246816)
@@ -487,7 +487,7 @@
         event.stop();
     }
 
-    spreadsheetStylePropertyRemoved(propertyView)
+    spreadsheetStylePropertyWillRemove(propertyView)
     {
         this._propertyViews.remove(propertyView);
 
@@ -494,7 +494,9 @@
         for (let index = 0; index < this._propertyViews.length; index++)
             this._propertyViews[index].index = index;
 
-        this.focused = false;
+        let wasFocused = document.activeElement && propertyView.element.contains(document.activeElement);
+        if (wasFocused)
+            this.focused = false;
     }
 
     spreadsheetStylePropertyShowProperty(propertyView, property)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js (246815 => 246816)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2019-06-25 23:38:03 UTC (rev 246815)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js	2019-06-25 23:40:14 UTC (rev 246816)
@@ -138,6 +138,9 @@
 
     remove(replacement = null)
     {
+        if (this._delegate && typeof this._delegate.spreadsheetStylePropertyWillRemove === "function")
+            this._delegate.spreadsheetStylePropertyWillRemove(this);
+
         this.element.remove();
 
         if (replacement)
@@ -146,9 +149,6 @@
             this._property.remove();
 
         this.detached();
-
-        if (this._delegate && typeof this._delegate.spreadsheetStylePropertyRemoved === "function")
-            this._delegate.spreadsheetStylePropertyRemoved(this);
     }
 
     update()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to