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

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

Issue 25741004: set and get scrollTop/Left through documentElement and body should be symmetric, according to the d… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: set and get scrollTop/Left through documentElement and body should be symmetric, according to the d… Created 7 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 47c101746908ca48f96edb526ca0d5fb61dc01e8..b667cd58106e28a1ffb25ddbcd1a0d3310805a17 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -725,6 +725,27 @@ int Element::scrollTop()
void Element::setScrollLeft(int newLeft)
{
document().updateLayoutIgnorePendingStylesheets();
+
+ if (document().documentElement() == this) {
+ if (document().inQuirksMode())
+ return;
+
+ Frame* frame = document().frame();
+ if (!frame)
+ return;
+ FrameView* view = frame->view();
+ if (!view)
+ return;
+
+ // WHATWG spec says [1]: "If the element is the root element invoke scroll()
+ // with x as first argument and zero as second". Blink intentionally matches
+ // other engine's behaviors here, instead, where the 'y' scroll position is
+ // preversed. See [2].
+ // [1] http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft
+ // [2] https://www.w3.org/Bugs/Public/show_bug.cgi?id=23448
+ view->setScrollPosition(IntPoint(static_cast<int>(newLeft * frame->pageZoomFactor()), view->scrollY()));
+ }
+
if (RenderBox* rend = renderBox())
rend->setScrollLeft(static_cast<int>(newLeft * rend->style()->effectiveZoom()));
}
@@ -732,6 +753,27 @@ void Element::setScrollLeft(int newLeft)
void Element::setScrollTop(int newTop)
{
document().updateLayoutIgnorePendingStylesheets();
+
+ if (document().documentElement() == this) {
+ if (document().inQuirksMode())
+ return;
+
+ Frame* frame = document().frame();
+ if (!frame)
+ return;
+ FrameView* view = frame->view();
+ if (!view)
+ return;
+
+ // WHATWG spec says [1]: "If the element is the root element invoke scroll()
+ // with zero as first argument and y as second". Blink intentionally
+ // matches other engine's behaviors here, instead, where the 'x' scroll
+ // position is preversed. See [2].
+ // [1] http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop
+ // [2] https://www.w3.org/Bugs/Public/show_bug.cgi?id=23448
+ view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(newTop * frame->pageZoomFactor())));
+ }
+
if (RenderBox* rend = renderBox())
rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiveZoom()));
}
« no previous file with comments | « LayoutTests/fast/repaint/resources/iframe-scroll-repaint-iframe.html ('k') | Source/core/html/HTMLBodyElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698