Bug 231341 - [LFC][IFC] InlineDisplay::Box should be able to tell if it's the first or the last box within the associated Layout::Box
Summary: [LFC][IFC] InlineDisplay::Box should be able to tell if it's the first or the...
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: 2021-10-06 17:02 PDT by zalan
Modified: 2021-10-07 08:41 PDT (History)
5 users (show)

See Also:


Attachments
Patch (17.00 KB, patch)
2021-10-06 17:08 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (17.10 KB, patch)
2021-10-07 08:03 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 2021-10-06 17:02:38 PDT
this is to help speed up box iterators
Comment 1 zalan 2021-10-06 17:08:30 PDT
Created attachment 440457 [details]
Patch
Comment 2 Antti Koivisto 2021-10-07 02:52:09 PDT
Comment on attachment 440457 [details]
Patch

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

> Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:47
> +    if (inlineBox.isFirstBox() && inlineBox.isLastBox())
> +        return { InlineDisplay::Box::PositionWithinInlineLevelBox::First, InlineDisplay::Box::PositionWithinInlineLevelBox::Last };
> +    if (inlineBox.isFirstBox())
> +        return { InlineDisplay::Box::PositionWithinInlineLevelBox::First };
> +    if (inlineBox.isLastBox())
> +        return { InlineDisplay::Box::PositionWithinInlineLevelBox::Last };
> +    return { };

I'd do

OptionSet<InlineDisplay::Box::PositionWithinInlineLevelBox> result;
if (inlineBox.isFirstBox())
    result.add(InlineDisplay::Box::PositionWithinInlineLevelBox::First);
if (inlineBox.isLastBox())
    result.add(InlineDisplay::Box::PositionWithinInlineLevelBox::Last);
return result;

> Source/WebCore/layout/formattingContexts/inline/InlineLevelBox.h:147
> +    // These bits are about whether this inline level box is the first/last generated box of the associated Layout::Box
> +    // (e.g. always true for atomic inline level boxes, but inline boxes spanning over multiple lines can produce separate first/last boxes).
> +    bool m_isFirstWithinLayoutBox : 1;
> +    bool m_isLastWithinLayoutBox : 1;

These could move up with other bools and probably don't need to be bitfields (or all of them should be).

> Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h:135
> +    bool m_isFirstWithinInlineLevelBox : 1;
> +    bool m_isLastWithinInlineLevelBox : 1;

Same here.
Comment 3 zalan 2021-10-07 08:03:27 PDT
Created attachment 440503 [details]
Patch
Comment 4 EWS 2021-10-07 08:40:48 PDT
Committed r283715 (242641@main): <https://commits.webkit.org/242641@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 440503 [details].
Comment 5 Radar WebKit Bug Importer 2021-10-07 08:41:17 PDT
<rdar://problem/83982733>