[webkit-changes] [WebKit/WebKit] 4b8b62: AX: AXTextOperation over multiple ranges is entire...

Samar Sunkaria noreply at github.com
Mon Oct 7 19:17:41 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4b8b62af6ff69eda42b461cbc3c46ec15428ca25
      https://github.com/WebKit/WebKit/commit/4b8b62af6ff69eda42b461cbc3c46ec15428ca25
  Author: Samar Sunkaria <sameesunkaria at me.com>
  Date:   2024-10-07 (Mon, 07 Oct 2024)

  Changed paths:
    M LayoutTests/accessibility/mac/text-operation/text-operation-capitalize-expected.txt
    M LayoutTests/accessibility/mac/text-operation/text-operation-lowercase-expected.txt
    A LayoutTests/accessibility/mac/text-operation/text-operation-replace-across-multiple-fields-expected.txt
    A LayoutTests/accessibility/mac/text-operation/text-operation-replace-across-multiple-fields.html
    A LayoutTests/accessibility/mac/text-operation/text-operation-replace-at-node-boundary-expected.txt
    A LayoutTests/accessibility/mac/text-operation/text-operation-replace-at-node-boundary.html
    M LayoutTests/accessibility/mac/text-operation/text-operation-smart-replace-expected.txt
    M LayoutTests/accessibility/mac/text-operation/text-operation-uppercase-expected.txt
    M LayoutTests/platform/mac-wk1/TestExpectations
    M LayoutTests/platform/mac-wk2/TestExpectations
    M LayoutTests/resources/accessibility-helper.js
    M Source/WebCore/accessibility/AccessibilityObject.cpp

  Log Message:
  -----------
  AX: AXTextOperation over multiple ranges is entirely broken
https://bugs.webkit.org/show_bug.cgi?id=278928
rdar://problem/135021789

Reviewed by Tyler Wilcock.

While the AXTextOperation parameterized accessibility attribute provides an API for replacing
multiple ranges of text, in practice it would fail to apply changes after the first replacement in
many cases, especially when using smart replacement.

This was happening because after performing a replacement, in some cases, the remaining SimpleRanges
in `AccessibilityTextOperation` become orphaned as the node they were referring to would no longer
be in the tree. Specifically, this happened whenever the replacement was not performed using
`ReplaceSelectionCommand::performTrivialReplace` but instead followed the longer path in
`ReplaceSelectionCommand::doApply`.

To address this issue, before performing any replacements, we construct character ranges with
respect to their root editable element for all of the provided ranges. The root editable element
seems to be preserved in the tree after performing a replacement using the `ReplaceSelectionCommand`.
Then, we can reconstruct the `SimpleRange` for each replacement, ensuring we always use a valid
SimpleRange.

* LayoutTests/accessibility/mac/text-operation/text-operation-capitalize-expected.txt:
* LayoutTests/accessibility/mac/text-operation/text-operation-lowercase-expected.txt:
* LayoutTests/accessibility/mac/text-operation/text-operation-replace-across-multiple-fields-expected.txt: Added.
* LayoutTests/accessibility/mac/text-operation/text-operation-replace-across-multiple-fields.html: Added.

AXTextOperation can be provided text marker ranges from multiple editable fields on a page.
This test ensures that replacements are performed correctly across multiple fields.

* LayoutTests/accessibility/mac/text-operation/text-operation-replace-at-node-boundary-expected.txt: Added.
* LayoutTests/accessibility/mac/text-operation/text-operation-replace-at-node-boundary.html: Added.

Using ReplaceSelectionCommand to perform a replacement over a zero-length range (effectively
an insert) at node boundaries can result in one less whitespace than expected. To resolve
this, AccessibilityObject::performTextOperation now inserts text instead of replacing it when
the selection length is zero.

This test asserts on the correct behavior for that edge case.

* LayoutTests/accessibility/mac/text-operation/text-operation-smart-replace-expected.txt:
* LayoutTests/accessibility/mac/text-operation/text-operation-uppercase-expected.txt:
* LayoutTests/platform/mac-wk1/TestExpectations:
* LayoutTests/platform/mac-wk2/TestExpectations:
* LayoutTests/resources/accessibility-helper.js:
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::textOperationRangeFromRange):
(WebCore::rangeFromTextOperationRange):
(WebCore::AccessibilityObject::performTextOperation):

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list