Chromium Code Reviews| Index: Source/core/html/HTMLBodyElement.cpp |
| diff --git a/Source/core/html/HTMLBodyElement.cpp b/Source/core/html/HTMLBodyElement.cpp |
| index 0633ec7122104481c21ff65ba6da706d813d4a67..26e85019652ecedd79f9f48169decd6c06270929 100644 |
| --- a/Source/core/html/HTMLBodyElement.cpp |
| +++ b/Source/core/html/HTMLBodyElement.cpp |
| @@ -36,6 +36,7 @@ |
| #include "core/html/parser/HTMLParserIdioms.h" |
| #include "core/frame/Frame.h" |
| #include "core/frame/FrameView.h" |
| +#include "core/rendering/RenderBox.h" |
| namespace WebCore { |
| @@ -201,18 +202,28 @@ static int adjustForZoom(int value, Document* document) |
| return static_cast<int>(value / zoomFactor); |
| } |
| +// Blink, Gecko and Presto's quirks mode implementations of overflow:scroll set to |
| +// body element differ from IE's: the formers can create a scrollable area for the |
| +// body element that is not the same as the root elements's one. On IE's quirks mode |
| +// though, as body is the root element, body's and the root element's scrollable areas, |
| +// if any, are the same. |
| +// Blink's {set}scroll{Top,Left} behaviors match Gecko's: even if there is a non-overflown |
| +// scrollable area, scrolling should not get propageted to the viewport in neither strict |
| +// or quirks modes. That is why canBeScrolledAndHasScrollableArea is not used, but hasOverflowClip. |
| int HTMLBodyElement::scrollLeft() |
| { |
| Document& document = this->document(); |
| + document.updateLayoutIgnorePendingStylesheets(); |
| + |
| + RenderBox* rend = renderBox(); |
|
Julien - ping for review
2013/11/01 16:49:15
s/rend/renderBox/. Let's not save any character, s
|
| + if (!rend) |
| + return 0; |
| + if (rend->hasOverflowClip()) |
|
Julien - ping for review
2013/11/01 16:49:15
FYI if <body> is the document element, this will b
|
| + return adjustForAbsoluteZoom(rend->scrollLeft(), rend); |
| - // FIXME: There are cases where body.scrollLeft is allowed to return |
| - // non-zero values in both quirks and strict mode. It happens when |
| - // <body> has an overflow that is not the Frame overflow. |
| - // http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft |
| if (!document.inQuirksMode()) |
| UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQuirksMode); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| FrameView* view = document.view(); |
| return view ? adjustForZoom(view->scrollX(), &document) : 0; |
| } |
| @@ -220,11 +231,18 @@ int HTMLBodyElement::scrollLeft() |
| void HTMLBodyElement::setScrollLeft(int scrollLeft) |
| { |
| Document& document = this->document(); |
| + document.updateLayoutIgnorePendingStylesheets(); |
| + |
| + RenderBox* rend = renderBox(); |
| + if (!rend) |
| + return; |
| + if (rend->hasOverflowClip()) { |
| + rend->setScrollLeft(static_cast<int>(scrollLeft * rend->style()->effectiveZoom())); |
|
Julien - ping for review
2013/11/01 16:49:15
Why the explicit static_cast instead of an implici
|
| + return; |
| + } |
| if (!document.inQuirksMode()) |
| UseCounter::countDeprecation(&document, UseCounter::ScrollLeftBodyNotQuirksMode); |
| - |
| - document.updateLayoutIgnorePendingStylesheets(); |
| Frame* frame = document.frame(); |
| if (!frame) |
| return; |
| @@ -237,15 +255,17 @@ void HTMLBodyElement::setScrollLeft(int scrollLeft) |
| int HTMLBodyElement::scrollTop() |
| { |
| Document& document = this->document(); |
| + document.updateLayoutIgnorePendingStylesheets(); |
| + |
| + RenderBox* rend = renderBox(); |
| + if (!rend) |
| + return 0; |
| + if (rend->hasOverflowClip()) |
| + return adjustForAbsoluteZoom(rend->scrollTop(), rend); |
| - // FIXME: There are cases where body.scrollTop is allowed to return |
| - // non-zero values in both quirks and strict mode. It happens when |
| - // body has a overflow that is not the Frame overflow. |
| - // http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop |
| if (!document.inQuirksMode()) |
| UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuirksMode); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| FrameView* view = document.view(); |
| return view ? adjustForZoom(view->scrollY(), &document) : 0; |
| } |
| @@ -253,11 +273,19 @@ int HTMLBodyElement::scrollTop() |
| void HTMLBodyElement::setScrollTop(int scrollTop) |
| { |
| Document& document = this->document(); |
| + document.updateLayoutIgnorePendingStylesheets(); |
| + |
| + RenderBox* rend = renderBox(); |
| + if (!rend) |
| + return; |
| + if (rend->hasOverflowClip()) { |
| + rend->setScrollTop(static_cast<int>(scrollTop * rend->style()->effectiveZoom())); |
| + return; |
| + } |
| if (!document.inQuirksMode()) |
| UseCounter::countDeprecation(&document, UseCounter::ScrollTopBodyNotQuirksMode); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| Frame* frame = document.frame(); |
| if (!frame) |
| return; |