OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" | 5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.
h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/mac/objc_property_releaser.h" | |
12 #include "base/mac/scoped_nsobject.h" | |
13 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
14 #import "ios/chrome/browser/ui/browser_view_controller.h" | 12 #import "ios/chrome/browser/ui/browser_view_controller.h" |
15 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_rec
ognizer.h" | 13 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_rec
ognizer.h" |
16 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h" | 14 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h" |
17 #include "ios/chrome/browser/ui/rtl_geometry.h" | 15 #include "ios/chrome/browser/ui/rtl_geometry.h" |
18 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | 16 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
19 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" | 17 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
20 #include "ios/chrome/browser/ui/uikit_ui_util.h" | 18 #include "ios/chrome/browser/ui/uikit_ui_util.h" |
21 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" | 19 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" |
22 #import "ios/web/public/web_state/ui/crw_web_view_proxy.h" | 20 #import "ios/web/public/web_state/ui/crw_web_view_proxy.h" |
23 | 21 |
| 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 23 #error "This file requires ARC support." |
| 24 #endif |
| 25 |
24 namespace { | 26 namespace { |
25 // This enum is used to record the overscroll actions performed by the user on | 27 // This enum is used to record the overscroll actions performed by the user on |
26 // the histogram named |OverscrollActions|. | 28 // the histogram named |OverscrollActions|. |
27 enum { | 29 enum { |
28 // Records each time the user selects the new tab action. | 30 // Records each time the user selects the new tab action. |
29 OVERSCROLL_ACTION_NEW_TAB, | 31 OVERSCROLL_ACTION_NEW_TAB, |
30 // Records each time the user selects the refresh action. | 32 // Records each time the user selects the refresh action. |
31 OVERSCROLL_ACTION_REFRESH, | 33 OVERSCROLL_ACTION_REFRESH, |
32 // Records each time the user selects the close tab action. | 34 // Records each time the user selects the close tab action. |
33 OVERSCROLL_ACTION_CLOSE_TAB, | 35 OVERSCROLL_ACTION_CLOSE_TAB, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 BOOL _allowPullingActions; | 145 BOOL _allowPullingActions; |
144 // Records if a transition to the overscroll state ACTION_READY was made. | 146 // Records if a transition to the overscroll state ACTION_READY was made. |
145 // This is used to record a cancel gesture. | 147 // This is used to record a cancel gesture. |
146 BOOL _didTransitionToActionReady; | 148 BOOL _didTransitionToActionReady; |
147 // Records that the controller will be dismissed at the end of the current | 149 // Records that the controller will be dismissed at the end of the current |
148 // animation. No new action should be started. | 150 // animation. No new action should be started. |
149 BOOL _shouldInvalidate; | 151 BOOL _shouldInvalidate; |
150 // Store the set of notifications that did increment the overscroll actions | 152 // Store the set of notifications that did increment the overscroll actions |
151 // lock. It is used in order to enforce the fact that the lock should only be | 153 // lock. It is used in order to enforce the fact that the lock should only be |
152 // incremented/decremented once for a given notification. | 154 // incremented/decremented once for a given notification. |
153 base::scoped_nsobject<NSMutableSet> _lockIncrementNotifications; | 155 NSMutableSet* _lockIncrementNotifications; |
154 // Store the notification name counterpart of another notification name. | 156 // Store the notification name counterpart of another notification name. |
155 // Overscroll actions locking and unlocking works by listening to balanced | 157 // Overscroll actions locking and unlocking works by listening to balanced |
156 // notifications. One notification lock and it's counterpart unlock. This | 158 // notifications. One notification lock and it's counterpart unlock. This |
157 // dictionary is used to retrieve the notification name from it's notification | 159 // dictionary is used to retrieve the notification name from it's notification |
158 // counterpart name. Exemple: | 160 // counterpart name. Exemple: |
159 // UIKeyboardWillShowNotification trigger a lock. Its counterpart notification | 161 // UIKeyboardWillShowNotification trigger a lock. Its counterpart notification |
160 // name is UIKeyboardWillHideNotification. | 162 // name is UIKeyboardWillHideNotification. |
161 base::scoped_nsobject<NSDictionary> _lockNotificationsCounterparts; | 163 NSDictionary* _lockNotificationsCounterparts; |
162 // A view used to catch touches on the webview. | 164 // A view used to catch touches on the webview. |
163 base::scoped_nsobject<UIView> _dummyView; | 165 UIView* _dummyView; |
164 // The proxy used to interact with the webview. | 166 // The proxy used to interact with the webview. |
165 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; | 167 id<CRWWebViewProxy> _webViewProxy; |
166 // The proxy used to interact with the webview's scrollview. | 168 // The proxy used to interact with the webview's scrollview. |
167 base::scoped_nsobject<CRWWebViewScrollViewProxy> _webViewScrollViewProxy; | 169 CRWWebViewScrollViewProxy* _webViewScrollViewProxy; |
168 // The scrollview driving the OverscrollActionsController when not using | 170 // The scrollview driving the OverscrollActionsController when not using |
169 // the scrollview from the CRWWebControllerObserver. | 171 // the scrollview from the CRWWebControllerObserver. |
170 base::scoped_nsobject<UIScrollView> _scrollview; | 172 UIScrollView* _scrollview; |
171 base::mac::ObjCPropertyReleaser _propertyReleaser_OverscrollActionsController; | |
172 } | 173 } |
173 | 174 |
174 // The view displayed over the header view holding the actions. | 175 // The view displayed over the header view holding the actions. |
175 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; | 176 @property(nonatomic, strong) OverscrollActionsView* overscrollActionView; |
176 // Initial top inset added to the scrollview for the header. | 177 // Initial top inset added to the scrollview for the header. |
177 // This property is set from the delegate headerInset and cached on first | 178 // This property is set from the delegate headerInset and cached on first |
178 // call. The cached value is reset when the webview proxy is set. | 179 // call. The cached value is reset when the webview proxy is set. |
179 @property(nonatomic, readonly) CGFloat initialContentInset; | 180 @property(nonatomic, readonly) CGFloat initialContentInset; |
180 // Initial top inset for the header. | 181 // Initial top inset for the header. |
181 // This property is set from the delegate headerInset and cached on first | 182 // This property is set from the delegate headerInset and cached on first |
182 // call. The cached value is reset when the webview proxy is set. | 183 // call. The cached value is reset when the webview proxy is set. |
183 @property(nonatomic, readonly) CGFloat initialHeaderInset; | 184 @property(nonatomic, readonly) CGFloat initialHeaderInset; |
184 // Initial height of the header view. | 185 // Initial height of the header view. |
185 // This property is set from the delegate headerHeight and cached on first | 186 // This property is set from the delegate headerHeight and cached on first |
186 // call. The cached value is reset when the webview proxy is set. | 187 // call. The cached value is reset when the webview proxy is set. |
187 @property(nonatomic, readonly) CGFloat initialHeaderHeight; | 188 @property(nonatomic, readonly) CGFloat initialHeaderHeight; |
188 // Redefined to be read-write. | 189 // Redefined to be read-write. |
189 @property(nonatomic, assign, readwrite) OverscrollState overscrollState; | 190 @property(nonatomic, assign, readwrite) OverscrollState overscrollState; |
190 // Point where the horizontal gesture started when the state of the | 191 // Point where the horizontal gesture started when the state of the |
191 // overscroll controller is in OverscrollStateActionReady. | 192 // overscroll controller is in OverscrollStateActionReady. |
192 @property(nonatomic, assign) CGPoint panPointScreenOrigin; | 193 @property(nonatomic, assign) CGPoint panPointScreenOrigin; |
193 // Pan gesture recognizer used to track horizontal touches. | 194 // Pan gesture recognizer used to track horizontal touches. |
194 @property(nonatomic, retain) UIPanGestureRecognizer* panGestureRecognizer; | 195 @property(nonatomic, strong) UIPanGestureRecognizer* panGestureRecognizer; |
195 | 196 |
196 // Registers notifications to lock the overscroll actions on certain UI states. | 197 // Registers notifications to lock the overscroll actions on certain UI states. |
197 - (void)registerNotifications; | 198 - (void)registerNotifications; |
198 // Setup/tearDown methods are used to register values when the delegate is set. | 199 // Setup/tearDown methods are used to register values when the delegate is set. |
199 - (void)tearDown; | 200 - (void)tearDown; |
200 - (void)setup; | 201 - (void)setup; |
201 // Resets scroll view's top content inset to |self.initialContentInset|. | 202 // Resets scroll view's top content inset to |self.initialContentInset|. |
202 - (void)resetScrollViewTopContentInset; | 203 - (void)resetScrollViewTopContentInset; |
203 // Access the headerView from the delegate. | 204 // Access the headerView from the delegate. |
204 - (UIView<RelaxedBoundsConstraintsHitTestSupport>*)headerView; | 205 - (UIView<RelaxedBoundsConstraintsHitTestSupport>*)headerView; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 @synthesize panPointScreenOrigin = _panPointScreenOrigin; | 240 @synthesize panPointScreenOrigin = _panPointScreenOrigin; |
240 @synthesize panGestureRecognizer = _panGestureRecognizer; | 241 @synthesize panGestureRecognizer = _panGestureRecognizer; |
241 | 242 |
242 - (instancetype)init { | 243 - (instancetype)init { |
243 return [self initWithScrollView:nil]; | 244 return [self initWithScrollView:nil]; |
244 } | 245 } |
245 | 246 |
246 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { | 247 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { |
247 self = [super init]; | 248 self = [super init]; |
248 if (self) { | 249 if (self) { |
249 _propertyReleaser_OverscrollActionsController.Init( | |
250 self, [OverscrollActionsController class]); | |
251 _overscrollActionView = | 250 _overscrollActionView = |
252 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; | 251 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; |
253 _overscrollActionView.delegate = self; | 252 _overscrollActionView.delegate = self; |
254 _scrollview.reset([scrollView retain]); | 253 _scrollview = scrollView; |
255 if (_scrollview) { | 254 if (_scrollview) { |
256 [self setup]; | 255 [self setup]; |
257 } | 256 } |
258 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); | 257 _lockIncrementNotifications = [[NSMutableSet alloc] init]; |
259 | 258 |
260 _lockNotificationsCounterparts.reset([@{ | 259 _lockNotificationsCounterparts = @{ |
261 UIKeyboardWillHideNotification : UIKeyboardWillShowNotification, | 260 UIKeyboardWillHideNotification : UIKeyboardWillShowNotification, |
262 kMenuWillHideNotification : kMenuWillShowNotification, | 261 kMenuWillHideNotification : kMenuWillShowNotification, |
263 kTabHistoryPopupWillHideNotification : | 262 kTabHistoryPopupWillHideNotification : |
264 kTabHistoryPopupWillShowNotification, | 263 kTabHistoryPopupWillShowNotification, |
265 kVoiceSearchWillHideNotification : kVoiceSearchWillShowNotification, | 264 kVoiceSearchWillHideNotification : kVoiceSearchWillShowNotification, |
266 kVoiceSearchBarViewButtonDeselectedNotification : | 265 kVoiceSearchBarViewButtonDeselectedNotification : |
267 kVoiceSearchBarViewButtonSelectedNotification, | 266 kVoiceSearchBarViewButtonSelectedNotification, |
268 ios_internal::kPageInfoWillHideNotification : | 267 ios_internal::kPageInfoWillHideNotification : |
269 ios_internal::kPageInfoWillShowNotification, | 268 ios_internal::kPageInfoWillShowNotification, |
270 ios_internal::kLocationBarResignsFirstResponderNotification : | 269 ios_internal::kLocationBarResignsFirstResponderNotification : |
271 ios_internal::kLocationBarBecomesFirstResponderNotification, | 270 ios_internal::kLocationBarBecomesFirstResponderNotification, |
272 ios_internal::kSideSwipeDidStopNotification : | 271 ios_internal::kSideSwipeDidStopNotification : |
273 ios_internal::kSideSwipeWillStartNotification | 272 ios_internal::kSideSwipeWillStartNotification |
274 } retain]); | 273 }; |
275 [self registerNotifications]; | 274 [self registerNotifications]; |
276 } | 275 } |
277 return self; | 276 return self; |
278 } | 277 } |
279 | 278 |
280 - (void)dealloc { | 279 - (void)dealloc { |
281 self.overscrollActionView.delegate = nil; | 280 self.overscrollActionView.delegate = nil; |
282 [self invalidate]; | 281 [self invalidate]; |
283 [super dealloc]; | |
284 } | 282 } |
285 | 283 |
286 - (void)scheduleInvalidate { | 284 - (void)scheduleInvalidate { |
287 if (self.overscrollState == OverscrollState::NO_PULL_STARTED) { | 285 if (self.overscrollState == OverscrollState::NO_PULL_STARTED) { |
288 [self invalidate]; | 286 [self invalidate]; |
289 } else { | 287 } else { |
290 _shouldInvalidate = YES; | 288 _shouldInvalidate = YES; |
291 } | 289 } |
292 } | 290 } |
293 | 291 |
294 - (void)invalidate { | 292 - (void)invalidate { |
295 [self clear]; | 293 [self clear]; |
296 [self stopBounce]; | 294 [self stopBounce]; |
297 [self tearDown]; | 295 [self tearDown]; |
298 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 296 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
299 [self setWebViewInteractionEnabled:YES]; | 297 [self setWebViewInteractionEnabled:YES]; |
300 _delegate = nil; | 298 _delegate = nil; |
301 _webViewProxy.reset(); | 299 _webViewProxy = nil; |
302 [_webViewScrollViewProxy removeObserver:self]; | 300 [_webViewScrollViewProxy removeObserver:self]; |
303 _webViewScrollViewProxy.reset(); | 301 _webViewScrollViewProxy = nil; |
304 } | 302 } |
305 | 303 |
306 - (void)clear { | 304 - (void)clear { |
307 self.overscrollState = OverscrollState::NO_PULL_STARTED; | 305 self.overscrollState = OverscrollState::NO_PULL_STARTED; |
308 } | 306 } |
309 | 307 |
310 - (void)enableOverscrollActions { | 308 - (void)enableOverscrollActions { |
311 _isOverscrollActionsDisabledForLoading = NO; | 309 _isOverscrollActionsDisabledForLoading = NO; |
312 [self setup]; | 310 [self setup]; |
313 } | 311 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 return YES; | 506 return YES; |
509 } | 507 } |
510 | 508 |
511 #pragma mark - CRWWebControllerObserver methods | 509 #pragma mark - CRWWebControllerObserver methods |
512 | 510 |
513 - (void)setWebViewProxy:(id<CRWWebViewProxy>)webViewProxy | 511 - (void)setWebViewProxy:(id<CRWWebViewProxy>)webViewProxy |
514 controller:(CRWWebController*)webController { | 512 controller:(CRWWebController*)webController { |
515 DCHECK([webViewProxy scrollViewProxy]); | 513 DCHECK([webViewProxy scrollViewProxy]); |
516 _initialHeaderInset = 0; | 514 _initialHeaderInset = 0; |
517 _initialHeaderHeight = 0; | 515 _initialHeaderHeight = 0; |
518 _webViewProxy.reset([webViewProxy retain]); | 516 _webViewProxy = webViewProxy; |
519 [_webViewScrollViewProxy removeObserver:self]; | 517 [_webViewScrollViewProxy removeObserver:self]; |
520 _webViewScrollViewProxy.reset([[webViewProxy scrollViewProxy] retain]); | 518 _webViewScrollViewProxy = [webViewProxy scrollViewProxy]; |
521 [_webViewScrollViewProxy addObserver:self]; | 519 [_webViewScrollViewProxy addObserver:self]; |
522 [self enableOverscrollActions]; | 520 [self enableOverscrollActions]; |
523 } | 521 } |
524 | 522 |
525 - (void)webControllerWillClose:(CRWWebController*)webController { | 523 - (void)webControllerWillClose:(CRWWebController*)webController { |
526 [self disableOverscrollActions]; | 524 [self disableOverscrollActions]; |
527 [_webViewScrollViewProxy removeObserver:self]; | 525 [_webViewScrollViewProxy removeObserver:self]; |
528 _webViewScrollViewProxy.reset(); | 526 _webViewScrollViewProxy = nil; |
529 } | 527 } |
530 | 528 |
531 #pragma mark - Private | 529 #pragma mark - Private |
532 | 530 |
533 - (void)recordMetricForTriggeredAction:(OverscrollAction)action { | 531 - (void)recordMetricForTriggeredAction:(OverscrollAction)action { |
534 switch (action) { | 532 switch (action) { |
535 case OverscrollAction::NONE: | 533 case OverscrollAction::NONE: |
536 UMA_HISTOGRAM_ENUMERATION(kOverscrollActionsHistogram, | 534 UMA_HISTOGRAM_ENUMERATION(kOverscrollActionsHistogram, |
537 OVERSCROLL_ACTION_CANCELED, | 535 OVERSCROLL_ACTION_CANCELED, |
538 OVERSCROLL_ACTION_COUNT); | 536 OVERSCROLL_ACTION_COUNT); |
(...skipping 12 matching lines...) Expand all Loading... |
551 UMA_HISTOGRAM_ENUMERATION(kOverscrollActionsHistogram, | 549 UMA_HISTOGRAM_ENUMERATION(kOverscrollActionsHistogram, |
552 OVERSCROLL_ACTION_CLOSE_TAB, | 550 OVERSCROLL_ACTION_CLOSE_TAB, |
553 OVERSCROLL_ACTION_COUNT); | 551 OVERSCROLL_ACTION_COUNT); |
554 break; | 552 break; |
555 } | 553 } |
556 } | 554 } |
557 | 555 |
558 - (void)registerNotifications { | 556 - (void)registerNotifications { |
559 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 557 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
560 for (NSString* counterpartNotificationName in _lockNotificationsCounterparts | 558 for (NSString* counterpartNotificationName in _lockNotificationsCounterparts |
561 .get()) { | 559 .allKeys) { |
562 [center addObserver:self | 560 [center addObserver:self |
563 selector:@selector(incrementOverscrollActionLockForNotification:) | 561 selector:@selector(incrementOverscrollActionLockForNotification:) |
564 name:[_lockNotificationsCounterparts | 562 name:[_lockNotificationsCounterparts |
565 objectForKey:counterpartNotificationName] | 563 objectForKey:counterpartNotificationName] |
566 object:nil]; | 564 object:nil]; |
567 [center addObserver:self | 565 [center addObserver:self |
568 selector:@selector(decrementOverscrollActionLockForNotification:) | 566 selector:@selector(decrementOverscrollActionLockForNotification:) |
569 name:counterpartNotificationName | 567 name:counterpartNotificationName |
570 object:nil]; | 568 object:nil]; |
571 } | 569 } |
572 [center addObserver:self | 570 [center addObserver:self |
573 selector:@selector(deviceOrientationDidChange) | 571 selector:@selector(deviceOrientationDidChange) |
574 name:UIDeviceOrientationDidChangeNotification | 572 name:UIDeviceOrientationDidChangeNotification |
575 object:nil]; | 573 object:nil]; |
576 } | 574 } |
577 | 575 |
578 - (void)tearDown { | 576 - (void)tearDown { |
579 [[self scrollView] removeGestureRecognizer:self.panGestureRecognizer]; | 577 [[self scrollView] removeGestureRecognizer:self.panGestureRecognizer]; |
580 self.panGestureRecognizer = nil; | 578 self.panGestureRecognizer = nil; |
581 } | 579 } |
582 | 580 |
583 - (void)setup { | 581 - (void)setup { |
584 base::scoped_nsobject<UIPanGestureRecognizer> panGesture; | 582 UIPanGestureRecognizer* panGesture; |
585 // Workaround a bug occuring when Speak Selection is enabled. | 583 // Workaround a bug occuring when Speak Selection is enabled. |
586 // See crbug.com/699655. | 584 // See crbug.com/699655. |
587 if (UIAccessibilityIsSpeakSelectionEnabled()) { | 585 if (UIAccessibilityIsSpeakSelectionEnabled()) { |
588 panGesture.reset([[OverscrollActionsGestureRecognizer alloc] | 586 panGesture = [[OverscrollActionsGestureRecognizer alloc] |
589 initWithTarget:self | 587 initWithTarget:self |
590 action:@selector(panGesture:)]); | 588 action:@selector(panGesture:)]; |
591 } else { | 589 } else { |
592 panGesture.reset([[UIPanGestureRecognizer alloc] | 590 panGesture = |
593 initWithTarget:self | 591 [[UIPanGestureRecognizer alloc] initWithTarget:self |
594 action:@selector(panGesture:)]); | 592 action:@selector(panGesture:)]; |
595 } | 593 } |
596 [panGesture setMaximumNumberOfTouches:1]; | 594 [panGesture setMaximumNumberOfTouches:1]; |
597 [panGesture setDelegate:self]; | 595 [panGesture setDelegate:self]; |
598 [[self scrollView] addGestureRecognizer:panGesture]; | 596 [[self scrollView] addGestureRecognizer:panGesture]; |
599 self.panGestureRecognizer = panGesture.get(); | 597 self.panGestureRecognizer = panGesture; |
600 } | 598 } |
601 | 599 |
602 - (id<OverscrollActionsScrollView>)scrollView { | 600 - (id<OverscrollActionsScrollView>)scrollView { |
603 if (_scrollview) { | 601 if (_scrollview) { |
604 return static_cast<id<OverscrollActionsScrollView>>(_scrollview.get()); | 602 return static_cast<id<OverscrollActionsScrollView>>(_scrollview); |
605 } else { | 603 } else { |
606 return static_cast<id<OverscrollActionsScrollView>>( | 604 return static_cast<id<OverscrollActionsScrollView>>( |
607 _webViewScrollViewProxy.get()); | 605 _webViewScrollViewProxy); |
608 } | 606 } |
609 } | 607 } |
610 | 608 |
611 - (void)setScrollViewContentInset:(UIEdgeInsets)contentInset { | 609 - (void)setScrollViewContentInset:(UIEdgeInsets)contentInset { |
612 if (_scrollview) | 610 if (_scrollview) |
613 [_scrollview setContentInset:contentInset]; | 611 [_scrollview setContentInset:contentInset]; |
614 else | 612 else |
615 [_webViewScrollViewProxy setContentInset:contentInset]; | 613 [_webViewScrollViewProxy setContentInset:contentInset]; |
616 } | 614 } |
617 | 615 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 for (UIGestureRecognizer* gesture in | 779 for (UIGestureRecognizer* gesture in |
782 [_webViewScrollViewProxy gestureRecognizers]) { | 780 [_webViewScrollViewProxy gestureRecognizers]) { |
783 if (![gesture isKindOfClass:[UIPanGestureRecognizer class]]) { | 781 if (![gesture isKindOfClass:[UIPanGestureRecognizer class]]) { |
784 [gesture setEnabled:enabled]; | 782 [gesture setEnabled:enabled]; |
785 } | 783 } |
786 } | 784 } |
787 // Add a dummy view on top of the webview in order to catch touches on some | 785 // Add a dummy view on top of the webview in order to catch touches on some |
788 // specific subviews. | 786 // specific subviews. |
789 if (!enabled) { | 787 if (!enabled) { |
790 if (!_dummyView) | 788 if (!_dummyView) |
791 _dummyView.reset([[UIView alloc] init]); | 789 _dummyView = [[UIView alloc] init]; |
792 [_dummyView setFrame:[_webViewProxy bounds]]; | 790 [_dummyView setFrame:[_webViewProxy bounds]]; |
793 [_webViewProxy addSubview:_dummyView]; | 791 [_webViewProxy addSubview:_dummyView]; |
794 } else { | 792 } else { |
795 [_dummyView removeFromSuperview]; | 793 [_dummyView removeFromSuperview]; |
796 } | 794 } |
797 } | 795 } |
798 | 796 |
799 - (void)updateWithVerticalOffset:(CGFloat)verticalOffset { | 797 - (void)updateWithVerticalOffset:(CGFloat)verticalOffset { |
800 self.overscrollActionView.backgroundView.alpha = | 798 self.overscrollActionView.backgroundView.alpha = |
801 1.0 - | 799 1.0 - |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 overscrollActionsController:self | 915 overscrollActionsController:self |
918 didTriggerAction:self.overscrollActionView.selectedAction]; | 916 didTriggerAction:self.overscrollActionView.selectedAction]; |
919 } | 917 } |
920 | 918 |
921 - (void)overscrollActionsView:(OverscrollActionsView*)view | 919 - (void)overscrollActionsView:(OverscrollActionsView*)view |
922 selectedActionDidChange:(OverscrollAction)newAction { | 920 selectedActionDidChange:(OverscrollAction)newAction { |
923 TriggerHapticFeedbackForSelectionChange(); | 921 TriggerHapticFeedbackForSelectionChange(); |
924 } | 922 } |
925 | 923 |
926 @end | 924 @end |
OLD | NEW |