Index: third_party/WebKit/Source/core/dom/Element.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp |
index 4d84f904586ca1e1b7fd7475ac9b7994b915b215..284e08fb43f2757c1cab98067562a489ee0033d4 100644 |
--- a/third_party/WebKit/Source/core/dom/Element.cpp |
+++ b/third_party/WebKit/Source/core/dom/Element.cpp |
@@ -147,7 +147,6 @@ namespace { |
// FrameHosts when elements are moved around. |
ScrollCustomizationCallbacks& scrollCustomizationCallbacks() |
{ |
- DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled()); |
DEFINE_STATIC_LOCAL(ScrollCustomizationCallbacks, scrollCustomizationCallbacks, (new ScrollCustomizationCallbacks)); |
return scrollCustomizationCallbacks; |
} |
@@ -504,9 +503,18 @@ void Element::setApplyScroll(ScrollStateCallback* scrollStateCallback, String na |
scrollCustomizationCallbacks().setApplyScroll(this, scrollStateCallback); |
} |
+void Element::removeApplyScroll() |
+{ |
+ scrollCustomizationCallbacks().removeApplyScroll(this); |
+} |
+ |
+ScrollStateCallback* Element::getApplyScroll() |
+{ |
+ return scrollCustomizationCallbacks().getApplyScroll(this); |
+} |
+ |
void Element::nativeDistributeScroll(ScrollState& scrollState) |
{ |
- DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled()); |
if (scrollState.fullyConsumed()) |
return; |
@@ -548,44 +556,44 @@ void Element::callDistributeScroll(ScrollState& scrollState) |
void Element::nativeApplyScroll(ScrollState& scrollState) |
{ |
DCHECK(RuntimeEnabledFeatures::scrollCustomizationEnabled()); |
+ |
+ // All elements in the scroll chain should be boxes. |
+ DCHECK(!layoutObject() || layoutObject()->isBox()); |
+ |
if (scrollState.fullyConsumed()) |
return; |
- const double deltaX = scrollState.deltaX(); |
- const double deltaY = scrollState.deltaY(); |
- bool scrolled = false; |
+ FloatSize delta(scrollState.deltaX(), scrollState.deltaY()); |
+ |
+ if (delta.isZero()) |
+ return; |
// TODO(esprehn): This should use updateLayoutIgnorePendingStylesheetsForNode. |
- if (deltaY || deltaX) |
- document().updateLayoutIgnorePendingStylesheets(); |
- |
- // Handle the scrollingElement separately, as it scrolls the viewport. |
- if (this == document().scrollingElement()) { |
- FloatSize delta(deltaX, deltaY); |
- if (document().frame()->applyScrollDelta(ScrollByPrecisePixel, delta, scrollState.isBeginning()).didScroll()) { |
- scrolled = true; |
- scrollState.consumeDeltaNative(scrollState.deltaX(), scrollState.deltaY()); |
- } |
- } else { |
- if (!layoutObject()) |
- return; |
- LayoutBoxItem curBox = LayoutBoxItem(toLayoutBox(layoutObject())).enclosingBox(); |
- // FIXME: Native scrollers should only consume the scroll they |
- // apply. See crbug.com/457765. |
- if (deltaX && curBox.scroll(ScrollByPrecisePixel, FloatSize(deltaX, 0)).didScrollX) { |
- scrollState.consumeDeltaNative(scrollState.deltaX(), 0); |
- scrolled = true; |
- } |
+ document().updateLayoutIgnorePendingStylesheets(); |
- if (deltaY && curBox.scroll(ScrollByPrecisePixel, FloatSize(0, deltaY)).didScrollY) { |
- scrollState.consumeDeltaNative(0, scrollState.deltaY()); |
- scrolled = true; |
- } |
- } |
+ LayoutBox* boxToScroll = nullptr; |
+ |
+ // Handle the scrollingElement separately, as it should scroll the viewport. |
+ if (this == document().scrollingElement()) |
+ boxToScroll = document().layoutView(); |
+ else if (layoutObject()) |
+ boxToScroll = toLayoutBox(layoutObject()); |
+ |
+ if (!boxToScroll) |
+ return; |
+ |
+ ScrollResult result = |
+ LayoutBoxItem(boxToScroll).enclosingBox().scroll( |
+ ScrollByPrecisePixel, |
+ delta); |
- if (!scrolled) |
+ if (!result.didScroll()) |
return; |
+ // FIXME: Native scrollers should only consume the scroll they |
+ // apply. See crbug.com/457765. |
+ scrollState.consumeDeltaNative(delta.width(), delta.height()); |
+ |
// We need to setCurrentNativeScrollingElement in both the |
// distributeScroll and applyScroll default implementations so |
// that if JS overrides one of these methods, but not the |