Bug 215406

Summary: Text manipulation should not manipulate nodes out of paragraph range
Product: WebKit Reporter: Sihui Liu <sihui_liu>
Component: HTML EditingAssignee: Sihui Liu <sihui_liu>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, mifenton, rniwa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch for landing none

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].