[webkit-changes] [WebKit/WebKit] e3415c: [iOS] Mail compose loses focus after long pressing...

Wenson Hsieh noreply at github.com
Sun Sep 10 22:49:07 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e3415c365a3f9135590b552cbf9326cc2bbf9c6d
      https://github.com/WebKit/WebKit/commit/e3415c365a3f9135590b552cbf9326cc2bbf9c6d
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-09-10 (Sun, 10 Sep 2023)

  Changed paths:
    A LayoutTests/editing/text-placeholder/removing-placeholder-restores-selection-expected.txt
    A LayoutTests/editing/text-placeholder/removing-placeholder-restores-selection.html
    M Source/WebCore/editing/Editor.cpp

  Log Message:
  -----------
  [iOS] Mail compose loses focus after long pressing and inserting text using  Pencil
https://bugs.webkit.org/show_bug.cgi?id=261388
rdar://114253457

Reviewed by Aditya Keerthi.

When tapping and holding over text in Mail compose to insert text by scribbling with  Pencil, we
insert a text placeholder at the beginning of the scribble interaction, and remove it after
committing the final recognized text.

Currently, the implementation of `Editor::removeTextPlaceholder` (unsuccessfully) attempts to
restore the selection to where it was prior to inserting the placeholder by saving the parent-
anchored equivalent DOM position before the placeholder element using `parentAnchoredEquivalent()`.
However, for a DOM position that's before or after the anchor node, the parent anchored equivalent
might end up returning a position anchored to the node itself. This causes the selection to be
"restored" to an position that's no longer in the DOM after removing the placeholder, which has the
effect of clearing out the selection entirely.

To fix this, we simply use the `positionInParentBeforeNode` helper instead, which actually
guarantees that we're anchored to an ancestor of the placeholder when computing the DOM position to
restore after removing the placeholder.

Test: editing/text-placeholder/removing-placeholder-restores-selection.html

* LayoutTests/editing/text-placeholder/removing-placeholder-restores-selection-expected.txt: Added.
* LayoutTests/editing/text-placeholder/removing-placeholder-restores-selection.html: Added.
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::removeTextPlaceholder):

Canonical link: https://commits.webkit.org/267854@main




More information about the webkit-changes mailing list