Bug 233336

Summary: AX: WebKit: need a method to get visible text and frame of an element on screen
Product: WebKit Reporter: chris fleizach <cfleizach>
Component: AccessibilityAssignee: chris fleizach <cfleizach>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, tyler_w, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
patch
none
patch
none
patch
ews-feeder: commit-queue-
patch
none
patch
none
patch
none
patch
ews-feeder: commit-queue-
patch
none
patch
none
patch
none
patch
ews-feeder: commit-queue-
patch
none
patch
none
patch
ews-feeder: commit-queue-
patch
none
patch
none
patch
andresg_22: review+, ews-feeder: commit-queue-
patch none

chris fleizach
Reported 2021-11-18 14:42:16 PST
We can determine what elements are on screen, but there is no good way to determine if the content in an element is on screen. If an element is only partially visible, we need to know what the visible content is, and what the accessibilityFrame is of that content. This is to support Books <rdar://problem/83657171>
Attachments
patch (26.34 KB, patch)
2021-11-18 14:52 PST, chris fleizach
no flags
patch (26.37 KB, patch)
2021-11-18 16:04 PST, chris fleizach
no flags
patch (26.39 KB, patch)
2021-11-18 16:06 PST, chris fleizach
ews-feeder: commit-queue-
patch (27.12 KB, patch)
2021-11-19 00:15 PST, chris fleizach
no flags
patch (48.47 KB, patch)
2021-11-19 17:07 PST, chris fleizach
no flags
patch (48.47 KB, patch)
2021-11-19 17:09 PST, chris fleizach
no flags
patch (56.51 KB, patch)
2021-11-19 17:16 PST, chris fleizach
ews-feeder: commit-queue-
patch (57.65 KB, patch)
2021-11-19 23:58 PST, chris fleizach
no flags
patch (49.81 KB, patch)
2021-11-19 23:59 PST, chris fleizach
no flags
patch (49.52 KB, patch)
2021-11-20 00:00 PST, chris fleizach
no flags
patch (49.52 KB, patch)
2021-11-20 00:11 PST, chris fleizach
ews-feeder: commit-queue-
patch (50.32 KB, patch)
2021-11-20 22:05 PST, chris fleizach
no flags
patch (50.29 KB, patch)
2021-11-20 22:55 PST, chris fleizach
no flags
patch (50.30 KB, patch)
2021-11-20 23:37 PST, chris fleizach
ews-feeder: commit-queue-
patch (50.36 KB, patch)
2021-11-21 21:34 PST, chris fleizach
no flags
patch (50.19 KB, patch)
2021-11-21 21:37 PST, chris fleizach
no flags
patch (50.19 KB, patch)
2021-11-21 21:38 PST, chris fleizach
andresg_22: review+
ews-feeder: commit-queue-
patch (50.16 KB, patch)
2021-11-22 07:41 PST, chris fleizach
no flags
chris fleizach
Comment 1 2021-11-18 14:52:05 PST
Tyler Wilcock
Comment 2 2021-11-18 15:48:11 PST
Comment on attachment 444744 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=444744&action=review > Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:491 > + std::optional<BoundaryPoint> endBoundary = range->end; Can these be auto? > Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:498 > + std::optional<BoundaryPoint> testStartBoundary = makeBoundaryPoint(nextLinePosition); Can this be auto? > Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:511 > + std::optional<BoundaryPoint> testEndBoundary = makeBoundaryPoint(previousLinePosition); Can this be auto? > Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:784 > +- (WebCore::AXCoreObject*)initializeBackingsStore Is this a typo (extra s)? initializeBackingsStore vs. initializeBackingStore
chris fleizach
Comment 3 2021-11-18 15:49:55 PST
Comment on attachment 444744 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=444744&action=review >> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:491 >> + std::optional<BoundaryPoint> endBoundary = range->end; > > Can these be auto? no it picks the wrong type >> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:498 >> + std::optional<BoundaryPoint> testStartBoundary = makeBoundaryPoint(nextLinePosition); > > Can this be auto? ditto >> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm:784 >> +- (WebCore::AXCoreObject*)initializeBackingsStore > > Is this a typo (extra s)? initializeBackingsStore vs. initializeBackingStore yea true
chris fleizach
Comment 4 2021-11-18 16:04:56 PST
chris fleizach
Comment 5 2021-11-18 16:06:51 PST
chris fleizach
Comment 6 2021-11-19 00:15:39 PST
Andres Gonzalez
Comment 7 2021-11-19 05:41:05 PST
(In reply to chris fleizach from comment #6) > Created attachment 444785 [details] > patch --- a/LayoutTests/accessibility/mac/visible-character-range.html +++ a/LayoutTests/accessibility/mac/visible-character-range.html +<script src="../../resources/js-test-pre.js"></script> Do just +<script src="../../resources/js-test.js"></script> no -pre. +<p id="description"></p> +<div id="console"></div> Remove these two lines, no needed any more. + if (window.accessibilityController) { + + var text = accessibilityController.accessibleElementById("group").childAtIndex(0); looks like indentation is off here, extra spaces. +<script src="../../resources/js-test-post.js"></script> Remove this line, not needed any more.
Andres Gonzalez
Comment 8 2021-11-19 06:51:18 PST
(In reply to chris fleizach from comment #6) > Created attachment 444785 [details] > patch --- a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm +++ a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm +#import "Position.h" ... +#import "SimpleRange.h" Doesn't seem right that we have to import Position.h here. +- (CGRect)frameForRange:(NSRange)range +{ + auto webRange = [self convertToDOMRange:range]; + if (!webRange) + return CGRectZero; + auto rect = self.axBackingObject->boundsForRange(*webRange); + return [self convertRectToSpace:rect space:AccessibilityConversionSpace::Screen]; +} Don't we need to check for if (![self _prepareAccessibilityCall]) --- a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h +++ a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.h +- (WebCore::FloatRect)accessibilityUnobscuredContentRect; Shouldn't this be in the core code instead of in the wrapper? +- (std::optional<WebCore::SimpleRange>)convertToDOMRange:(NSRange)range; ... +extern NSRange convertToNSRange(const WebCore::SimpleRange&); Can we make the first one also a function so that we have a symmetric pair of convert functions? Also consider "make" instead of "convert" for the names since it seems that that's the trend in other conversion functions in WebKit. --- a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm +++ a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm +- (FloatRect)accessibilityUnobscuredContentRect +{ + auto document = self.axBackingObject->document(); + if (!document || !document->view()) + return { }; + return FloatRect(snappedIntRect(document->view()->unobscuredContentRect())); +} Should be an AXCoreObject method instead. +- (NSRange)accessibilityVisibleCharacterRange The algorithm implementation of moving by line and intersecting with the given rect should be a core method, and then this wrapper method would do the conversions to NSRange of the result. + NSRange fullRange = convertToNSRange(SimpleRange(*startBoundary, *endBoundary)); Can we use initializer list instead of SimpleRange(...)? +- (WebCore::AXCoreObject*)initializeBackingStore This does more than initializing, it updates. Since we already are using updateObjectBackingStore, perhaps we can call this one just updateBackingStore? or _updateBackingStore?
Andres Gonzalez
Comment 9 2021-11-19 06:54:15 PST
(In reply to chris fleizach from comment #6) > Created attachment 444785 [details] > patch The test should also be enabled on iOS.
chris fleizach
Comment 10 2021-11-19 17:07:52 PST
chris fleizach
Comment 11 2021-11-19 17:09:34 PST
chris fleizach
Comment 12 2021-11-19 17:16:15 PST
chris fleizach
Comment 13 2021-11-19 23:58:09 PST
chris fleizach
Comment 14 2021-11-19 23:59:01 PST
chris fleizach
Comment 15 2021-11-20 00:00:09 PST
chris fleizach
Comment 16 2021-11-20 00:11:55 PST
chris fleizach
Comment 17 2021-11-20 22:05:10 PST
chris fleizach
Comment 18 2021-11-20 22:55:32 PST
chris fleizach
Comment 19 2021-11-20 23:37:11 PST
chris fleizach
Comment 20 2021-11-21 21:34:51 PST
chris fleizach
Comment 21 2021-11-21 21:37:10 PST
chris fleizach
Comment 22 2021-11-21 21:38:26 PST
Andres Gonzalez
Comment 23 2021-11-22 06:52:26 PST
(In reply to chris fleizach from comment #22) > Created attachment 444942 [details] > patch --- a/Source/WebCore/accessibility/AccessibilityObject.cpp +++ a/Source/WebCore/accessibility/AccessibilityObject.cpp +std::optional<SimpleRange> AccessibilityObject::visibleCharacterRange() const +{ ... + return SimpleRange(*startBoundary, *endBoundary); +} I think you may be able to do the more stylish: return {{ *startBoundary, *endBoundary }};
chris fleizach
Comment 24 2021-11-22 07:41:00 PST
EWS
Comment 25 2021-11-22 12:34:26 PST
Committed r286116 (244503@main): <https://commits.webkit.org/244503@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 444966 [details].
Note You need to log in before you can comment on or make changes to this bug.