Bug 157611 - indexForVisiblePosition should use the root editable element as the scope
Summary: indexForVisiblePosition should use the root editable element as the scope
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-05-11 22:45 PDT by Ryosuke Niwa
Modified: 2016-05-12 12:50 PDT (History)
3 users (show)

See Also:


Attachments
Cleanup (7.12 KB, patch)
2016-05-11 22:53 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Removed redundant assertion (7.04 KB, patch)
2016-05-11 22:54 PDT, Ryosuke Niwa
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2016-05-11 22:45:08 PDT
We should be using the highest editing host as the scope in indexForVisiblePosition when it's called inside an editable region.
This is blocking the work to make VoiceOver work with undo/redo after the rewrite in the bug 153361.
Comment 1 Radar WebKit Bug Importer 2016-05-11 22:45:48 PDT
<rdar://problem/26239047>
Comment 2 Ryosuke Niwa 2016-05-11 22:53:41 PDT
Created attachment 278700 [details]
Cleanup
Comment 3 Ryosuke Niwa 2016-05-11 22:54:34 PDT
Created attachment 278701 [details]
Removed redundant assertion
Comment 4 Darin Adler 2016-05-12 09:17:54 PDT
Comment on attachment 278701 [details]
Removed redundant assertion

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

> Source/WebCore/editing/ApplyBlockElementCommand.cpp:100
> +        // Workaround the fact indexForVisiblePosition can return a larger index due to TextIterator

The verb is two word: "work around". The noun is "workaround". Here we are using it as a verb.

> Source/WebCore/editing/ApplyBlockElementCommand.cpp:102
> +        // FIXME: Add a new TextIterator beavhior to suppress this behavior.

Spelling error here in the first "behavior".

I find the two uses of the word "behavior" here confusing, so I would use the identifier TextIteratorBehavior to be clearer.

> Source/WebCore/editing/htmlediting.cpp:1137
> +    Document& document = *position.document();

auto& perhaps

> Source/WebCore/editing/htmlediting.cpp:1141
> +        scope = downcast<ContainerNode>(editableRoot);

If this is a safe cast, then why does highestEditableRoot return a Node* and not a ContanerNode*?

> Source/WebCore/editing/htmlediting.cpp:1149
> +    RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get()), position.parentAnchoredEquivalent());

Should use auto here instead of RefPtr<Range>. I believe this will make range be a Ref instead of a RefPtr.
Comment 5 Ryosuke Niwa 2016-05-12 12:50:02 PDT
Comment on attachment 278701 [details]
Removed redundant assertion

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

Thanks for the review

>> Source/WebCore/editing/htmlediting.cpp:1141
>> +        scope = downcast<ContainerNode>(editableRoot);
> 
> If this is a safe cast, then why does highestEditableRoot return a Node* and not a ContanerNode*?

We should probably change highestEditableRoot to return a ContainerNode* later.
Comment 6 Ryosuke Niwa 2016-05-12 12:50:22 PDT
Committed r200787: <http://trac.webkit.org/changeset/200787>