Access the scroll values directly in ScrollTimeline draft
authorBotond Ballo <botond@mozilla.com>
Wed, 27 Jul 2016 15:07:51 -0400
changeset 393429 d6feb7e51adfbe4a622dda5dafe313ec6df76f01
parent 393428 8324702c372224098cd12b445f626e28273b8165
child 393430 d1bfeb9f0c2fce2b49fd7b6a71e8ff6d2c3557b8
push id24313
push userbballo@mozilla.com
push dateWed, 27 Jul 2016 21:32:22 +0000
milestone50.0a1
Access the scroll values directly in ScrollTimeline MozReview-Commit-ID: 2BzlAbDOoic
dom/animation/ScrollTimeline.cpp
dom/animation/ScrollTimeline.h
--- 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