Bug 240906 - Make shouldApplyContainment methods more flexible
Summary: Make shouldApplyContainment methods more flexible
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 15
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks: 243534
  Show dependency treegraph
 
Reported: 2022-05-25 06:42 PDT by Rob Buis
Modified: 2022-08-11 22:14 PDT (History)
11 users (show)

See Also:


Attachments
Patch (13.81 KB, patch)
2022-05-25 07:18 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (13.49 KB, patch)
2022-05-26 02:18 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 Rob Buis 2022-05-25 06:42:54 PDT
In r293943 some shouldApplyContainment methods were optimised, however
they are not flexible enough to deal with the content-visibility feature,
which in certain cases can influence containment. So to be flexible use
lambdas that return a bool instead of relying on effectiveContainment().
Comment 1 Rob Buis 2022-05-25 07:18:26 PDT
Created attachment 459757 [details]
Patch
Comment 2 Simon Fraser (smfr) 2022-05-25 13:31:07 PDT
Comment on attachment 459757 [details]
Patch

These functions are hot because they fall into the "containingBlock" code path. Does this affect performance?
Comment 3 Rob Buis 2022-05-25 14:00:55 PDT
(In reply to Simon Fraser (smfr) from comment #2)
> Comment on attachment 459757 [details]
> Patch
> 
> These functions are hot because they fall into the "containingBlock" code
> path. Does this affect performance?

Are you thinking of canContainFixedPositionObjects/canContainAbsolutelyPositionedObjects or more?
If the lambda's are nicely inlined the performance should be the same, but I never checked efficiency for that (I guess I could try godbold.org tomorrow). An older patch used bool parameters for shouldApplyLayoutOrPaintContainment/shouldApplySizeOrStyleContainment, to me it does not look as nice as lambdas, but it pretty much guarantees same perf as we have now, and it works to support content-visibility later on, so I do not mind using that instead.
Comment 4 Rob Buis 2022-05-26 02:18:17 PDT
Created attachment 459779 [details]
Patch
Comment 5 Rob Buis 2022-05-26 08:09:13 PDT
(In reply to Rob Buis from comment #3)
> (In reply to Simon Fraser (smfr) from comment #2)
> > Comment on attachment 459757 [details]
> > Patch
> > 
> > These functions are hot because they fall into the "containingBlock" code
> > path. Does this affect performance?
> 
> Are you thinking of
> canContainFixedPositionObjects/canContainAbsolutelyPositionedObjects or more?
> If the lambda's are nicely inlined the performance should be the same, but I
> never checked efficiency for that (I guess I could try godbold.org
> tomorrow). An older patch used bool parameters for
> shouldApplyLayoutOrPaintContainment/shouldApplySizeOrStyleContainment, to me
> it does not look as nice as lambdas, but it pretty much guarantees same perf
> as we have now, and it works to support content-visibility later on, so I do
> not mind using that instead.

From checking godbolt.org output the lambdas do seem to generate quite some extra instructions, so I changed the patch to use boolean parameters instead.
Comment 6 Radar WebKit Bug Importer 2022-06-01 06:43:13 PDT
<rdar://problem/94218126>
Comment 7 Rob Buis 2022-06-08 05:15:20 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1373
Comment 8 Rob Buis 2022-06-08 05:18:26 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1374
Comment 9 Rob Buis 2022-07-29 11:28:03 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2857
Comment 10 Rob Buis 2022-08-10 01:25:55 PDT
Pull request: https://github.com/WebKit/WebKit/pull/3182
Comment 11 EWS 2022-08-11 00:40:00 PDT
Committed 253324@main (6c79952a8e99): <https://commits.webkit.org/253324@main>

Reviewed commits have been landed. Closing PR #3182 and removing active labels.