Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Unified Diff: ios/web/web_state/crw_web_view_scroll_view_proxy.mm

Issue 2594793004: Revert 'Bypass UIWebView.scrollView's contentInset implementation with UIScrollView's. (Closed)
Patch Set: Eugene comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/public/web_state/crw_web_view_scroll_view_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/crw_web_view_scroll_view_proxy.mm
diff --git a/ios/web/web_state/crw_web_view_scroll_view_proxy.mm b/ios/web/web_state/crw_web_view_scroll_view_proxy.mm
index e22aaaea04cc3a6d30bcf76dc3995b3aa7267d4b..291f4093a46b085626706808506a5a35f26e1050 100644
--- a/ios/web/web_state/crw_web_view_scroll_view_proxy.mm
+++ b/ios/web/web_state/crw_web_view_scroll_view_proxy.mm
@@ -18,11 +18,6 @@
@interface CRWWebViewScrollViewProxy () {
__weak UIScrollView* _scrollView;
base::scoped_nsobject<id> _observers;
- // When |_ignoreScroll| is set to YES, do not pass on -scrollViewDidScroll
- // calls to observers. This is used by -setContentInsetFast, which needs to
- // update and reset the contentOffset to force a fast update. These updates
- // should be a no-op for the contentOffset, so the callbacks can be ignored.
- BOOL _ignoreScroll;
}
// Returns the key paths that need to be observed for UIScrollView.
@@ -114,40 +109,6 @@
return _scrollView ? [_scrollView contentOffset] : CGPointZero;
}
-- (void)setContentInsetFast:(UIEdgeInsets)contentInset {
- if (!_scrollView)
- return;
-
- // The method -scrollViewSetContentInsetImpl below is bypassing UIWebView's
- // subclassed UIScrollView implemention of setContentOffset. UIKIt's
- // implementation calls the internal method |_updateViewSettings| after
- // updating the contentInsets. This ensures things like absolute positions
- // are correctly updated. The problem is |_updateViewSettings| does lots of
- // other things and is very very slow. The workaround below simply sets the
- // scrollView's content insets directly, and then fiddles with the
- // contentOffset below to correct the absolute positioning of elements.
- static void (*scrollViewSetContentInsetImpl)(id, SEL, UIEdgeInsets);
- static SEL setContentInset;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- setContentInset = @selector(setContentInset:);
- scrollViewSetContentInsetImpl =
- (void (*)(id, SEL, UIEdgeInsets))class_getMethodImplementation(
- [UIScrollView class], setContentInset);
- });
- scrollViewSetContentInsetImpl(_scrollView, setContentInset, contentInset);
-
- // Change and then reset the contentOffset to force the view into updating the
- // absolute position of elements and content frame. Updating the
- // contentOffset will cause the -scrollViewDidScroll callback to fire.
- // Because we are eventually setting the contentOffset back to it's original
- // position, we can ignore these calls.
- base::AutoReset<BOOL> autoReset(&_ignoreScroll, YES);
- CGPoint contentOffset = [_scrollView contentOffset];
- _scrollView.contentOffset = CGPointMake(contentOffset.x, contentOffset.y + 1);
- _scrollView.contentOffset = contentOffset;
-}
-
- (void)setContentInset:(UIEdgeInsets)contentInset {
[_scrollView setContentInset:contentInset];
}
@@ -189,9 +150,7 @@
- (void)scrollViewDidScroll:(UIScrollView*)scrollView {
DCHECK_EQ(_scrollView, scrollView);
- if (!_ignoreScroll) {
- [_observers webViewScrollViewDidScroll:self];
- }
+ [_observers webViewScrollViewDidScroll:self];
}
- (void)scrollViewWillBeginDragging:(UIScrollView*)scrollView {
« no previous file with comments | « ios/web/public/web_state/crw_web_view_scroll_view_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698