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

Unified Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1424313003: element.scrollIntoView only scrolls the layout viewport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback Created 5 years, 2 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
Index: third_party/WebKit/Source/core/dom/Element.cpp
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp
index 08e1817cfe6ff258e84a5e7de1cd1a4846ed3f85..6caa4218ca71bc24056790b0f67a55005f2d7a64 100644
--- a/third_party/WebKit/Source/core/dom/Element.cpp
+++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -475,12 +475,14 @@ void Element::scrollIntoView(bool alignToTop)
if (!layoutObject())
return;
+ bool makeVisibleInVisualViewport = !document().page()->settings().inertVisualViewport();
+
LayoutRect bounds = boundingBox();
// Align to the top / bottom and to the closest edge.
if (alignToTop)
- layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
+ layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways, ProgrammaticScroll, makeVisibleInVisualViewport);
else
- layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways);
+ layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignBottomAlways, ProgrammaticScroll, makeVisibleInVisualViewport);
}
void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
@@ -490,11 +492,13 @@ void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
if (!layoutObject())
return;
+ bool makeVisibleInVisualViewport = !document().page()->settings().inertVisualViewport();
+
LayoutRect bounds = boundingBox();
if (centerIfNeeded)
- layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded);
+ layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignCenterIfNeeded, ScrollAlignment::alignCenterIfNeeded, ProgrammaticScroll, makeVisibleInVisualViewport);
else
- layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
+ layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded, ProgrammaticScroll, makeVisibleInVisualViewport);
}
void Element::setDistributeScroll(ScrollStateCallback* scrollStateCallback, String nativeScrollBehavior)

Powered by Google App Engine
This is Rietveld 408576698