Chromium Code Reviews| Index: Source/core/dom/Element.cpp |
| diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp |
| index 71191c2d41e13f567b68072831047999af2ca051..5df6909caedb43f7aa41d396ad4d3224dec2cf73 100644 |
| --- a/Source/core/dom/Element.cpp |
| +++ b/Source/core/dom/Element.cpp |
| @@ -711,20 +711,15 @@ double Element::scrollLeft() |
| { |
| document().updateLayoutIgnorePendingStylesheets(); |
| - if (document().documentElement() != this) { |
| - if (LayoutBox* box = layoutBox()) |
| - return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); |
| - return 0; |
| - } |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - if (document().inQuirksMode()) |
| - return 0; |
| - |
| + if (document().scrollingElement() == this) { |
| if (LocalDOMWindow* window = document().domWindow()) |
| return window->scrollX(); |
|
tdresser
2015/04/13 13:45:30
I think these would be somewhat easier to read as:
Rick Byers
2015/04/13 20:08:31
Done for these cases 'window' is used only once.
|
| + return 0; |
| } |
| + if (LayoutBox* box = layoutBox()) |
| + return adjustScrollForAbsoluteZoom(box->scrollLeft(), *box); |
| + |
| return 0; |
| } |
| @@ -732,20 +727,15 @@ double Element::scrollTop() |
| { |
| document().updateLayoutIgnorePendingStylesheets(); |
| - if (document().documentElement() != this) { |
| - if (LayoutBox* box = layoutBox()) |
| - return adjustScrollForAbsoluteZoom(box->scrollTop(), *box); |
| - return 0; |
| - } |
| - |
| - if (RuntimeEnabledFeatures::scrollTopLeftInteropEnabled()) { |
| - if (document().inQuirksMode()) |
| - return 0; |
| - |
| + if (document().scrollingElement() == this) { |
| if (LocalDOMWindow* window = document().domWindow()) |
| return window->scrollY(); |
| + return 0; |
| } |
| + 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 (FrameView* view = document().view()) |
| + return adjustForAbsoluteZoom(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 (FrameView* view = document().view()) |
| + return adjustForAbsoluteZoom(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); |
| } |
| } |