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

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

Issue 670833002: Early out if the scroll position passed in by js is NaN (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 6 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: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index e6adcbf20803289c0b34ae37f93e15ae70b84cb8..63162b5f190958312a3b58fc108cc2480d829d08 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -665,9 +665,12 @@ void Element::setScrollLeft(double newLeft)
{
document().updateLayoutIgnorePendingStylesheets();
+ if (std::isnan(newLeft))
+ return;
+
if (document().documentElement() != this) {
RenderBox* rend = renderBox();
- if (rend && !std::isnan(newLeft))
+ if (rend)
rend->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * rend->style()->effectiveZoom()));
return;
}
@@ -712,9 +715,12 @@ void Element::setScrollTop(double newTop)
{
document().updateLayoutIgnorePendingStylesheets();
+ if (std::isnan(newTop))
+ return;
+
if (document().documentElement() != this) {
RenderBox* rend = renderBox();
- if (rend && !std::isnan(newTop))
+ if (rend)
rend->setScrollTop(LayoutUnit::fromFloatRound(newTop * rend->style()->effectiveZoom()));
return;
}
« no previous file with comments | « LayoutTests/fast/scrolling/scrolling-apis-nan-scroll-position-expected.txt ('k') | Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698