Chromium Code Reviews| Index: Source/core/dom/Element.cpp |
| diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp |
| index 2607f8068404cfcac097b193fdb630258c627a04..3467c2e30ec27313a45df7cba7d0abaa777d6161 100644 |
| --- a/Source/core/dom/Element.cpp |
| +++ b/Source/core/dom/Element.cpp |
| @@ -113,6 +113,7 @@ |
| #include "core/page/Page.h" |
| #include "core/page/PointerLockController.h" |
| #include "core/page/SpatialNavigation.h" |
| +#include "core/page/scrolling/ScrollState.h" |
| #include "core/svg/SVGDocumentExtensions.h" |
| #include "core/svg/SVGElement.h" |
| #include "platform/EventDispatchForbiddenScope.h" |
| @@ -481,6 +482,70 @@ void Element::scrollIntoViewIfNeeded(bool centerIfNeeded) |
| layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded); |
| } |
| +void Element::distributeScroll(ScrollState& scrollState) |
| +{ |
| + ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); |
| + if (scrollState.fullyConsumed()) |
| + return; |
| + |
| + scrollState.distributeToScrollChainDescendant(); |
| + |
| + // If the scroll doesn't propagate, and we're currently scrolling |
| + // an element other than this one, don't scroll. |
|
Rick Byers
2015/03/11 02:22:18
this comment says what (i.e. repeats the code belo
tdresser
2015/03/20 18:00:36
Done.
|
| + if (!scrollState.shouldPropagate() |
| + && scrollState.deltaConsumedForScrollSequence() |
|
Rick Byers
2015/03/11 02:22:18
Can you add a comment to the declaration of deltaC
tdresser
2015/03/20 18:00:36
Can you clarify what about the comment doesn't mak
Rick Byers
2015/03/26 21:22:48
Ah, I was looking at the method declaration - didn
|
| + && scrollState.currentNativeScrollingElement() != this) { |
| + return; |
| + } |
| + |
| + const double deltaX = scrollState.deltaX(); |
| + const double deltaY = scrollState.deltaY(); |
| + |
| + applyScroll(scrollState); |
| + |
| + if (deltaX != scrollState.deltaX() || deltaY != scrollState.deltaY()) |
| + scrollState.setCurrentNativeScrollingElement(this); |
| +} |
| + |
| +void Element::applyScroll(ScrollState& scrollState) |
| +{ |
| + ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled()); |
| + if (scrollState.fullyConsumed()) |
| + return; |
| + |
| + const double deltaX = scrollState.deltaX(); |
| + const double deltaY = scrollState.deltaY(); |
| + bool scrolled = false; |
| + |
| + // Handle the documentElement separately, as it scrolls the FrameView. |
| + if (this == document().documentElement()) { |
| + FloatSize delta(deltaX, deltaY); |
| + if (document().frame()->applyScrollDelta(delta, scrollState.isBeginning())) |
| + scrolled = true; |
| + } else { |
| + if (!layoutObject()) |
| + return; |
| + LayoutBox* curBox = layoutObject()->enclosingBox(); |
| + if (deltaX && curBox->scroll(ScrollLeft, ScrollByPrecisePixel, deltaX)) |
| + scrolled = true; |
| + |
| + if (deltaY && curBox->scroll(ScrollUp, ScrollByPrecisePixel, deltaY)) |
| + scrolled = true; |
| + } |
| + |
| + if (!scrolled) |
| + return; |
| + |
| + // We need to setCurrentNativeScrollingElement in both the |
| + // distributeScroll and applyScroll default implementations so |
| + // that if JS overrides one of these methods, but not the |
| + // other, this bookkeeping remains accurate. |
| + scrollState.setCurrentNativeScrollingElement(this); |
| + scrollState.consumeDeltaNative(scrollState.deltaX(), scrollState.deltaY()); |
|
Rick Byers
2015/03/11 02:22:18
If curBox->scroll(ScrollLeft) returned true, but c
tdresser
2015/03/20 18:00:36
Done.
|
| + if (scrollState.fromUserInput()) |
| + document().frame()->view()->setWasScrolledByUser(true); |
| +}; |
| + |
| static float localZoomForRenderer(LayoutObject& renderer) |
| { |
| // FIXME: This does the wrong thing if two opposing zooms are in effect and canceled each |