Bug 213156 - Text manipulation does not observe newly displayed element inside previously observed content
Summary: Text manipulation does not observe newly displayed element inside previously ...
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-06-12 16:45 PDT by Sihui Liu
Modified: 2020-06-17 11:34 PDT (History)
5 users (show)

See Also:


Attachments
Patch (12.42 KB, patch)
2020-06-12 16:56 PDT, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (12.67 KB, patch)
2020-06-15 10:21 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-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].