| 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_release_properties.h" | 11 #include "base/mac/objc_property_releaser.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; |
| 171 } | 172 } |
| 172 | 173 |
| 173 // The view displayed over the header view holding the actions. | 174 // The view displayed over the header view holding the actions. |
| 174 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; | 175 @property(nonatomic, retain) OverscrollActionsView* overscrollActionView; |
| 175 // Initial top inset added to the scrollview for the header. | 176 // Initial top inset added to the scrollview for the header. |
| 176 // This property is set from the delegate headerInset and cached on first | 177 // 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. | 178 // call. The cached value is reset when the webview proxy is set. |
| 178 @property(nonatomic, readonly) CGFloat initialContentInset; | 179 @property(nonatomic, readonly) CGFloat initialContentInset; |
| 179 // Initial top inset for the header. | 180 // Initial top inset for the header. |
| 180 // This property is set from the delegate headerInset and cached on first | 181 // 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; | 239 @synthesize panPointScreenOrigin = _panPointScreenOrigin; |
| 239 @synthesize panGestureRecognizer = _panGestureRecognizer; | 240 @synthesize panGestureRecognizer = _panGestureRecognizer; |
| 240 | 241 |
| 241 - (instancetype)init { | 242 - (instancetype)init { |
| 242 return [self initWithScrollView:nil]; | 243 return [self initWithScrollView:nil]; |
| 243 } | 244 } |
| 244 | 245 |
| 245 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { | 246 - (instancetype)initWithScrollView:(UIScrollView*)scrollView { |
| 246 self = [super init]; | 247 self = [super init]; |
| 247 if (self) { | 248 if (self) { |
| 249 _propertyReleaser_OverscrollActionsController.Init( |
| 250 self, [OverscrollActionsController class]); |
| 248 _overscrollActionView = | 251 _overscrollActionView = |
| 249 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; | 252 [[OverscrollActionsView alloc] initWithFrame:CGRectZero]; |
| 250 _overscrollActionView.delegate = self; | 253 _overscrollActionView.delegate = self; |
| 251 _scrollview.reset([scrollView retain]); | 254 _scrollview.reset([scrollView retain]); |
| 252 if (_scrollview) { | 255 if (_scrollview) { |
| 253 [self setup]; | 256 [self setup]; |
| 254 } | 257 } |
| 255 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); | 258 _lockIncrementNotifications.reset([[NSMutableSet alloc] init]); |
| 256 | 259 |
| 257 _lockNotificationsCounterparts.reset([@{ | 260 _lockNotificationsCounterparts.reset([@{ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 270 ios_internal::kSideSwipeWillStartNotification | 273 ios_internal::kSideSwipeWillStartNotification |
| 271 } retain]); | 274 } retain]); |
| 272 [self registerNotifications]; | 275 [self registerNotifications]; |
| 273 } | 276 } |
| 274 return self; | 277 return self; |
| 275 } | 278 } |
| 276 | 279 |
| 277 - (void)dealloc { | 280 - (void)dealloc { |
| 278 self.overscrollActionView.delegate = nil; | 281 self.overscrollActionView.delegate = nil; |
| 279 [self invalidate]; | 282 [self invalidate]; |
| 280 base::mac::ReleaseProperties(self); | |
| 281 [super dealloc]; | 283 [super dealloc]; |
| 282 } | 284 } |
| 283 | 285 |
| 284 - (void)scheduleInvalidate { | 286 - (void)scheduleInvalidate { |
| 285 if (self.overscrollState == OverscrollState::NO_PULL_STARTED) { | 287 if (self.overscrollState == OverscrollState::NO_PULL_STARTED) { |
| 286 [self invalidate]; | 288 [self invalidate]; |
| 287 } else { | 289 } else { |
| 288 _shouldInvalidate = YES; | 290 _shouldInvalidate = YES; |
| 289 } | 291 } |
| 290 } | 292 } |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 overscrollActionsController:self | 911 overscrollActionsController:self |
| 910 didTriggerAction:self.overscrollActionView.selectedAction]; | 912 didTriggerAction:self.overscrollActionView.selectedAction]; |
| 911 } | 913 } |
| 912 | 914 |
| 913 - (void)overscrollActionsView:(OverscrollActionsView*)view | 915 - (void)overscrollActionsView:(OverscrollActionsView*)view |
| 914 selectedActionDidChange:(OverscrollAction)newAction { | 916 selectedActionDidChange:(OverscrollAction)newAction { |
| 915 TriggerHapticFeedbackForSelectionChange(); | 917 TriggerHapticFeedbackForSelectionChange(); |
| 916 } | 918 } |
| 917 | 919 |
| 918 @end | 920 @end |
| OLD | NEW |