Bug 210697 - [iOS] -_didFinishTextInteractionInTextInputContext should only zoom to reveal focused element if it changed
Summary: [iOS] -_didFinishTextInteractionInTextInputContext should only zoom to reveal...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Local Build
Hardware: iPhone / iPad iOS 13
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks: 210704
  Show dependency treegraph
 
Reported: 2020-04-18 14:04 PDT by Daniel Bates
Modified: 2020-04-21 15:54 PDT (History)
6 users (show)

See Also:


Attachments
Patch and tests (35.86 KB, patch)
2020-04-18 15:29 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch and tests (35.08 KB, patch)
2020-04-18 16:23 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
To Land (46.87 KB, patch)
2020-04-21 13:19 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
To Land (46.70 KB, patch)
2020-04-21 13:21 PDT, 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-04-18 14:04:29 PDT
-_didFinishTextInteractionInTextInputContext should only zoom to reveal the focused element if it changed via a call to -_focusTextInputContext.
Comment 1 Daniel Bates 2020-04-18 14:04:44 PDT
<rdar://problem/60997530>
Comment 2 Daniel Bates 2020-04-18 14:11:51 PDT
The effect of this bug can be seen on a google.com using the following steps:

1. Visit google.com and search for "Disneyland" and scroll the page until the search field becomes fixed to the top of the page.
2. Use -_requestTextInputContextsInRect to get the context for the search field at the top of the page.
3. Call -_willBeginTextInteractionInTextInputContext with this context.
4. Call -_focusTextInputContext with this context.
5. Call -_didFinishTextInteractionInTextInputContext with this context.

Then the page will scroll to the top because -_didFinishTextInteractionInTextInputContext marks the view as needing to reveal the focused element.
Comment 3 Daniel Bates 2020-04-18 14:13:58 PDT
(In reply to Daniel Bates from comment #2)
> The effect of this bug can be seen on a google.com using the following steps:
> 
> 1. Visit google.com and search for "Disneyland" and scroll the page until
> the search field becomes fixed to the top of the page.

1.5. Tap on the search field

> 2. Use -_requestTextInputContextsInRect to get the context for the search
> field at the top of the page.
> 3. Call -_willBeginTextInteractionInTextInputContext with this context.
> 4. Call -_focusTextInputContext with this context.
> 5. Call -_didFinishTextInteractionInTextInputContext with this context.
> 
> Then the page will scroll to the top because
> -_didFinishTextInteractionInTextInputContext marks the view as needing to
> reveal the focused element.
Comment 4 Daniel Bates 2020-04-18 15:29:21 PDT
Created attachment 396866 [details]
Patch and tests
Comment 5 Daniel Bates 2020-04-18 16:00:57 PDT
This patch depends on the patch for bug #210624 due to placement of the added tests in the file.
Comment 6 Daniel Bates 2020-04-18 16:23:15 PDT
Created attachment 396872 [details]
Patch and tests
Comment 7 Daniel Bates 2020-04-18 21:58:25 PDT
Comment on attachment 396872 [details]
Patch and tests

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

> Source/WebKit/ChangeLog:26
> +        making this a FIXME, but this function is otherwise capable of handling multiple innocations

innocations  => invocations

> Source/WebKit/ChangeLog:31
> +        do everything we do now except for marking the page as needing reveal the focused element

Needing reveal  => needing to reveal

> Source/WebKit/ChangeLog:39
> +        element. Passing true to visiblePositionInFocusedNodeForPoint() asserts this to be true.

asserts  => will ultimately assert
Comment 8 Wenson Hsieh 2020-04-20 10:02:47 PDT
Comment on attachment 396872 [details]
Patch and tests

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

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:5104
> +        _textInteractionDidChangeFocusedElement |= NO;

Was this intended to be `_textInteractionDidChangeFocusedElement = NO;`? If not, can we just remove this line?

> Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:583
> +    // Zoom scale of scroll view should change to reveal the focused element.

I don’t believe this is true for iPad. Maybe we can only do the scale check if we’re on iPhone?

> Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:605
> +    // Zoom scale of scroll view should change to reveal the focused element.

Ditto.
Comment 9 Daniel Bates 2020-04-20 11:00:11 PDT
Comment on attachment 396872 [details]
Patch and tests

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

Thanks for the review, Wenson.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:5104
>> +        _textInteractionDidChangeFocusedElement |= NO;
> 
> Was this intended to be `_textInteractionDidChangeFocusedElement = NO;`? If not, can we just remove this line?

OK I'll remove this line.

>> Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:583
>> +    // Zoom scale of scroll view should change to reveal the focused element.
> 
> I don’t believe this is true for iPad. Maybe we can only do the scale check if we’re on iPhone?

I'll check on iPad.
Comment 10 Daniel Bates 2020-04-21 13:19:25 PDT
Created attachment 397109 [details]
To Land
Comment 11 Daniel Bates 2020-04-21 13:21:19 PDT
Created attachment 397110 [details]
To Land
Comment 12 Daniel Bates 2020-04-21 13:22:15 PDT
Comment on attachment 397110 [details]
To Land

Clearing flags on attachment: 397110

Committed r260449: <https://trac.webkit.org/changeset/260449>
Comment 13 Daniel Bates 2020-04-21 13:22:17 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Ryan Haddad 2020-04-21 15:46:09 PDT
(In reply to Daniel Bates from comment #12)
> Comment on attachment 397110 [details]
> To Land
> 
> Clearing flags on attachment: 397110
> 
> Committed r260449: <https://trac.webkit.org/changeset/260449>
This change broke the iOS build:
/Volumes/Data/slave/ios-13-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:550:5: error: unknown type name 'IPhoneUserInterfaceSwizzler'; did you mean 'TestWebKitAPI::IPhoneUserInterfaceSwizzler'?

https://build.webkit.org/builders/Apple%20iOS%2013%20Release%20%28Build%29/builds/6599/steps/compile-webkit/logs/stdio
Comment 15 Daniel Bates 2020-04-21 15:54:01 PDT
(In reply to Ryan Haddad from comment #14)
> (In reply to Daniel Bates from comment #12)
> > Comment on attachment 397110 [details]
> > To Land
> > 
> > Clearing flags on attachment: 397110
> > 
> > Committed r260449: <https://trac.webkit.org/changeset/260449>
> This change broke the iOS build:
> /Volumes/Data/slave/ios-13-release/build/Tools/TestWebKitAPI/Tests/
> WebKitCocoa/RequestTextInputContext.mm:550:5: error: unknown type name
> 'IPhoneUserInterfaceSwizzler'; did you mean
> 'TestWebKitAPI::IPhoneUserInterfaceSwizzler'?
> 
> https://build.webkit.org/builders/Apple%20iOS%2013%20Release%20%28Build%29/
> builds/6599/steps/compile-webkit/logs/stdio

Fixed in <https://trac.webkit.org/changeset/260469>