Chromium Code Reviews| Index: Source/core/html/HTMLBodyElement.cpp |
| diff --git a/Source/core/html/HTMLBodyElement.cpp b/Source/core/html/HTMLBodyElement.cpp |
| index f92220d4ea0810e8ec498bdc59061fcbb8bd4d06..183466aa90292e38b4babb89ff71646999bd1e4f 100644 |
| --- a/Source/core/html/HTMLBodyElement.cpp |
| +++ b/Source/core/html/HTMLBodyElement.cpp |
| @@ -31,13 +31,9 @@ |
| #include "core/css/StylePropertySet.h" |
| #include "core/css/parser/CSSParser.h" |
| #include "core/dom/Attribute.h" |
| -#include "core/frame/FrameView.h" |
| -#include "core/frame/LocalFrame.h" |
| -#include "core/frame/ScrollToOptions.h" |
| #include "core/frame/UseCounter.h" |
| #include "core/html/HTMLFrameElementBase.h" |
| #include "core/html/parser/HTMLParserIdioms.h" |
| -#include "core/layout/LayoutBox.h" |
| namespace blink { |
| @@ -196,181 +192,4 @@ bool HTMLBodyElement::supportsFocus() const |
| return hasEditableStyle() || HTMLElement::supportsFocus(); |
| } |
| -static int adjustForZoom(int value, Document* document) |
| -{ |
| - LocalFrame* frame = document->frame(); |
| - float zoomFactor = frame->pageZoomFactor(); |
| - if (zoomFactor == 1) |
| - return value; |
| - // Needed because of truncation (rather than rounding) when scaling up. |
| - if (zoomFactor > 1) |
| - value++; |
| - return static_cast<int>(value / zoomFactor); |
| -} |
| - |
| -// Blink, Gecko and Presto's quirks mode implementations of overflow set to the |
| -// 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. |
| -// In order words, a <body> will only have an overflow clip (that differs from |
| -// documentElement's) if both html and body nodes have its overflow set to either hidden, |
| -// auto or scroll. |
| -// That said, Blink's {set}scroll{Top,Left} behaviors match Gecko's: even if there is a non-overflown |
| -// scrollable area, scrolling should not get propagated to the viewport in neither strict |
| -// or quirks modes. |
| -double HTMLBodyElement::scrollLeft() |
| -{ |
| - Document& document = this->document(); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - LayoutBox* render = layoutBox(); |
| - if (!render) |
| - return 0; |
| - if (render->hasOverflowClip()) |
| - return adjustScrollForAbsoluteZoom(render->scrollLeft(), *render); |
| - if (!document.inQuirksMode()) |
| - return 0; |
| - } |
| - |
| - if (LocalDOMWindow* window = document.domWindow()) |
| - return window->scrollX(); |
| - return 0; |
| -} |
| - |
| -void HTMLBodyElement::setScrollLeft(double scrollLeft) |
| -{ |
| - Document& document = this->document(); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - |
| - if (std::isnan(scrollLeft)) |
| - return; |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - LayoutBox* render = layoutBox(); |
| - if (!render) |
| - return; |
| - if (render->hasOverflowClip()) { |
| - // FIXME: Investigate how are other browsers casting to int (rounding, ceiling, ...). |
|
tdresser
2015/04/13 13:45:30
Is our behavior here correct at this point?
Rick Byers
2015/04/13 20:08:31
I removed the special casing of body in this regar
|
| - render->setScrollLeft(static_cast<int>(scrollLeft * render->style()->effectiveZoom())); |
| - return; |
| - } |
| - if (!document.inQuirksMode()) |
| - return; |
| - } |
| - |
| - if (LocalDOMWindow* window = document.domWindow()) |
| - window->scrollTo(scrollLeft, window->scrollY()); |
| -} |
| - |
| -double HTMLBodyElement::scrollTop() |
| -{ |
| - Document& document = this->document(); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - LayoutBox* render = layoutBox(); |
| - if (!render) |
| - return 0; |
| - if (render->hasOverflowClip()) |
| - return adjustLayoutUnitForAbsoluteZoom(render->scrollTop(), *render); |
| - if (!document.inQuirksMode()) |
| - return 0; |
| - } |
| - |
| - if (LocalDOMWindow* window = document.domWindow()) |
| - return window->scrollY(); |
| - return 0; |
| -} |
| - |
| -void HTMLBodyElement::setScrollTop(double scrollTop) |
| -{ |
| - Document& document = this->document(); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - |
| - if (std::isnan(scrollTop)) |
| - return; |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - LayoutBox* render = layoutBox(); |
| - if (!render) |
| - return; |
| - if (render->hasOverflowClip()) { |
| - // FIXME: Investigate how are other browsers casting to int (rounding, ceiling, ...). |
| - render->setScrollTop(static_cast<int>(scrollTop * render->style()->effectiveZoom())); |
| - return; |
| - } |
| - if (!document.inQuirksMode()) |
| - return; |
| - } |
| - |
| - if (LocalDOMWindow* window = document.domWindow()) |
| - window->scrollTo(window->scrollX(), scrollTop); |
| -} |
| - |
| -int HTMLBodyElement::scrollHeight() |
| -{ |
| - // Update the document's layout. |
| - Document& document = this->document(); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - FrameView* view = document.view(); |
| - return view ? adjustForZoom(view->contentsHeight(), &document) : 0; |
| -} |
| - |
| -int HTMLBodyElement::scrollWidth() |
| -{ |
| - // Update the document's layout. |
| - Document& document = this->document(); |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - FrameView* view = document.view(); |
| - return view ? adjustForZoom(view->contentsWidth(), &document) : 0; |
| -} |
| - |
| -void HTMLBodyElement::scrollBy(const ScrollToOptions& scrollToOptions) |
| -{ |
| - Document& document = this->document(); |
| - |
| - // FIXME: This should be removed once scroll updates are processed only after |
| - // the compositing update. See http://crbug.com/420741. |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - LayoutBox* render = layoutBox(); |
| - if (!render) |
| - return; |
| - if (render->hasOverflowClip()) { |
| - scrollLayoutBoxBy(scrollToOptions); |
| - return; |
| - } |
| - if (!document.inQuirksMode()) |
| - return; |
| - } |
| - |
| - scrollFrameBy(scrollToOptions); |
| -} |
| - |
| -void HTMLBodyElement::scrollTo(const ScrollToOptions& scrollToOptions) |
| -{ |
| - Document& document = this->document(); |
| - |
| - // FIXME: This should be removed once scroll updates are processed only after |
| - // the compositing update. See http://crbug.com/420741. |
| - document.updateLayoutIgnorePendingStylesheets(); |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - LayoutBox* render = layoutBox(); |
| - if (!render) |
| - return; |
| - if (render->hasOverflowClip()) { |
| - scrollLayoutBoxTo(scrollToOptions); |
| - return; |
| - } |
| - if (!document.inQuirksMode()) |
| - return; |
| - } |
| - |
| - scrollFrameTo(scrollToOptions); |
| -} |
| - |
| } // namespace blink |