Bug 236261 - Incorrect abspos layout when toggling contain
Summary: Incorrect abspos layout when toggling contain
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-07 14:37 PST by Simon Fraser (smfr)
Modified: 2022-02-10 05:07 PST (History)
14 users (show)

See Also:


Attachments
testcase (924 bytes, text/html)
2022-02-07 14:37 PST, Simon Fraser (smfr)
no flags Details
Patch (5.31 KB, patch)
2022-02-08 07:50 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.66 KB, patch)
2022-02-08 11:18 PST, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.76 KB, patch)
2022-02-10 03:19 PST, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2022-02-07 14:37:28 PST
Created attachment 451153 [details]
testcase

Open the testcase and hover the black-outlined box.

Note how the green box (abspos) moves to the wrong position.
Comment 1 Rob Buis 2022-02-08 03:57:15 PST
The problem is that the children of the contain container are not being relayout after hover.
Comment 2 Rob Buis 2022-02-08 07:50:30 PST
Created attachment 451246 [details]
Patch
Comment 3 EWS Watchlist 2022-02-08 07:52:34 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 4 Rob Buis 2022-02-08 11:18:15 PST
Created attachment 451279 [details]
Patch
Comment 5 Simon Fraser (smfr) 2022-02-09 12:17:19 PST
Comment on attachment 451279 [details]
Patch

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

> Source/WebCore/rendering/RenderBlock.cpp:381
> +    if (oldStyle.position() == newStyle.position() && hadTransform == willHaveTransform && (hadLayoutContainment == willHaveLayoutContainment))

No need for the last pair of parens.

> Source/WebCore/rendering/RenderBlock.cpp:387
> +        outOfFlowDescendantsHaveNewContainingBlock = hadLayoutContainment && !willHaveLayoutContainment;

I can't figure out why it's hadLayoutContainment && !willHaveLayoutContainment and not also !hadLayoutContainment && willHaveLayoutContainment

> LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-020.html:38
> +  window.requestAnimationFrame( () => {

No space before () unless this is WPT style. I'd drop 'window.' too
Comment 6 Rob Buis 2022-02-10 03:19:56 PST
Created attachment 451510 [details]
Patch
Comment 7 EWS 2022-02-10 05:03:18 PST
Committed r289527 (247058@main): <https://commits.webkit.org/247058@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 451510 [details].
Comment 8 Radar WebKit Bug Importer 2022-02-10 05:04:17 PST
<rdar://problem/88749136>
Comment 9 Rob Buis 2022-02-10 05:07:22 PST
Comment on attachment 451279 [details]
Patch

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

>> Source/WebCore/rendering/RenderBlock.cpp:381
>> +    if (oldStyle.position() == newStyle.position() && hadTransform == willHaveTransform && (hadLayoutContainment == willHaveLayoutContainment))
> 
> No need for the last pair of parens.

Fixed.

>> Source/WebCore/rendering/RenderBlock.cpp:387
>> +        outOfFlowDescendantsHaveNewContainingBlock = hadLayoutContainment && !willHaveLayoutContainment;
> 
> I can't figure out why it's hadLayoutContainment && !willHaveLayoutContainment and not also !hadLayoutContainment && willHaveLayoutContainment

Yes, this was tricky. The idea is in the case of !hadLayoutContainment && willHaveLayoutContainment we want to enter the below block "We are a new containing block.".

>> LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-layout-020.html:38
>> +  window.requestAnimationFrame( () => {
> 
> No space before () unless this is WPT style. I'd drop 'window.' too

Fixed.