Bug 235692

Summary: Add support for decorating and scrolling to ranges in WebFoundTextRangeController
Product: WebKit Reporter: Aditya Keerthi <akeerthi>
Component: New BugsAssignee: Aditya Keerthi <akeerthi>
Status: RESOLVED FIXED    
Severity: Normal CC: hi, megan_gardner, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 235691    
Bug Blocks: 235830    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
wenson_hsieh: review+, ews-feeder: commit-queue-
Patch for landing none

Description Aditya Keerthi 2022-01-26 23:39:27 PST
...
Comment 1 Aditya Keerthi 2022-01-26 23:39:44 PST
rdar://88117232
Comment 2 Aditya Keerthi 2022-01-27 11:57:07 PST
Created attachment 450163 [details]
Patch
Comment 3 Aditya Keerthi 2022-01-27 23:42:06 PST
Created attachment 450209 [details]
Patch
Comment 4 Aditya Keerthi 2022-01-28 10:28:38 PST
Created attachment 450251 [details]
Patch
Comment 5 Wenson Hsieh 2022-01-28 11:11:35 PST
Comment on attachment 450251 [details]
Patch

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

> Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:109
> +    if (style == FindDecorationStyle::Normal) {
> +        simpleRange->start.document().markers().removeMarkers(*simpleRange, WebCore::DocumentMarker::TextMatch);
> +    } else if (style == FindDecorationStyle::Found) {
> +        simpleRange->start.document().markers().addMarker(*simpleRange, WebCore::DocumentMarker::TextMatch);
> +    } else if (style == FindDecorationStyle::Highlighted) {

I think the { } here around single-line if statements should be omitted (unless that rule has changed recently?)

> Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:136
> +    OptionSet<WebCore::TemporarySelectionOption> temporarySelectionOptions { WebCore::TemporarySelectionOption::DelegateMainFrameScroll, WebCore::TemporarySelectionOption::RevealSelectionBounds };

Nit - can you replace "OptionSet<WebCore::TemporarySelectionOption>" with just OptionSet? (I think that type deduction should be sufficient to infer the type here)

> Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:259
> +    auto* mainFrameView = m_webPage->corePage()->mainFrame().view();

I think we should be protecting these with RefPtr (especially since the logic below involves more than just simple getters)

> Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:288
> +    for (auto* frame = m_webPage->corePage()->mainFrame().document()->topDocument().frame(); frame; frame = frame->tree().traverseNext()) {
> +        if (frame->tree().uniqueName() == range.frameIdentifier)
> +            return frame->document();
> +    }

Can we simplify this logic a bit using `FrameTree::find()`?
Comment 6 Aditya Keerthi 2022-01-28 11:50:16 PST
Created attachment 450263 [details]
Patch for landing
Comment 7 Aditya Keerthi 2022-01-28 11:52:30 PST
(In reply to Wenson Hsieh from comment #5)
> Comment on attachment 450251 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=450251&action=review

Thanks for the review!
 
> > Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:109
> > +    if (style == FindDecorationStyle::Normal) {
> > +        simpleRange->start.document().markers().removeMarkers(*simpleRange, WebCore::DocumentMarker::TextMatch);
> > +    } else if (style == FindDecorationStyle::Found) {
> > +        simpleRange->start.document().markers().addMarker(*simpleRange, WebCore::DocumentMarker::TextMatch);
> > +    } else if (style == FindDecorationStyle::Highlighted) {
> 
> I think the { } here around single-line if statements should be omitted
> (unless that rule has changed recently?)

Removed { }.
 
> > Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:136
> > +    OptionSet<WebCore::TemporarySelectionOption> temporarySelectionOptions { WebCore::TemporarySelectionOption::DelegateMainFrameScroll, WebCore::TemporarySelectionOption::RevealSelectionBounds };
> 
> Nit - can you replace "OptionSet<WebCore::TemporarySelectionOption>" with
> just OptionSet? (I think that type deduction should be sufficient to infer
> the type here)

Type deduction worked. Updated another OptionSet in this patch too.
 
> > Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:259
> > +    auto* mainFrameView = m_webPage->corePage()->mainFrame().view();
> 
> I think we should be protecting these with RefPtr (especially since the
> logic below involves more than just simple getters)

Done!
 
> > Source/WebKit/WebProcess/WebPage/WebFoundTextRangeController.cpp:288
> > +    for (auto* frame = m_webPage->corePage()->mainFrame().document()->topDocument().frame(); frame; frame = frame->tree().traverseNext()) {
> > +        if (frame->tree().uniqueName() == range.frameIdentifier)
> > +            return frame->document();
> > +    }
> 
> Can we simplify this logic a bit using `FrameTree::find()`?

Replaced this logic with `FrameTree::find()`.
Comment 8 EWS 2022-01-28 13:47:39 PST
Committed r288760 (246548@main): <https://commits.webkit.org/246548@main>

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