Bug 226731

Summary: Factor MarkedText collection out of LegacyInlineTextBox
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: Layout and RenderingAssignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, changseok, esprehn+autocc, ews-watchlist, glenn, kondapallykalyan, mcatanzaro, megan_gardner, mmaxfield, pdr, sam, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
Patch for landing none

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].