Bug 213156

Summary: Text manipulation does not observe newly displayed element inside previously observed content
Product: WebKit Reporter: Sihui Liu <sihui_liu>
Component: HTML EditingAssignee: Sihui Liu <sihui_liu>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, ews-watchlist, mifenton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=213311
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Sihui Liu 2020-06-12 16:45:13 PDT
...
Comment 1 Sihui Liu 2020-06-12 16:46:41 PDT
<rdar://problems/63734491>
Comment 2 Sihui Liu 2020-06-12 16:56:28 PDT
Created attachment 401804 [details]
Patch
Comment 3 Darin Adler 2020-06-13 14:34:07 PDT
Comment on attachment 401804 [details]
Patch

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

> Source/WebCore/editing/TextManipulationController.cpp:774
> -        updateInsertions(lastTopDownPath, topDownPath, nullptr, reusedOriginalNodes, insertions);
> +        updateInsertions(lastTopDownPath, topDownPath, nullptr, reusedOriginalNodes, insertions, false);

This goes against WebKit coding style. We frown on functions with boolean arguments, where call sites pass a constant, since there’s no way to tell what "false" means. We prefer either separately named functions that make the difference clear, or enum classes for boolean values so you can see their meaning at the call site.

> Source/WebCore/editing/TextManipulationController.cpp:781
> -        insertions.append(NodeInsertion { lastTopDownPath.size() ? lastTopDownPath.last().second.ptr() : nullptr, *node });
> +        insertions.append(NodeInsertion { lastTopDownPath.size() ? lastTopDownPath.last().second.ptr() : nullptr, *node, false });

I think the same applies here, even though this is aggregate initialization rather than function calling. The enum class approach helps make these things easier to understand at the call site. The "false" is quite mysterious.
Comment 4 Sihui Liu 2020-06-15 10:12:33 PDT
(In reply to Darin Adler from comment #3)
> Comment on attachment 401804 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=401804&action=review
> 
> > Source/WebCore/editing/TextManipulationController.cpp:774
> > -        updateInsertions(lastTopDownPath, topDownPath, nullptr, reusedOriginalNodes, insertions);
> > +        updateInsertions(lastTopDownPath, topDownPath, nullptr, reusedOriginalNodes, insertions, false);
> 
> This goes against WebKit coding style. We frown on functions with boolean
> arguments, where call sites pass a constant, since there’s no way to tell
> what "false" means. We prefer either separately named functions that make
> the difference clear, or enum classes for boolean values so you can see
> their meaning at the call site.
> 
> > Source/WebCore/editing/TextManipulationController.cpp:781
> > -        insertions.append(NodeInsertion { lastTopDownPath.size() ? lastTopDownPath.last().second.ptr() : nullptr, *node });
> > +        insertions.append(NodeInsertion { lastTopDownPath.size() ? lastTopDownPath.last().second.ptr() : nullptr, *node, false });
> 
> I think the same applies here, even though this is aggregate initialization
> rather than function calling. The enum class approach helps make these
> things easier to understand at the call site. The "false" is quite
> mysterious.

Thanks for the review. I will use enum class IsNodeManipulated.
Comment 5 Sihui Liu 2020-06-15 10:21:48 PDT
Created attachment 401909 [details]
Patch for landing
Comment 6 EWS 2020-06-15 10:51:43 PDT
Committed r263044: <https://trac.webkit.org/changeset/263044>

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