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
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
21 // The class forwards some of the methods onto the UIScrollView. For more
22 // information look at the UIScrollView documentation.
23 // TODO(kkhorimoto): 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
, assign
) UIEdgeInsets scrollIndicatorInsets
;
29 @
property(nonatomic
, assign
) CGSize contentSize
;
30 @
property(nonatomic
, readonly
) CGRect frame
;
31 @
property(nonatomic
, getter
=isScrollEnabled
) BOOL scrollEnabled
;
32 @
property(nonatomic
, assign
) BOOL bounces
;
33 @
property(nonatomic
, readonly
) UIPanGestureRecognizer
* panGestureRecognizer
;
34 // Returns the scrollview's gesture recognizers.
35 @
property(nonatomic
, readonly
) NSArray
* gestureRecognizers
;
37 // Calls UIScrollView's implementation of setContentInset: directly. This
38 // bypasses a very slow update path in UIWebView.
39 - (void)setContentInsetFast
:(UIEdgeInsets
)contentInset
;
41 - (void)addGestureRecognizer
:(UIGestureRecognizer
*)gestureRecognizer
;
42 - (void)removeGestureRecognizer
:(UIGestureRecognizer
*)gestureRecognizer
;
43 - (void)setContentOffset
:(CGPoint
)contentOffset animated
:(BOOL
)animated
;
45 // Used by the CRWWebViewProxy to set the UIScrollView to be managed.
46 - (void)setScrollView
:(UIScrollView
*)scrollView
;
48 // Adds |observer| to subscribe to change notifications.
49 - (void)addObserver
:(id
<CRWWebViewScrollViewProxyObserver
>)observer
;
51 // Removes |observer| as a subscriber for change notifications.
52 - (void)removeObserver
:(id
<CRWWebViewScrollViewProxyObserver
>)observer
;
56 // A protocol to be implemented by objects to listen for changes to the
58 // This is an exact mirror of the UIScrollViewDelegate callbacks. For more
59 // information look at the UIScrollViewDelegate documentation.
60 @protocol CRWWebViewScrollViewObserver
<NSObject
>
62 - (void)webViewScrollViewDidScroll
:
63 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
64 - (void)webViewScrollViewWillBeginDragging
:
65 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
66 - (void)webViewScrollViewWillEndDragging
:
67 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
68 withVelocity
:(CGPoint
)velocity
69 targetContentOffset
:(inout CGPoint
*)targetContentOffset
;
70 - (void)webViewScrollViewDidEndDragging
:
71 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
72 willDecelerate
:(BOOL
)decelerate
;
73 - (void)webViewScrollViewDidEndScrollingAnimation
:
74 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
75 - (void)webViewScrollViewDidEndDecelerating
:
76 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
77 - (BOOL
)webViewScrollViewShouldScrollToTop
:
78 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
79 - (void)webViewScrollViewDidZoom
:
80 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
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
>
89 // Called when the underlying scrollview of the proxy is set.
90 - (void)webViewScrollViewProxyDidSetScrollView
:
91 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
94 #endif // IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_VIEW_SCROLL_VIEW_PROXY_H_