Only try to scroll scrollable layers, and force Gecko to generate a scrollable layer even for smaller pages.
authorAli Juma <ajuma@mozilla.com>
Mon, 20 Feb 2012 11:30:05 -0500
changeset 89182 0e7445af29d1b8ddd7bec875228b07799ab6419c
parent 89181 cf7c1f3d4c7f689787ed3ca71ebe2be9c88c13a7
child 89183 9ed5ea2c73578293b9f43fdb8acbadfa4f525c80
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Only try to scroll scrollable layers, and force Gecko to generate a scrollable layer even for smaller pages.
gfx/layers/ipc/CompositorParent.cpp
layout/generic/nsGfxScrollFrame.cpp
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -194,33 +194,33 @@ CompositorParent::Composite()
   if (mExpectedComposeTime + TimeDuration::FromMilliseconds(15) < mozilla::TimeStamp::Now()) {
     printf_stderr("Compositor: Compose frame took %i time then expected.\n",
                   (int)(mozilla::TimeStamp::Now() - mExpectedComposeTime).ToMilliseconds());
   }
 #endif
 }
 
 #ifdef MOZ_WIDGET_ANDROID
-// Do a breadth-first search to find the first layer in the tree with a
-// displayport set.
+// Do a breadth-first search to find the first layer in the tree that is
+// scrollable.
 Layer*
 CompositorParent::GetPrimaryScrollableLayer()
 {
   Layer* root = mLayerManager->GetRoot();
 
   nsTArray<Layer*> queue;
   queue.AppendElement(root);
   for (unsigned i = 0; i < queue.Length(); i++) {
     ContainerLayer* containerLayer = queue[i]->AsContainerLayer();
     if (!containerLayer) {
       continue;
     }
 
     const FrameMetrics& frameMetrics = containerLayer->GetFrameMetrics();
-    if (!frameMetrics.mDisplayPort.IsEmpty()) {
+    if (frameMetrics.IsScrollable()) {
       return containerLayer;
     }
 
     Layer* child = containerLayer->GetFirstChild();
     while (child) {
       queue.AppendElement(child);
       child = child->GetNextSibling();
     }
@@ -266,29 +266,37 @@ CompositorParent::TransformShadowTree()
 
   gfx3DMatrix shadowTransform = layer->GetTransform();
 
   ContainerLayer* container = layer->AsContainerLayer();
 
   const FrameMetrics* metrics = &container->GetFrameMetrics();
   const gfx3DMatrix& currentTransform = layer->GetTransform();
 
-  float tempScaleDiffX = GetXScale(mLayerManager->GetRoot()->GetTransform()) * mXScale;
-  float tempScaleDiffY = GetYScale(mLayerManager->GetRoot()->GetTransform()) * mYScale;
+  if (metrics && metrics->IsScrollable()) {
+    float tempScaleDiffX = GetXScale(mLayerManager->GetRoot()->GetTransform()) * mXScale;
+    float tempScaleDiffY = GetYScale(mLayerManager->GetRoot()->GetTransform()) * mYScale;
 
-  nsIntPoint metricsScrollOffset = metrics->mViewportScrollOffset;
+    nsIntPoint metricsScrollOffset = metrics->mViewportScrollOffset;
 
-  nsIntPoint scrollCompensation(
-    (mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
-    (mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
-  ViewTransform treeTransform(-scrollCompensation, mXScale,
+    nsIntPoint scrollCompensation(
+      (mScrollOffset.x / tempScaleDiffX - metricsScrollOffset.x) * mXScale,
+      (mScrollOffset.y / tempScaleDiffY - metricsScrollOffset.y) * mYScale);
+    ViewTransform treeTransform(-scrollCompensation, mXScale,
                               mYScale);
-  shadowTransform = gfx3DMatrix(treeTransform) * currentTransform;
+    shadowTransform = gfx3DMatrix(treeTransform) * currentTransform;
 
-  shadow->SetShadowTransform(shadowTransform);
+    shadow->SetShadowTransform(shadowTransform);
+  } else {
+    ViewTransform treeTransform(nsIntPoint(0,0), mXScale,
+                              mYScale);
+    shadowTransform = gfx3DMatrix(treeTransform) * currentTransform;
+
+    shadow->SetShadowTransform(shadowTransform);
+  }
 #endif
 }
 
 void
 CompositorParent::AsyncRender()
 {
   if (mPaused || !mLayerManager) {
     return;
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2071,17 +2071,17 @@ nsGfxScrollFrameInner::BuildDisplayList(
   // process).
   nsRect scrollRange = GetScrollRange();
   ScrollbarStyles styles = GetScrollbarStylesFromFrame();
   mShouldBuildLayer =
      ((XRE_GetProcessType() == GeckoProcessType_Content || usingDisplayport) &&
      (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN ||
       styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN) &&
      (scrollRange.width > 0 ||
-      scrollRange.height > 0) &&
+      scrollRange.height > 0 || usingDisplayport) &&
      (usingDisplayport || !mIsRoot ||
       !mOuter->PresContext()->IsRootContentDocument()));
 
   if (ShouldBuildLayer()) {
     // ScrollLayerWrapper must always be created because it initializes the
     // scroll layer count. The display lists depend on this.
     ScrollLayerWrapper wrapper(mOuter, mScrolledFrame);