Bug 233109

Summary: Implement parsing and animation support for offset shorthand
Product: WebKit Reporter: Kiet Ho <kiet.ho>
Component: CSSAssignee: Kiet Ho <kiet.ho>
Status: RESOLVED FIXED    
Severity: Normal CC: clopez, dino, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, joepeck, jonlee, kyle.bavender, macpherson, menard, nmouchtaris, simon.fraser, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 233108    
Bug Blocks: 203847    
Attachments:
Description Flags
WIP
none
WIP
none
WIP
none
Patch
none
Patch
dino: review+, ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch none

Description Kiet Ho 2021-11-14 13:39:55 PST
Implement parsing and animation support for offset shorthand
Comment 1 Kiet Ho 2021-11-15 16:38:06 PST
Created attachment 444318 [details]
WIP
Comment 2 EWS Watchlist 2021-11-15 16:38:55 PST
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 3 Kiet Ho 2021-11-15 16:40:35 PST
*** Bug 232760 has been marked as a duplicate of this bug. ***
Comment 4 Kiet Ho 2021-11-15 18:00:24 PST
Created attachment 444324 [details]
WIP
Comment 5 Kiet Ho 2021-11-19 10:54:34 PST
Created attachment 444836 [details]
WIP
Comment 6 Kiet Ho 2021-11-19 10:58:56 PST
Still needs to figure out what is the correct serialization format. In particular, is it needed to make the serialization as short as possible?

For example, Chrome and this patch serializes "auto none" to "auto none". However, "auto" is equivalent and shorter.

On the other hand, "auto none reverse" must be serialized to "auto none reverse" and not "auto reverse", because according to the grammar, if offset-rotate is serialized, then so is offset-path.
Comment 7 Radar WebKit Bug Importer 2021-11-19 11:06:18 PST
<rdar://problem/85611877>
Comment 8 Nikos Mouchtaris 2022-02-10 23:56:01 PST
Created attachment 451649 [details]
Patch
Comment 9 Nikos Mouchtaris 2022-02-11 10:58:37 PST
Created attachment 451727 [details]
Patch
Comment 10 Dean Jackson 2022-02-15 12:57:26 PST
Comment on attachment 451727 [details]
Patch

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

> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:2640
> +    {
> +        auto innerList = CSSValueList::createSpaceSeparated();
> +        innerList->append(valueForPositionOrAuto(style, style.offsetPosition()));
> +        innerList->append(valueForPathOperation(style, style.offsetPath(), SVGPathConversion::ForceAbsolute));
> +        innerList->append(CSSValuePool::singleton().createValue(style.offsetDistance(), style));
> +        innerList->append(valueForOffsetRotate(style.offsetRotate()));
> +
> +        outerList->append(WTFMove(innerList));
> +    }

Any reason for this being in its own  scope?

> Source/WebCore/css/StyleProperties.cpp:466
> +static bool isAutoKeyword(const CSSValue& value)
> +{
> +    if (!is<CSSPrimitiveValue>(value))
> +        return false;
> +
> +    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
> +    return primitiveValue.isValueID() && primitiveValue.valueID() == CSSValueAuto;
> +}

Is this really the first/only time we're checking for this keyword in the file?

> Source/WebCore/css/StyleProperties.cpp:508
> +            if (!offsetDistance.value() || !is<CSSPrimitiveValue>(offsetDistance.value()))

Maybe a local variable for offsetDistance.value() to avoid calling it multiple times?

> Source/WebCore/css/StyleProperties.cpp:527
> +            if (!offsetRotate.value() || !is<CSSOffsetRotateValue>(offsetRotate.value()))

Same with this .value()
Comment 11 Nikos Mouchtaris 2022-02-15 15:03:13 PST
Created attachment 452096 [details]
Patch
Comment 12 Nikos Mouchtaris 2022-02-15 15:04:32 PST
(In reply to Dean Jackson from comment #10)
> Comment on attachment 451727 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=451727&action=review
> 
> > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:2640
> > +    {
> > +        auto innerList = CSSValueList::createSpaceSeparated();
> > +        innerList->append(valueForPositionOrAuto(style, style.offsetPosition()));
> > +        innerList->append(valueForPathOperation(style, style.offsetPath(), SVGPathConversion::ForceAbsolute));
> > +        innerList->append(CSSValuePool::singleton().createValue(style.offsetDistance(), style));
> > +        innerList->append(valueForOffsetRotate(style.offsetRotate()));
> > +
> > +        outerList->append(WTFMove(innerList));
> > +    }
> 
> Any reason for this being in its own  scope?
Fixed.
> 
> > Source/WebCore/css/StyleProperties.cpp:466
> > +static bool isAutoKeyword(const CSSValue& value)
> > +{
> > +    if (!is<CSSPrimitiveValue>(value))
> > +        return false;
> > +
> > +    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
> > +    return primitiveValue.isValueID() && primitiveValue.valueID() == CSSValueAuto;
> > +}
> 
> Is this really the first/only time we're checking for this keyword in the
> file?
No reason for this to be its own function.
> 
> > Source/WebCore/css/StyleProperties.cpp:508
> > +            if (!offsetDistance.value() || !is<CSSPrimitiveValue>(offsetDistance.value()))
> 
> Maybe a local variable for offsetDistance.value() to avoid calling it
> multiple times?
Fixed.
> 
> > Source/WebCore/css/StyleProperties.cpp:527
> > +            if (!offsetRotate.value() || !is<CSSOffsetRotateValue>(offsetRotate.value()))
> 
> Same with this .value()
Fixed.
Comment 13 Nikos Mouchtaris 2022-02-15 16:47:47 PST
Created attachment 452109 [details]
Patch
Comment 14 EWS 2022-02-15 21:28:19 PST
Committed r289876 (247314@main): <https://commits.webkit.org/247314@main>

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