Title: [263630] trunk
Revision
263630
Author
dba...@webkit.org
Date
2020-06-27 15:59:30 -0700 (Sat, 27 Jun 2020)

Log Message

Revert r262654 because it caused <rdar://problem/64664156>.
Moreover it is no longer necessary as the embedding client
changes selection through a different SPI after focusing.

Source/WebKit:

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanUpInteraction]):
(-[WKContentView _didCommitLoadForMainFrame]):
(-[WKContentView _focusTextInputContext:placeCaretAt:completionHandler:]):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (263629 => 263630)


--- trunk/Source/WebKit/ChangeLog	2020-06-27 22:18:41 UTC (rev 263629)
+++ trunk/Source/WebKit/ChangeLog	2020-06-27 22:59:30 UTC (rev 263630)
@@ -1,3 +1,15 @@
+2020-06-27  Daniel Bates  <daba...@apple.com>
+
+        Revert r262654 because it caused <rdar://problem/64664156>.
+        Moreover it is no longer necessary as the embedding client
+        changes selection through a different SPI after focusing.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView cleanUpInteraction]):
+        (-[WKContentView _didCommitLoadForMainFrame]):
+        (-[WKContentView _focusTextInputContext:placeCaretAt:completionHandler:]):
+
 2020-06-26  David Kilzer  <ddkil...@apple.com>
 
         Crash at WebKit: __62-[WKContentView(WKInteraction) resignFirstResponderForWebView]_block_invoke

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (263629 => 263630)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-06-27 22:18:41 UTC (rev 263629)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2020-06-27 22:59:30 UTC (rev 263630)
@@ -362,8 +362,6 @@
     BOOL _textInteractionIsHappening;
     bool _isWaitingOnPositionInformation;
 
-    Optional<WebCore::IntPoint> _pointInsideLastFocusedTextInputContext;
-
     WebCore::PointerID m_commitPotentialTapPointerId;
 
     BOOL _keyboardDidRequestDismissal;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (263629 => 263630)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-06-27 22:18:41 UTC (rev 263629)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-06-27 22:59:30 UTC (rev 263630)
@@ -936,7 +936,6 @@
 
     _textInteractionDidChangeFocusedElement = NO;
     _textInteractionIsHappening = NO;
-    _pointInsideLastFocusedTextInputContext = WTF::nullopt;
 
     if (_interactionViewsContainerView) {
         [self.layer removeObserver:self forKeyPath:@"transform"];
@@ -4303,7 +4302,6 @@
 
     _textInteractionDidChangeFocusedElement = NO;
     _textInteractionIsHappening = NO;
-    _pointInsideLastFocusedTextInputContext = WTF::nullopt;
     _hasValidPositionInformation = NO;
     _positionInformation = { };
 }
@@ -5175,12 +5173,10 @@
         completionHandler(nil);
         return;
     }
-    WebCore::IntPoint pointInsideTextInputContext { point };
-    if ([self _isTextInputContextFocused:context] && _pointInsideLastFocusedTextInputContext == pointInsideTextInputContext) {
+    if ([self _isTextInputContextFocused:context]) {
         completionHandler(_focusedElementInformation.isReadOnly ? nil : self);
         return;
     }
-    _pointInsideLastFocusedTextInputContext = pointInsideTextInputContext;
     _usingGestureForSelection = YES;
     auto checkFocusedElement = [weakSelf = WeakObjCPtr<WKContentView> { self }, context = adoptNS([context copy]), completionHandler = makeBlockPtr(completionHandler)] (bool success) {
         auto strongSelf = weakSelf.get();
@@ -5194,7 +5190,7 @@
         strongSelf->_usingGestureForSelection = NO;
         completionHandler(isFocused && isEditable ? strongSelf.get() : nil);
     };
-    _page->focusTextInputContextAndPlaceCaret(context._textInputContext, pointInsideTextInputContext, WTFMove(checkFocusedElement));
+    _page->focusTextInputContextAndPlaceCaret(context._textInputContext, WebCore::IntPoint { point }, WTFMove(checkFocusedElement));
 }
 
 - (void)_requestTextInputContextsInRect:(CGRect)rect completionHandler:(void (^)(NSArray<_WKTextInputContext *> *))completionHandler

Modified: trunk/Tools/ChangeLog (263629 => 263630)


--- trunk/Tools/ChangeLog	2020-06-27 22:18:41 UTC (rev 263629)
+++ trunk/Tools/ChangeLog	2020-06-27 22:59:30 UTC (rev 263630)
@@ -1,3 +1,12 @@
+2020-06-27  Daniel Bates  <daba...@apple.com>
+
+        Revert r262654 because it caused <rdar://problem/64664156>.
+        Moreover it is no longer necessary as the embedding client
+        changes selection through a different SPI after focusing.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
+        (TestWebKitAPI::TEST):
+
 2020-06-27  Keith Miller  <keith_mil...@apple.com>
 
         compare-results should be able to parse multiple JSONs at once by merging them

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm (263629 => 263630)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm	2020-06-27 22:18:41 UTC (rev 263629)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm	2020-06-27 22:59:30 UTC (rev 263630)
@@ -382,7 +382,7 @@
     EXPECT_NULL([webView synchronouslyFocusTextInputContext:inputElement.get() placeCaretAt:[inputElement boundingRect].origin]);
 }
 
