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

Unified Diff: Source/core/dom/Element.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/dom/Document.idl ('k') | Source/core/frame/FrameView.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index 71191c2d41e13f567b68072831047999af2ca051..04dce919eac3a5c55956e42d22989f87e1df3ee6 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -711,19 +711,14 @@ double Element::scrollLeft()
{
document().updateLayoutIgnorePendingStylesheets();
- if (document().documentElement() != this) {
- if (LayoutBox* box = layoutBox())
- return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box);
+ if (document().scrollingElement() == this) {
+ if (document().domWindow())
+ return document().domWindow()->scrollX();
return 0;
}
- if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
- if (document().inQuirksMode())
- return 0;
-
- if (LocalDOMWindow* window = document().domWindow())
- return window->scrollX();
- }
+ if (LayoutBox* box = layoutBox())
+ return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box);
return 0;
}
@@ -732,19 +727,14 @@ double Element::scrollTop()
{
document().updateLayoutIgnorePendingStylesheets();
- if (document().documentElement() != this) {
- if (LayoutBox* box = layoutBox())
- return adjustScrollForAbsoluteZoom(box->scrollTop(), *box);
+ if (document().scrollingElement() == this) {
+ if (document().domWindow())
+ return document().domWindow()->scrollY();
return 0;
}
- if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
- if (document().inQuirksMode())
- return 0;
-
- if (LocalDOMWindow* window = document().domWindow())
- return window->scrollY();
- }
+ if (LayoutBox* box = layoutBox())
+ return adjustScrollForAbsoluteZoom(box->scrollTop(), *box);
return 0;
}
@@ -756,19 +746,13 @@ void Element::setScrollLeft(double newLeft)
if (std::isnan(newLeft))
return;
- if (document().documentElement() != this) {
+ if (document().scrollingElement() == this) {
+ if (LocalDOMWindow* window = document().domWindow())
+ window->scrollTo(newLeft, window->scrollY());
+ } else {
LayoutBox* box = layoutBox();
if (box)
box->setScrollLeft(LayoutUnit::fromFloatRound(newLeft * box->style()->effectiveZoom()));
- return;
- }
-
- if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
- if (document().inQuirksMode())
- return;
-
- if (LocalDOMWindow* window = document().domWindow())
- window->scrollTo(newLeft, window->scrollY());
}
}
@@ -779,25 +763,26 @@ void Element::setScrollTop(double newTop)
if (std::isnan(newTop))
return;
- if (document().documentElement() != this) {
+ if (document().scrollingElement() == this) {
+ if (LocalDOMWindow* window = document().domWindow())
+ window->scrollTo(window->scrollX(), newTop);
+ } else {
LayoutBox* box = layoutBox();
if (box)
box->setScrollTop(LayoutUnit::fromFloatRound(newTop * box->style()->effectiveZoom()));
- return;
- }
-
- if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
- if (document().inQuirksMode())
- return;
-
- if (LocalDOMWindow* window = document().domWindow())
- window->scrollTo(window->scrollX(), newTop);
}
}
int Element::scrollWidth()
{
document().updateLayoutIgnorePendingStylesheets();
+
+ if (document().scrollingElement() == this) {
+ if (document().view())
+ return adjustForAbsoluteZoom(document().view()->contentsWidth(), document().frame()->pageZoomFactor());
+ return 0;
+ }
+
if (LayoutBox* box = layoutBox())
return adjustLayoutUnitForAbsoluteZoom(box->scrollWidth(), *box).round();
return 0;
@@ -806,6 +791,13 @@ int Element::scrollWidth()
int Element::scrollHeight()
{
document().updateLayoutIgnorePendingStylesheets();
+
+ if (document().scrollingElement() == this) {
+ if (document().view())
+ return adjustForAbsoluteZoom(document().view()->contentsHeight(), document().frame()->pageZoomFactor());
+ return 0;
+ }
+
if (LayoutBox* box = layoutBox())
return adjustLayoutUnitForAbsoluteZoom(box->scrollHeight(), *box).round();
return 0;
@@ -825,15 +817,10 @@ void Element::scrollBy(const ScrollToOptions& scrollToOptions)
// the compositing update. See http://crbug.com/420741.
document().updateLayoutIgnorePendingStylesheets();
- if (document().documentElement() != this) {
- scrollLayoutBoxBy(scrollToOptions);
- return;
- }
-
- if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
- if (document().inQuirksMode())
- return;
+ if (document().scrollingElement() == this) {
scrollFrameBy(scrollToOptions);
+ } else {
+ scrollLayoutBoxBy(scrollToOptions);
}
}
@@ -851,15 +838,10 @@ void Element::scrollTo(const ScrollToOptions& scrollToOptions)
// the compositing update. See http://crbug.com/420741.
document().updateLayoutIgnorePendingStylesheets();
- if (document().documentElement() != this) {
- scrollLayoutBoxTo(scrollToOptions);
- return;
- }
-
- if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) {
- if (document().inQuirksMode())
- return;
+ if (document().scrollingElement() == this) {
scrollFrameTo(scrollToOptions);
+ } else {
+ scrollLayoutBoxTo(scrollToOptions);
}
}
« no previous file with comments | « Source/core/dom/Document.idl ('k') | Source/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698