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

Unified Diff: Source/core/frame/LocalDOMWindow.cpp

Issue 1071983002: Don't force layout for scrollTo(0,0). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added comments 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 | « LayoutTests/fast/scrolling/scroll-to-origin-with-options-no-layout-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/LocalDOMWindow.cpp
diff --git a/Source/core/frame/LocalDOMWindow.cpp b/Source/core/frame/LocalDOMWindow.cpp
index 0c636c0bd315c613ab58748e3a472d3563458a3d..2b4002e5bd41cb79b7d8d80a3b90a3b75f179829 100644
--- a/Source/core/frame/LocalDOMWindow.cpp
+++ b/Source/core/frame/LocalDOMWindow.cpp
@@ -1210,11 +1210,14 @@ void LocalDOMWindow::scrollTo(double x, double y) const
if (!isCurrentlyDisplayedInFrame())
return;
- document()->updateLayoutIgnorePendingStylesheets();
-
if (std::isnan(x) || std::isnan(y))
return;
+ // It is only necessary to have an up-to-date layout if the position may be clamped,
+ // which is never the case for (0, 0).
+ if (x || y)
+ document()->updateLayoutIgnorePendingStylesheets();
+
DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFactor());
scrollViewportTo(frame(), layoutPos, ScrollBehaviorAuto);
}
@@ -1224,8 +1227,6 @@ void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const
if (!isCurrentlyDisplayedInFrame())
return;
- document()->updateLayoutIgnorePendingStylesheets();
-
FrameView* view = frame()->view();
if (!view)
return;
@@ -1234,6 +1235,15 @@ void LocalDOMWindow::scrollTo(const ScrollToOptions& scrollToOptions) const
if (!host)
return;
+ // It is only necessary to have an up-to-date layout if the position may be clamped,
+ // which is never the case for (0, 0).
+ if (!scrollToOptions.hasLeft()
+ || !scrollToOptions.hasTop()
+ || scrollToOptions.left()
+ || scrollToOptions.top()) {
+ document()->updateLayoutIgnorePendingStylesheets();
+ }
+
double scaledX = 0.0;
double scaledY = 0.0;
« no previous file with comments | « LayoutTests/fast/scrolling/scroll-to-origin-with-options-no-layout-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698