| 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/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/mac/objc_property_releaser.h" | 12 #include "base/mac/objc_release_properties.h" |
| 13 #include "base/mac/scoped_nsobject.h" | 13 #include "base/mac/scoped_nsobject.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #import "ios/chrome/browser/ui/browser_view_controller.h" | 15 #import "ios/chrome/browser/ui/browser_view_controller.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 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" | 20 #import "ios/chrome/browser/ui/voice/voice_search_notification_names.h" |
| 21 #import "ios/web/public/web_state/crw_web_view_proxy.h" | 21 #import "ios/web/public/web_state/crw_web_view_proxy.h" |
| 22 | 22 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 base::scoped_nsobject<NSDictionary> _lockNotificationsCounterparts; | 160 base::scoped_nsobject<NSDictionary> _lockNotificationsCounterparts; |
| 161 // A view used to catch touches on the webview. | 161 // A view used to catch touches on the webview. |
| 162 base::scoped_nsobject<UIView> _dummyView; | 162 base::scoped_nsobject<UIView> _dummyView; |
| 163 // The proxy used to interact with the webview. | 163 // The proxy used to interact with the webview. |
| 164 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; | 164 base::scoped_nsprotocol<id<CRWWebViewProxy>> _webViewProxy; |
| 165 // The proxy used to interact with the webview's scrollview. | 165 // The proxy used to interact with the webview's scrollview. |
| 166 base::scoped_nsobject<CRWWebViewScrollViewProxy> _webViewScrollViewProxy; | 166 base::scoped_nsobject<CRWWebViewScrollViewProxy> _webViewScrollViewProxy; |
| 167 // The scrollview driving the OverscrollActionsController when not using | 167 // The scrollview driving the OverscrollActionsController when not using |
| 168 // the scrollview from the CRWWebControllerObserver. | 168 // the scrollview from the CRWWebControllerObserver. |
| 169 base::scoped_nsobject<UIScrollView> _scrollview; | 169 base::scoped_nsobject<UIScrollView> _scrollview; |
| 170 base::mac::ObjCPropertyReleaser _propertyReleaser_OverscrollActionsController; | |
| 171 } | 170 } |
| 172 | 171 |
| 173 // The view displayed over the header view holding the actions. | 172 // The view displayed over the header view holding the actions. |
| 174 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; | 173 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; |
| 175 // Initial top inset added to the scrollview for the header. | 174 // Initial top inset added to the scrollview for the header. |
| 176 // This property is set from the delegate headerInset and cached on first | 175 // This property is set from the delegate headerInset and cached on first |
| 177 // call. The cached value is reset when the webview proxy is set. | 176 // call. The cached value is reset when the webview proxy is set. |
| 178 @property(nonatomic, readonly) CGFloat initialContentInset; | 177 @property(nonatomic, readonly) CGFloat initialContentInset; |
| 179 // Initial top inset for the header. | 178 // Initial top inset for the header. |
| 180 // This property is set from the delegate headerInset and cached on first | 179 // 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... |
| 238 @synthesize panPointScreenOrigin = _panPointScreenOrigin; | 237 @synthesize panPointScreenOrigin = _panPointScreenOrigin; |
| 239 @synthesize panGestureRecognizer = _panGestureRecognizer; | 238 @synthesize panGestureRecognizer = _panGestureRecognizer; |
| 240 | 239 |
| 241 - (instancetype)init { | 240 - (instancetype)init { |
| 242 return [self initWithScrollView:nil]; | 241 return [self initWithScrollView:nil]; |
| 243 } | 242 } |
| 244 | 243 |
| 245 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { | 244 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { |
| 246 self = [super init]; | 245 self = [super init]; |
| 247 if (self) { | 246 if (self) { |
| 248 _propertyReleaser_OverscrollActionsController.Init( | |
| 249 self, [OverscrollActionsController class]); | |
| 250 _overscrollActionView = | 247 _overscrollActionView = |
| 251 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; | 248 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; |
| 252 _overscrollActionView.delegate = self; | 249 _overscrollActionView.delegate = self; |
| 253 _scrollview.reset([scrollView retain]); | 250 _scrollview.reset([scrollView retain]); |
| 254 if (_scrollview) { | 251 if (_scrollview) { |
| 255 [self setup]; | 252 [self setup]; |
| 256 } | 253 } |
| 257 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); | 254 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); |
| 258 | 255 |
| 259 _lockNotificationsCounterparts.reset([@{ | 256 _lockNotificationsCounterparts.reset([@{ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 272 ios_internal::kSideSwipeWillStartNotification | 269 ios_internal::kSideSwipeWillStartNotification |
| 273 } retain]); | 270 } retain]); |
| 274 [self registerNotifications]; | 271 [self registerNotifications]; |
| 275 } | 272 } |
| 276 return self; | 273 return self; |
| 277 } | 274 } |
| 278 | 275 |
| 279 - (void)dealloc { | 276 - (void)dealloc { |
| 280 self.overscrollActionView.delegate = nil; | 277 self.overscrollActionView.delegate = nil; |
| 281 [self invalidate]; | 278 [self invalidate]; |
| 279 base::mac::ReleaseProperties(self); |
| 282 [super dealloc]; | 280 [super dealloc]; |
| 283 } | 281 } |
| 284 | 282 |
| 285 - (void)scheduleInvalidate { | 283 - (void)scheduleInvalidate { |
| 286 if (self.overscrollState == OverscrollState::NO_PULL_STARTED) { | 284 if (self.overscrollState == OverscrollState::NO_PULL_STARTED) { |
| 287 [self invalidate]; | 285 [self invalidate]; |
| 288 } else { | 286 } else { |
| 289 _shouldInvalidate = YES; | 287 _shouldInvalidate = YES; |
| 290 } | 288 } |
| 291 } | 289 } |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 overscrollActionsController:self | 920 overscrollActionsController:self |
| 923 didTriggerAction:self.overscrollActionView.selectedAction]; | 921 didTriggerAction:self.overscrollActionView.selectedAction]; |
| 924 } | 922 } |
| 925 | 923 |
| 926 - (void)overscrollActionsView:(OverscrollActionsView*)view | 924 - (void)overscrollActionsView:(OverscrollActionsView*)view |
| 927 selectedActionDidChange:(OverscrollAction)newAction { | 925 selectedActionDidChange:(OverscrollAction)newAction { |
| 928 [self triggerHapticFeedbackForSelectionChange]; | 926 [self triggerHapticFeedbackForSelectionChange]; |
| 929 } | 927 } |
| 930 | 928 |
| 931 @end | 929 @end |
| OLD | NEW |