Changeset 240368 in webkit


Ignore:
Timestamp:
Jan 23, 2019 4:59:12 PM (5 years ago)
Author:
Nikita Vasilyev
Message:

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):

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r240351 r240368  
     12019-01-23  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Refactor WI.CSSStyleDeclaration.prototype.update
     4        https://bugs.webkit.org/show_bug.cgi?id=193737
     5
     6        Reviewed by Matt Baker.
     7
     8        Remove unused event data from the WI.CSSStyleDeclaration.Event.PropertiesChanged event.
     9
     10        * UserInterface/Models/CSSStyleDeclaration.js:
     11        (WI.CSSStyleDeclaration.prototype.update):
     12
    1132019-01-23  Devin Rousso  <drousso@apple.com>
    214
  • trunk/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js

    r240314 r240368  
    112112        properties = properties || [];
    113113
    114         var oldProperties = this._properties || [];
    115         var oldText = this._text;
     114        let oldProperties = this._properties || [];
     115        let oldText = this._text;
    116116
    117117        this._text = text;
     
    124124        this._visibleProperties = null;
    125125
    126         var editable = this.editable;
     126        let editable = this.editable;
    127127
    128128        for (let property of this._properties) {
     
    141141        }
    142142
    143         var removedProperties = [];
    144         for (var i = 0; i < oldProperties.length; ++i) {
    145             var oldProperty = oldProperties[i];
    146 
    147             if (!this._enabledProperties.includes(oldProperty)) {
    148                 // Clear the index, since it is no longer valid.
    149                 oldProperty.index = NaN;
    150 
    151                 removedProperties.push(oldProperty);
    152 
    153                 // Keep around old properties in pending in case they
    154                 // are needed again during editing.
    155                 if (editable)
    156                     this._pendingProperties.push(oldProperty);
    157             }
     143        for (let oldProperty of oldProperties) {
     144            if (this._enabledProperties.includes(oldProperty))
     145                continue;
     146
     147            // Clear the index, since it is no longer valid.
     148            oldProperty.index = NaN;
     149
     150            // Keep around old properties in pending in case they
     151            // are needed again during editing.
     152            if (editable)
     153                this._pendingProperties.push(oldProperty);
    158154        }
    159155
     
    161157            return;
    162158
    163         var addedProperties = [];
    164         for (var i = 0; i < this._enabledProperties.length; ++i) {
    165             if (!oldProperties.includes(this._enabledProperties[i]))
    166                 addedProperties.push(this._enabledProperties[i]);
    167         }
    168 
    169159        // Don't fire the event if there is text and it hasn't changed.
    170         if (oldText && this._text && oldText === this._text) {
    171             if (!this._locked || suppressLock) {
    172                 // We shouldn't have any added or removed properties in this case.
    173                 console.assert(!addedProperties.length && !removedProperties.length);
    174             }
    175 
    176             if (!addedProperties.length && !removedProperties.length)
    177                 return;
    178         }
     160        if (oldText && this._text && oldText === this._text)
     161            return;
    179162
    180163        function delayed()
    181164        {
    182             this.dispatchEventToListeners(WI.CSSStyleDeclaration.Event.PropertiesChanged, {addedProperties, removedProperties});
     165            this.dispatchEventToListeners(WI.CSSStyleDeclaration.Event.PropertiesChanged);
    183166        }
    184167
Note: See TracChangeset for help on using the changeset viewer.