Bug 176247 - AX: Provide a way for Accessibility to cache the selection while retrieving rects for speak selection
Summary: AX: Provide a way for Accessibility to cache the selection while retrieving r...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-01 15:29 PDT by Nan Wang
Modified: 2017-10-19 16:34 PDT (History)
8 users (show)

See Also:


Attachments
patch (13.24 KB, patch)
2017-09-01 16:23 PDT, Nan Wang
no flags Details | Formatted Diff | Diff
patch (13.44 KB, patch)
2017-10-16 16:58 PDT, Nan Wang
no flags Details | Formatted Diff | Diff
patch (13.28 KB, patch)
2017-10-19 09:31 PDT, Nan Wang
rniwa: review+
Details | Formatted Diff | Diff
patch to land (13.65 KB, patch)
2017-10-19 14:43 PDT, Nan Wang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nan Wang 2017-09-01 15:29:13 PDT
_accessibilityRetrieveRectsAtSelectionOffset:withText: is problematic for speak selection since it would use the current selection as the search range. The rects would be wrong when a speak session is active and the user tries to select some other text.
Comment 1 Radar WebKit Bug Importer 2017-09-01 15:29:31 PDT
<rdar://problem/34217143>
Comment 2 Nan Wang 2017-09-01 16:23:04 PDT
Created attachment 319665 [details]
patch
Comment 3 Nan Wang 2017-10-16 16:58:14 PDT
Created attachment 323958 [details]
patch

merge with TOT
Comment 4 Nan Wang 2017-10-17 08:39:12 PDT
Comment on attachment 323958 [details]
patch

Can someone take a look? Thanks!
Comment 5 Ryosuke Niwa 2017-10-18 18:55:56 PDT
Comment on attachment 323958 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323958&action=review

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:1893
> +void WebPage::cacheSelectionForAccessibility(bool shouldCache)

I don't think we should call this a "cache" since what we're doing here is to save the selection at the time of invocation.
A better name might be like storeSelectionForAccessibility or freezeSelectionForAccessibility.

There is an alternative approach which is to expose some sort of opaque object like WKWebViewSelection
and then add a new variant of getRectsForGranularityWithSelectionOffset which takes that opaque object
and computes the correct rect but that might be a bit of an overkill for this particular bug.
Comment 6 Ryosuke Niwa 2017-10-18 18:57:03 PDT
By the way, feel free to email my webkit.org or apple.com email address if you need a code review.
Comment 7 Nan Wang 2017-10-19 08:42:51 PDT
Comment on attachment 323958 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=323958&action=review

>> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:1893
>> +void WebPage::cacheSelectionForAccessibility(bool shouldCache)
> 
> I don't think we should call this a "cache" since what we're doing here is to save the selection at the time of invocation.
> A better name might be like storeSelectionForAccessibility or freezeSelectionForAccessibility.
> 
> There is an alternative approach which is to expose some sort of opaque object like WKWebViewSelection
> and then add a new variant of getRectsForGranularityWithSelectionOffset which takes that opaque object
> and computes the correct rect but that might be a bit of an overkill for this particular bug.

Thanks for the alternative approach! But for this particular bug I think it's more straightforward to go with the current approach and it's easier for the iOS assistive technology to adapt the changes.
I will rename them.
Comment 8 Nan Wang 2017-10-19 08:43:08 PDT
(In reply to Ryosuke Niwa from comment #6)
> By the way, feel free to email my webkit.org or apple.com email address if
> you need a code review.

Sure! Thanks for the review.
Comment 9 Nan Wang 2017-10-19 09:31:06 PDT
Created attachment 324241 [details]
patch

rename
Comment 10 Ryosuke Niwa 2017-10-19 13:29:30 PDT
Comment on attachment 324241 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=324241&action=review

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:2313
> +- (void)_accessibilityStoreSelection:(BOOL)shouldStore
> +{
> +    _page->storeSelectionForAccessibility(shouldStore);
> +}

Maybe it's better to add _accessibilityClearSelection instead of making this method take a bool
It's kind of weird to say _accessibilityStoreSelection: FALSE.
It sounds as if we're going to not store selection in the future instead of the call directly clearing what's already been stored.
Comment 11 Nan Wang 2017-10-19 13:41:21 PDT
(In reply to Ryosuke Niwa from comment #10)
> Comment on attachment 324241 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=324241&action=review
> 
> > Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:2313
> > +- (void)_accessibilityStoreSelection:(BOOL)shouldStore
> > +{
> > +    _page->storeSelectionForAccessibility(shouldStore);
> > +}
> 
> Maybe it's better to add _accessibilityClearSelection instead of making this
> method take a bool
> It's kind of weird to say _accessibilityStoreSelection: FALSE.
> It sounds as if we're going to not store selection in the future instead of
> the call directly clearing what's already been stored.

Ok I will make another patch to address this.
Comment 12 Nan Wang 2017-10-19 14:43:51 PDT
Created attachment 324294 [details]
patch to land

update from review
Comment 13 Nan Wang 2017-10-19 14:45:10 PDT
I want to make sure tests are still passing. 
Ryosuke, can you take a quick look again? Thanks.
Comment 14 WebKit Commit Bot 2017-10-19 16:34:20 PDT
Comment on attachment 324294 [details]
patch to land

Clearing flags on attachment: 324294

Committed r223726: <https://trac.webkit.org/changeset/223726>
Comment 15 WebKit Commit Bot 2017-10-19 16:34:22 PDT
All reviewed patches have been landed.  Closing bug.