Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 #import "ios/web_view/public/cwv_scroll_view.h" | |
| 6 | |
| 7 #import "ios/web/public/web_state/ui/crw_web_view_scroll_view_proxy.h" | |
| 8 #import "ios/web_view/internal/cwv_scroll_view_internal.h" | |
| 9 #import "ios/web_view/public/cwv_scroll_view_delegate.h" | |
| 10 | |
| 11 @interface CWVScrollView ()<CRWWebViewScrollViewProxyObserver> | |
| 12 @end | |
| 13 | |
| 14 @implementation CWVScrollView | |
| 15 | |
| 16 @synthesize delegate = _delegate; | |
| 17 @synthesize proxy = _proxy; | |
| 18 | |
| 19 - (void)setProxy:(CRWWebViewScrollViewProxy*)proxy { | |
| 20 if (_proxy) { | |
|
Eugene But (OOO till 7-30)
2017/04/26 19:11:31
There is no need for this check, calling a method
Hiroshi Ichikawa
2017/04/27 02:30:10
Done.
| |
| 21 [_proxy removeObserver:self]; | |
| 22 } | |
| 23 _proxy = proxy; | |
| 24 if (_proxy) { | |
| 25 [_proxy addObserver:self]; | |
|
Eugene But (OOO till 7-30)
2017/04/26 19:11:31
ditto
Hiroshi Ichikawa
2017/04/27 02:30:10
Done.
| |
| 26 } | |
| 27 } | |
| 28 | |
| 29 - (CGPoint)contentOffset { | |
| 30 return _proxy.contentOffset; | |
| 31 } | |
| 32 | |
| 33 - (void)setContentOffset:(CGPoint)contentOffset { | |
| 34 _proxy.contentOffset = contentOffset; | |
| 35 } | |
| 36 | |
| 37 - (CGRect)frame { | |
| 38 return _proxy.frame; | |
| 39 } | |
| 40 | |
| 41 - (CGRect)bounds { | |
| 42 return {_proxy.contentOffset, _proxy.frame.size}; | |
| 43 } | |
| 44 | |
| 45 - (CGSize)contentSize { | |
| 46 return _proxy.contentSize; | |
| 47 } | |
| 48 | |
| 49 - (BOOL)isDragging { | |
| 50 return _proxy.dragging; | |
| 51 } | |
| 52 | |
| 53 - (void)addGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer { | |
| 54 [_proxy addGestureRecognizer:gestureRecognizer]; | |
| 55 } | |
| 56 | |
| 57 - (UIEdgeInsets)contentInset { | |
| 58 return _proxy.contentInset; | |
| 59 } | |
| 60 | |
| 61 - (void)setContentInset:(UIEdgeInsets)contentInset { | |
| 62 _proxy.contentInset = contentInset; | |
| 63 } | |
| 64 | |
| 65 #pragma mark - CRWWebViewScrollViewObserver | |
| 66 | |
| 67 - (void)webViewScrollViewWillBeginDragging: | |
| 68 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy { | |
| 69 if ([_delegate | |
| 70 respondsToSelector:@selector(webViewScrollViewWillBeginDragging:)]) { | |
| 71 [_delegate scrollViewWillBeginDragging:self]; | |
| 72 } | |
| 73 } | |
| 74 - (void)webViewScrollViewWillEndDragging: | |
| 75 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy | |
| 76 withVelocity:(CGPoint)velocity | |
| 77 targetContentOffset:(inout CGPoint*)targetContentOffset { | |
| 78 if ([_delegate respondsToSelector:@selector | |
|
Eugene But (OOO till 7-30)
2017/04/26 19:11:31
Do you want to create a local variable for selecto
Hiroshi Ichikawa
2017/04/27 02:30:10
Done.
| |
| 79 (webViewScrollViewWillEndDragging:withVelocity | |
| 80 :targetContentOffset:)]) { | |
| 81 [_delegate scrollViewWillEndDragging:self | |
| 82 withVelocity:velocity | |
| 83 targetContentOffset:targetContentOffset]; | |
| 84 } | |
| 85 } | |
| 86 | |
| 87 - (void)webViewScrollViewDidScroll: | |
| 88 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy { | |
| 89 if ([_delegate respondsToSelector:@selector(scrollViewDidScroll:)]) { | |
| 90 [_delegate scrollViewDidScroll:self]; | |
| 91 } | |
| 92 } | |
| 93 | |
| 94 - (void)webViewScrollViewDidEndDecelerating: | |
| 95 (CRWWebViewScrollViewProxy*)webViewScrollViewProxy { | |
| 96 if ([_delegate | |
| 97 respondsToSelector:@selector(webViewScrollViewDidEndDecelerating:)]) { | |
|
Eugene But (OOO till 7-30)
2017/04/26 19:11:31
ditto
Hiroshi Ichikawa
2017/04/27 02:30:11
Done.
| |
| 98 [_delegate scrollViewDidEndDecelerating:self]; | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 @end | |
| OLD | NEW |