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

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 295cd9fbd11ba889a4b3ea5cb7741a1f3759ccc6..fc9327d408afbc15ad84f4bf41637b1a66d1a9af 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -724,6 +724,20 @@ 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;
+ view->setScrollPosition(IntPoint(static_cast<int>(newLeft * frame->pageZoomFactor()), view->scrollY()));
Julien - ping for review 2013/10/05 01:05:46 The specification is weird and seem to imply that
+ }
+
if (RenderBox* rend = renderBox())
rend->setScrollLeft(static_cast<int>(newLeft * rend->style()->effectiveZoom()));
}
@@ -731,6 +745,20 @@ 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;
+ view->setScrollPosition(IntPoint(view->scrollX(), static_cast<int>(newTop * frame->pageZoomFactor())));
+ }
+
if (RenderBox* rend = renderBox())
rend->setScrollTop(static_cast<int>(newTop * rend->style()->effectiveZoom()));
}

Powered by Google App Engine
This is Rietveld 408576698