Bug 216656 - Selection API: Introduce LiveRangeSelectionEnabled, off by default
Summary: Selection API: Introduce LiveRangeSelectionEnabled, off by default
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
Depends on:
Blocks: 216325
  Show dependency treegraph
 
Reported: 2020-09-17 11:20 PDT by Darin Adler
Modified: 2020-09-28 15:31 PDT (History)
9 users (show)

See Also:


Attachments
Patch (87.33 KB, patch)
2020-09-17 17:01 PDT, Darin Adler
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (87.36 KB, patch)
2020-09-17 17:35 PDT, Darin Adler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2020-09-17 11:20:54 PDT
Selection API as documented in https://www.w3.org/TR/selection-api/ calls for behavior where the range returned is a live range that both reflects changes to the selection and can be modified to change the selection. This is a significant first step in implementing that, with a few loose ends remaining.
Comment 1 Darin Adler 2020-09-17 17:01:11 PDT Comment hidden (obsolete)
Comment 2 Darin Adler 2020-09-17 17:02:02 PDT
There are a few small changes from the patch that Sam reviewed in bug 216325, including things that addressed his feedback and Alex’s as well, and some other small tweaks.
Comment 3 Darin Adler 2020-09-17 17:35:45 PDT
Created attachment 409093 [details]
Patch
Comment 4 Darin Adler 2020-09-17 18:45:06 PDT
Committed r267220: <https://trac.webkit.org/changeset/267220>
Comment 5 Radar WebKit Bug Importer 2020-09-17 18:46:17 PDT
<rdar://problem/69111988>
Comment 6 Ryosuke Niwa 2020-09-17 19:21:49 PDT
Comment on attachment 409093 [details]
Patch

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

> Source/WebCore/editing/FrameSelection.cpp:1522
> +LayoutUnit FrameSelection::lineDirectionPointForBlockDirectionNavigation(PositionType type)

Can we convert PositionType to enum class?

> Source/WebCore/editing/FrameSelection.cpp:2795
> +        }

Need a FIXME here to keep the JS wrapper of this range alive here too.

> Source/WebCore/editing/FrameSelection.cpp:2812
> +    updateFromAssociatedLiveRange();

Ditto.

> Source/WebCore/editing/FrameSelection.cpp:2829
> +        disassociateLiveRange();

Like I commented in the other bug, I think it would be useful to leave a comment here explaining when this case will be hit.

> Source/WebCore/editing/FrameSelection.h:52
> +enum EUserTriggered : bool { NotUserTriggered, UserTriggered };
> +enum RevealExtentOption : bool { RevealExtent, DoNotRevealExtent };

Can we use enum class for these?

> Source/WebCore/editing/FrameSelection.h:313
> +    WeakPtr<Document> m_document;

Nice
Comment 7 Darin Adler 2020-09-18 08:58:27 PDT
Comment on attachment 409093 [details]
Patch

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

>> Source/WebCore/editing/FrameSelection.cpp:1522
>> +LayoutUnit FrameSelection::lineDirectionPointForBlockDirectionNavigation(PositionType type)
> 
> Can we convert PositionType to enum class?

OK, I will do that in a follow-up.

>> Source/WebCore/editing/FrameSelection.cpp:2795
>> +        }
> 
> Need a FIXME here to keep the JS wrapper of this range alive here too.

I think we only need one FIXME, in associateLiveRange. Not three in three different functions. Not sure why I put it in disassociateLiveRange!

In any case, I am mostly done with the patch that resolves the problem now, so figuring out how many FIXMEs we want and where is a very short term issue.

>> Source/WebCore/editing/FrameSelection.cpp:2829
>> +        disassociateLiveRange();
> 
> Like I commented in the other bug, I think it would be useful to leave a comment here explaining when this case will be hit.

Yes, sorry, I forgot. Will add a comment.

>> Source/WebCore/editing/FrameSelection.h:52
>> +enum RevealExtentOption : bool { RevealExtent, DoNotRevealExtent };
> 
> Can we use enum class for these?

OK. Will do. Also rename EUserTriggered to remove the E.