Bug 235692 - Add support for decorating and scrolling to ranges in WebFoundTextRangeController
Summary: Add support for decorating and scrolling to ranges in WebFoundTextRangeContro...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Aditya Keerthi
URL:
Keywords: InRadar
Depends on: 235691
Blocks: 235830
  Show dependency treegraph
 
Reported: 2022-01-26 23:39 PST by Aditya Keerthi
Modified: 2022-01-28 13:47 PST (History)
5 users (show)

See Also:


Attachments
Patch (14.49 KB, patch)
2022-01-27 11:57 PST, Aditya Keerthi
no flags Details | Formatted Diff | Diff
Patch (14.49 KB, patch)
2022-01-27 23:42 PST, Aditya Keerthi
no flags Details | Formatted Diff | Diff
Patch (16.25 KB, patch)
2022-01-28 10:28 PST, Aditya Keerthi
wenson_hsieh: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch for landing (16.08 KB, patch)
2022-01-28 11:50 PST, Aditya Keerthi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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].