Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4d7674e3b99d52397632cd994afb20b7e7da5371
      
https://github.com/WebKit/WebKit/commit/4d7674e3b99d52397632cd994afb20b7e7da5371
  Author: Joshua Hoffman <[email protected]>
  Date:   2023-09-14 (Thu, 14 Sep 2023)

  Changed paths:
    A 
LayoutTests/accessibility/ios-simulator/inline-prediction-attributed-string-expected.txt
    A 
LayoutTests/accessibility/ios-simulator/inline-prediction-attributed-string.html
    M LayoutTests/platform/ios-16/TestExpectations
    M Source/WebCore/accessibility/AXObjectCache.cpp
    M Source/WebCore/accessibility/AXObjectCache.h
    M Source/WebCore/accessibility/AccessibilityObject.h
    M Source/WebCore/accessibility/AccessibilityObjectInterface.h
    M Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm
    M Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h
    M Source/WebCore/editing/Editor.cpp

  Log Message:
  -----------
  AX: Expose accessibility attributes for inline text predictions
https://bugs.webkit.org/show_bug.cgi?id=261056
rdar://114844079

Reviewed by Andres Gonzalez.

At present, WebKit does not expose inline predictions to AX clients on iOS. 
This patch addresses that by adding the attributes
UIAccessibilityInlineTextCompletion and 
UIAccessibilityAcceptedInlineTextCompletion to the attributed string provided 
to ATs.

This is accomplished through two new member variables in accessibility objects, 
which are updated in
AccessibilityObject::setLastPresentedTextPrediction (iOS only):
- m_lastPresentedTextPrediction: the "rest" of the word being predicted. For 
example, if the text "opportun" had been typed, and
"ity" was presented as a prediction, we would store "ity".
- m_lastPresentedTextPredictionComplete: the whole word being predicted. Using 
the previous example, we would store the whole word,
"opportunity".

In both cases, we store the string value and the position, offset to the start 
of the editor. LastPresentedTextPrediction is reset
once a prediction is "accepted", and m_lastPresentedTextPredictionComplete is 
reset once we start a new composition.

In the iOS accessibility wrapper, we access these values and apply them to the 
resulting attributed string, if applicable. The
attributedStringSetCompositionAttributes method handles this work, and checks 
the location and range of the values to ensure
that they are valid.

This patch also includes a new test that simulates inline predictions and 
checks that the correct attributes are exposed.

* 
LayoutTests/accessibility/ios-simulator/inline-prediction-attributed-string-expected.txt:
 Added.
* 
LayoutTests/accessibility/ios-simulator/inline-prediction-attributed-string.html:
 Added.
* LayoutTests/platform/ios-16/TestExpectations:
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::onTextCompositionChange):
* Source/WebCore/accessibility/AXObjectCache.h:
(WebCore::AXObjectCache::onTextCompositionChange):
* Source/WebCore/accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::InlineTextPrediction::reset):
(WebCore::AccessibilityObject::lastPresentedTextPrediction const):
(WebCore::AccessibilityObject::lastPresentedTextPredictionComplete const):
* Source/WebCore/accessibility/AccessibilityObjectInterface.h:
* Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm:
(WebCore::AccessibilityObject::setLastPresentedTextPrediction):
(WebCore::attributedStringSetCompositionAttributes):
(WebCore::attributedStringCreate):
* Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.h:
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::setComposition):

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to