[go: up one dir, main page]

[ios] Show currently selected match on the bottom of the screen

This change will move the position of a newly selected match to
the bottom of the screen as opposed to the top so that it does not
get covered up by any webpage toolbar on AMP pages.

(cherry picked from commit bbec82e94521cb3934b1c1a194e3725e6c5c2c9c)

Change-Id: I95fa390c2ebb4fccc12e5609234e28a440aabca5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1653845
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: Eugene But <eugenebut@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#668565}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663031
Reviewed-by: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#380}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/ios/web/web_state/js/find_in_page_js_unittest.mm b/ios/web/web_state/js/find_in_page_js_unittest.mm
index 775b727..3ea5190 100644
--- a/ios/web/web_state/js/find_in_page_js_unittest.mm
+++ b/ios/web/web_state/js/find_in_page_js_unittest.mm
@@ -430,9 +430,9 @@
         web_state()->GetWebViewProxy().scrollViewProxy.contentOffset.y;
     return top_scroll_after_select > 0;
   }));
-  // Scroll offset should be 1035.333333 for iPhoneX and 1035.500000 for every
+  // Scroll offset should be 1032.6667 for iPhoneX and 1033 for every
   // other device.
-  EXPECT_NEAR(top_scroll_after_select, 1035.0, 0.5);
+  EXPECT_NEAR(top_scroll_after_select, 1032.75, 0.5);
 }
 
 // Tests that FindInPage is able to clear CSS and match highlighting.
diff --git a/ios/web/web_state/js/resources/find_in_page.js b/ios/web/web_state/js/resources/find_in_page.js
index 3da29c3..675a3ff5 100644
--- a/ios/web/web_state/js/resources/find_in_page.js
+++ b/ios/web/web_state/js/resources/find_in_page.js
@@ -683,7 +683,7 @@
     return;
   }
 
-  match.nodes[0].scrollIntoView();
+  match.nodes[0].scrollIntoView(/*alignToTop=*/false);
 };
 
 /**