Changeset 163795 in webkit
- Timestamp:
- Feb 10, 2014 10:09:55 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r163794 r163795 1 2014-02-10 Tim Horton <timothy_horton@apple.com> 2 3 [iOS][wk2] WebKit2 View Gestures (Swipe): Forward swipe gesture 4 https://bugs.webkit.org/show_bug.cgi?id=128523 5 <rdar://problem/16020378> 6 7 Reviewed by Darin Adler. 8 9 We can't install the gesture recognizer on a view that's going to be 10 reparented during the swipe, because the gesture will be cancelled. 11 Install the recognizer on the WKView and move the WKView's scrollview 12 child around instead. 13 14 * UIProcess/API/ios/WKViewIOS.mm: 15 (-[WKView setAllowsBackForwardNavigationGestures:]): 16 We'll install the gesture recognizer on the WKView, but swipe the scrollview. 17 18 * UIProcess/ios/ViewGestureControllerIOS.mm: 19 (-[WKSwipeTransitionController initWithViewGestureController:gestureRecognizerView:]): 20 Clarify that WKSwipeTransitionController gets handed only the view to install the gesture recognizer on. 21 (-[WKSwipeTransitionController gestureRecognizerForInteractiveTransition:WithTarget:action:]): 22 Use public enum values so we can get rid of one private header. 23 24 (WebKit::ViewGestureController::installSwipeHandler): 25 Separate out the gesture recognizer view from the one that gets swiped. 26 27 (WebKit::ViewGestureController::beginSwipeGesture): 28 Record a snapshot before beginning the swipe. This is important for the back-then-forward 29 swipe case, and matches the behavior of the Mac implementation. 30 31 (WebKit::ViewGestureController::endSwipeGesture): 32 * UIProcess/mac/ViewGestureController.h: 33 Slight geometry adjustments due to the change in targetted view. 34 1 35 2014-02-10 Filip Pizlo <fpizlo@apple.com> 2 36 -
trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm
r163666 r163795 117 117 if (allowsBackForwardNavigationGestures && !_gestureController) { 118 118 _gestureController = std::make_unique<ViewGestureController>(*webPageProxy); 119 _gestureController->installSwipeHandler(self );119 _gestureController->installSwipeHandler(self, [self scrollView]); 120 120 } else 121 121 _gestureController = nullptr; -
trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm
r163666 r163795 36 36 #import "WebProcessProxy.h" 37 37 #import <QuartzCore/QuartzCore.h> 38 #import <UIKit/UIApplication_Private.h>39 38 #import <UIKit/UIScreenEdgePanGestureRecognizer.h> 40 39 #import <UIKit/UIViewControllerTransitioning_Private.h> … … 51 50 52 51 @interface WKSwipeTransitionController : NSObject <_UINavigationInteractiveTransitionBaseDelegate> 53 - (instancetype)initWithViewGestureController:(WebKit::ViewGestureController*)gestureController swipingView:(UIView *)view;52 - (instancetype)initWithViewGestureController:(WebKit::ViewGestureController*)gestureController gestureRecognizerView:(UIView *)gestureRecognizerView; 54 53 @end 55 54 … … 58 57 WebKit::ViewGestureController *_gestureController; 59 58 RetainPtr<_UINavigationInteractiveTransitionBase> _backTransitionController; 59 RetainPtr<_UINavigationInteractiveTransitionBase> _forwardTransitionController; 60 60 } 61 61 … … 63 63 static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 3_s; 64 64 65 - (instancetype)initWithViewGestureController:(WebKit::ViewGestureController*)gestureController swipingView:(UIView *)view65 - (instancetype)initWithViewGestureController:(WebKit::ViewGestureController*)gestureController gestureRecognizerView:(UIView *)gestureRecognizerView 66 66 { 67 67 self = [super init]; … … 70 70 71 71 _backTransitionController = adoptNS([_UINavigationInteractiveTransitionBase alloc]); 72 _backTransitionController = [_backTransitionController initWithGestureRecognizerView:view animator:nil delegate:self]; 72 _backTransitionController = [_backTransitionController initWithGestureRecognizerView:gestureRecognizerView animator:nil delegate:self]; 73 74 _forwardTransitionController = adoptNS([_UINavigationInteractiveTransitionBase alloc]); 75 _forwardTransitionController = [_forwardTransitionController initWithGestureRecognizerView:gestureRecognizerView animator:nil delegate:self]; 76 [_forwardTransitionController setShouldReverseTranslation:YES]; 73 77 } 74 78 return self; … … 105 109 switch ([self directionForTransition:transition]) { 106 110 case WebKit::ViewGestureController::SwipeDirection::Left: 107 [recognizer setEdges:UI MinXEdge];111 [recognizer setEdges:UIRectEdgeLeft]; 108 112 break; 109 113 case WebKit::ViewGestureController::SwipeDirection::Right: 110 [recognizer setEdges:UI MaxXEdge];114 [recognizer setEdges:UIRectEdgeRight]; 111 115 break; 112 116 } … … 130 134 } 131 135 132 void ViewGestureController::installSwipeHandler(UIView * view)136 void ViewGestureController::installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView) 133 137 { 134 138 ASSERT(!m_swipeInteractiveTransitionDelegate); 135 m_swipeInteractiveTransitionDelegate = adoptNS([[WKSwipeTransitionController alloc] initWithViewGestureController:this swipingView:view]);136 m_liveSwipeView = view;139 m_swipeInteractiveTransitionDelegate = adoptNS([[WKSwipeTransitionController alloc] initWithViewGestureController:this gestureRecognizerView:gestureRecognizerView]); 140 m_liveSwipeView = swipingView; 137 141 } 138 142 … … 141 145 if (m_activeGestureType != ViewGestureType::None) 142 146 return; 147 148 ViewSnapshotStore::shared().recordSnapshot(m_webPageProxy); 143 149 144 150 WebKit::WebBackForwardListItem* targetItem = direction == SwipeDirection::Left ? m_webPageProxy.backForwardList().backItem() : m_webPageProxy.backForwardList().forwardItem(); … … 147 153 148 154 RetainPtr<UIViewController> snapshotViewController = adoptNS([[UIViewController alloc] init]); 149 m_snapshotView = adoptNS([[UIView alloc] initWithFrame:[m_liveSwipeView bounds]]);155 m_snapshotView = adoptNS([[UIView alloc] initWithFrame:[m_liveSwipeView frame]]); 150 156 if (snapshot) { 151 157 #if USE(IOSURFACE) … … 172 178 [targettedViewController setView:m_liveSwipeView]; 173 179 174 m_originalLiveSwipeViewFrame = m_liveSwipeView.frame;175 m_liveSwipeView.frame = m_liveSwipeView.bounds;176 177 180 UINavigationControllerOperation transitionOperation = direction == SwipeDirection::Left ? UINavigationControllerOperationPop : UINavigationControllerOperationPush; 178 181 RetainPtr<_UINavigationParallaxTransition> animationController = adoptNS([[_UINavigationParallaxTransition alloc] initWithCurrentOperation:transitionOperation]); … … 182 185 [transitionContext _setToViewController:snapshotViewController.get()]; 183 186 [transitionContext _setContainerView:m_transitionContainerView.get()]; 184 [transitionContext _setFromStartFrame:[m_liveSwipeView bounds]];185 [transitionContext _setToEndFrame:[m_liveSwipeView bounds]];187 [transitionContext _setFromStartFrame:[m_liveSwipeView frame]]; 188 [transitionContext _setToEndFrame:[m_liveSwipeView frame]]; 186 189 [transitionContext _setToStartFrame:CGRectZero]; 187 190 [transitionContext _setFromEndFrame:CGRectZero]; … … 215 218 m_transitionContainerView = nullptr; 216 219 217 [m_liveSwipeView setFrame:m_originalLiveSwipeViewFrame];218 [m_snapshotView setFrame:m_originalLiveSwipeViewFrame];219 220 220 if (cancelled) { 221 221 removeSwipeSnapshot(); -
trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h
r163666 r163795 88 88 void endActiveGesture(); 89 89 #else 90 void installSwipeHandler(UIView * );90 void installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView); 91 91 bool canSwipeInDirection(SwipeDirection); 92 92 void beginSwipeGesture(_UINavigationInteractiveTransitionBase *, SwipeDirection); … … 145 145 bool m_hasPendingSwipe; 146 146 SwipeDirection m_pendingSwipeDirection; 147 #else 148 CGRect m_originalLiveSwipeViewFrame; 149 147 #else 150 148 UIView *m_liveSwipeView; 151 149 RetainPtr<UIView> m_snapshotView;
Note: See TracChangeset
for help on using the changeset viewer.