Animated keyboard scrolling is extremely chaotic
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 20:55:33 +0000 (20:55 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 20:55:33 +0000 (20:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196164
<rdar://problem/48702444>

Reviewed by Simon Fraser.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _interpretKeyEvent:isCharEvent:]):
Consume keyboard events instead of interpreting them traditionally
if WKKeyboardScrollingAnimator is animating.

* UIProcess/ios/WKKeyboardScrollingAnimator.h:
* UIProcess/ios/WKKeyboardScrollingAnimator.mm:
(-[WKKeyboardScrollingAnimator beginWithEvent:]):
(-[WKKeyboardScrollingAnimator handleKeyEvent:]):
(-[WKKeyboardScrollingAnimator stopAnimatedScroll]):
(-[WKKeyboardScrollingAnimator scrollTriggeringKeyIsPressed]):
(-[WKKeyboardScrollingAnimator displayLinkFired:]):
(-[WKKeyboardScrollViewAnimator scrollTriggeringKeyIsPressed]):
Expose the current state of interactive scrolling, and rename the related member.

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

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

index 87b98cd..61ad34a 100644 (file)
@@ -1,3 +1,26 @@
+2019-03-25  Tim Horton  <timothy_horton@apple.com>
+
+        Animated keyboard scrolling is extremely chaotic
+        https://bugs.webkit.org/show_bug.cgi?id=196164
+        <rdar://problem/48702444>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _interpretKeyEvent:isCharEvent:]):
+        Consume keyboard events instead of interpreting them traditionally
+        if WKKeyboardScrollingAnimator is animating.
+
+        * UIProcess/ios/WKKeyboardScrollingAnimator.h:
+        * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
+        (-[WKKeyboardScrollingAnimator beginWithEvent:]):
+        (-[WKKeyboardScrollingAnimator handleKeyEvent:]):
+        (-[WKKeyboardScrollingAnimator stopAnimatedScroll]):
+        (-[WKKeyboardScrollingAnimator scrollTriggeringKeyIsPressed]):
+        (-[WKKeyboardScrollingAnimator displayLinkFired:]):
+        (-[WKKeyboardScrollViewAnimator scrollTriggeringKeyIsPressed]):
+        Expose the current state of interactive scrolling, and rename the related member.
+
 2019-03-25  Keith Rollin  <krollin@apple.com>
 
         Add WebKit logging for first paint and other interesting layout milestones
index 546b441..36b5727 100644 (file)
@@ -4449,7 +4449,7 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
     if (!contentEditable && event.isTabKey)
         return NO;
 
-    if ([_keyboardScrollingAnimator beginWithEvent:event])
+    if ([_keyboardScrollingAnimator beginWithEvent:event] || [_keyboardScrollingAnimator scrollTriggeringKeyIsPressed])
         return YES;
 
     UIKeyboardImpl *keyboard = [UIKeyboardImpl sharedInstance];
index c7b3041..3ff83b6 100644 (file)
@@ -62,6 +62,8 @@ enum class ScrollingDirection : uint8_t {
 - (BOOL)beginWithEvent:(::WebEvent *)event;
 - (void)handleKeyEvent:(::WebEvent *)event;
 
+- (BOOL)scrollTriggeringKeyIsPressed;
+
 @property (nonatomic, weak) id <WKKeyboardScrollViewAnimatorDelegate> delegate;
 
 @end
index d87e65d..3f30198 100644 (file)
@@ -99,7 +99,7 @@ struct KeyboardScrollParameters {
 
     Optional<WebKit::KeyboardScroll> _currentScroll;
 
-    BOOL _hasPressedScrollingKey;
+    BOOL _scrollTriggeringKeyIsPressed;
 
     WebCore::FloatSize _velocity; // Points per second.
 
@@ -295,13 +295,13 @@ static WebCore::PhysicalBoxSide boxSide(WebKit::ScrollingDirection direction)
     if (!scroll)
         return NO;
 
-    if (_hasPressedScrollingKey)
+    if (_scrollTriggeringKeyIsPressed)
         return NO;
 
     if (![_scrollable rubberbandableDirections].at(boxSide(scroll->direction)))
         return NO;
 
-    _hasPressedScrollingKey = YES;
+    _scrollTriggeringKeyIsPressed = YES;
     _currentScroll = scroll;
 
 #if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
@@ -328,13 +328,13 @@ static WebCore::PhysicalBoxSide boxSide(WebKit::ScrollingDirection direction)
 
 - (void)handleKeyEvent:(::WebEvent *)event
 {
-    if (!_hasPressedScrollingKey)
+    if (!_scrollTriggeringKeyIsPressed)
         return;
 
     auto scroll = [self keyboardScrollForEvent:event];
     if (!scroll || event.type == WebEventKeyUp) {
         [self stopAnimatedScroll];
-        _hasPressedScrollingKey = NO;
+        _scrollTriggeringKeyIsPressed = NO;
     }
 }
 
@@ -382,6 +382,11 @@ static WebCore::FloatPoint farthestPointInDirection(WebCore::FloatPoint a, WebCo
 #endif
 }
 
+- (BOOL)scrollTriggeringKeyIsPressed
+{
+    return _scrollTriggeringKeyIsPressed;
+}
+
 - (void)willStartInteractiveScroll
 {
     // If the user touches the screen to start an interactive scroll, stop everything.
@@ -458,7 +463,7 @@ static WebCore::FloatPoint farthestPointInDirection(WebCore::FloatPoint a, WebCo
 
     // If we've effectively stopped scrolling, and no key is pressed,
     // shut down the display link.
-    if (!_hasPressedScrollingKey && _velocity.diagonalLengthSquared() < 1) {
+    if (!_scrollTriggeringKeyIsPressed && _velocity.diagonalLengthSquared() < 1) {
         [_scrollable didFinishScrolling];
         [self stopDisplayLink];
         _velocity = { };
@@ -564,6 +569,11 @@ static WebCore::FloatPoint farthestPointInDirection(WebCore::FloatPoint a, WebCo
     return [_animator handleKeyEvent:event];
 }
 
+- (BOOL)scrollTriggeringKeyIsPressed
+{
+    return [_animator scrollTriggeringKeyIsPressed];
+}
+
 - (BOOL)isKeyboardScrollable
 {
     if (!_delegateRespondsToIsKeyboardScrollable)