-TEST(RequestTextInputContext, CaretShouldMoveInAlreadyFocusedField)
+TEST(RequestTextInputContext, CaretShouldNotMoveInAlreadyFocusedField)
 {
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -395,7 +395,7 @@
 
     EXPECT_WK_STREQ("BODY", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]);
 
-    // Place the caret the end of the field.
+    // Place the caret the end of the field; should succeed becausse field is not already focused.
     RetainPtr<_WKTextInputContext> inputElement = contexts[0];
     CGRect boundingRect = [inputElement boundingRect];
     CGPoint endPosition = CGPointMake(boundingRect.origin.x + boundingRect.size.width, boundingRect.origin.y + boundingRect.size.height / 2);
@@ -404,14 +404,14 @@
     EXPECT_EQ(static_cast<int>(exampleTextLength), [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionStart"] intValue]);
     EXPECT_EQ(static_cast<int>(exampleTextLength), [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionEnd"] intValue]);
 
-    // Try to place the caret at the start of the field.
+    // Try to place the caret at the start of the field; should fail since field is already focused.
     EXPECT_EQ((UIResponder<UITextInput> *)[webView textInputContentView], [webView synchronouslyFocusTextInputContext:inputElement.get() placeCaretAt:boundingRect.origin]);
     EXPECT_WK_STREQ("INPUT", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]);
-    EXPECT_EQ(0, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionStart"] intValue]);
-    EXPECT_EQ(0, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionEnd"] intValue]);
+    EXPECT_EQ(static_cast<int>(exampleTextLength), [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionStart"] intValue]);
+    EXPECT_EQ(static_cast<int>(exampleTextLength), [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionEnd"] intValue]);
 }
 
-TEST(RequestTextInputContext, CaretShouldMoveInAlreadyFocusedField2)
+TEST(RequestTextInputContext, CaretShouldNotMoveInAlreadyFocusedField2)
 {
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -428,14 +428,14 @@
     EXPECT_EQ(1, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionStart"] intValue]);
     EXPECT_EQ(1, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionEnd"] intValue]);
 
-    // Use -focusTextInputContext: to place the caret at the beginning of the field.
+    // Use -focusTextInputContext: to place the caret at the beginning of the field; no change because the field is already focused.
     NSArray<_WKTextInputContext *> *contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView bounds]];
     EXPECT_EQ(1UL, contexts.count);
     RetainPtr<_WKTextInputContext> inputElement = contexts[0];
     EXPECT_EQ((UIResponder<UITextInput> *)[webView textInputContentView], [webView synchronouslyFocusTextInputContext:inputElement.get() placeCaretAt:[inputElement boundingRect].origin]);
     EXPECT_WK_STREQ("INPUT", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]);
-    EXPECT_EQ(0, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionStart"] intValue]);
-    EXPECT_EQ(0, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionEnd"] intValue]);
+    EXPECT_EQ(1, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionStart"] intValue]);
+    EXPECT_EQ(1, [[webView objectByEvaluatingJavaScript:@"document.activeElement.selectionEnd"] intValue]);
 }
 
 TEST(RequestTextInputContext, PlaceCaretInNonAssistedFocusedField)
@@ -846,7 +846,7 @@
     EXPECT_TRUE(didScroll);
 }
 
-TEST(RequestTextInputContext, TextInteraction_FocusingAssistedElementShouldScrollToReveal)
+TEST(RequestTextInputContext, TextInteraction_FocusingAssistedElementShouldNotScrollToReveal)
 {
     IPhoneUserInterfaceSwizzler userInterfaceSwizzler;
 
@@ -868,7 +868,7 @@
     auto scrollDelegate = adoptNS([[TextInteractionScrollDelegate alloc] init]);
     [webView scrollView].delegate = scrollDelegate.get();
 
-    // Focus the field using -focusTextInputContext; scroll view should scroll to reveal new caret position in the focused element.
+    // Focus the field using -focusTextInputContext; scroll view should not scroll to reveal focused element.
     {
         TextInteractionForScope scope { webView, inputElement };
         EXPECT_EQ((UIResponder<UITextInput> *)[webView textInputContentView], [webView synchronouslyFocusTextInputContext:inputElement.get() placeCaretAt:[inputElement boundingRect].origin]);
@@ -875,7 +875,7 @@
     }
 
     EXPECT_WK_STREQ("INPUT", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]);
-    EXPECT_TRUE(didScroll);
+    EXPECT_FALSE(didScroll);
 }
 
 TEST(RequestTextInputContext, TextInteraction_FocusingNonAssistedFocusedElementScrollsToReveal)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to