Changeset 260590 in webkit


Ignore:
Timestamp:
Apr 23, 2020 12:49:50 PM (4 years ago)
Author:
Devin Rousso
Message:

Web Inspector: REGRESSION: Elements: Styles: color functions are missing swatches
https://bugs.webkit.org/show_bug.cgi?id=210930

Reviewed by Brian Burg.

  • UserInterface/Views/SpreadsheetStyleProperty.js:

(WI.SpreadsheetStyleProperty.prototype._replaceSpecialTokens):
(WI.SpreadsheetStyleProperty.prototype._addGradientTokens):
(WI.SpreadsheetStyleProperty.prototype._addColorTokens):
(WI.SpreadsheetStyleProperty.prototype._addTimingFunctionTokens):
(WI.SpreadsheetStyleProperty.prototype._addBoxShadowTokens):
(WI.SpreadsheetStyleProperty.prototype._addVariableTokens):
Only attempt to WI.Color.fromString when at a ")" that is not part of another function.
Drive-by: add variable tokens after variable text is resolved, as otherwise the variable is

replaced with a WI.InlineSwatch, which replaces the original text, preventing it
from being used for looking up the variable name.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r260589 r260590  
     12020-04-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: REGRESSION: Elements: Styles: color functions are missing swatches
     4        https://bugs.webkit.org/show_bug.cgi?id=210930
     5
     6        Reviewed by Brian Burg.
     7
     8        * UserInterface/Views/SpreadsheetStyleProperty.js:
     9        (WI.SpreadsheetStyleProperty.prototype._replaceSpecialTokens):
     10        (WI.SpreadsheetStyleProperty.prototype._addGradientTokens):
     11        (WI.SpreadsheetStyleProperty.prototype._addColorTokens):
     12        (WI.SpreadsheetStyleProperty.prototype._addTimingFunctionTokens):
     13        (WI.SpreadsheetStyleProperty.prototype._addBoxShadowTokens):
     14        (WI.SpreadsheetStyleProperty.prototype._addVariableTokens):
     15        Only attempt to `WI.Color.fromString` when at a ")" that is not part of another function.
     16        Drive-by: add variable tokens after variable text is resolved, as otherwise the variable is
     17                  replaced with a `WI.InlineSwatch`, which replaces the original text, preventing it
     18                  from being used for looking up the variable name.
     19
    1202020-04-23  Devin Rousso  <drousso@apple.com>
    221
  • trunk/Source/WebInspectorUI/UserInterface/Views/SpreadsheetStyleProperty.js

    r259929 r260590  
    556556            return this._addBoxShadowTokens(tokens);
    557557
    558         tokens = this._addVariableTokens(tokens);
    559 
    560558        if (this._property.isVariable || WI.CSSKeywordCompletions.isColorAwareProperty(this._property.name)) {
    561559            tokens = this._addGradientTokens(tokens);
     
    567565            tokens = this._addTimingFunctionTokens(tokens, "spring");
    568566        }
     567
     568        tokens = this._addVariableTokens(tokens);
    569569
    570570        return tokens;
     
    593593
    594594                let rawTokens = tokens.slice(gradientStartIndex, i + 1);
     595
    595596                let text = this._resolveVariables(rawTokens.map((token) => token.value).join(""));
     597                rawTokens = this._addVariableTokens(rawTokens);
     598
    596599                let gradient = WI.Gradient.fromString(text);
    597600                if (gradient)
     
    640643                }
    641644
    642                 if (token.value === ")") {
    643                     --openParentheses;
    644                     if (openParentheses)
    645                         continue;
    646                 }
    647 
    648                 // Color Function end
     645                if (token.value !== ")")
     646                    continue;
     647
     648                if (--openParentheses)
     649                    continue;
    649650
    650651                let rawTokens = tokens.slice(colorFunctionStartIndex, i + 1);
     652
    651653                let text = this._resolveVariables(rawTokens.map((token) => token.value).join(""));
     654                rawTokens = this._addVariableTokens(rawTokens);
     655
    652656                pushPossibleColorToken(text, ...rawTokens);
    653657                colorFunctionStartIndex = NaN;
     
    679683
    680684                let rawTokens = tokens.slice(startIndex, i + 1);
     685
    681686                let text = this._resolveVariables(rawTokens.map((token) => token.value).join(""));
     687                rawTokens = this._addVariableTokens(rawTokens);
    682688
    683689                let valueObject;
     
    732738
    733739                let text = this._resolveVariables(nonWhitespaceTokens.map((rawToken) => rawToken.value).join(""));
     740                nonWhitespaceTokens = this._addVariableTokens(nonWhitespaceTokens);
     741
    734742                let boxShadow = WI.BoxShadow.fromString(text);
    735743                if (boxShadow)
     
    804812                    if (fallbackStartIndex !== -1) {
    805813                        contents.pushAll(rawTokens.slice(variableNameIndex + 1, fallbackStartIndex));
    806                         contents.pushAll(this._replaceSpecialTokens(rawTokens.slice(fallbackStartIndex, i)));
     814
     815                        let fallbackTokens = rawTokens.slice(fallbackStartIndex, i);
     816                        fallbackTokens = this._addBoxShadowTokens(fallbackTokens);
     817                        fallbackTokens = this._addGradientTokens(fallbackTokens);
     818                        fallbackTokens = this._addColorTokens(fallbackTokens);
     819                        fallbackTokens = this._addTimingFunctionTokens(fallbackTokens, "cubic-bezier");
     820                        fallbackTokens = this._addTimingFunctionTokens(fallbackTokens, "spring");
     821                        fallbackTokens = this._addVariableTokens(fallbackTokens);
     822                        contents.pushAll(fallbackTokens);
    807823                    } else
    808824                        contents.pushAll(rawTokens.slice(variableNameIndex + 1, i));
Note: See TracChangeset for help on using the changeset viewer.