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 @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 // Adds |observer| to subscribe to change notifications.
48 - (void)addObserver
:(id
<CRWWebViewScrollViewProxyObserver
>)observer
;
50 // Removes |observer| as a subscriber for change notifications.
51 - (void)removeObserver
:(id
<CRWWebViewScrollViewProxyObserver
>)observer
;
55 // A protocol to be implemented by objects to listen for changes to the
57 // This is an exact mirror of the UIScrollViewDelegate callbacks. For more
58 // information look at the UIScrollViewDelegate documentation.
59 @protocol CRWWebViewScrollViewObserver
<NSObject
>
61 - (void)webViewScrollViewDidScroll
:
62 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
63 - (void)webViewScrollViewWillBeginDragging
:
64 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
65 - (void)webViewScrollViewWillEndDragging
:
66 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
67 withVelocity
:(CGPoint
)velocity
68 targetContentOffset
:(inout CGPoint
*)targetContentOffset
;
69 - (void)webViewScrollViewDidEndDragging
:
70 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
71 willDecelerate
:(BOOL
)decelerate
;
72 - (void)webViewScrollViewDidEndScrollingAnimation
:
73 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
74 - (void)webViewScrollViewDidEndDecelerating
:
75 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
76 - (BOOL
)webViewScrollViewShouldScrollToTop
:
77 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
80 // A protocol to be implemented by objects to listen for changes to the
81 // CRWWebViewScrollViewProxyObserver.
82 // It inherit from CRWWebViewScrollViewScrollViewObserver which only implements
83 // methods for listening to scrollview changes.
84 @protocol CRWWebViewScrollViewProxyObserver
<CRWWebViewScrollViewObserver
>
86 // Called when the underlying scrollview of the proxy is set.
87 - (void)webViewScrollViewProxyDidSetScrollView
:
88 (CRWWebViewScrollViewProxy
*)webViewScrollViewProxy
;
91 #endif // IOS_WEB_PUBLIC_WEB_STATE_CRW_WEB_VIEW_SCROLL_VIEW_PROXY_H_