Bug 238560 - `contain: layout` on the html element should change position:fixed behavior
Summary: `contain: layout` on the html element should change position:fixed behavior
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: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2022-03-30 10:52 PDT by Simon Fraser (smfr)
Modified: 2022-08-04 17:42 PDT (History)
20 users (show)

See Also:


Attachments
Patch (1.63 KB, patch)
2022-04-15 10:10 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (1.62 KB, patch)
2022-04-16 01:11 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (6.11 KB, patch)
2022-04-18 08:31 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (7.98 KB, patch)
2022-04-21 13:30 PDT, 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-03-30 10:52:17 PDT
https://codepen.io/smfr/pen/VwyzQvb

https://www.w3.org/TR/css-contain-1/#layout-containment says that layout containment creates containing block for position:fixed. That doesn't work in WebKit.
Comment 1 Radar WebKit Bug Importer 2022-04-06 10:53:14 PDT
<rdar://problem/91364127>
Comment 2 Rob Buis 2022-04-13 07:14:57 PDT
I noticed the problem goes away if RenderLayerCompositor treats contain: layout always as a composited layer. However I guess it should work for non composited too...
Comment 3 Simon Fraser (smfr) 2022-04-13 09:22:08 PDT
Seems like `RenderElement::canContainFixedPositionObjects()` already considers containment so not sure why this is broken. Maybe RenderLayer::flagsForUpdateLayerPositions() also needs fixing.
Comment 4 Rob Buis 2022-04-15 10:10:24 PDT
Created attachment 457706 [details]
Patch
Comment 5 Simon Fraser (smfr) 2022-04-15 10:26:50 PDT
Comment on attachment 457706 [details]
Patch

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

> Source/WebCore/rendering/RenderBox.cpp:2325
> +    else if (hasTransform() || shouldApplyLayoutContainment(*this))

This should share code with canContainFixedPositionObjects()
Comment 6 Rob Buis 2022-04-16 01:11:08 PDT
Created attachment 457744 [details]
Patch
Comment 7 Rob Buis 2022-04-18 08:31:39 PDT
Created attachment 457806 [details]
Patch
Comment 8 EWS Watchlist 2022-04-18 08:33:16 PDT
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 9 Rob Buis 2022-04-19 13:29:54 PDT
Comment on attachment 457706 [details]
Patch

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

>> Source/WebCore/rendering/RenderBox.cpp:2325
>> +    else if (hasTransform() || shouldApplyLayoutContainment(*this))
> 
> This should share code with canContainFixedPositionObjects()

Done.
Comment 10 Simon Fraser (smfr) 2022-04-21 11:20:53 PDT
Comment on attachment 457806 [details]
Patch

RenderSVGRoot::mapLocalToContainer() and RenderBox::mapAbsoluteToLocalPoint() need the same change.
Comment 11 Rob Buis 2022-04-21 13:30:17 PDT
Created attachment 458086 [details]
Patch
Comment 12 EWS 2022-04-21 22:36:41 PDT
Committed r293209 (249880@main): <https://commits.webkit.org/249880@main>

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