Bug 174393 - AX: [iOS] Implement a way to retrieve a text marker range with desired text that is closest to a position
Summary: AX: [iOS] Implement a way to retrieve a text marker range with desired text t...
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-07-11 15:08 PDT by Nan Wang
Modified: 2017-07-12 15:20 PDT (History)
13 users (show)

See Also:


Attachments
Patch (20.18 KB, patch)
2017-07-11 15:32 PDT, Nan Wang
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-elcapitan (1.34 MB, application/zip)
2017-07-11 16:51 PDT, Build Bot
no flags Details
patch (20.24 KB, patch)
2017-07-11 17:31 PDT, Nan Wang
no flags Details | Formatted Diff | Diff
patch (20.90 KB, patch)
2017-07-11 23:31 PDT, Nan Wang
no flags Details | Formatted Diff | Diff
patch (20.72 KB, patch)
2017-07-12 00:54 PDT, Nan Wang
cfleizach: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews125 for ios-simulator-wk2 (11.70 MB, application/zip)
2017-07-12 03:40 PDT, Build Bot
no flags Details
Patch (20.75 KB, patch)
2017-07-12 14:08 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-07-11 15:08:01 PDT
On iOS, we should have a way to retrieve a text marker range with desired text that is closest to a certain position. So that clients that only know NSRange can get more accurate text range from the webcore.
Comment 1 Radar WebKit Bug Importer 2017-07-11 15:08:30 PDT
<rdar://problem/33248006>
Comment 2 Nan Wang 2017-07-11 15:32:11 PDT
Created attachment 315175 [details]
Patch
Comment 3 Build Bot 2017-07-11 16:50:59 PDT
Comment on attachment 315175 [details]
Patch

Attachment 315175 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/4103555

New failing tests:
storage/indexeddb/modern/new-database-after-user-delete.html
Comment 4 Build Bot 2017-07-11 16:51:00 PDT
Created attachment 315192 [details]
Archive of layout-test-results from ews100 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 5 chris fleizach 2017-07-11 16:55:54 PDT
Comment on attachment 315175 [details]
Patch

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

> Source/WebCore/accessibility/AXObjectCache.cpp:1756
> +    auto range = Range::create(m_document, startPosition, originalRange->startPosition());

does auto handle the RefPtr<Range> creation so that this gets released?

> Tools/DumpRenderTree/AccessibilityUIElement.cpp:1488
> +    JSStringRef searchText = 0;

nullptr

> Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm:626
> +    NSArray *textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil];

do we need to worry that startMarker->platformTextMarker() might be null?
Comment 6 Nan Wang 2017-07-11 17:04:34 PDT
Comment on attachment 315175 [details]
Patch

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

>> Source/WebCore/accessibility/AXObjectCache.cpp:1756
>> +    auto range = Range::create(m_document, startPosition, originalRange->startPosition());
> 
> does auto handle the RefPtr<Range> creation so that this gets released?

Range::create will generate a reference, Range&

>> Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm:626
>> +    NSArray *textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil];
> 
> do we need to worry that startMarker->platformTextMarker() might be null?

Ok
Comment 7 Nan Wang 2017-07-11 17:09:01 PDT
Comment on attachment 315175 [details]
Patch

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

>>> Source/WebCore/accessibility/AXObjectCache.cpp:1756
>>> +    auto range = Range::create(m_document, startPosition, originalRange->startPosition());
>> 
>> does auto handle the RefPtr<Range> creation so that this gets released?
> 
> Range::create will generate a reference, Range&

nevermind, will double check
Comment 8 Nan Wang 2017-07-11 17:31:27 PDT
Created attachment 315196 [details]
patch

updated from review
Comment 9 chris fleizach 2017-07-11 17:46:53 PDT
Comment on attachment 315196 [details]
patch

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

> Source/WebCore/accessibility/AXObjectCache.cpp:1752
> +    auto searchRange = Range::create(m_document, startPosition, endPosition);

another Range::Create here

> Source/WebCore/accessibility/AXObjectCache.h:336
> +    RefPtr<Range> rangeMatchesTextNearRange(RefPtr<Range> originalRange, const String& matchText);

probably don't need to put argument names here

> Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:64
> +#import <UIKit/UIGeometry.h>

what is this one used for?

> Tools/DumpRenderTree/AccessibilityUIElement.cpp:1489
> +    AccessibilityTextMarker* startMarker = 0;

nullptr

> Tools/DumpRenderTree/AccessibilityUIElement.cpp:1490
> +    AccessibilityTextMarker* endMarker = 0;

nullptr

> Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:1207
> +    

extra line
Comment 10 Nan Wang 2017-07-11 23:30:16 PDT
Comment on attachment 315196 [details]
patch

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

>> Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:64
>> +#import <UIKit/UIGeometry.h>
> 
> what is this one used for?

For [NSValue valueWithCGRect:rect]
Comment 11 Nan Wang 2017-07-11 23:31:21 PDT
Created attachment 315210 [details]
patch

More review comments
Comment 12 chris fleizach 2017-07-12 00:35:08 PDT
Comment on attachment 315210 [details]
patch

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

> Source/WebCore/accessibility/AXObjectCache.cpp:1732
> +    RefPtr<ContainerNode> root;

