Bug 245351 - [LFC][Cleanup] Remove Layout::Box::formattingContextRoot
Summary: [LFC][Cleanup] Remove Layout::Box::formattingContextRoot
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-09-18 20:04 PDT by zalan
Modified: 2022-09-19 22:14 PDT (History)
5 users (show)

See Also:


Attachments
Patch (22.64 KB, patch)
2022-09-18 20:30 PDT, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2022-09-18 20:04:00 PDT
ssia
Comment 1 zalan 2022-09-18 20:30:16 PDT
Created attachment 462427 [details]
Patch
Comment 2 Antti Koivisto 2022-09-19 06:07:09 PDT
Comment on attachment 462427 [details]
Patch

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

> Source/WebCore/layout/formattingContexts/FormattingContext.cpp:280
>      for (auto& descendant : descendantsOfType<Box>(root)) {
>          if (!descendant.isOutOfFlowPositioned())
>              continue;
> -        if (&descendant.formattingContextRoot() != &root)
> +        auto nearestFormattingContextRoot = [&] {
> +            auto* ancestor = &descendant.containingBlock();
> +            for (; !ancestor->establishesBlockFormattingContext(); ancestor = &ancestor->containingBlock()) { }
> +            return ancestor;
> +        };
> +        if (nearestFormattingContextRoot() != &root)
>              continue;
>          formattingState().addOutOfFlowBox(descendant);
>      }

This loop could just avoid traversing into subtrees that are in a separate formatting context.
Comment 3 zalan 2022-09-19 15:34:10 PDT
(In reply to Antti Koivisto from comment #2)
> Comment on attachment 462427 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=462427&action=review
> 
> > Source/WebCore/layout/formattingContexts/FormattingContext.cpp:280
> >      for (auto& descendant : descendantsOfType<Box>(root)) {
> >          if (!descendant.isOutOfFlowPositioned())
> >              continue;
> > -        if (&descendant.formattingContextRoot() != &root)
> > +        auto nearestFormattingContextRoot = [&] {
> > +            auto* ancestor = &descendant.containingBlock();
> > +            for (; !ancestor->establishesBlockFormattingContext(); ancestor = &ancestor->containingBlock()) { }
> > +            return ancestor;
> > +        };
> > +        if (nearestFormattingContextRoot() != &root)
> >              continue;
> >          formattingState().addOutOfFlowBox(descendant);
> >      }
> 
> This loop could just avoid traversing into subtrees that are in a separate
> formatting context.
Yeah, this needs to be re-worked when getting it into shipping configuration (BFC) (there's a FIXME somewhere here).
Comment 4 EWS 2022-09-19 22:13:39 PDT
Committed 254662@main (3d0a14637f43): <https://commits.webkit.org/254662@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 462427 [details].
Comment 5 Radar WebKit Bug Importer 2022-09-19 22:14:18 PDT
<rdar://problem/100156556>