| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_VIEW_SCROLL_VIEW_PROXY_H_ | |
| 6 #define IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_VIEW_SCROLL_VIEW_PROXY_H_ | |
| 7 | |
| 8 #import <UIKit/UIKit.h> | |
| 9 | |
| 10 @protocol CRWWebViewScrollViewProxyObserver; | |
| 11 | |
| 12 // Provides an interface for web state observers to access the WebState's | |
| 13 // UIScrollView in a limited and controlled manner. | |
| 14 // This class is designed to limit lifetime of the UIScrollView such that it is | |
| 15 // not retained beyond WebState. It is also a way to tunnel UIScrollViewDelegate | |
| 16 // callbacks. | |
| 17 // NOTE: The API exposed by the proxy class isn't intended to be restrictive. | |
| 18 // The features needing to access other UIScrollView properties and methods | |
| 19 // needed to drive the UIScrollView are free to extend the proxy class as | |
| 20 // needed. | |
| 21 // The class forwards some of the methods onto the UIScrollView. For more | |
| 22 // information look at the UIScrollView documentation. | |
| 23 // TODO(crbug.com/546152): rename class to CRWContentViewScrollViewProxy. | |
| 24 @interface CRWWebViewScrollViewProxy : NSObject<UIScrollViewDelegate> | |
| 25 @property(nonatomic, assign) CGPoint contentOffset; | |
| 26 @property(nonatomic, assign) UIEdgeInsets contentInset; | |
| 27 @property(nonatomic, readonly) BOOL isZooming; | |
| 28 @property(nonatomic, readonly) CGFloat zoomScale; | |
| 29 @property(nonatomic, assign) UIEdgeInsets scrollIndicatorInsets; | |
| 30 @property(nonatomic, assign) CGSize contentSize; | |
| 31 @property(nonatomic, readonly) CGRect frame; | |
| 32 @property(nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; | |
| 33 @property(nonatomic, assign) BOOL bounces; | |
| 34 @property(weak, nonatomic, readonly) | |
| 35 UIPanGestureRecognizer* panGestureRecognizer; | |
| 36 // Returns the scrollview's gesture recognizers. | |
| 37 @property(weak, nonatomic, readonly) NSArray* gestureRecognizers; | |
| 38 | |
| 39 - (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer; | |
| 40 - (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer; | |
| 41 - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; | |
| 42 | |
| 43 // Used by the CRWWebViewProxy to set the UIScrollView to be managed. | |
| 44 - (void)setScrollView:(UIScrollView*)scrollView; | |
| 45 | |
| 46 // Adds |observer| to subscribe to change notifications. | |
| 47 - (void)addObserver:(id<CRWWebViewScrollViewProxyObserver>)observer; | |
| 48 | |
| 49 // Removes |observer| as a subscriber for change notifications. | |
| 50 - (void)removeObserver:(id<CRWWebViewScrollViewProxyObserver>)observer; | |
| 51 | |
| 52 @end | |
| 53 | |
| 54 // A protocol to be implemented by objects to listen for changes to the | |
| 55 // UIScrollView. | |
| 56 // This is an exact mirror of the UIScrollViewDelegate callbacks. For more | |
| 57 // information look at the UIScrollViewDelegate documentation. | |
| 58 @protocol CRWWebViewScrollViewObserver<NSObject> | |
| 59 @optional | |
| 60 - (void)webViewScrollViewDidScroll: | |
| 61 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 62 - (void)webViewScrollViewWillBeginDragging: | |
| 63 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 64 - (void)webViewScrollViewWillEndDragging: | |
| 65 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy | |
| 66 withVelocity:(CGPoint)velocity | |
| 67 targetContentOffset:(inout CGPoint*)targetContentOffset; | |
| 68 - (void)webViewScrollViewDidEndDragging: | |
| 69 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy | |
| 70 willDecelerate:(BOOL)decelerate; | |
| 71 - (void)webViewScrollViewDidEndScrollingAnimation: | |
| 72 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 73 - (void)webViewScrollViewDidEndDecelerating: | |
| 74 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 75 - (BOOL)webViewScrollViewShouldScrollToTop: | |
| 76 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 77 - (void)webViewScrollViewDidZoom: | |
| 78 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 79 - (void)webViewScrollViewDidResetContentSize: | |
| 80 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 81 @end | |
| 82 | |
| 83 // A protocol to be implemented by objects to listen for changes to the | |
| 84 // CRWWebViewScrollViewProxyObserver. | |
| 85 // It inherit from CRWWebViewScrollViewScrollViewObserver which only implements | |
| 86 // methods for listening to scrollview changes. | |
| 87 @protocol CRWWebViewScrollViewProxyObserver<CRWWebViewScrollViewObserver> | |
| 88 @optional | |
| 89 // Called when the underlying scrollview of the proxy is set. | |
| 90 - (void)webViewScrollViewProxyDidSetScrollView: | |
| 91 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy; | |
| 92 @end | |
| 93 | |
| 94 #endif // IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_VIEW_SCROLL_VIEW_PROXY_H_ | |
| OLD | NEW |