Commit 18c81529 authored by Hiroshi Ichikawa's avatar Hiroshi Ichikawa Committed by Commit Bot

Add |subviews| property to the scroll view

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I084dedb73e3b5ccc0d958aef88c54e0d8cf820bd
Reviewed-on: https://chromium-review.googlesource.com/795492
Commit-Queue: Hiroshi Ichikawa <ichikawa@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520809}
parent d76da5a0
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
UIPanGestureRecognizer* panGestureRecognizer; UIPanGestureRecognizer* panGestureRecognizer;
// Returns the scrollview's gesture recognizers. // Returns the scrollview's gesture recognizers.
@property(weak, nonatomic, readonly) NSArray* gestureRecognizers; @property(weak, nonatomic, readonly) NSArray* gestureRecognizers;
@property(nonatomic, readonly, copy) NSArray<__kindof UIView*>* subviews;
- (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer; - (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer;
- (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer; - (void)removeGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer;
......
...@@ -203,6 +203,10 @@ ...@@ -203,6 +203,10 @@
return [_scrollView gestureRecognizers]; return [_scrollView gestureRecognizers];
} }
- (NSArray<__kindof UIView*>*)subviews {
return _scrollView ? [_scrollView subviews] : @[];
}
#pragma mark - #pragma mark -
#pragma mark UIScrollViewDelegate callbacks #pragma mark UIScrollViewDelegate callbacks
......
...@@ -126,6 +126,10 @@ TEST_F(CRWWebViewScrollViewProxyTest, ScrollViewPresent) { ...@@ -126,6 +126,10 @@ TEST_F(CRWWebViewScrollViewProxyTest, ScrollViewPresent) {
[[[mockScrollView_ expect] andReturnValue:@NO] scrollsToTop]; [[[mockScrollView_ expect] andReturnValue:@NO] scrollsToTop];
EXPECT_FALSE([webViewScrollViewProxy_ scrollsToTop]); EXPECT_FALSE([webViewScrollViewProxy_ scrollsToTop]);
NSArray<__kindof UIView*>* subviews = [NSArray array];
[[[mockScrollView_ expect] andReturn:subviews] subviews];
EXPECT_EQ(subviews, [webViewScrollViewProxy_ subviews]);
if (@available(iOS 11, *)) { if (@available(iOS 11, *)) {
[[[mockScrollView_ expect] [[[mockScrollView_ expect]
andReturnValue:@(UIScrollViewContentInsetAdjustmentAutomatic)] andReturnValue:@(UIScrollViewContentInsetAdjustmentAutomatic)]
...@@ -159,6 +163,7 @@ TEST_F(CRWWebViewScrollViewProxyTest, ScrollViewAbsent) { ...@@ -159,6 +163,7 @@ TEST_F(CRWWebViewScrollViewProxyTest, ScrollViewAbsent) {
EXPECT_FALSE([webViewScrollViewProxy_ isDragging]); EXPECT_FALSE([webViewScrollViewProxy_ isDragging]);
EXPECT_FALSE([webViewScrollViewProxy_ isTracking]); EXPECT_FALSE([webViewScrollViewProxy_ isTracking]);
EXPECT_FALSE([webViewScrollViewProxy_ scrollsToTop]); EXPECT_FALSE([webViewScrollViewProxy_ scrollsToTop]);
EXPECT_EQ((NSUInteger)0, [webViewScrollViewProxy_ subviews].count);
if (@available(iOS 11, *)) { if (@available(iOS 11, *)) {
EXPECT_EQ(UIScrollViewContentInsetAdjustmentAutomatic, EXPECT_EQ(UIScrollViewContentInsetAdjustmentAutomatic,
[webViewScrollViewProxy_ contentInsetAdjustmentBehavior]); [webViewScrollViewProxy_ contentInsetAdjustmentBehavior]);
......
...@@ -89,6 +89,10 @@ ...@@ -89,6 +89,10 @@
return _proxy.panGestureRecognizer; return _proxy.panGestureRecognizer;
} }
- (NSArray<__kindof UIView*>*)subviews {
return _proxy.subviews;
}
- (UIEdgeInsets)contentInset { - (UIEdgeInsets)contentInset {
return _proxy.contentInset; return _proxy.contentInset;
} }
......
...@@ -36,6 +36,7 @@ CWV_EXPORT ...@@ -36,6 +36,7 @@ CWV_EXPORT
UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior
API_AVAILABLE(ios(11.0)); API_AVAILABLE(ios(11.0));
@property(nonatomic, readonly) UIPanGestureRecognizer* panGestureRecognizer; @property(nonatomic, readonly) UIPanGestureRecognizer* panGestureRecognizer;
@property(nonatomic, readonly, copy) NSArray<__kindof UIView*>* subviews;
// KVO compliant. // KVO compliant.
@property(nonatomic, readonly) CGSize contentSize; @property(nonatomic, readonly) CGSize contentSize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment