Bug 202501 - Support percentages in the scale() transform functions, and the scale property
Summary: Support percentages in the scale() transform functions, and the scale property
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Simon Fraser (smfr)
URL:
Keywords: InRadar, WebExposed
Depends on: 229974
Blocks:
  Show dependency treegraph
 
Reported: 2019-10-02 16:34 PDT by Dean Jackson
Modified: 2021-09-08 08:34 PDT (History)
9 users (show)

See Also:


Attachments
Patch (22.29 KB, patch)
2021-09-07 09:57 PDT, Simon Fraser (smfr)
sam: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (22.98 KB, patch)
2021-09-07 13:05 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff
Patch (30.73 KB, patch)
2021-09-07 20:25 PDT, Simon Fraser (smfr)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2019-10-02 16:34:37 PDT
https://github.com/w3c/csswg-drafts/issues/3399

transform: scale(ABC) can now take percentage values for ABC.
Comment 1 Radar WebKit Bug Importer 2019-10-02 16:35:01 PDT
<rdar://problem/55929521>
Comment 2 Simon Fraser (smfr) 2021-09-07 09:57:22 PDT
Created attachment 437518 [details]
Patch
Comment 3 Simon Fraser (smfr) 2021-09-07 10:36:09 PDT
Looks like I have an issue about losing calc() in computed style.
Comment 4 Sam Weinig 2021-09-07 10:39:18 PDT
Comment on attachment 437518 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=437518&action=review

> Source/WebCore/ChangeLog:9
> +        on the scale property. These value are converted by numbers by dividing by 100

"converted by numbers" -> "converted to numbers".

> Source/WebCore/css/parser/CSSPropertyParser.cpp:1796
> +static bool consumeNumbersOrPercentsDividedBy100(CSSParserTokenRange& args, RefPtr<CSSFunctionValue>& transformValue, unsigned numberOfArguments)

RefPtr<CSSFunctionValue> -> Ref<CSSFunctionValue>.

I think also naming this something about being a comma separated list would be good.

> Source/WebCore/css/parser/CSSPropertyParser.cpp:1799
> +        RefPtr<CSSPrimitiveValue> parsedValue = consumeNumberOrPercentDividedBy100(args, ValueRange::All);

I would use auto here.

> Source/WebCore/css/parser/CSSPropertyParser.cpp:1805
> +    } while (numberOfArguments);

You could make this a tad more efficient (remove a branch) if you did it like:

auto parseNumberAndAppend = [&] {
    auto parsedValue = consumeNumberOrPercentDividedBy100(args, ValueRange::All);
    if (!parsedValue)
        return false;

    transformValue->append(parsedValue.releaseNonNull());
    --numberOfArguments;
    return true;
};

if (!parseNumberAndAppend())
    return false;

while (numberOfArguments) {
    if (!consumeCommaIncludingWhitespace(args))
        return false;

    if (!parseNumberAndAppend())
        return false;
}

return true;
Comment 5 Simon Fraser (smfr) 2021-09-07 13:05:30 PDT
Created attachment 437547 [details]
Patch
Comment 6 Simon Fraser (smfr) 2021-09-07 20:25:37 PDT
Created attachment 437588 [details]
Patch
Comment 7 EWS 2021-09-08 08:34:45 PDT
Committed r282144 (241441@main): <https://commits.webkit.org/241441@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 437588 [details].