Bug 215406 - Text manipulation should not manipulate nodes out of paragraph range
Summary: Text manipulation should not manipulate nodes out of paragraph range
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: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-11 21:03 PDT by Sihui Liu
Modified: 2020-08-24 11:06 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.73 KB, patch)
2020-08-11 21:15 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (5.75 KB, patch)
2020-08-24 10:39 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sihui Liu 2020-08-11 21:03:58 PDT
...
Comment 1 Sihui Liu 2020-08-11 21:15:30 PDT
Created attachment 406445 [details]
Patch
Comment 2 Wenson Hsieh 2020-08-12 09:31:49 PDT
Comment on attachment 406445 [details]
Patch

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

> Source/WebCore/ChangeLog:3
> +        Text manipulationshould not manipulate nodes out of paragraph range

Nit - space before “should”

> Source/WebCore/ChangeLog:9
> +        the nodes on the start path but out ouf range correctly, and may change position of those nodes by mistake. For 

Nit - “out of”

> Source/WebCore/editing/TextManipulationController.cpp:840
> +    while (!startTopDownPath.isEmpty()) {
> +        auto lastNode = startTopDownPath.last();
> +        ASSERT(is<ContainerNode>(lastNode.get()));
> +        if (!downcast<ContainerNode>(lastNode.get()).hasOneChild())
> +            break;
> +        nodesToRemove.add(startTopDownPath.takeLast());
> +    }

Perhaps getPath() should just return `Vector<Ref<ContainerNode>>` instead, and change this into something along the lines of:
```
while (!startTopDownPath.isEmpty() && startTopDownPath.last()->hasOneChild())
    nodesToRemove.add(startTopDownPath.takeLast());
```
Comment 3 Radar WebKit Bug Importer 2020-08-18 21:04:14 PDT
<rdar://problem/67375376>
Comment 4 Ryosuke Niwa 2020-08-20 17:42:47 PDT
Is this patch getting landed??
Comment 5 Sihui Liu 2020-08-24 09:19:50 PDT
(In reply to Ryosuke Niwa from comment #4)
> Is this patch getting landed??

Yes, will land soon.
Comment 6 Sihui Liu 2020-08-24 10:36:42 PDT
Comment on attachment 406445 [details]
Patch

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

>> Source/WebCore/ChangeLog:3
>> +        Text manipulationshould not manipulate nodes out of paragraph range
> 
> Nit - space before “should”

Okay.

>> Source/WebCore/ChangeLog:9
>> +        the nodes on the start path but out ouf range correctly, and may change position of those nodes by mistake. For 
> 
> Nit - “out of”

Okay.

>> Source/WebCore/editing/TextManipulationController.cpp:840
>> +    }
> 
> Perhaps getPath() should just return `Vector<Ref<ContainerNode>>` instead, and change this into something along the lines of:
> ```
> while (!startTopDownPath.isEmpty() && startTopDownPath.last()->hasOneChild())
>     nodesToRemove.add(startTopDownPath.takeLast());
> ```

I tried this and found we need to make changes to updateInsertions(), which seems unnecessary for fixing the bug. I can do this in a follow-up patch, as getPath should only return ContainerNodes.
Comment 7 Sihui Liu 2020-08-24 10:39:16 PDT
Created attachment 407109 [details]
Patch for landing
Comment 8 EWS 2020-08-24 11:06:05 PDT
Committed r266075: <https://trac.webkit.org/changeset/266075>

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