Web Inspector: Refactor WI.CSSStyleDeclaration.prototype.update
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2019 00:59:12 +0000 (00:59 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2019 00:59:12 +0000 (00:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193737

Reviewed by Matt Baker.

Remove unused event data from the WI.CSSStyleDeclaration.Event.PropertiesChanged event.

* UserInterface/Models/CSSStyleDeclaration.js:
(WI.CSSStyleDeclaration.prototype.update):

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

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

index 2c0371f..44053a8 100644 (file)
@@ -1,3 +1,15 @@
+2019-01-23  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Refactor WI.CSSStyleDeclaration.prototype.update
+        https://bugs.webkit.org/show_bug.cgi?id=193737
+
+        Reviewed by Matt Baker.
+
+        Remove unused event data from the WI.CSSStyleDeclaration.Event.PropertiesChanged event.
+
+        * UserInterface/Models/CSSStyleDeclaration.js:
+        (WI.CSSStyleDeclaration.prototype.update):
+
 2019-01-23  Devin Rousso  <drousso@apple.com>
 
         WebInspector: Confusingly nested events in the timeline for Mutation Observers
index 1ddc3ff..99780b9 100644 (file)
@@ -111,8 +111,8 @@ WI.CSSStyleDeclaration = class CSSStyleDeclaration extends WI.Object
         text = text || "";
         properties = properties || [];
 
-        var oldProperties = this._properties || [];
-        var oldText = this._text;
+        let oldProperties = this._properties || [];
+        let oldText = this._text;
 
         this._text = text;
         this._properties = properties;
@@ -123,7 +123,7 @@ WI.CSSStyleDeclaration = class CSSStyleDeclaration extends WI.Object
 
         this._visibleProperties = null;
 
-        var editable = this.editable;
+        let editable = this.editable;
 
         for (let property of this._properties) {
             property.ownerStyle = this;
@@ -140,46 +140,29 @@ WI.CSSStyleDeclaration = class CSSStyleDeclaration extends WI.Object
             }
         }
 
-        var removedProperties = [];
-        for (var i = 0; i < oldProperties.length; ++i) {
-            var oldProperty = oldProperties[i];
+        for (let oldProperty of oldProperties) {
+            if (this._enabledProperties.includes(oldProperty))
+                continue;
 
-            if (!this._enabledProperties.includes(oldProperty)) {
-                // Clear the index, since it is no longer valid.
-                oldProperty.index = NaN;
+            // Clear the index, since it is no longer valid.
+            oldProperty.index = NaN;
 
-                removedProperties.push(oldProperty);
-
-                // Keep around old properties in pending in case they
-                // are needed again during editing.
-                if (editable)
-                    this._pendingProperties.push(oldProperty);
-            }
+            // Keep around old properties in pending in case they
+            // are needed again during editing.
+            if (editable)
+                this._pendingProperties.push(oldProperty);
         }
 
         if (dontFireEvents)
             return;
 
-        var addedProperties = [];
-        for (var i = 0; i < this._enabledProperties.length; ++i) {
-            if (!oldProperties.includes(this._enabledProperties[i]))
-                addedProperties.push(this._enabledProperties[i]);
-        }
-
         // Don't fire the event if there is text and it hasn't changed.
-        if (oldText && this._text && oldText === this._text) {
-            if (!this._locked || suppressLock) {
-                // We shouldn't have any added or removed properties in this case.
-                console.assert(!addedProperties.length && !removedProperties.length);
-            }
-
-            if (!addedProperties.length && !removedProperties.length)
-                return;
-        }
+        if (oldText && this._text && oldText === this._text)
+            return;
 
         function delayed()
         {
-            this.dispatchEventToListeners(WI.CSSStyleDeclaration.Event.PropertiesChanged, {addedProperties, removedProperties});
+            this.dispatchEventToListeners(WI.CSSStyleDeclaration.Event.PropertiesChanged);
         }
 
         // Delay firing the PropertiesChanged event so DOMNodeStyles has a chance to mark overridden and associated properties.