Access the scroll values directly in ScrollTimeline
MozReview-Commit-ID: 2BzlAbDOoic
--- a/dom/animation/ScrollTimeline.cpp
+++ b/dom/animation/ScrollTimeline.cpp
@@ -232,35 +232,32 @@ ScrollTimeline::CalculateTimeRange()
mTimeRange = 0;
for (Animation* animation : mAnimationOrder) {
StickyTimeDuration endTime = animation->EffectEnd();
mTimeRange = StickyTimeDuration::Max(endTime, mTimeRange);
}
}
void
-ScrollTimeline::SetScrollValues(double aCurrentScroll, double aMinScroll,
- double aMaxScroll)
+ScrollTimeline::SetScrollValues()
{
- mCurrentScroll = aCurrentScroll;
- mMinScroll = aMinScroll;
- mMaxScroll = aMaxScroll;
+ if (mElement) {
+ if (mOrientation == Orientation::Horizontal) {
+ mCurrentScroll = mElement->ScrollLeft();
+ mMinScroll = mElement->ScrollLeftMin();
+ mMaxScroll = mElement->ScrollLeftMax();
+ } else {
+ mCurrentScroll = mElement->ScrollTop();
+ mMinScroll = mElement->ScrollTopMin();
+ mMaxScroll = mElement->ScrollTopMax();
+ }
+ }
}
void
ScrollObserverImpl::notify()
{
- printf_stderr("[WALDOWALDO] ScrollObserverImpl::notify()\n");
- if (mElement) {
- if (mOrientation == Orientation::Horizontal) {
- mTimeline->SetScrollValues(mElement->ScrollLeft(),
- mElement->ScrollLeftMin(),
- mElement->ScrollLeftMax());
- } else {
- mTimeline->SetScrollValues(mElement->ScrollTop(),
- mElement->ScrollTopMin(),
- mElement->ScrollTopMax());
- }
- }
+ printf_stderr("[WALDOWALDO] ScrollObserverImpl::notify()\n");
+ mTimeline->SetScrollValues();
}
} // namespace dom
} // namespace mozilla
--- a/dom/animation/ScrollTimeline.h
+++ b/dom/animation/ScrollTimeline.h
@@ -20,27 +20,22 @@
struct JSContext;
namespace mozilla {
namespace dom {
class ScrollObserver;
class ScrollObserverImpl : public ScrollObserver {
public:
- ScrollObserverImpl(Element* elem, Orientation aOrientation,
- ScrollTimeline* aTimeline) {
- mElement = elem;
- mOrientation = aOrientation;
+ ScrollObserverImpl(ScrollTimeline* aTimeline) {
mTimeline = aTimeline;
}
void notify() override;
private:
- Element* mElement;
- Orientation mOrientation;
ScrollTimeline* mTimeline;
};
class ScrollTimeline final
: public AnimationTimeline
, public nsARefreshObserver
{
public:
@@ -52,17 +47,17 @@ public:
, mDocument(aDocument)
, mIsObservingRefreshDriver(false)
, mOrientation(aOrientation)
, mElement(aTarget)
, mCurrentScroll(0)
, mMinScroll(0)
, mMaxScroll(0)
{
- mScrollObserver = new ScrollObserverImpl(aTarget, mOrientation, this);
+ mScrollObserver = new ScrollObserverImpl(this);
aTarget->RegistScrollTimelineObserver(mScrollObserver);
CalculateTimeRange();
}
protected:
virtual ~ScrollTimeline()
{
MOZ_ASSERT(!mIsObservingRefreshDriver, "Timeline should have disassociated"
@@ -104,17 +99,17 @@ public:
void RemoveAnimation(Animation* aAnimation) override;
// nsARefreshObserver methods
void WillRefresh(TimeStamp aTime) override;
void NotifyRefreshDriverCreated(nsRefreshDriver* aDriver);
void NotifyRefreshDriverDestroying(nsRefreshDriver* aDriver);
- void SetScrollValues(double aCurrent, double aMin, double aMax);
+ void SetScrollValues();
protected:
nsRefreshDriver* GetRefreshDriver() const;
void CalculateTimeRange();
nsCOMPtr<nsIDocument> mDocument;
// The most recently used refresh driver time. This is used in cases where