Bug 226731 - Factor MarkedText collection out of LegacyInlineTextBox
Summary: Factor MarkedText collection out of LegacyInlineTextBox
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: Michael Catanzaro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-07 09:00 PDT by Antti Koivisto
Modified: 2021-06-08 13:44 PDT (History)
14 users (show)

See Also:


Attachments
patch (35.03 KB, patch)
2021-06-07 09:07 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
Patch for landing (1.10 KB, patch)
2021-06-08 12:46 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2021-06-07 09:00:11 PDT
less legacy
Comment 1 Antti Koivisto 2021-06-07 09:07:42 PDT
Created attachment 430753 [details]
patch
Comment 2 Sam Weinig 2021-06-08 07:40:24 PDT
Comment on attachment 430753 [details]
patch

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

> Source/WebCore/rendering/LegacyInlineTextBox.cpp:498
> +        Vector<MarkedText> markedTexts;
> +        markedTexts.appendVector(MarkedText::collectForDocumentMarkers(renderer(), selectableRange, MarkedText::PaintPhase::Background));
> +        markedTexts.appendVector(MarkedText::collectForHighlights(renderer(), parent()->renderer(), selectableRange, MarkedText::PaintPhase::Background));

This would be slightly more efficient if you did this as:

auto markedTexts = MarkedText::collectForDocumentMarkers(renderer(), selectableRange, MarkedText::PaintPhase::Background);
markedTexts.appendVector(MarkedText::collectForHighlights(renderer(), parent()->renderer(), selectableRange, MarkedText::PaintPhase::Background));

though I do like the symmetry in your version.

> Source/WebCore/rendering/LegacyInlineTextBox.cpp:671
> +    auto markedTexts = MarkedText::collectForDocumentMarkers(renderer(), selectableRange(), MarkedText::PaintPhase::Decoration);
> +    for (auto& markedText : MarkedText::subdivide(markedTexts, MarkedText::OverlapStrategy::Frontmost))

I wonder if it would make sense at some point to make collectForDocumentMarkers take a functor that does the subdivide rather than allocating the vector then subdividing.
Comment 3 Antti Koivisto 2021-06-08 07:48:59 PDT
> This would be slightly more efficient if you did this as:
> 
> auto markedTexts = MarkedText::collectForDocumentMarkers(renderer(),
> selectableRange, MarkedText::PaintPhase::Background);
> markedTexts.appendVector(MarkedText::collectForHighlights(renderer(),
> parent()->renderer(), selectableRange, MarkedText::PaintPhase::Background));
> 
> though I do like the symmetry in your version.

Is there a meaningful efficiency difference? Moving into an empty vector is just setting a pointer?

But yeah, I went for symmetry here.


> I wonder if it would make sense at some point to make
> collectForDocumentMarkers take a functor that does the subdivide rather than
> allocating the vector then subdividing.

There is lots of cleanup potential here but I'll try to stay focused on getting stuff out from legacy lines for now. Should be easier to see what to do when everything has been moved out.
Comment 4 EWS 2021-06-08 11:02:26 PDT
Committed r278621 (238606@main): <https://commits.webkit.org/238606@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430753 [details].
Comment 5 Radar WebKit Bug Importer 2021-06-08 11:03:22 PDT
<rdar://problem/79021715>
Comment 6 Michael Catanzaro 2021-06-08 12:46:09 PDT
Reopening to attach new patch.
Comment 7 Michael Catanzaro 2021-06-08 12:46:12 PDT
Created attachment 430878 [details]
Patch for landing
Comment 8 EWS 2021-06-08 13:44:20 PDT
Committed r278627 (238611@main): <https://commits.webkit.org/238611@main>

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