Diff
Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/ChangeLog 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog 2019-01-18 20:39:24 UTC (rev 240166)
@@ -1,3 +1,39 @@
+2019-01-18 Tim Horton <timothy_hor...@apple.com>
+
+ REGRESSION (r236935): Holding down arrow key does not cause repeated DOM keydown events on device
+ https://bugs.webkit.org/show_bug.cgi?id=191408
+ <rdar://problem/45895135>
+
+ Rubber-stamped by Simon Fraser.
+
+ * SourcesCocoa.txt:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _scrollByContentOffset:]):
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView setupInteraction]):
+ (-[WKContentView cleanupInteraction]):
+ (-[WKContentView scrollViewWillStartPanOrPinchGesture]):
+ (-[WKContentView canPerformActionForWebView:withSender:]):
+ (-[WKContentView keyCommands]):
+ (-[WKContentView _arrowKeyForWebView:]):
+ (-[WKContentView _didHandleKeyEvent:eventWasHandled:]):
+ (-[WKContentView _scrollOffsetForEvent:]):
+ (-[WKContentView _interpretKeyEvent:isCharEvent:]):
+ (-[WKContentView isScrollableForKeyboardScrollViewAnimator:]): Deleted.
+ (-[WKContentView keyboardScrollViewAnimator:distanceForIncrement:]): Deleted.
+ (-[WKContentView keyboardScrollViewAnimatorWillScroll:]): Deleted.
+ (-[WKContentView keyboardScrollViewAnimatorDidFinishScrolling:]): Deleted.
+ * UIProcess/ios/WKKeyboardScrollingAnimator.h: Removed.
+ * UIProcess/ios/WKKeyboardScrollingAnimator.mm: Removed.
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView dealloc]):
+ (-[WKPDFView web_handleKeyEvent:]):
+ (-[WKPDFView web_initWithFrame:webView:mimeType:]):
+ * WebKit.xcodeproj/project.pbxproj:
+ Revert WKKeyboardScrollingAnimator.
+
2019-01-16 Alan Coon <alanc...@apple.com>
Apply patch. rdar://problem/47260377
Modified: branches/safari-607-branch/Source/WebKit/SourcesCocoa.txt (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/SourcesCocoa.txt 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/SourcesCocoa.txt 2019-01-18 20:39:24 UTC (rev 240166)
@@ -395,7 +395,6 @@
UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm
UIProcess/ios/WKInkPickerView.mm
UIProcess/ios/WKInspectorNodeSearchGestureRecognizer.mm
-UIProcess/ios/WKKeyboardScrollingAnimator.mm
UIProcess/ios/WKLegacyPDFView.mm
UIProcess/ios/WKPasswordView.mm
UIProcess/ios/WKPDFPageNumberIndicator.mm
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2019-01-18 20:39:24 UTC (rev 240166)
@@ -2207,6 +2207,24 @@
return true;
}
+- (void)_scrollByContentOffset:(WebCore::FloatPoint)contentOffsetDelta
+{
+ WebCore::FloatPoint scaledOffsetDelta = contentOffsetDelta;
+ CGFloat zoomScale = contentZoomScale(self);
+ scaledOffsetDelta.scale(zoomScale);
+
+ CGPoint currentOffset = [_scrollView _isAnimatingScroll] ? [_scrollView _animatedTargetOffset] : [_scrollView contentOffset];
+ CGPoint boundedOffset = contentOffsetBoundedInValidRange(_scrollView.get(), currentOffset + scaledOffsetDelta);
+
+ if (CGPointEqualToPoint(boundedOffset, currentOffset))
+ return;
+ [_contentView willStartZoomOrScroll];
+
+ LOG_WITH_STREAM(VisibleRects, stream << "_scrollByContentOffset: scrolling to " << WebCore::FloatPoint(boundedOffset));
+
+ [_scrollView setContentOffset:boundedOffset animated:YES];
+}
+
- (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated
{
[self _zoomToPoint:origin atScale:[_scrollView minimumZoomScale] animated:animated];
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2019-01-18 20:39:24 UTC (rev 240166)
@@ -101,6 +101,7 @@
- (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin;
- (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
+- (void)_scrollByContentOffset:(WebCore::FloatPoint)offset;
- (void)_zoomToFocusRect:(const WebCore::FloatRect&)focusedElementRect selectionRect:(const WebCore::FloatRect&)selectionRectInDocumentCoordinates insideFixed:(BOOL)insideFixed fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
- (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
- (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
@@ -139,6 +140,7 @@
- (void)_didChangeEditorState;
- (void)_addShortcut:(id)sender;
+- (void)_arrowKey:(id)sender;
- (void)_define:(id)sender;
- (void)_lookup:(id)sender;
- (void)_share:(id)sender;
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2019-01-18 20:39:24 UTC (rev 240166)
@@ -41,7 +41,6 @@
#import "WKAirPlayRoutePicker.h"
#import "WKFileUploadPanel.h"
#import "WKFormPeripheral.h"
-#import "WKKeyboardScrollingAnimator.h"
#import "WKShareSheet.h"
#import "WKSyntheticClickTapGestureRecognizer.h"
#import "_WKFormInputSession.h"
@@ -110,6 +109,7 @@
#define FOR_EACH_WKCONTENTVIEW_ACTION(M) \
M(_addShortcut) \
+ M(_arrowKey) \
M(_define) \
M(_lookup) \
M(_promptForReplace) \
@@ -271,8 +271,6 @@
std::unique_ptr<WebKit::InputViewUpdateDeferrer> _inputViewUpdateDeferrer;
- RetainPtr<WKKeyboardScrollViewAnimator> _keyboardScrollingAnimator;
-
#if ENABLE(DATALIST_ELEMENT)
RetainPtr<UIView <WKFormControl>> _dataListTextSuggestionsInputView;
RetainPtr<NSArray<UITextSuggestion *>> _dataListTextSuggestions;
@@ -332,7 +330,7 @@
@end
-@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UITextAutoscrolling, UITextInputMultiDocument, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWebTouchEventsGestureRecognizerDelegate, UIWKInteractionViewProtocol, WKActionSheetAssistantDelegate, WKFileUploadPanelDelegate, WKKeyboardScrollViewAnimatorDelegate
+@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UITextAutoscrolling, UITextInputMultiDocument, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWebTouchEventsGestureRecognizerDelegate, UIWKInteractionViewProtocol, WKActionSheetAssistantDelegate, WKFileUploadPanelDelegate
#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
, WKShareSheetDelegate
#endif
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-01-18 20:39:24 UTC (rev 240166)
@@ -81,6 +81,7 @@
#import <WebCore/FloatQuad.h>
#import <WebCore/FontAttributeChanges.h>
#import <WebCore/InputMode.h>
+#import <WebCore/KeyEventCodesIOS.h>
#import <WebCore/LocalizedStrings.h>
#import <WebCore/NotImplemented.h>
#import <WebCore/Pasteboard.h>
@@ -651,9 +652,6 @@
[self.superview addSubview:_interactionViewsContainerView.get()];
}
- _keyboardScrollingAnimator = adoptNS([[WKKeyboardScrollViewAnimator alloc] initWithScrollView:_webView.scrollView]);
- [_keyboardScrollingAnimator setDelegate:self];
-
[self.layer addObserver:self forKeyPath:@"transform" options:NSKeyValueObservingOptionInitial context:nil];
_touchEventGestureRecognizer = adoptNS([[UIWebTouchEventsGestureRecognizer alloc] initWithTarget:self action:@selector(_webTouchEventsRecognized:) touchDelegate:self]);
@@ -846,9 +844,6 @@
_inputViewUpdateDeferrer = nullptr;
_focusedElementInformation = { };
- [_keyboardScrollingAnimator invalidate];
- _keyboardScrollingAnimator = nil;
-
#if HAVE(PENCILKIT)
_drawingCoordinator = nil;
#endif
@@ -2182,8 +2177,6 @@
{
_page->hideValidationMessage();
- [_keyboardScrollingAnimator willStartInteractiveScroll];
-
_canSendTouchEventsAsynchronously = YES;
}
@@ -2539,6 +2532,8 @@
- (BOOL)canPerformActionForWebView:(SEL)action withSender:(id)sender
{
+ if (action == @selector(_arrowKey:))
+ return [self isFirstResponder];
if (action == @selector(_nextAccessoryTab:))
return hasFocusedElement(_focusedElementInformation) && _focusedElementInformation.hasNextNode;
if (action == @selector(_previousAccessoryTab:))
@@ -3313,16 +3308,46 @@
- (NSArray *)keyCommands
{
- if (!_page->editorState().isContentEditable)
- return nil;
+ static NSArray *nonEditableKeyCommands = [@[
+ [UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow modifierFlags:0 action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow modifierFlags:0 action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:0 action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:0 action:@selector(_arrowKey:)],
- static NSArray* editableKeyCommands = [@[
+ [UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow modifierFlags:UIKeyModifierCommand action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow modifierFlags:UIKeyModifierCommand action:@selector(_arrowKey:)],
+
+ [UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow modifierFlags:UIKeyModifierShift action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow modifierFlags:UIKeyModifierShift action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:UIKeyModifierShift action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:UIKeyModifierShift action:@selector(_arrowKey:)],
+
+ [UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow modifierFlags:UIKeyModifierAlternate action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow modifierFlags:UIKeyModifierAlternate action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:UIKeyModifierAlternate action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:UIKeyModifierAlternate action:@selector(_arrowKey:)],
+
+ [UIKeyCommand keyCommandWithInput:@" " modifierFlags:0 action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:@" " modifierFlags:UIKeyModifierShift action:@selector(_arrowKey:)],
+
+ [UIKeyCommand keyCommandWithInput:UIKeyInputPageDown modifierFlags:0 action:@selector(_arrowKey:)],
+ [UIKeyCommand keyCommandWithInput:UIKeyInputPageDown modifierFlags:0 action:@selector(_arrowKey:)],
+ ] retain];
+
+ static NSArray *editableKeyCommands = [@[
[UIKeyCommand keyCommandWithInput:@"\t" modifierFlags:0 action:@selector(_nextAccessoryTab:)],
[UIKeyCommand keyCommandWithInput:@"\t" modifierFlags:UIKeyModifierShift action:@selector(_previousAccessoryTab:)]
] retain];
- return editableKeyCommands;
+
+ return (_page->editorState().isContentEditable) ? editableKeyCommands : nonEditableKeyCommands;
}
+- (void)_arrowKeyForWebView:(id)sender
+{
+ UIKeyCommand *command = sender;
+ [self handleKeyEvent:command._triggeringEvent];
+}
+
- (void)_nextAccessoryTabForWebView:(id)sender
{
[self accessoryTab:YES];
@@ -3973,9 +3998,6 @@
- (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled
{
- if (!(event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged))
- [_keyboardScrollingAnimator handleKeyEvent:event];
-
if (auto handler = WTFMove(_keyWebEventHandler)) {
handler(event, eventWasHandled);
return;
@@ -4001,6 +4023,75 @@
_uiEventBeingResent = nil;
}
+- (Optional<WebCore::FloatPoint>)_scrollOffsetForEvent:(::WebEvent *)event
+{
+ static const unsigned kWebSpaceKey = 0x20;
+
+ if (_page->editorState().isContentEditable)
+ return WTF::nullopt;
+
+ if (_focusedElementInformation.elementType == WebKit::InputType::Select)
+ return WTF::nullopt;
+
+ NSString *charactersIgnoringModifiers = event.charactersIgnoringModifiers;
+ if (!charactersIgnoringModifiers.length)
+ return WTF::nullopt;
+
+ auto firstCharacter = [charactersIgnoringModifiers characterAtIndex:0];
+
+ enum ScrollingIncrement { Document, Page, Line };
+ enum ScrollingDirection { Up, Down, Left, Right };
+
+ auto computeOffset = ^(ScrollingIncrement increment, ScrollingDirection direction) {
+ bool isHorizontal = (direction == Left || direction == Right);
+
+ CGFloat scrollDistance = ^ CGFloat {
+ switch (increment) {
+ case Document:
+ ASSERT(!isHorizontal);
+ return self.bounds.size.height;
+ case Page:
+ ASSERT(!isHorizontal);
+ return WebCore::Scrollbar::pageStep(_page->unobscuredContentRect().height(), self.bounds.size.height);
+ case Line:
+ return WebCore::Scrollbar::pixelsPerLineStep();
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+ }();
+
+ if (direction == Up || direction == Left)
+ scrollDistance = -scrollDistance;
+
+ return (isHorizontal ? WebCore::FloatPoint(scrollDistance, 0) : WebCore::FloatPoint(0, scrollDistance));
+ };
+
+ if (firstCharacter == NSLeftArrowFunctionKey)
+ return computeOffset(Line, Left);
+ if (firstCharacter == NSRightArrowFunctionKey)
+ return computeOffset(Line, Right);
+
+ ScrollingIncrement incrementForVerticalArrowKey = Line;
+ if (event.modifierFlags & WebEventFlagMaskOptionKey)
+ incrementForVerticalArrowKey = Page;
+ else if (event.modifierFlags & WebEventFlagMaskCommandKey)
+ incrementForVerticalArrowKey = Document;
+ if (firstCharacter == NSUpArrowFunctionKey)
+ return computeOffset(incrementForVerticalArrowKey, Up);
+ if (firstCharacter == NSDownArrowFunctionKey)
+ return computeOffset(incrementForVerticalArrowKey, Down);
+
+ if (firstCharacter == NSPageDownFunctionKey)
+ return computeOffset(Page, Down);
+ if (firstCharacter == NSPageUpFunctionKey)
+ return computeOffset(Page, Up);
+
+ if (firstCharacter == kWebSpaceKey)
+ return computeOffset(Page, (event.modifierFlags & WebEventFlagMaskShiftKey) ? Up : Down);
+
+ return WTF::nullopt;
+}
+
- (BOOL)_interpretKeyEvent:(::WebEvent *)event isCharEvent:(BOOL)isCharEvent
{
static const unsigned kWebEnterKey = 0x0003;
@@ -4017,8 +4108,10 @@
if (!contentEditable && event.isTabKey)
return NO;
- if ([_keyboardScrollingAnimator beginWithEvent:event])
+ if (Optional<WebCore::FloatPoint> scrollOffset = [self _scrollOffsetForEvent:event]) {
+ [_webView _scrollByContentOffset:*scrollOffset];
return YES;
+ }
UIKeyboardImpl *keyboard = [UIKeyboardImpl sharedInstance];
@@ -4067,41 +4160,6 @@
return NO;
}
-- (BOOL)isScrollableForKeyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator
-{
- if (_page->editorState().isContentEditable)
- return NO;
-
- if (_focusedElementInformation.elementType == WebKit::InputType::Select)
- return NO;
-
- return YES;
-}
-
-- (CGFloat)keyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator distanceForIncrement:(WebKit::ScrollingIncrement)increment
-{
- switch (increment) {
- case WebKit::ScrollingIncrement::Document:
- return [self convertRect:self.bounds toView:_webView].size.height;
- case WebKit::ScrollingIncrement::Page:
- return [self convertSize:CGSizeMake(0, WebCore::Scrollbar::pageStep(_page->unobscuredContentRect().height(), self.bounds.size.height)) toView:_webView].height;
- case WebKit::ScrollingIncrement::Line:
- return [self convertSize:CGSizeMake(0, WebCore::Scrollbar::pixelsPerLineStep()) toView:_webView].height;
- }
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-- (void)keyboardScrollViewAnimatorWillScroll:(WKKeyboardScrollViewAnimator *)animator
-{
- [self willStartZoomOrScroll];
-}
-
-- (void)keyboardScrollViewAnimatorDidFinishScrolling:(WKKeyboardScrollViewAnimator *)animator
-{
- [_webView _didFinishScrolling];
-}
-
- (void)executeEditCommandWithCallback:(NSString *)commandName
{
[self beginSelectionChange];
Deleted: branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.h (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.h 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.h 2019-01-18 20:39:24 UTC (rev 240166)
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if PLATFORM(IOS_FAMILY)
-
-namespace WebCore {
-class FloatPoint;
-}
-
-namespace WebKit {
-
-enum class ScrollingIncrement : uint8_t {
- Document,
- Page,
- Line
-};
-
-}
-
-@class UIScrollView;
-@class WebEvent;
-@protocol WKKeyboardScrollViewAnimatorDelegate;
-
-@interface WKKeyboardScrollViewAnimator : NSObject
-
-- (instancetype)init NS_UNAVAILABLE;
-- (instancetype)initWithScrollView:(UIScrollView *)scrollView;
-
-- (void)invalidate;
-
-- (void)willStartInteractiveScroll;
-
-- (BOOL)beginWithEvent:(::WebEvent *)event;
-- (void)handleKeyEvent:(::WebEvent *)event;
-
-@property (nonatomic, weak) id <WKKeyboardScrollViewAnimatorDelegate> delegate;
-
-@end
-
-@protocol WKKeyboardScrollViewAnimatorDelegate <NSObject>
-@optional
-- (BOOL)isScrollableForKeyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator;
-- (CGFloat)keyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator distanceForIncrement:(WebKit::ScrollingIncrement)increment;
-- (void)keyboardScrollViewAnimatorWillScroll:(WKKeyboardScrollViewAnimator *)animator;
-- (void)keyboardScrollViewAnimatorDidFinishScrolling:(WKKeyboardScrollViewAnimator *)animator;
-
-@end
-
-#endif // PLATFORM(IOS_FAMILY)
Deleted: branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm 2019-01-18 20:39:24 UTC (rev 240166)
@@ -1,697 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WKKeyboardScrollingAnimator.h"
-
-#if PLATFORM(IOS_FAMILY)
-
-#import "AccessibilitySupportSPI.h"
-#import "UIKitSPI.h"
-#import <QuartzCore/CADisplayLink.h>
-#import <WebCore/FloatPoint.h>
-#import <WebCore/KeyEventCodesIOS.h>
-#import <WebCore/RectEdges.h>
-#import <WebCore/WebEvent.h>
-#import <WebKit/UIKitSPI.h>
-#import <algorithm>
-#import <wtf/RetainPtr.h>
-#import <wtf/WeakObjCPtr.h>
-
-namespace WebKit {
-
-enum class ScrollingDirection : uint8_t { Up, Down, Left, Right };
-
-struct KeyboardScroll {
- WebCore::FloatSize offset; // Points per increment.
- WebCore::FloatSize maximumVelocity; // Points per second.
- WebCore::FloatSize force;
-
- WebKit::ScrollingIncrement increment;
- WebKit::ScrollingDirection direction;
-};
-
-struct KeyboardScrollParameters {
- CGFloat springMass { 1 };
- CGFloat springStiffness { 109 };
- CGFloat springDamping { 20 };
-
- CGFloat maximumVelocityMultiplier { 25 };
- CGFloat timeToMaximumVelocity { 1 };
-
- CGFloat rubberBandForce { 5000 };
-};
-
-}
-
-@protocol WKKeyboardScrollableInternal <NSObject>
-@required
-- (BOOL)isKeyboardScrollable;
-- (CGFloat)distanceForIncrement:(WebKit::ScrollingIncrement)increment;
-- (void)scrollToContentOffset:(WebCore::FloatPoint)offset animated:(BOOL)animated;
-- (void)scrollWithScrollToExtentAnimationTo:(CGPoint)offset;
-- (CGPoint)contentOffset;
-- (CGSize)interactiveScrollVelocity;
-- (CGPoint)boundedContentOffset:(CGPoint)offset;
-- (WebCore::RectEdges<bool>)scrollableDirectionsFromOffset:(CGPoint)offset;
-- (WebCore::RectEdges<bool>)rubberbandableDirections;
-- (void)didFinishScrolling;
-
-@end
-
-@interface WKKeyboardScrollingAnimator : NSObject
-
-- (instancetype)init NS_UNAVAILABLE;
-- (instancetype)initWithScrollable:(id <WKKeyboardScrollableInternal>)scrollable;
-
-- (void)invalidate;
-
-- (void)willStartInteractiveScroll;
-
-- (BOOL)beginWithEvent:(::WebEvent *)event;
-- (void)handleKeyEvent:(::WebEvent *)event;
-
-@end
-
-@implementation WKKeyboardScrollingAnimator {
- id <WKKeyboardScrollableInternal> _scrollable;
- RetainPtr<CADisplayLink> _displayLink;
-
- Optional<WebKit::KeyboardScroll> _currentScroll;
-
- BOOL _hasPressedScrollingKey;
-
- WebCore::FloatSize _velocity; // Points per second.
-
- WebCore::FloatPoint _idealPosition;
- WebCore::FloatPoint _currentPosition;
- WebCore::FloatPoint _idealPositionForMinimumTravel;
-
-#if !ENABLE(ANIMATED_KEYBOARD_SCROLLING)
- RetainPtr<NSTimer> _repeatTimer;
-#endif
-}
-
-- (instancetype)init
-{
- return nil;
-}
-
-- (instancetype)initWithScrollable:(id <WKKeyboardScrollableInternal>)scrollable
-{
- self = [super init];
- if (!self)
- return nil;
-
- _scrollable = scrollable;
-
- return self;
-}
-
-- (const WebKit::KeyboardScrollParameters &)parameters
-{
- static const WebKit::KeyboardScrollParameters parameters;
- return parameters;
-}
-
-- (void)invalidate
-{
- [self stopAnimatedScroll];
-#if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
- [self stopDisplayLink];
-#endif
- _scrollable = nil;
-}
-
-static WebCore::FloatSize unitVector(WebKit::ScrollingDirection direction)
-{
- switch (direction) {
- case WebKit::ScrollingDirection::Up:
- return { 0, -1 };
- case WebKit::ScrollingDirection::Down:
- return { 0, 1 };
- case WebKit::ScrollingDirection::Left:
- return { -1, 0 };
- case WebKit::ScrollingDirection::Right:
- return { 1, 0 };
- }
-}
-
-#if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
-static WebCore::FloatSize perpendicularAbsoluteUnitVector(WebKit::ScrollingDirection direction)
-{
- switch (direction) {
- case WebKit::ScrollingDirection::Up:
- case WebKit::ScrollingDirection::Down:
- return { 1, 0 };
- case WebKit::ScrollingDirection::Left:
- case WebKit::ScrollingDirection::Right:
- return { 0, 1 };
- }
-}
-#endif
-
-static WebCore::PhysicalBoxSide boxSide(WebKit::ScrollingDirection direction)
-{
- switch (direction) {
- case WebKit::ScrollingDirection::Up:
- return WebCore::PhysicalBoxSide::Top;
- case WebKit::ScrollingDirection::Down:
- return WebCore::PhysicalBoxSide::Bottom;
- case WebKit::ScrollingDirection::Left:
- return WebCore::PhysicalBoxSide::Left;
- case WebKit::ScrollingDirection::Right:
- return WebCore::PhysicalBoxSide::Right;
- }
-}
-
-- (Optional<WebKit::KeyboardScroll>)keyboardScrollForEvent:(::WebEvent *)event
-{
- static const unsigned kWebSpaceKey = 0x20;
-
- if (![_scrollable isKeyboardScrollable])
- return WTF::nullopt;
-
- NSString *charactersIgnoringModifiers = event.charactersIgnoringModifiers;
- if (!charactersIgnoringModifiers.length)
- return WTF::nullopt;
-
- enum class Key : uint8_t { Other, LeftArrow, RightArrow, UpArrow, DownArrow, PageUp, PageDown, Space };
-
- auto key = ^{
- auto firstCharacter = [charactersIgnoringModifiers characterAtIndex:0];
- switch (firstCharacter) {
- case NSLeftArrowFunctionKey:
- return Key::LeftArrow;
- case NSRightArrowFunctionKey:
- return Key::RightArrow;
- case NSUpArrowFunctionKey:
- return Key::UpArrow;
- case NSDownArrowFunctionKey:
- return Key::DownArrow;
- case NSPageDownFunctionKey:
- return Key::PageDown;
- case NSPageUpFunctionKey:
- return Key::PageUp;
- case kWebSpaceKey:
- return Key::Space;
- default:
- return Key::Other;
- };
- }();
-
- if (key == Key::Other)
- return WTF::nullopt;
-
- BOOL shiftPressed = event.modifierFlags & WebEventFlagMaskShiftKey;
- BOOL altPressed = event.modifierFlags & WebEventFlagMaskOptionKey;
- BOOL cmdPressed = event.modifierFlags & WebEventFlagMaskCommandKey;
-
- auto increment = ^{
- switch (key) {
- case Key::LeftArrow:
- case Key::RightArrow:
- return WebKit::ScrollingIncrement::Line;
- case Key::UpArrow:
- case Key::DownArrow:
- if (altPressed)
- return WebKit::ScrollingIncrement::Page;
- if (cmdPressed)
- return WebKit::ScrollingIncrement::Document;
- return WebKit::ScrollingIncrement::Line;
- case Key::PageUp:
- case Key::PageDown:
- case Key::Space:
- return WebKit::ScrollingIncrement::Page;
- case Key::Other:
- ASSERT_NOT_REACHED();
- return WebKit::ScrollingIncrement::Line;
- };
- }();
-
- auto direction = ^() {
- switch (key) {
- case Key::LeftArrow:
- return WebKit::ScrollingDirection::Left;
- case Key::RightArrow:
- return WebKit::ScrollingDirection::Right;
- case Key::UpArrow:
- case Key::PageUp:
- return WebKit::ScrollingDirection::Up;
- case Key::DownArrow:
- case Key::PageDown:
- return WebKit::ScrollingDirection::Down;
- case Key::Space:
- return shiftPressed ? WebKit::ScrollingDirection::Up : WebKit::ScrollingDirection::Down;
- case Key::Other:
- ASSERT_NOT_REACHED();
- return WebKit::ScrollingDirection::Down;
- };
- }();
-
- CGFloat scrollDistance = [_scrollable distanceForIncrement:increment];
-
- WebKit::KeyboardScroll scroll;
- scroll.offset = unitVector(direction).scaled(scrollDistance);
- scroll.increment = increment;
- scroll.direction = direction;
- scroll.maximumVelocity = scroll.offset.scaled(self.parameters.maximumVelocityMultiplier);
-
- // Apply a constant force to achieve Vmax in timeToMaximumVelocity seconds.
- // F_constant = m * Vmax / t
- scroll.force = scroll.maximumVelocity.scaled(self.parameters.springMass / self.parameters.timeToMaximumVelocity);
-
- return scroll;
-}
-
-- (BOOL)beginWithEvent:(::WebEvent *)event
-{
- if (event.type != WebEventKeyDown)
- return NO;
-
- auto scroll = [self keyboardScrollForEvent:event];
- if (!scroll)
- return NO;
-
- if (_hasPressedScrollingKey)
- return NO;
-
- if (![_scrollable rubberbandableDirections].at(boxSide(scroll->direction)))
- return NO;
-
- _hasPressedScrollingKey = YES;
- _currentScroll = scroll;
-
-#if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
- if (scroll->increment == WebKit::ScrollingIncrement::Document) {
- _velocity = { };
- [self stopAnimatedScroll];
- [self stopDisplayLink];
- [_scrollable scrollWithScrollToExtentAnimationTo:[_scrollable boundedContentOffset:_currentPosition + scroll->offset]];
- return YES;
- }
-
- [self startDisplayLinkIfNeeded];
-
- _currentPosition = WebCore::FloatPoint([_scrollable contentOffset]);
- _velocity += WebCore::FloatSize([_scrollable interactiveScrollVelocity]);
- _idealPositionForMinimumTravel = _currentPosition + _currentScroll->offset;
-#else
- [self startRepeatTimerIfNeeded];
- [self performDiscreteScroll];
-#endif
-
- return YES;
-}
-
-- (void)handleKeyEvent:(::WebEvent *)event
-{
- if (!_hasPressedScrollingKey)
- return;
-
- auto scroll = [self keyboardScrollForEvent:event];
- if (!scroll || event.type == WebEventKeyUp) {
- [self stopAnimatedScroll];
- _hasPressedScrollingKey = NO;
- }
-}
-
-static WebCore::FloatPoint farthestPointInDirection(WebCore::FloatPoint a, WebCore::FloatPoint b, WebKit::ScrollingDirection direction)
-{
- switch (direction) {
- case WebKit::ScrollingDirection::Up:
- return WebCore::FloatPoint(a.x(), std::min(a.y(), b.y()));
- case WebKit::ScrollingDirection::Down:
- return WebCore::FloatPoint(a.x(), std::max(a.y(), b.y()));
- case WebKit::ScrollingDirection::Left:
- return WebCore::FloatPoint(std::min(a.x(), b.x()), a.y());
- case WebKit::ScrollingDirection::Right:
- return WebCore::FloatPoint(std::max(a.x(), b.x()), a.y());
- }
-
- ASSERT_NOT_REACHED();
- return { };
-}
-
-- (void)stopAnimatedScroll
-{
- if (!_currentScroll)
- return;
-
- // Determine the settling position of the spring, conserving the system's current energy.
- // Kinetic = elastic potential
- // 1/2 * m * v^2 = 1/2 * k * x^2
- // x = sqrt(v^2 * m / k)
- auto displacementMagnitudeSquared = (_velocity * _velocity).scaled(self.parameters.springMass / self.parameters.springStiffness);
- WebCore::FloatSize displacement = {
- std::copysign(sqrt(displacementMagnitudeSquared.width()), _velocity.width()),
- std::copysign(sqrt(displacementMagnitudeSquared.height()), _velocity.height())
- };
-
- // If the spring would settle before the minimum travel distance
- // for an instantaneous tap, move the settling position of the spring
- // out to that point.
- _idealPosition = [_scrollable boundedContentOffset:farthestPointInDirection(_currentPosition + displacement, _idealPositionForMinimumTravel, _currentScroll->direction)];
-
- _currentScroll = WTF::nullopt;
-
-#if !ENABLE(ANIMATED_KEYBOARD_SCROLLING)
- [self stopRepeatTimer];
-#endif
-}
-
-- (void)willStartInteractiveScroll
-{
- // If the user touches the screen to start an interactive scroll, stop everything.
- _velocity = { };
- [self stopAnimatedScroll];
-
-#if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
- [self stopDisplayLink];
-#endif
-}
-
-#if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
-
-- (void)startDisplayLinkIfNeeded
-{
- if (_displayLink)
- return;
-
- _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkFired:)];
- [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
-}
-
-- (void)stopDisplayLink
-{
- [_displayLink invalidate];
- _displayLink = nil;
-}
-
-- (void)displayLinkFired:(CADisplayLink *)sender
-{
- WebCore::FloatSize force;
- WebCore::FloatSize axesToApplySpring = { 1, 1 };
-
- if (_currentScroll) {
- auto scrollableDirections = [_scrollable scrollableDirectionsFromOffset:_currentPosition];
- auto direction = _currentScroll->direction;
-
- if (scrollableDirections.at(boxSide(direction))) {
- // Apply the scrolling force. Only apply the spring in the perpendicular axis,
- // otherwise it drags against the direction of motion.
- axesToApplySpring = perpendicularAbsoluteUnitVector(direction);
- force = _currentScroll->force;
- } else {
- // The scroll view cannot scroll in this direction, and is rubber-banding.
- // Apply a constant and significant force; otherwise, the force for a
- // single-line increment is not strong enough to rubber-band perceptibly.
- force = unitVector(direction).scaled(self.parameters.rubberBandForce);
- }
-
- // If we've reached or exceeded the maximum velocity, stop applying any force.
- // However, we won't let the spring snap, we'll just keep going at the same
- // velocity until the user raises their finger or we hit an edge.
- if (fabs(_velocity.width()) >= fabs(_currentScroll->maximumVelocity.width()))
- force.setWidth(0);
- if (fabs(_velocity.height()) >= fabs(_currentScroll->maximumVelocity.height()))
- force.setHeight(0);
- }
-
- WebCore::FloatPoint idealPosition = [_scrollable boundedContentOffset:_currentScroll ? _currentPosition : _idealPosition];
- WebCore::FloatSize displacement = _currentPosition - idealPosition;
-
- // Compute the spring's force, and apply it in allowed directions.
- // F_spring = -k * x - c * v
- auto springForce = - displacement.scaled(self.parameters.springStiffness) - _velocity.scaled(self.parameters.springDamping);
- force += springForce * axesToApplySpring;
-
- // Integrate acceleration -> velocity -> position for this time step.
- CFTimeInterval frameDuration = sender.targetTimestamp - sender.timestamp;
- WebCore::FloatSize acceleration = force.scaled(1. / self.parameters.springMass);
- _velocity += acceleration.scaled(frameDuration);
- _currentPosition += _velocity.scaled(frameDuration);
-
- [_scrollable scrollToContentOffset:_currentPosition animated:NO];
-
- // If we've effectively stopped scrolling, and no key is pressed,
- // shut down the display link.
- if (!_hasPressedScrollingKey && _velocity.diagonalLengthSquared() < 1) {
- [_scrollable didFinishScrolling];
- [self stopDisplayLink];
- _velocity = { };
- }
-}
-
-#else
-
-- (void)startRepeatTimerIfNeeded
-{
- if (_repeatTimer)
- return;
-
- if (!_AXSKeyRepeatEnabled())
- return;
-
- _repeatTimer = [NSTimer scheduledTimerWithTimeInterval:_AXSKeyRepeatDelay() target:self selector:@selector(performDiscreteScroll) userInfo:nil repeats:YES];
-}
-
-- (void)stopRepeatTimer
-{
- [_repeatTimer invalidate];
- _repeatTimer = nil;
-}
-
-- (void)performDiscreteScroll
-{
- _currentPosition = WebCore::FloatPoint([_scrollable contentOffset]);
- _idealPositionForMinimumTravel = _currentPosition + _currentScroll->offset;
- [_scrollable scrollToContentOffset:[_scrollable boundedContentOffset:_idealPositionForMinimumTravel] animated:YES];
-}
-
-#endif
-
-@end
-
-@interface WKKeyboardScrollViewAnimator () <WKKeyboardScrollableInternal>
-@end
-
-@implementation WKKeyboardScrollViewAnimator {
- WeakObjCPtr<UIScrollView> _scrollView;
- RetainPtr<WKKeyboardScrollingAnimator> _animator;
-
- BOOL _delegateRespondsToIsKeyboardScrollable;
- BOOL _delegateRespondsToDistanceForIncrement;
- BOOL _delegateRespondsToWillScroll;
- BOOL _delegateRespondsToDidFinishScrolling;
-}
-
-- (instancetype)init
-{
- return nil;
-}
-
-- (instancetype)initWithScrollView:(UIScrollView *)scrollView
-{
- self = [super init];
- if (!self)
- return nil;
-
- _scrollView = scrollView;
- _animator = adoptNS([[WKKeyboardScrollingAnimator alloc] initWithScrollable:self]);
-
- return self;
-}
-
-- (void)dealloc
-{
- [_animator invalidate];
- [super dealloc];
-}
-
-- (void)invalidate
-{
- _scrollView = nil;
-
- [_animator invalidate];
- _animator = nil;
-}
-
-- (void)setDelegate:(id <WKKeyboardScrollViewAnimatorDelegate>)delegate
-{
- _delegate = delegate;
-
- _delegateRespondsToIsKeyboardScrollable = [_delegate respondsToSelector:@selector(isScrollableForKeyboardScrollViewAnimator:)];
- _delegateRespondsToDistanceForIncrement = [_delegate respondsToSelector:@selector(keyboardScrollViewAnimator:distanceForIncrement:)];
- _delegateRespondsToWillScroll = [_delegate respondsToSelector:@selector(keyboardScrollViewAnimatorWillScroll:)];
- _delegateRespondsToDidFinishScrolling = [_delegate respondsToSelector:@selector(keyboardScrollViewAnimatorDidFinishScrolling:)];
-}
-
-- (void)willStartInteractiveScroll
-{
- [_animator willStartInteractiveScroll];
-}
-
-- (BOOL)beginWithEvent:(::WebEvent *)event
-{
- return [_animator beginWithEvent:event];
-}
-
-- (void)handleKeyEvent:(::WebEvent *)event
-{
- return [_animator handleKeyEvent:event];
-}
-
-- (BOOL)isKeyboardScrollable
-{
- if (!_delegateRespondsToIsKeyboardScrollable)
- return YES;
- return [_delegate isScrollableForKeyboardScrollViewAnimator:self];
-}
-
-- (CGFloat)distanceForIncrement:(WebKit::ScrollingIncrement)increment
-{
- auto scrollView = _scrollView.getAutoreleased();
- if (!scrollView)
- return 0;
-
- const CGFloat defaultPageScrollFraction = 0.8;
- const CGFloat defaultLineScrollHeight = 40;
-
- if (!_delegateRespondsToDistanceForIncrement) {
- switch (increment) {
- case WebKit::ScrollingIncrement::Document:
- return scrollView.contentSize.height;
- case WebKit::ScrollingIncrement::Page:
- return scrollView.frame.size.height * defaultPageScrollFraction;
- case WebKit::ScrollingIncrement::Line:
- return defaultLineScrollHeight * scrollView.zoomScale;
- }
- ASSERT_NOT_REACHED();
- return 0;
- }
-
- return [_delegate keyboardScrollViewAnimator:self distanceForIncrement:increment];
-}
-
-- (void)scrollToContentOffset:(WebCore::FloatPoint)contentOffsetDelta animated:(BOOL)animated
-{
- auto scrollView = _scrollView.getAutoreleased();
- if (!scrollView)
- return;
- if (_delegateRespondsToWillScroll)
- [_delegate keyboardScrollViewAnimatorWillScroll:self];
- [scrollView setContentOffset:contentOffsetDelta animated:animated];
-#if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
- [scrollView _flashScrollIndicatorsPersistingPreviousFlashes:YES];
-#endif
-}
-
-- (void)scrollWithScrollToExtentAnimationTo:(CGPoint)offset
-{
- auto scrollView = _scrollView.getAutoreleased();
- [scrollView _setContentOffsetWithDecelerationAnimation:offset];
-#if ENABLE(ANIMATED_KEYBOARD_SCROLLING)
- [scrollView flashScrollIndicators];
-#endif
-}
-
-- (CGPoint)contentOffset
-{
- auto scrollView = _scrollView.getAutoreleased();
- if (!scrollView)
- return CGPointZero;
-
- return [scrollView contentOffset];
-}
-
-- (CGPoint)boundedContentOffset:(CGPoint)offset
-{
- auto scrollView = _scrollView.getAutoreleased();
- if (!scrollView)
- return CGPointZero;
-
- return [scrollView _adjustedContentOffsetForContentOffset:offset];
-}
-
-- (CGSize)interactiveScrollVelocity
-{
- auto scrollView = _scrollView.getAutoreleased();
- if (!scrollView)
- return CGSizeZero;
-
- const NSTimeInterval millisecondsPerSecond = 1000;
- return CGSizeMake(scrollView._horizontalVelocity * millisecondsPerSecond, scrollView._verticalVelocity * millisecondsPerSecond);
-}
-
-- (WebCore::RectEdges<bool>)scrollableDirectionsFromOffset:(CGPoint)offset
-{
- auto scrollView = _scrollView.getAutoreleased();
- if (!scrollView)
- return { };
-
- UIEdgeInsets contentInsets = scrollView.adjustedContentInset;
-
- CGSize contentSize = scrollView.contentSize;
- CGSize scrollViewSize = scrollView.bounds.size;
-
- CGPoint minimumContentOffset = CGPointMake(-contentInsets.left, -contentInsets.top);
- CGPoint maximumContentOffset = CGPointMake(std::max(minimumContentOffset.x, contentSize.width + contentInsets.right - scrollViewSize.width), std::max(minimumContentOffset.y, contentSize.height + contentInsets.bottom - scrollViewSize.height));
-
- WebCore::RectEdges<bool> edges;
-
- edges.setTop(offset.y > minimumContentOffset.y);
- edges.setBottom(offset.y < maximumContentOffset.y);
- edges.setLeft(offset.x > minimumContentOffset.x);
- edges.setRight(offset.x < maximumContentOffset.x);
-
- return edges;
-}
-
-- (WebCore::RectEdges<bool>)rubberbandableDirections
-{
- auto scrollView = _scrollView.getAutoreleased();
- if (!scrollView)
- return { };
-
- WebCore::RectEdges<bool> edges;
-
- edges.setTop(scrollView._canScrollWithoutBouncingY);
- edges.setBottom(edges.top());
- edges.setLeft(scrollView._canScrollWithoutBouncingX);
- edges.setRight(edges.left());
-
- return edges;
-}
-
-- (void)didFinishScrolling
-{
- if (_delegateRespondsToDidFinishScrolling)
- [_delegate keyboardScrollViewAnimatorDidFinishScrolling:self];
-}
-
-@end
-
-#endif // PLATFORM(IOS_FAMILY)
Modified: branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKPDFView.mm (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKPDFView.mm 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/ios/WKPDFView.mm 2019-01-18 20:39:24 UTC (rev 240166)
@@ -33,7 +33,6 @@
#import "PDFKitSPI.h"
#import "UIKitSPI.h"
#import "WKActionSheetAssistant.h"
-#import "WKKeyboardScrollingAnimator.h"
#import "WKUIDelegatePrivate.h"
#import "WKWebEvent.h"
#import "WKWebViewInternal.h"
@@ -68,7 +67,6 @@
WebKit::InteractionInformationAtPosition _positionInformation;
RetainPtr<NSString> _suggestedFilename;
WeakObjCPtr<WKWebView> _webView;
- RetainPtr<WKKeyboardScrollViewAnimator> _keyboardScrollingAnimator;
}
- (void)dealloc
@@ -76,7 +74,6 @@
[_actionSheetAssistant cleanupSheet];
[[_hostViewController view] removeFromSuperview];
[_pageNumberIndicator removeFromSuperview];
- [_keyboardScrollingAnimator invalidate];
std::memset(_passwordForPrinting.mutableData(), 0, _passwordForPrinting.length());
[super dealloc];
}
@@ -84,10 +81,6 @@
- (BOOL)web_handleKeyEvent:(::UIEvent *)event
{
auto webEvent = adoptNS([[WKWebEvent alloc] initWithEvent:event]);
-
- if ([_keyboardScrollingAnimator beginWithEvent:webEvent.get()])
- return YES;
- [_keyboardScrollingAnimator handleKeyEvent:webEvent.get()];
return NO;
}
@@ -115,8 +108,6 @@
self.backgroundColor = UIColor.grayColor;
webView.scrollView.backgroundColor = UIColor.grayColor;
- _keyboardScrollingAnimator = adoptNS([[WKKeyboardScrollViewAnimator alloc] initWithScrollView:webView.scrollView]);
-
_webView = webView;
return self;
}
Modified: branches/safari-607-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (240165 => 240166)
--- branches/safari-607-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-01-18 20:38:28 UTC (rev 240165)
+++ branches/safari-607-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2019-01-18 20:39:24 UTC (rev 240166)
@@ -713,7 +713,6 @@
2DD45ADE1E5F8972006C355F /* InputViewUpdateDeferrer.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD45ADC1E5F8972006C355F /* InputViewUpdateDeferrer.h */; };
2DD5A7291EBF08D5009BA597 /* VisibleWebPageCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD5A7281EBF08D5009BA597 /* VisibleWebPageCounter.h */; };
2DD5A72B1EBF09A7009BA597 /* HiddenPageThrottlingAutoIncreasesCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD5A72A1EBF09A7009BA597 /* HiddenPageThrottlingAutoIncreasesCounter.h */; };
- 2DD5E129210ADC7B00DB6012 /* WKKeyboardScrollingAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD5E127210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.h */; };
2DD67A2E1BD819730053B251 /* APIFindMatchesClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD67A2D1BD819730053B251 /* APIFindMatchesClient.h */; };
2DD67A351BD861060053B251 /* WKTextFinderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD67A331BD861060053B251 /* WKTextFinderClient.h */; };
2DD9EB2D1A6F012500BB1267 /* APINavigationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD9EB2C1A6F012500BB1267 /* APINavigationClient.h */; };
@@ -2778,8 +2777,6 @@
2DD45ADD1E5F8972006C355F /* InputViewUpdateDeferrer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = InputViewUpdateDeferrer.mm; path = ios/InputViewUpdateDeferrer.mm; sourceTree = "<group>"; };
2DD5A7281EBF08D5009BA597 /* VisibleWebPageCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisibleWebPageCounter.h; sourceTree = "<group>"; };
2DD5A72A1EBF09A7009BA597 /* HiddenPageThrottlingAutoIncreasesCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HiddenPageThrottlingAutoIncreasesCounter.h; sourceTree = "<group>"; };
- 2DD5E126210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKKeyboardScrollingAnimator.mm; path = ios/WKKeyboardScrollingAnimator.mm; sourceTree = "<group>"; };
- 2DD5E127210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKKeyboardScrollingAnimator.h; path = ios/WKKeyboardScrollingAnimator.h; sourceTree = "<group>"; };
2DD67A2D1BD819730053B251 /* APIFindMatchesClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIFindMatchesClient.h; sourceTree = "<group>"; };
2DD67A331BD861060053B251 /* WKTextFinderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKTextFinderClient.h; sourceTree = "<group>"; };
2DD67A341BD861060053B251 /* WKTextFinderClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKTextFinderClient.mm; sourceTree = "<group>"; };
@@ -5848,8 +5845,6 @@
0F3C7257196F5F5000AEDD0C /* WKInspectorHighlightView.mm */,
A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */,
A54293A3195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm */,
- 2DD5E127210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.h */,
- 2DD5E126210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.mm */,
2DA1E4FC18C02B6A00DBC929 /* WKLegacyPDFView.h */,
2DA1E4FD18C02B6A00DBC929 /* WKLegacyPDFView.mm */,
A15EEDE41E301CEE000069B0 /* WKPasswordView.h */,
@@ -9701,7 +9696,6 @@
994BADF41F7D781400B571E7 /* WKInspectorViewController.h in Headers */,
A5C0F0AB2000658200536536 /* WKInspectorWindow.h in Headers */,
A518B5D21FE1D55B00F9FA28 /* WKInspectorWKWebView.h in Headers */,
- 2DD5E129210ADC7B00DB6012 /* WKKeyboardScrollingAnimator.h in Headers */,
51A9E10B1315CD18009E7031 /* WKKeyValueStorageManager.h in Headers */,
2D790A9F1AD7164900AB90B3 /* WKLayoutMode.h in Headers */,
2DA1E4FE18C02B6A00DBC929 /* WKLegacyPDFView.h in Headers */,