[Extra zoom mode] Add support for new focused form control overlay behaviors
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2018 20:49:06 +0000 (20:49 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Mar 2018 20:49:06 +0000 (20:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184043
<rdar://problem/38758727>

Reviewed by Tim Horton.

See below for more details.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _willStartScrollingOrZooming]):
(-[WKContentView _didEndScrollingOrZooming]):

Suppress focused form control navigation while the scroll view is undergoing a scroll or zoom animation (e.g.,
when moving from one focused form control to another).

(-[WKContentView textInputController:didCommitText:withSuggestion:]):

When dismissing an input view controller, allow focused form control navigation only after updating assisted
node information to ensure that focus rects aren't stale as the user begins to navigate between forms.

(-[WKContentView rectForFocusedFormControlController:inCoordinateSpace:]):
(-[WKContentView nextRectForFocusedFormControlController:inCoordinateSpace:]):
(-[WKContentView previousRectForFocusedFormControlController:inCoordinateSpace:]):
(-[WKContentView scrollViewForFocusedFormControlController:]):
(-[WKContentView highlightedRectForFocusedFormControlController:inCoordinateSpace:]): Deleted.

Implement some new focused form overlay delegate hooks to vend the scroll view, as well as the rects of next and
previous focusable form controls.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230003 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

index 74f0b12..f9c8923 100644 (file)
@@ -1,3 +1,34 @@
+2018-03-27  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] Add support for new focused form control overlay behaviors
+        https://bugs.webkit.org/show_bug.cgi?id=184043
+        <rdar://problem/38758727>
+
+        Reviewed by Tim Horton.
+
+        See below for more details.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _willStartScrollingOrZooming]):
+        (-[WKContentView _didEndScrollingOrZooming]):
+
+        Suppress focused form control navigation while the scroll view is undergoing a scroll or zoom animation (e.g.,
+        when moving from one focused form control to another).
+
+        (-[WKContentView textInputController:didCommitText:withSuggestion:]):
+
+        When dismissing an input view controller, allow focused form control navigation only after updating assisted
+        node information to ensure that focus rects aren't stale as the user begins to navigate between forms.
+
+        (-[WKContentView rectForFocusedFormControlController:inCoordinateSpace:]):
+        (-[WKContentView nextRectForFocusedFormControlController:inCoordinateSpace:]):
+        (-[WKContentView previousRectForFocusedFormControlController:inCoordinateSpace:]):
+        (-[WKContentView scrollViewForFocusedFormControlController:]):
+        (-[WKContentView highlightedRectForFocusedFormControlController:inCoordinateSpace:]): Deleted.
+
+        Implement some new focused form overlay delegate hooks to vend the scroll view, as well as the rects of next and
+        previous focusable form controls.
+
 2018-03-27  Brent Fulgham  <bfulgham@apple.com>
 
         Further refine cookie read/write logging
index 504d6ce..96999a7 100644 (file)
@@ -1953,6 +1953,10 @@ static void cancelPotentialTapIfNecessary(WKContentView* contentView)
     [_webSelectionAssistant willStartScrollingOrZoomingPage];
     [_textSelectionAssistant willStartScrollingOverflow];
     _page->setIsScrollingOrZooming(true);
+
+#if ENABLE(EXTRA_ZOOM_MODE)
+    [_focusedFormControlViewController disengageFocusedFormControlNavigation];
+#endif
 }
 
 - (void)scrollViewWillStartPanOrPinchGesture
@@ -1969,6 +1973,10 @@ static void cancelPotentialTapIfNecessary(WKContentView* contentView)
         [_textSelectionAssistant didEndScrollingOverflow];
     }
     _page->setIsScrollingOrZooming(false);
+
+#if ENABLE(EXTRA_ZOOM_MODE)
+    [_focusedFormControlViewController engageFocusedFormControlNavigation];
+#endif
 }
 
 - (BOOL)requiresAccessoryView
@@ -4301,8 +4309,11 @@ static bool isAssistableInputType(InputType type)
     [_focusedFormControlViewController show:NO];
     [self dismissAllInputViewControllers];
     [self updateCurrentAssistedNodeInformation:[weakSelf = WeakObjCPtr<WKContentView>(self)] (bool didUpdate) {
-        if (didUpdate)
-            [weakSelf.get()->_focusedFormControlViewController reloadData:YES];
+        if (didUpdate) {
+            auto focusedFormController = weakSelf.get()->_focusedFormControlViewController;
+            [focusedFormController reloadData:YES];
+            [focusedFormController engageFocusedFormControlNavigation];
+        }
     }];
 }
 
@@ -4330,11 +4341,32 @@ static bool isAssistableInputType(InputType type)
     }];
 }
 
-- (CGRect)highlightedRectForFocusedFormControlController:(WKFocusedFormControlViewController *)controller inCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace
+- (CGRect)rectForFocusedFormControlController:(WKFocusedFormControlViewController *)controller inCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace
 {
     return [self convertRect:_assistedNodeInformation.elementRect toCoordinateSpace:coordinateSpace];
 }
 
+- (CGRect)nextRectForFocusedFormControlController:(WKFocusedFormControlViewController *)controller inCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace
+{
+    if (!_assistedNodeInformation.hasNextNode)
+        return CGRectNull;
+
+    return [self convertRect:_assistedNodeInformation.nextNodeRect toCoordinateSpace:coordinateSpace];
+}
+
+- (CGRect)previousRectForFocusedFormControlController:(WKFocusedFormControlViewController *)controller inCoordinateSpace:(id <UICoordinateSpace>)coordinateSpace
+{
+    if (!_assistedNodeInformation.hasPreviousNode)
+        return CGRectNull;
+
+    return [self convertRect:_assistedNodeInformation.previousNodeRect toCoordinateSpace:coordinateSpace];
+}
+
+- (UIScrollView *)scrollViewForFocusedFormControlController:(WKFocusedFormControlViewController *)controller
+{
+    return self._scroller;
+}
+
 - (NSString *)actionNameForFocusedFormControlController:(WKFocusedFormControlViewController *)controller
 {
     if (_assistedNodeInformation.formAction.isEmpty())