⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285896 in webkit


Ignore:
Timestamp:
Nov 16, 2021, 4:23:20 PM (5 years ago)
Author:
Nikita Vasilyev
Message:

Web Inspector: Remove unused dontCreateIfMissing argument from CSSStyleDeclaration.prototype.propertyForName
https://bugs.webkit.org/show_bug.cgi?id=233198

Reviewed by Devin Rousso.

Source/WebInspectorUI:

dontCreateIfMissing was always set to true.

  • UserInterface/Models/CSSStyleDeclaration.js:

(WI.CSSStyleDeclaration.prototype.propertyForName):
Drive-by: inline findMatch function, which was only used once.

  • UserInterface/Models/DOMNodeStyles.js:

(WI.DOMNodeStyles.prototype._parseStylePropertyPayload):

  • UserInterface/Models/Font.js:

(WI.Font):

  • UserInterface/Views/BoxModelDetailsSectionRow.js:

(WI.BoxModelDetailsSectionRow.prototype._getPropertyValue):

  • UserInterface/Views/SpreadsheetStyleProperty.js:

(WI.SpreadsheetStyleProperty.prototype._addVariableTokens):

LayoutTests:

  • inspector/css/overridden-property.html:
  • inspector/css/pseudo-element-matches-for-pseudo-element-node.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285885 r285896  
     12021-11-16  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Remove unused `dontCreateIfMissing` argument from CSSStyleDeclaration.prototype.propertyForName
     4        https://bugs.webkit.org/show_bug.cgi?id=233198
     5
     6        Reviewed by Devin Rousso.
     7
     8        * inspector/css/overridden-property.html:
     9        * inspector/css/pseudo-element-matches-for-pseudo-element-node.html:
     10
    1112021-11-16  Rob Buis  <rbuis@igalia.com>
    212
  • trunk/LayoutTests/inspector/css/overridden-property.html

    r278848 r285896  
    9393        test(resolve, reject) {
    9494            getStyleDeclaration(".longhand-overridden-by-shorthand", (style) => {
    95                 const dontCreateIfMissing = true;
    96                 let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
     95                let borderTopColorProperty = style.propertyForName("border-top-color");
    9796                InspectorTest.expectTrue(borderTopColorProperty.overridden, "border-top-color is overridden.");
    9897
    99                 let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
     98                let borderColorProperty = style.propertyForName("border-color");
    10099                InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");
    101100
     
    109108        test(resolve, reject) {
    110109            getStyleDeclaration(".longhand-overridden-by-important-shorthand", (style) => {
    111                 const dontCreateIfMissing = true;
    112                 let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
    113                 InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");
    114 
    115                 let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
     110                let borderColorProperty = style.propertyForName("border-color");
     111                InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");
     112
     113                let borderTopColorProperty = style.propertyForName("border-top-color");
    116114                InspectorTest.expectTrue(borderTopColorProperty.overridden, "border-top-color is overridden.");
    117115
     
    125123        test(resolve, reject) {
    126124            getStyleDeclaration(".shorthand-overridden-by-important-longhand", (style) => {
    127                 const dontCreateIfMissing = true;
    128                 let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
     125                let borderTopColorProperty = style.propertyForName("border-top-color");
    129126                InspectorTest.expectFalse(borderTopColorProperty.overridden, "border-top-color is NOT overridden.");
    130127
    131                 let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
     128                let borderColorProperty = style.propertyForName("border-color");
    132129                InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");
    133130
     
    141138        test(resolve, reject) {
    142139            getStyleDeclaration(".shorthand-not-overridden-by-longhand", (style) => {
    143                 const dontCreateIfMissing = true;
    144                 let borderColorProperty = style.propertyForName("border-color", dontCreateIfMissing);
    145                 InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");
    146 
    147                 let borderTopColorProperty = style.propertyForName("border-top-color", dontCreateIfMissing);
     140                let borderColorProperty = style.propertyForName("border-color");
     141                InspectorTest.expectFalse(borderColorProperty.overridden, "border-color is NOT overridden.");
     142
     143                let borderTopColorProperty = style.propertyForName("border-top-color");
    148144                InspectorTest.expectFalse(borderTopColorProperty.overridden, "border-top-color is NOT overridden.");
    149145
     
    157153        test(resolve, reject) {
    158154            getStyleDeclaration(".mixed-case-variables-not-overridden", (style) => {
    159                 const dontCreateIfMissing = true;
    160                 let lowercaseVariableProperty = style.propertyForName("--foo", dontCreateIfMissing);
     155                let lowercaseVariableProperty = style.propertyForName("--foo");
    161156                InspectorTest.expectFalse(lowercaseVariableProperty.overridden, "`--foo` is NOT overridden.");
    162157
    163                 let uppercaseVariableProperty = style.propertyForName("--FOO", dontCreateIfMissing);
     158                let uppercaseVariableProperty = style.propertyForName("--FOO");
    164159                InspectorTest.expectFalse(uppercaseVariableProperty.overridden, "`--FOO` is NOT overridden.");
    165160
  • trunk/LayoutTests/inspector/css/pseudo-element-matches-for-pseudo-element-node.html

    r253242 r285896  
    1818
    1919        function logProperty(propertyName) {
    20             const dontCreateIfMissing = true;
    21             let property = nodeStyles.computedStyle.propertyForName(propertyName, dontCreateIfMissing);
     20            let property = nodeStyles.computedStyle.propertyForName(propertyName);
    2221            InspectorTest.log(`PROPERTY: ${property.name}: ${property.value};`);
    2322        }
  • trunk/Source/WebInspectorUI/ChangeLog

    r285851 r285896  
     12021-11-16  Nikita Vasilyev  <nvasilyev@apple.com>
     2
     3        Web Inspector: Remove unused `dontCreateIfMissing` argument from CSSStyleDeclaration.prototype.propertyForName
     4        https://bugs.webkit.org/show_bug.cgi?id=233198
     5
     6        Reviewed by Devin Rousso.
     7
     8        `dontCreateIfMissing` was always set to `true`.
     9
     10        * UserInterface/Models/CSSStyleDeclaration.js:
     11        (WI.CSSStyleDeclaration.prototype.propertyForName):
     12        Drive-by: inline findMatch function, which was only used once.
     13
     14        * UserInterface/Models/DOMNodeStyles.js:
     15        (WI.DOMNodeStyles.prototype._parseStylePropertyPayload):
     16        * UserInterface/Models/Font.js:
     17        (WI.Font):
     18        * UserInterface/Views/BoxModelDetailsSectionRow.js:
     19        (WI.BoxModelDetailsSectionRow.prototype._getPropertyValue):
     20        * UserInterface/Views/SpreadsheetStyleProperty.js:
     21        (WI.SpreadsheetStyleProperty.prototype._addVariableTokens):
     22
    1232021-11-15  Patrick Angle  <pangle@apple.com>
    224
  • trunk/Source/WebInspectorUI/UserInterface/Models/CSSStyleDeclaration.js

    r283723 r285896  
    302302    }
    303303
    304     propertyForName(name, dontCreateIfMissing)
     304    propertyForName(name)
    305305    {
    306306        console.assert(name);
     
    314314        // account for overridden properties.
    315315
    316         function findMatch(properties)
    317         {
    318             for (var i = 0; i < properties.length; ++i) {
    319                 var property = properties[i];
    320                 if (property.canonicalName !== name && property.name !== name)
    321                     continue;
    322                 if (bestMatchProperty && !bestMatchProperty.overridden && property.overridden)
    323                     continue;
    324                 bestMatchProperty = property;
    325             }
    326         }
    327 
    328         var bestMatchProperty = null;
    329 
    330         findMatch(this.enabledProperties);
    331 
    332         if (bestMatchProperty)
    333             return bestMatchProperty;
    334 
    335         if (dontCreateIfMissing || !this.editable)
    336             return null;
    337 
    338         findMatch(this._pendingProperties, true);
    339 
    340         if (bestMatchProperty)
    341             return bestMatchProperty;
    342 
    343         var newProperty = new WI.CSSProperty(NaN, null, name);
    344         newProperty.ownerStyle = this;
    345 
    346         this._pendingProperties.push(newProperty);
    347 
    348         return newProperty;
     316        let bestMatchProperty = null;
     317        for (let property of this.enabledProperties) {
     318            if (property.canonicalName !== name && property.name !== name)
     319                continue;
     320            if (bestMatchProperty && !bestMatchProperty.overridden && property.overridden)
     321                continue;
     322            bestMatchProperty = property;
     323        }
     324
     325        return bestMatchProperty;
    349326    }
    350327
     
    386363                        continue;
    387364
    388                     let variableProperty = this.propertyForName(variableTokens[variableNameIndex].value, true);
     365                    let variableProperty = this.propertyForName(variableTokens[variableNameIndex].value);
    389366                    if (variableProperty)
    390367                        return variableProperty.value.trim();
  • trunk/Source/WebInspectorUI/UserInterface/Models/DOMNodeStyles.js

    r283899 r285896  
    546546        if (styleDeclaration) {
    547547            // Use propertyForName when the index is NaN since propertyForName is fast in that case.
    548             var property = isNaN(index) ? styleDeclaration.propertyForName(name, true) : styleDeclaration.enabledProperties[index];
     548            var property = isNaN(index) ? styleDeclaration.propertyForName(name) : styleDeclaration.enabledProperties[index];
    549549
    550550            // Reuse a property if the index and name matches. Otherwise it is a different property
  • trunk/Source/WebInspectorUI/UserInterface/Models/Font.js

    r270637 r285896  
    207207    _computedPropertyValueForName(domNodeStyle, name)
    208208    {
    209         const dontCreateIfMissing = true;
    210         return domNodeStyle.computedStyle?.propertyForName(name, dontCreateIfMissing)?.value || "";
     209        return domNodeStyle.computedStyle?.propertyForName(name)?.value || "";
    211210    }
    212211};
  • trunk/Source/WebInspectorUI/UserInterface/Views/BoxModelDetailsSectionRow.js

    r272670 r285896  
    8181    _getPropertyValue(style, propertyName)
    8282    {
    83         const dontCreateIfMissing = true;
    84         let property = style.propertyForName(propertyName, dontCreateIfMissing);
     83        let property = style.propertyForName(propertyName);
    8584        if (!property)
    8685            return null;
  • trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js

    r285851 r285896  
    871871
    872872                    if (WI.settings.experimentalEnableStylesJumpToVariableDeclaration.value && this._property.ownerStyle.type !== WI.CSSStyleDeclaration.Type.Computed && this._delegate && this._delegate.spreadsheetStylePropertySelectByProperty) {
    873                         const dontCreateIfMissing = true;
    874                         let effectiveVariableProperty = this._property.ownerStyle.nodeStyles.effectivePropertyForName(rawTokens[variableNameIndex].value, dontCreateIfMissing);
     873                        let effectiveVariableProperty = this._property.ownerStyle.nodeStyles.effectivePropertyForName(rawTokens[variableNameIndex].value);
    875874                        if (effectiveVariableProperty) {
    876875                            let arrowElement = WI.createGoToArrowButton();
Note: See TracChangeset for help on using the changeset viewer.