Bug 245351

Summary: [LFC][Cleanup] Remove Layout::Box::formattingContextRoot
Product: WebKit Reporter: zalan <zalan>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, koivisto, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

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>