| Index: Source/core/dom/Element.cpp
|
| diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
|
| index c69348e34641b001dad546df2a175dd3c422cf6d..de4a717d27d26144a960de0af74112ff58bd10f7 100644
|
| --- a/Source/core/dom/Element.cpp
|
| +++ b/Source/core/dom/Element.cpp
|
| @@ -30,6 +30,7 @@
|
| #include "bindings/core/v8/Dictionary.h"
|
| #include "bindings/core/v8/ExceptionMessages.h"
|
| #include "bindings/core/v8/ExceptionState.h"
|
| +#include "bindings/core/v8/ToV8.h"
|
| #include "bindings/core/v8/V8DOMWrapper.h"
|
| #include "bindings/core/v8/V8PerContextData.h"
|
| #include "core/CSSValueKeywords.h"
|
| @@ -113,6 +114,7 @@
|
| #include "core/page/PointerLockController.h"
|
| #include "core/page/SpatialNavigation.h"
|
| #include "core/page/scrolling/ScrollState.h"
|
| +#include "core/page/scrolling/ScrollStateCallback.h"
|
| #include "core/paint/DeprecatedPaintLayer.h"
|
| #include "core/svg/SVGDocumentExtensions.h"
|
| #include "core/svg/SVGElement.h"
|
| @@ -470,7 +472,66 @@ void Element::scrollIntoViewIfNeeded(bool centerIfNeeded)
|
| layoutObject()->scrollRectToVisible(bounds, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
|
| }
|
|
|
| -void Element::distributeScroll(ScrollState& scrollState)
|
| +namespace {
|
| +
|
| +class DistributeScrollCallback : public ScrollStateCallback {
|
| +public:
|
| + DistributeScrollCallback()
|
| + {
|
| + m_callbackType = CallbackType::DISTRIBUTE_SCROLL;
|
| + }
|
| + void handleEvent(ScrollState* scrollState)
|
| + {
|
| + ASSERT(m_targetElement);
|
| + ASSERT(scrollState);
|
| + m_targetElement->nativeDistributeScroll(*scrollState);
|
| + }
|
| +};
|
| +
|
| +class ApplyScrollCallback : public ScrollStateCallback {
|
| +public:
|
| + ApplyScrollCallback()
|
| + {
|
| + m_callbackType = CallbackType::APPLY_SCROLL;
|
| + }
|
| +
|
| + void handleEvent(ScrollState* scrollState)
|
| + {
|
| + ASSERT(m_targetElement);
|
| + ASSERT(scrollState);
|
| + m_targetElement->nativeApplyScroll(*scrollState);
|
| + }
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +void Element::setDistributeScroll(ScrollStateCallback* scrollStateCallback)
|
| +{
|
| + scrollStateCallback->setCallbackType(ScrollStateCallback::CallbackType::DISTRIBUTE_SCROLL);
|
| + ensureElementRareData().setDistributeScroll(adoptRefWillBeNoop(scrollStateCallback));
|
| +}
|
| +
|
| +ScriptValue Element::distributeScroll(ScriptState* scriptState)
|
| +{
|
| + if (!hasRareData() || !elementRareData()->getDistributeScroll())
|
| + setDistributeScroll(new DistributeScrollCallback());
|
| + return elementRareData()->getDistributeScroll()->toScriptValue(scriptState);
|
| +}
|
| +
|
| +void Element::setApplyScroll(ScrollStateCallback* scrollStateCallback)
|
| +{
|
| + scrollStateCallback->setCallbackType(ScrollStateCallback::CallbackType::APPLY_SCROLL);
|
| + ensureElementRareData().setApplyScroll(adoptRefWillBeNoop(scrollStateCallback));
|
| +}
|
| +
|
| +ScriptValue Element::applyScroll(ScriptState* scriptState)
|
| +{
|
| + if (!hasRareData() || !elementRareData()->getApplyScroll())
|
| + setApplyScroll(new ApplyScrollCallback());
|
| + return elementRareData()->getApplyScroll()->toScriptValue(scriptState);
|
| +}
|
| +
|
| +void Element::nativeDistributeScroll(ScrollState& scrollState)
|
| {
|
| ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled());
|
| if (scrollState.fullyConsumed())
|
| @@ -490,15 +551,25 @@ void Element::distributeScroll(ScrollState& scrollState)
|
| const double deltaX = scrollState.deltaX();
|
| const double deltaY = scrollState.deltaY();
|
|
|
| - applyScroll(scrollState);
|
| + callApplyScroll(scrollState);
|
|
|
| if (deltaX != scrollState.deltaX() || deltaY != scrollState.deltaY())
|
| scrollState.setCurrentNativeScrollingElement(this);
|
| }
|
|
|
| -void Element::applyScroll(ScrollState& scrollState)
|
| +void Element::callDistributeScroll(ScrollState& scrollState)
|
| +{
|
| + if (!hasRareData() || !elementRareData()->getDistributeScroll())
|
| + nativeDistributeScroll(scrollState);
|
| + else
|
| + elementRareData()->getDistributeScroll()->handleEventForElement(*this, &scrollState);
|
| +};
|
| +
|
| +void Element::nativeApplyScroll(ScrollState& scrollState)
|
| {
|
| ASSERT(RuntimeEnabledFeatures::scrollCustomizationEnabled());
|
| + document().updateLayoutIgnorePendingStylesheets();
|
| +
|
| if (scrollState.fullyConsumed())
|
| return;
|
|
|
| @@ -506,8 +577,8 @@ void Element::applyScroll(ScrollState& scrollState)
|
| const double deltaY = scrollState.deltaY();
|
| bool scrolled = false;
|
|
|
| - // Handle the documentElement separately, as it scrolls the FrameView.
|
| - if (this == document().documentElement()) {
|
| + // Handle the scrollingElement separately, as it scrolls the FrameView.
|
| + if (this == document().scrollingElement()) {
|
| FloatSize delta(deltaX, deltaY);
|
| if (document().frame()->applyScrollDelta(delta, scrollState.isBeginning()).didScroll()) {
|
| scrolled = true;
|
| @@ -542,6 +613,14 @@ void Element::applyScroll(ScrollState& scrollState)
|
| document().frame()->view()->setWasScrolledByUser(true);
|
| };
|
|
|
| +void Element::callApplyScroll(ScrollState& scrollState)
|
| +{
|
| + if (!hasRareData() || !elementRareData()->getApplyScroll())
|
| + nativeApplyScroll(scrollState);
|
| + else
|
| + elementRareData()->getApplyScroll()->handleEventForElement(*this, &scrollState);
|
| +};
|
| +
|
| static float localZoomForLayoutObject(LayoutObject& layoutObject)
|
| {
|
| // FIXME: This does the wrong thing if two opposing zooms are in effect and canceled each
|
|
|