Bug 1321428 - Populate scroll timeline information in FrameLayerBuilder. r=mattwoodrow draft
authorBotond Ballo <botond@mozilla.com>
Wed, 22 Feb 2017 18:19:56 -0500
changeset 542200 5f1938fd2be6dfe7423c3fd66b1d2f6898f05214
parent 542199 b14c87d6d8a9e1130608bf2fbd3a6c0688855956
child 542201 8609e1cfc7e52793739986c1fc7540dcdc123964
push id50961
push userbballo@mozilla.com
push dateFri, 24 Mar 2017 22:03:27 +0000
reviewersmattwoodrow
bugs1321428
milestone55.0a1
Bug 1321428 - Populate scroll timeline information in FrameLayerBuilder. r=mattwoodrow MozReview-Commit-ID: wUSSjwvlt
layout/painting/nsDisplayList.cpp
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -14,16 +14,17 @@
 
 #include <stdint.h>
 #include <algorithm>
 #include <limits>
 
 #include "gfxUtils.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
+#include "mozilla/dom/ScrollTimeline.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/layers/PLayerTransaction.h"
 #include "nsCSSRendering.h"
 #include "nsRenderingContext.h"
 #include "nsISelectionController.h"
 #include "nsIPresShell.h"
 #include "nsRegion.h"
 #include "nsStyleStructInlines.h"
@@ -561,16 +562,31 @@ AddAnimationForProperty(nsIFrame* aFrame
     //        RawServoAnimationValue.
     SetAnimatable(aProperty.mProperty,
                   { baseStyle, nullptr },
                   aFrame, refBox,
                   animation->baseStyle());
   } else {
     animation->baseStyle() = null_t();
   }
+  if (ScrollTimeline* scrollTimeline = aAnimation->GetTimeline()->AsScrollTimeline()) {
+    // The scroll frame may have been reflowed since the ScrollTimeline was
+    // constructed. Call QueryScrollValues() to pick up its updated metrics.
+    ScrollTimeline::ScrollRange range = scrollTimeline->GetScrollRange();
+    animation->scrollTimelineInfo() = ScrollTimelineInfo{
+      scrollTimeline->Orientation(),
+      nsLayoutUtils::FindOrCreateIDFor(scrollTimeline->SourceElement()),
+      TimeDuration{scrollTimeline->GetEffectiveTimeRange()},
+      range.mMinScroll,
+      range.mMaxScroll,
+      scrollTimeline->Fill()
+    };
+  } else {
+    animation->scrollTimelineInfo() = null_t{};
+  }
 
   for (uint32_t segIdx = 0; segIdx < aProperty.mSegments.Length(); segIdx++) {
     const AnimationPropertySegment& segment = aProperty.mSegments[segIdx];
 
     AnimationSegment* animSegment = animation->segments().AppendElement();
     SetAnimatable(aProperty.mProperty,
                   segment.mFromValue,
                   aFrame, refBox,
@@ -5824,20 +5840,20 @@ nsDisplayOwnLayer::BuildLayer(nsDisplayL
                               LayerManager* aManager,
                               const ContainerLayerParameters& aContainerParameters)
 {
   RefPtr<ContainerLayer> layer = aManager->GetLayerBuilder()->
     BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList,
                            aContainerParameters, nullptr,
                            FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR);
   if (mFlags & VERTICAL_SCROLLBAR) {
-    layer->SetScrollbarData(mScrollTarget, ScrollDirection::VERTICAL, mScrollbarThumbRatio);
+    layer->SetScrollbarData(mScrollTarget, layers::ScrollDirection::VERTICAL, mScrollbarThumbRatio);
   }
   if (mFlags & HORIZONTAL_SCROLLBAR) {
-    layer->SetScrollbarData(mScrollTarget, ScrollDirection::HORIZONTAL, mScrollbarThumbRatio);
+    layer->SetScrollbarData(mScrollTarget, layers::ScrollDirection::HORIZONTAL, mScrollbarThumbRatio);
   }
   if (mFlags & SCROLLBAR_CONTAINER) {
     layer->SetIsScrollbarContainer(mScrollTarget);
   }
 
   if (mFlags & GENERATE_SUBDOC_INVALIDATIONS) {
     mFrame->PresContext()->SetNotifySubDocInvalidationData(layer);
   }