Bug 208352 - Page::editableElementsInRect() should find nested editable elements and return found elements in paint order
Summary: Page::editableElementsInRect() should find nested editable elements and retur...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-27 16:21 PST by Daniel Bates
Modified: 2020-03-02 11:54 PST (History)
7 users (show)

See Also:


Attachments
Patch (7.68 KB, patch)
2020-02-27 16:32 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (10.33 KB, patch)
2020-02-29 15:44 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch + iOS guess (12.88 KB, patch)
2020-02-29 16:05 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (12.82 KB, patch)
2020-03-01 16:23 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (13.08 KB, patch)
2020-03-01 16:25 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
To land (13.09 KB, patch)
2020-03-02 10:49 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
To land - removed unused Deque header (13.32 KB, patch)
2020-03-02 11:03 PST, Daniel Bates
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2020-02-27 16:21:50 PST
Page::editableElementsInRect() cannot find nested editable elements and the order of the returned elements are in DOM order, not paint order. The former means that a client can never get a hold of those elements. The latter means that a client cannot tell which element is closest to a person's face.
Comment 1 Radar WebKit Bug Importer 2020-02-27 16:22:03 PST
<rdar://problem/59867815>
Comment 2 Daniel Bates 2020-02-27 16:32:23 PST
Created attachment 391940 [details]
Patch
Comment 3 Daniel Bates 2020-02-29 15:44:08 PST
Created attachment 392075 [details]
Patch

Update test results for Mac.
Comment 4 Daniel Bates 2020-02-29 15:45:40 PST
Comment on attachment 392075 [details]
Patch

Patch does not address the iOS test failure and more likely the updated results will cause more iOS test failures. I am very suspicious of "[webView scrollView].contentOffset = ..." in the test code. I would have expected window.scrollTo() to also work on iOS. In fact, as I'm typing this now and thinking about how iOS is currently failing I think setting .contentOffset will never produce good results because the engine is never told about the scroll position change so it cannot update its visible content rect and hit testing will fail.

The kind of failure seen on the bots in the earlier patch: the test is hit testing at the top of the document (scrolled offscreen). As to why the test passes before my change. I can answer that: the original code was ASYMMETRIC! Walking the DOM will find things **outside the visible viewport** whereas hit testing will NOT, by default.
Comment 5 Daniel Bates 2020-02-29 15:51:37 PST
Just to be clear, the asymmetry with the current code that the visible content rect in the UI process does NOT match the visible content rect in the web process. In the UI process, the visible content rect reflects the set contentOffset, but the web process never is told about this offset.
Comment 6 Daniel Bates 2020-02-29 15:55:21 PST
^^^ both of those comments about iOS are guesses....I'll find out soon...
Comment 7 Daniel Bates 2020-02-29 16:05:33 PST
Created attachment 392078 [details]
Patch + iOS guess
Comment 8 Daniel Bates 2020-03-01 14:54:38 PST
Comment on attachment 392078 [details]
Patch + iOS guess

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

> Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:147
> +    [webView _scheduleVisibleContentRectUpdate];

schedule is not enough.... need to wait...-_doAfterNextVisibleContentRectUpdate
Comment 9 Daniel Bates 2020-03-01 16:23:16 PST
Created attachment 392106 [details]
Patch
Comment 10 Daniel Bates 2020-03-01 16:25:25 PST
Created attachment 392107 [details]
Patch
Comment 11 Daniel Bates 2020-03-01 16:31:57 PST
Comment on attachment 392107 [details]
Patch

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

> Tools/ChangeLog:13
> +        to a y position of 50000. Otherwise, it's impossible to do because the page height is < 5000px.

5000 not 50000!
Comment 12 Wenson Hsieh 2020-03-02 09:41:30 PST
Comment on attachment 392107 [details]
Patch

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

> Source/WebCore/page/Page.cpp:930
> +    auto* frameView = mainFrame().view();

auto frameView = makeRefPtr(mainFrame().view());

We generally ref local variables like this in new code (especially in this case, since the hit-testing code below will trigger layout).

> Source/WebCore/page/Page.cpp:934
> +    auto* document = mainFrame().document();

Ditto.
Comment 13 Daniel Bates 2020-03-02 10:23:44 PST
Comment on attachment 392107 [details]
Patch

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

Thanks for the review!

>> Source/WebCore/page/Page.cpp:930
>> +    auto* frameView = mainFrame().view();
> 
> auto frameView = makeRefPtr(mainFrame().view());
> 
> We generally ref local variables like this in new code (especially in this case, since the hit-testing code below will trigger layout).

OK

>> Source/WebCore/page/Page.cpp:934
>> +    auto* document = mainFrame().document();
> 
> Ditto.

OK
Comment 14 Daniel Bates 2020-03-02 10:49:37 PST
Created attachment 392154 [details]
To land
Comment 15 Daniel Bates 2020-03-02 11:03:56 PST
Created attachment 392155 [details]
To land - removed unused Deque header
Comment 16 Daniel Bates 2020-03-02 11:54:47 PST
Comment on attachment 392155 [details]
To land - removed unused Deque header

Clearing flags on attachment: 392155

Committed r257722: <https://trac.webkit.org/changeset/257722>
Comment 17 Daniel Bates 2020-03-02 11:54:49 PST
All reviewed patches have been landed.  Closing bug.