WebKit Bugzilla
Attachment 373082 Details for
Bug 199310
: -[WKContentView _selectionClipRects] returns a bogus value in -reloadInputViews when focusing an element
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix non-iOS builds
bug-199310-20190627214557.patch (text/plain), 11.43 KB, created by
Wenson Hsieh
on 2019-06-27 21:45:57 PDT
(
hide
)
Description:
Fix non-iOS builds
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-06-27 21:45:57 PDT
Size:
11.43 KB
patch
obsolete
>Subversion Revision: 246908 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f9d9b1731875be17e94a592b03c548eceaea5699..763b37aec479b2cb5ae813da5bc9741e60d141c2 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,28 @@ >+2019-06-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ -[WKContentView _selectionClipRects] returns a bogus value in -reloadInputViews when focusing an element >+ https://bugs.webkit.org/show_bug.cgi?id=199310 >+ <rdar://problem/52292137> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When reloading input views under -_elementDidFocus:, -_selectionClipRect returns the value of the previously >+ focused element; this is because _selectionClipRect depends on EditorState's post layout data, which is only >+ guaranteed to arrive during the next remote layer tree commit after the element is focused. >+ >+ However, some clients need to inspect this value under the call to -reloadInputViews when an element is focused; >+ to make this work, simply check whether we are currently waiting for post-layout EditorState data to arrive >+ following element focus; if so, return the FocusedElementInformation's elementRect, which represents the initial >+ state of the focused element. Otherwise, use the EditorState's post layout data, which is guaranteed to be more >+ up-to-date than the FocusedElementInformation's element rect. >+ >+ Test: KeyboardInputTests.SelectionClipRectsWhenPresentingInputView >+ >+ * UIProcess/WebPageProxy.h: >+ (WebKit::WebPageProxy::waitingForPostLayoutEditorStateUpdateAfterFocusingElement const): >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView _selectionClipRect]): >+ > 2019-06-27 Daniel Bates <dabates@apple.com> > > [iOS] Select all with existing range selection replaces range instead of selecting all text >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 2c540f7c05756ff8dd9468c3439fbd2d1bb9a54a..a80d15e458d643674a9a51d97fac444a237a7506 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1374,6 +1374,7 @@ public: > > #if PLATFORM(IOS_FAMILY) > void setIsKeyboardAnimatingIn(bool isKeyboardAnimatingIn) { m_isKeyboardAnimatingIn = isKeyboardAnimatingIn; } >+ bool waitingForPostLayoutEditorStateUpdateAfterFocusingElement() const { return m_waitingForPostLayoutEditorStateUpdateAfterFocusingElement; } > #endif > > #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index fa25ea91fa7997d4e7e11b3b3cd480acdf28ba8c..88d33ed2828dfa95d3ba5c6c9bc8000fa309df2b 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -1763,6 +1763,10 @@ - (CGRect)_selectionClipRect > { > if (!hasFocusedElement(_focusedElementInformation)) > return CGRectNull; >+ >+ if (_page->waitingForPostLayoutEditorStateUpdateAfterFocusingElement()) >+ return _focusedElementInformation.elementRect; >+ > return _page->editorState().postLayoutData().focusedElementRect; > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index e14b12394b510c1278ff483b17d556a5fbff8a48..75cacc600cdc3bfc39b7258680943c50781680f4 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,35 @@ >+2019-06-27 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ -[WKContentView _selectionClipRects] returns a bogus value in -reloadInputViews when focusing an element >+ https://bugs.webkit.org/show_bug.cgi?id=199310 >+ <rdar://problem/52292137> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a new API test to verify that _selectionClipRects returns the correct value when invoked under the scope of >+ _elementDidFocus. >+ >+ * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm: >+ (TestWebKitAPI::TEST): >+ * TestWebKitAPI/Tests/ios/TestInputDelegate.h: >+ * TestWebKitAPI/Tests/ios/TestInputDelegate.mm: >+ (-[TestInputDelegate setDidStartInputSessionHandler:]): >+ (-[TestInputDelegate didStartInputSessionHandler]): >+ >+ Add plumbing for a handler block in TestInputDelegate. >+ >+ (-[TestInputDelegate setWillStartInputSessionHandler:]): >+ >+ Drive-by style fixes to add a space between id and < for Objective-C protocols. >+ >+ (-[TestInputDelegate willStartInputSessionHandler]): >+ (-[TestInputDelegate _webView:willStartInputSession:]): >+ (-[TestInputDelegate _webView:didStartInputSession:]): >+ * TestWebKitAPI/cocoa/TestWKWebView.h: >+ * TestWebKitAPI/ios/UIKitSPI.h: >+ >+ Add a declaration for _selectionClipRects. >+ > 2019-06-27 Beth Dakin <bdakin@apple.com> > > Upstream use of MACCATALYST >diff --git a/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm b/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm >index a7ab42097fd6b3e96976553284954a3ab909a01f..350b6263ac5f1f9890df55bc00487a05a3062130 100644 >--- a/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm >+++ b/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm >@@ -505,6 +505,28 @@ TEST(KeyboardInputTests, DisableSmartQuotesAndDashes) > checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault); > } > >+TEST(KeyboardInputTests, SelectionClipRectsWhenPresentingInputView) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]); >+ [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy { >+ return _WKFocusStartsInputSessionPolicyAllow; >+ }]; >+ >+ CGRect selectionClipRect = CGRectNull; >+ [inputDelegate setDidStartInputSessionHandler:[&] (WKWebView *, id <_WKFormInputSession>) { >+ selectionClipRect = [[webView textInputContentView] _selectionClipRect]; >+ }]; >+ [webView _setInputDelegate:inputDelegate.get()]; >+ [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><input>"]; >+ [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.querySelector('input').focus()"]; >+ >+ EXPECT_EQ(10, selectionClipRect.origin.x); >+ EXPECT_EQ(10, selectionClipRect.origin.y); >+ EXPECT_EQ(136, selectionClipRect.size.width); >+ EXPECT_EQ(22, selectionClipRect.size.height); >+} >+ > } // namespace TestWebKitAPI > > #endif // PLATFORM(IOS_FAMILY) >diff --git a/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h >index fadb4469590d2c405b893284e8ae1e0539962726..366a42a06f054d20cbb59f7682d890d2cd215a94 100644 >--- a/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h >+++ b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h >@@ -36,6 +36,7 @@ > @interface TestInputDelegate : NSObject <_WKInputDelegate> > @property (nonatomic, copy) _WKFocusStartsInputSessionPolicy (^focusStartsInputSessionPolicyHandler)(WKWebView *, id <_WKFocusedElementInfo>); > @property (nonatomic, copy) void (^willStartInputSessionHandler)(WKWebView *, id <_WKFormInputSession>); >+@property (nonatomic, copy) void (^didStartInputSessionHandler)(WKWebView *, id <_WKFormInputSession>); > @end > > #endif >diff --git a/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm >index 124d82c67d202271c2ea0cfe6320267cad72aee2..5ef4dd28b959a64c007bc346c94f76ad193f0aa0 100644 >--- a/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm >+++ b/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm >@@ -33,6 +33,7 @@ > @implementation TestInputDelegate { > BlockPtr<_WKFocusStartsInputSessionPolicy(WKWebView *, id <_WKFocusedElementInfo>)> _focusStartsInputSessionPolicyHandler; > BlockPtr<void(WKWebView *, id <_WKFormInputSession>)> _willStartInputSessionHandler; >+ BlockPtr<void(WKWebView *, id <_WKFormInputSession>)> _didStartInputSessionHandler; > } > > - (void)setFocusStartsInputSessionPolicyHandler:(_WKFocusStartsInputSessionPolicy (^)(WKWebView *, id <_WKFocusedElementInfo>))handler >@@ -45,12 +46,22 @@ - (_WKFocusStartsInputSessionPolicy (^)(WKWebView *, id <_WKFocusedElementInfo>) > return _focusStartsInputSessionPolicyHandler.get(); > } > >-- (void)setWillStartInputSessionHandler:(void (^)(WKWebView *, id<_WKFormInputSession>))willStartInputSessionHandler >+- (void)setDidStartInputSessionHandler:(void (^)(WKWebView *, id <_WKFormInputSession>))handler >+{ >+ _didStartInputSessionHandler = makeBlockPtr(handler); >+} >+ >+- (void (^)(WKWebView *, id <_WKFormInputSession>))didStartInputSessionHandler >+{ >+ return _didStartInputSessionHandler.get(); >+} >+ >+- (void)setWillStartInputSessionHandler:(void (^)(WKWebView *, id <_WKFormInputSession>))willStartInputSessionHandler > { > _willStartInputSessionHandler = makeBlockPtr(willStartInputSessionHandler); > } > >-- (void (^)(WKWebView *, id<_WKFormInputSession>))willStartInputSessionHandler >+- (void (^)(WKWebView *, id <_WKFormInputSession>))willStartInputSessionHandler > { > return _willStartInputSessionHandler.get(); > } >@@ -60,12 +71,18 @@ - (_WKFocusStartsInputSessionPolicy)_webView:(WKWebView *)webView decidePolicyFo > return self.focusStartsInputSessionPolicyHandler ? self.focusStartsInputSessionPolicyHandler(webView, info) : _WKFocusStartsInputSessionPolicyAuto; > } > >-- (void)_webView:(WKWebView *)webView willStartInputSession:(id<_WKFormInputSession>)inputSession >+- (void)_webView:(WKWebView *)webView willStartInputSession:(id <_WKFormInputSession>)inputSession > { > if (_willStartInputSessionHandler) > _willStartInputSessionHandler(webView, inputSession); > } > >+- (void)_webView:(WKWebView *)webView didStartInputSession:(id <_WKFormInputSession>)inputSession >+{ >+ if (_didStartInputSessionHandler) >+ _didStartInputSessionHandler(webView, inputSession); >+} >+ > @end > > #endif // PLATFORM(IOS_FAMILY) >diff --git a/Tools/TestWebKitAPI/cocoa/TestWKWebView.h b/Tools/TestWebKitAPI/cocoa/TestWKWebView.h >index b668a00c38e96affcb9041a545c7cf6748dc0ae1..99f0c7614a5a8bfd2fecbde0c309ce9fd27115a5 100644 >--- a/Tools/TestWebKitAPI/cocoa/TestWKWebView.h >+++ b/Tools/TestWebKitAPI/cocoa/TestWKWebView.h >@@ -30,6 +30,7 @@ > > #if PLATFORM(IOS_FAMILY) > @class _WKActivatedElementInfo; >+@protocol UITextInputInternal; > @protocol UITextInputMultiDocument; > @protocol UITextInputPrivate; > @protocol UIWKInteractionViewProtocol; >@@ -85,7 +86,7 @@ > @end > > @interface TestWKWebView (IOSOnly) >-@property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputMultiDocument, UIWKInteractionViewProtocol> *textInputContentView; >+@property (nonatomic, readonly) UIView <UITextInputPrivate, UITextInputInternal, UITextInputMultiDocument, UIWKInteractionViewProtocol> *textInputContentView; > @property (nonatomic, readonly) RetainPtr<NSArray> selectionRectsAfterPresentationUpdate; > @property (nonatomic, readonly) CGRect caretViewRectInContentCoordinates; > @property (nonatomic, readonly) NSArray<NSValue *> *selectionViewRectsInContentCoordinates; >diff --git a/Tools/TestWebKitAPI/ios/UIKitSPI.h b/Tools/TestWebKitAPI/ios/UIKitSPI.h >index 1a98f4ad1679d250d13f06af3381a6ea09dced47..92ebdfe4d0fdbd78c997a59e33dca4a4dc96e36f 100644 >--- a/Tools/TestWebKitAPI/ios/UIKitSPI.h >+++ b/Tools/TestWebKitAPI/ios/UIKitSPI.h >@@ -218,4 +218,8 @@ typedef NS_ENUM(NSUInteger, _UIClickInteractionEvent) { > > #endif // PLATFORM(IOS) > >+@protocol UITextInputInternal >+- (CGRect)_selectionClipRect; >+@end >+ > #endif // PLATFORM(IOS_FAMILY)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199310
:
373080
| 373082