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

Unified Diff: Source/core/html/HTMLBodyElement.cpp

Issue 1075393002: Implement Document.scrollingElement API behind experimental feature flag (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Minor fix and comment tweak Created 5 years, 8 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
« no previous file with comments | « Source/core/html/HTMLBodyElement.h ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, ...).
- 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
« no previous file with comments | « Source/core/html/HTMLBodyElement.h ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698