| 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" | 11 #include "base/mac/objc_release_properties.h" |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #import "ios/chrome/browser/ui/browser_view_controller.h" | 14 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 15 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_rec
ognizer.h" | 15 #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" | 16 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_view.h" |
| 17 #include "ios/chrome/browser/ui/rtl_geometry.h" | 17 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 18 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" | 18 #import "ios/chrome/browser/ui/toolbar/toolbar_controller.h" |
| 19 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" | 19 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
| 20 #include "ios/chrome/browser/ui/uikit_ui_util.h" | 20 #include "ios/chrome/browser/ui/uikit_ui_util.h" |
| 21 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" | 21 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 base::scoped_nsobject<NSDictionary> _lockNotificationsCounterparts; | 161 base::scoped_nsobject<NSDictionary> _lockNotificationsCounterparts; |
| 162 // A view used to catch touches on the webview. | 162 // A view used to catch touches on the webview. |
| 163 base::scoped_nsobject<UIView> _dummyView; | 163 base::scoped_nsobject<UIView> _dummyView; |
| 164 // The proxy used to interact with the webview. | 164 // The proxy used to interact with the webview. |
| 165 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; | 165 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; |
| 166 // The proxy used to interact with the webview's scrollview. | 166 // The proxy used to interact with the webview's scrollview. |
| 167 base::scoped_nsobject<CRWWebViewScrollViewProxy> _webViewScrollViewProxy; | 167 base::scoped_nsobject<CRWWebViewScrollViewProxy> _webViewScrollViewProxy; |
| 168 // The scrollview driving the OverscrollActionsController when not using | 168 // The scrollview driving the OverscrollActionsController when not using |
| 169 // the scrollview from the CRWWebControllerObserver. | 169 // the scrollview from the CRWWebControllerObserver. |
| 170 base::scoped_nsobject<UIScrollView> _scrollview; | 170 base::scoped_nsobject<UIScrollView> _scrollview; |
| 171 base::mac::ObjCPropertyReleaser _propertyReleaser_OverscrollActionsController; | |
| 172 } | 171 } |
| 173 | 172 |
| 174 // The view displayed over the header view holding the actions. | 173 // The view displayed over the header view holding the actions. |
| 175 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; | 174 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; |
| 176 // Initial top inset added to the scrollview for the header. | 175 // Initial top inset added to the scrollview for the header. |
| 177 // This property is set from the delegate headerInset and cached on first | 176 // 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. | 177 // call. The cached value is reset when the webview proxy is set. |
| 179 @property(nonatomic, readonly) CGFloat initialContentInset; | 178 @property(nonatomic, readonly) CGFloat initialContentInset; |
| 180 // Initial top inset for the header. | 179 // Initial top inset for the header. |
| 181 // This property is set from the delegate headerInset and cached on first | 180 // This property is set from the delegate headerInset and cached on first |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 @synthesize panPointScreenOrigin = _panPointScreenOrigin; | 238 @synthesize panPointScreenOrigin = _panPointScreenOrigin; |
| 240 @synthesize panGestureRecognizer = _panGestureRecognizer; | 239 @synthesize panGestureRecognizer = _panGestureRecognizer; |
| 241 | 240 |
| 242 - (instancetype)init { | 241 - (instancetype)init { |
| 243 return [self initWithScrollView:nil]; | 242 return [self initWithScrollView:nil]; |
| 244 } | 243 } |
| 245 | 244 |
| 246 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { | 245 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { |
| 247 self = [super init]; | 246 self = [super init]; |
| 248 if (self) { | 247 if (self) { |
| 249 _propertyReleaser_OverscrollActionsController.Init( | |
| 250 self, [OverscrollActionsController class]); | |
| 251 _overscrollActionView = | 248 _overscrollActionView = |
| 252 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; | 249 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; |
| 253 _overscrollActionView.delegate = self; | 250 _overscrollActionView.delegate = self; |
| 254 _scrollview.reset([scrollView retain]); | 251 _scrollview.reset([scrollView retain]); |
| 255 if (_scrollview) { | 252 if (_scrollview) { |
| 256 [self setup]; | 253 [self setup]; |
| 257 } | 254 } |
| 258 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); | 255 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); |
| 259 | 256 |
| 260 _lockNotificationsCounterparts.reset([@{ | 257 _lockNotificationsCounterparts.reset([@{ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 273 ios_internal::kSideSwipeWillStartNotification | 270 ios_internal::kSideSwipeWillStartNotification |
| 274 } retain]); | 271 } retain]); |
| 275 [self registerNotifications]; | 272 [self registerNotifications]; |
| 276 } | 273 } |
| 277 return self; | 274 return self; |
| 278 } | 275 } |
| 279 | 276 |
| 280 - (void)dealloc { | 277 - (void)dealloc { |
| 281 self.overscrollActionView.delegate = nil; | 278 self.overscrollActionView.delegate = nil; |
| 282 [self invalidate]; | 279 [self invalidate]; |
| 280 base::mac::ReleaseProperties(self); |
| 283 [super dealloc]; | 281 [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 } |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 overscrollActionsController:self | 909 overscrollActionsController:self |
| 912 didTriggerAction:self.overscrollActionView.selectedAction]; | 910 didTriggerAction:self.overscrollActionView.selectedAction]; |
| 913 } | 911 } |
| 914 | 912 |
| 915 - (void)overscrollActionsView:(OverscrollActionsView*)view | 913 - (void)overscrollActionsView:(OverscrollActionsView*)view |
| 916 selectedActionDidChange:(OverscrollAction)newAction { | 914 selectedActionDidChange:(OverscrollAction)newAction { |
| 917 TriggerHapticFeedbackForSelectionChange(); | 915 TriggerHapticFeedbackForSelectionChange(); |
| 918 } | 916 } |
| 919 | 917 |
| 920 @end | 918 @end |
| OLD | NEW |