Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ios / web / public / web_state / crw_web_view_scroll_view_proxy.h
blob725577d9705e5eedcca74105fdecaf87e41bdbe8
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.
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_
8 #import <UIKit/UIKit.h>
10 @protocol CRWWebViewScrollViewProxyObserver;
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 @interface CRWWebViewScrollViewProxy : NSObject<UIScrollViewDelegate>
24 @property(nonatomic, assign) CGPoint contentOffset;
25 @property(nonatomic, assign) UIEdgeInsets contentInset;
26 @property(nonatomic, readonly) BOOL isZooming;
27 @property(nonatomic, assign) UIEdgeInsets scrollIndicatorInsets;
28 @property(nonatomic, assign) CGSize contentSize;
29 @property(nonatomic, readonly) CGRect frame;
30 @property(nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;
31 @property(nonatomic, assign) BOOL bounces;
32 @property(nonatomic, readonly) UIPanGestureRecognizer* panGestureRecognizer;
33 // Returns the scrollview's gesture recognizers.
34 @property(nonatomic, readonly) NSArray* gestureRecognizers;
36 // Calls UIScrollView's implementation of setContentInset: directly. This
37 // bypasses a very slow update path in UIWebView.
38 - (void)setContentInsetFast:(UIEdgeInsets)contentInset;
40 - (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer;
41 - (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer;
42 - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
44 // Used by the CRWWebViewProxy to set the UIScrollView to be managed.
45 - (void)setScrollView:(UIScrollView*)scrollView;
47 // Copies all display properties that can be set on a CRWWebViewScrollViewProxy
48 // from the underlying UIScrollView into |scrollView|.
49 - (void)copyPropertiesToScrollView:(UIScrollView*)scrollView;
51 // Adds |observer| to subscribe to change notifications.
52 - (void)addObserver:(id<CRWWebViewScrollViewProxyObserver>)observer;
54 // Removes |observer| as a subscriber for change notifications.
55 - (void)removeObserver:(id<CRWWebViewScrollViewProxyObserver>)observer;
57 @end
59 // A protocol to be implemented by objects to listen for changes to the
60 // UIScrollView.
61 // This is an exact mirror of the UIScrollViewDelegate callbacks. For more
62 // information look at the UIScrollViewDelegate documentation.
63 @protocol CRWWebViewScrollViewObserver<NSObject>
64 @optional
65 - (void)webViewScrollViewDidScroll:
66 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy;
67 - (void)webViewScrollViewWillBeginDragging:
68 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy;
69 - (void)webViewScrollViewWillEndDragging:
70 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy
71 withVelocity:(CGPoint)velocity
72 targetContentOffset:(inout CGPoint*)targetContentOffset;
73 - (void)webViewScrollViewDidEndDragging:
74 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy
75 willDecelerate:(BOOL)decelerate;
76 - (void)webViewScrollViewDidEndScrollingAnimation:
77 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy;
78 - (void)webViewScrollViewDidEndDecelerating:
79 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy;
80 - (BOOL)webViewScrollViewShouldScrollToTop:
81 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy;
82 @end
84 // A protocol to be implemented by objects to listen for changes to the
85 // CRWWebViewScrollViewProxyObserver.
86 // It inherit from CRWWebViewScrollViewScrollViewObserver which only implements
87 // methods for listening to scrollview changes.
88 @protocol CRWWebViewScrollViewProxyObserver<CRWWebViewScrollViewObserver>
89 @optional
90 // Called when the underlying scrollview of the proxy is set.
91 - (void)webViewScrollViewProxyDidSetScrollView:
92 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy;
93 @end
95 #endif // IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_VIEW_SCROLL_VIEW_PROXY_H_