does this need to be initialized to nullptr?

> Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:64
> +#import <UIKit/UIGeometry.h>

I think you can use valueWithRect which is in foundation/nsgeometry.h

I think that will just work. not sure if you even need an import for that
Comment 13 Nan Wang 2017-07-12 00:47:09 PDT
Comment on attachment 315210 [details]
patch

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

>> Source/WebCore/accessibility/AXObjectCache.cpp:1732
>> +    RefPtr<ContainerNode> root;
> 
> does this need to be initialized to nullptr?

root will be set in indexForVisiblePosition(position, root), but yes I can initialize that.
Comment 14 Nan Wang 2017-07-12 00:52:31 PDT
(In reply to Nan Wang from comment #13)
> Comment on attachment 315210 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=315210&action=review
> 
> >> Source/WebCore/accessibility/AXObjectCache.cpp:1732
> >> +    RefPtr<ContainerNode> root;
> > 
> > does this need to be initialized to nullptr?
> 
> root will be set in indexForVisiblePosition(position, root), but yes I can
> initialize that.

I've checked most use cases of indexForVisiblePosition(position, root) in the project, and they didn't initialize the ContainerNode scope. So I will keep the consistency.
Comment 15 Nan Wang 2017-07-12 00:54:46 PDT
Created attachment 315214 [details]
patch

more updates
Comment 16 Build Bot 2017-07-12 03:40:11 PDT
Comment on attachment 315214 [details]
patch

Attachment 315214 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/4106126

New failing tests:
imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/invalid-src.html
Comment 17 Build Bot 2017-07-12 03:40:13 PDT
Created attachment 315226 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.5
Comment 18 Nan Wang 2017-07-12 09:38:11 PDT
test failure shouldn't be related
Comment 19 Nan Wang 2017-07-12 10:58:27 PDT
Committed r219409: <http://trac.webkit.org/changeset/219409>
Comment 21 chris fleizach 2017-07-12 13:08:06 PDT
(In reply to Matt Lewis from comment #20)
> The revision r21940 has broken the windows builds.
> 
> https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/
> 2973/steps/compile-webkit/logs/stdio
> https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/
> 2974

Are we sure that's related. The error seems to be

===== BUILD FAILED ======

Please ensure you have run Tools/Scripts/update-webkit to install dependencies.
Comment 22 chris fleizach 2017-07-12 13:08:30 PDT
(In reply to chris fleizach from comment #21)
> (In reply to Matt Lewis from comment #20)
> > The revision r21940 has broken the windows builds.
> > 
> > https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/
> > 2973/steps/compile-webkit/logs/stdio
> > https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/
> > 2974
> 
> Are we sure that's related. The error seems to be
> 
> ===== BUILD FAILED ======
> 
> Please ensure you have run Tools/Scripts/update-webkit to install
> dependencies.

Nevermind
here's the error

C:\cygwin\home\buildbot\slave\win-release\build\Tools\DumpRenderTree\AccessibilityUIElement.cpp(1724): error C2039: 'textMarkerRangeMatchesTextNearMarkers': is not a member of 'AccessibilityUIElement' [C:\cygwin\home\buildbot\slave\win-release\build\WebKitBuild\Release\Tools\DumpRenderTree\DumpRenderTreeLib.vcxproj]
Comment 23 Matt Lewis 2017-07-12 13:12:10 PDT
(In reply to chris fleizach from comment #22)
> (In reply to chris fleizach from comment #21)
> > (In reply to Matt Lewis from comment #20)
> > > The revision r21940 has broken the windows builds.
> > > 
> > > https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/
> > > 2973/steps/compile-webkit/logs/stdio
> > > https://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/
> > > 2974
> > 
> > Are we sure that's related. The error seems to be
> > 
> > ===== BUILD FAILED ======
> > 
> > Please ensure you have run Tools/Scripts/update-webkit to install
> > dependencies.
> 
> Nevermind
> here's the error
> 
> C:\cygwin\home\buildbot\slave\win-
> release\build\Tools\DumpRenderTree\AccessibilityUIElement.cpp(1724): error
> C2039: 'textMarkerRangeMatchesTextNearMarkers': is not a member of
> 'AccessibilityUIElement'
> [C:\cygwin\home\buildbot\slave\win-
> release\build\WebKitBuild\Release\Tools\DumpRenderTree\DumpRenderTreeLib.
> vcxproj]

Was about to respond with that! Thanks!
Comment 24 Matt Lewis 2017-07-12 13:57:47 PDT
Reverted r219409 for reason:

The revision caused the Windows builds to fail.

Committed r219424: <http://trac.webkit.org/changeset/219424>
Comment 25 Nan Wang 2017-07-12 14:08:27 PDT
Created attachment 315281 [details]
Patch

Fix windows build
Comment 26 WebKit Commit Bot 2017-07-12 15:20:47 PDT
Comment on attachment 315281 [details]
Patch

Clearing flags on attachment: 315281

Committed r219426: <http://trac.webkit.org/changeset/219426>
Comment 27 WebKit Commit Bot 2017-07-12 15:20:49 PDT
All reviewed patches have been landed.  Closing bug.