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

Unified Diff: ios/chrome/browser/find_in_page/find_in_page_controller.mm

Issue 1071723002: [Find in Page] Prevent scrolling past the page edge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/find_in_page/find_in_page_controller.mm
diff --git a/ios/chrome/browser/find_in_page/find_in_page_controller.mm b/ios/chrome/browser/find_in_page/find_in_page_controller.mm
index 0d1621e15ae12f2e5c816d8048dc24394cdec2ad..6871efe004a13dcfad3e95930ad61e6342b87fd0 100644
--- a/ios/chrome/browser/find_in_page/find_in_page_controller.mm
+++ b/ios/chrome/browser/find_in_page/find_in_page_controller.mm
@@ -58,6 +58,9 @@ const NSTimeInterval kRecurringPumpDelay = .01;
- (void)processPumpResult:(BOOL)finished
scrollPoint:(CGPoint)scrollPoint
completionHandler:(ProceduralBlock)completionHandler;
+// Prevent overscroll.
sdefresne 2015/04/08 20:02:19 API recommendation: since each invocation follow t
justincohen 2015/04/08 20:25:51 messaged offline about this.
+- (CGPoint)limitOverscroll:(CRWWebViewScrollViewProxy*)scrollViewProxy
+ atPoint:(CGPpoint)point;
// Returns the associated web state. May be null.
- (web::WebState*)webState;
@end
@@ -133,11 +136,24 @@ const NSTimeInterval kRecurringPumpDelay = .01;
return [_webViewProxy scrollViewProxy];
}
+- (CGPoint)limitoverscroll:(CRWWebViewScrollViewProxy*)scrollViewProxy
+ atPoint:(CGPpoint)point {
+ CGFloat contentHeight = scrollViewProxy.contentSize.height;
+ CGFloat frameHeight = scrollViewProxy.frame.size.height;
+ CGFloat maxScroll = fmax(0, contentHeight - frameHeight);
sdefresne 2015/04/08 20:02:19 nit: please use std::max() from <cmath>
justincohen 2015/04/08 20:25:51 Done.
+ if (point.y > maxScroll) {
+ point.y = maxScroll;
+ }
+ return point;
+}
+
- (void)processPumpResult:(BOOL)finished
scrollPoint:(CGPoint)scrollPoint
completionHandler:(ProceduralBlock)completionHandler {
if (finished) {
[_delegate willAdjustScrollPosition];
+ scrollPoint = [self limitOverscroll:[_webViewProxy scrollViewProxy]
+ atPoint:scrollPoint];
[[_webViewProxy scrollViewProxy] setContentOffset:scrollPoint animated:YES];
if (completionHandler)
completionHandler();
@@ -199,6 +215,8 @@ const NSTimeInterval kRecurringPumpDelay = .01;
base::scoped_nsobject<FindInPageController> strongSelf([weakSelf retain]);
if (finished) {
[[strongSelf delegate] willAdjustScrollPosition];
+ point =
+ [self limitOverscroll:[strongSelf webViewScrollView] atPoint:point];
sdefresne 2015/04/08 20:02:18 point = [strongSelf limitOverscroll:[strongSelf we
justincohen 2015/04/08 20:25:51 Done.
[[strongSelf webViewScrollView] setContentOffset:point animated:YES];
}
completionHandler(finished);
@@ -212,12 +230,7 @@ const NSTimeInterval kRecurringPumpDelay = .01;
[_findInPageJsManager nextMatchWithCompletionHandler:^(CGPoint point) {
base::scoped_nsobject<FindInPageController> strongSelf([weakSelf retain]);
[[strongSelf delegate] willAdjustScrollPosition];
- CGFloat contentHeight = [strongSelf webViewScrollView].contentSize.height;
- CGFloat frameHeight = [strongSelf webViewScrollView].frame.size.height;
- CGFloat maxScroll = fmax(0, contentHeight - frameHeight);
- if (point.y > maxScroll) {
- point.y = maxScroll;
- }
+ point = [self limitOverscroll:[strongSelf webViewScrollView] atPoint:point];
sdefresne 2015/04/08 20:02:18 point = [strongSelf limitOverscroll:[strongSelf we
justincohen 2015/04/08 20:25:51 Done.
[[strongSelf webViewScrollView] setContentOffset:point animated:YES];
if (completionHandler)
completionHandler();
@@ -232,6 +245,7 @@ const NSTimeInterval kRecurringPumpDelay = .01;
[_findInPageJsManager previousMatchWithCompletionHandler:^(CGPoint point) {
base::scoped_nsobject<FindInPageController> strongSelf([weakSelf retain]);
[[strongSelf delegate] willAdjustScrollPosition];
+ point = [self limitOverscroll:[strongSelf webViewScrollView] atPoint:point];
sdefresne 2015/04/08 20:02:18 point = [strongSelf limitOverscroll:[strongSelf we
justincohen 2015/04/08 20:25:51 Done.
[[strongSelf webViewScrollView] setContentOffset:point animated:YES];
if (completionHandler)
completionHandler();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698