Bug 1374236 - Refactor MaybeSetupTransactionIdAllocator to avoid passing nsView*. r?mats draft
authorAndi-Bogdan Postelnicu <bpostelnicu@mozilla.com>
Mon, 19 Jun 2017 18:58:42 +0300
changeset 596679 28dcd149d8d1d301efc6bd198a84d7f6c8b7f54e
parent 596219 95543bdc59bd038a3d5d084b85a4fec493c349ee
child 634031 6986133b6647e44b485f1349fa22433027744b91
push id64715
push userbmo:bpostelnicu@mozilla.com
push dateMon, 19 Jun 2017 15:59:37 +0000
reviewersmats
bugs1374236
milestone56.0a1
Bug 1374236 - Refactor MaybeSetupTransactionIdAllocator to avoid passing nsView*. r?mats MozReview-Commit-ID: L3jedbOFdCP
layout/base/PresShell.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/painting/nsDisplayList.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6372,17 +6372,17 @@ PresShell::Paint(nsView*         aViewTo
       bool computeInvalidRect = computeInvalidFunc ||
                                 (layerManager->GetBackendType() == LayersBackend::LAYERS_BASIC);
 
       UniquePtr<LayerProperties> props;
       if (computeInvalidRect) {
         props = Move(LayerProperties::CloneFrom(layerManager->GetRoot()));
       }
 
-      MaybeSetupTransactionIdAllocator(layerManager, aViewToPaint);
+      MaybeSetupTransactionIdAllocator(layerManager, presContext);
 
       if (layerManager->EndEmptyTransaction((aFlags & PAINT_COMPOSITE) ?
             LayerManager::END_DEFAULT : LayerManager::END_NO_COMPOSITE)) {
         nsIntRegion invalid;
         if (props) {
           invalid = props->ComputeDifferences(layerManager->GetRoot(), computeInvalidFunc);
         } else {
           LayerProperties::ClearInvalidations(layerManager->GetRoot());
@@ -6439,17 +6439,17 @@ PresShell::Paint(nsView*         aViewTo
     nsPresContext* pc = GetPresContext();
     nsIntRect bounds =
       pc->GetVisibleArea().ToOutsidePixels(pc->AppUnitsPerDevPixel());
     bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor);
     root->SetColor(Color::FromABGR(bgcolor));
     root->SetVisibleRegion(LayerIntRegion::FromUnknownRegion(bounds));
     layerManager->SetRoot(root);
   }
-  MaybeSetupTransactionIdAllocator(layerManager, aViewToPaint);
+  MaybeSetupTransactionIdAllocator(layerManager, presContext);
   layerManager->EndTransaction(nullptr, nullptr, (aFlags & PAINT_COMPOSITE) ?
     LayerManager::END_DEFAULT : LayerManager::END_NO_COMPOSITE);
 }
 
 // static
 void
 nsIPresShell::SetCapturingContent(nsIContent* aContent, uint8_t aFlags)
 {
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -8597,24 +8597,24 @@ void StrokeLineWithSnapping(const nsPoin
   Point p2 = NSPointToPoint(aP2, aAppUnitsPerDevPixel);
   SnapLineToDevicePixelsForStroking(p1, p2, aDrawTarget,
                                     aStrokeOptions.mLineWidth);
   aDrawTarget.StrokeLine(p1, p2, aPattern, aStrokeOptions, aDrawOptions);
 }
 
 namespace layout {
 
-
 void
-MaybeSetupTransactionIdAllocator(layers::LayerManager* aManager, nsView* aView)
-{
-  if (aManager->GetBackendType() == LayersBackend::LAYERS_CLIENT ||
-      aManager->GetBackendType() == LayersBackend::LAYERS_WR) {
-    nsRefreshDriver *refresh = aView->GetViewManager()->GetPresShell()->GetPresContext()->RefreshDriver();
-    aManager->SetTransactionIdAllocator(refresh);
+MaybeSetupTransactionIdAllocator(layers::LayerManager* aManager,
+                                 nsPresContext* aPresContext)
+{
+  auto backendType = aManager->GetBackendType();
+  if (backendType == LayersBackend::LAYERS_CLIENT ||
+      backendType == LayersBackend::LAYERS_WR) {
+    aManager->SetTransactionIdAllocator(aPresContext->RefreshDriver());
   }
 }
 
 } // namespace layout
 } // namespace mozilla
 
 /* static */ bool
 nsLayoutUtils::IsOutlineStyleAutoEnabled()
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -3071,17 +3071,18 @@ void StrokeLineWithSnapping(const nsPoin
       explicit AutoMaybeDisableFontInflation(nsIFrame *aFrame);
 
       ~AutoMaybeDisableFontInflation();
     private:
       nsPresContext *mPresContext;
       bool mOldValue;
     };
 
-    void MaybeSetupTransactionIdAllocator(layers::LayerManager* aManager, nsView* aView);
+    void MaybeSetupTransactionIdAllocator(layers::LayerManager* aManager,
+                                          nsPresContext* aPresContext);
 
   } // namespace layout
 } // namespace mozilla
 
 class nsSetAttrRunnable : public mozilla::Runnable
 {
 public:
   nsSetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName,
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2280,17 +2280,17 @@ already_AddRefed<LayerManager> nsDisplay
       rootPresContext->ComputePluginGeometryUpdates(aBuilder->RootReferenceFrame(), aBuilder, this);
     }
     // The layer system caches plugin configuration information for forwarding
     // with layer updates which needs to get set during reflow. This must be
     // called even if there are no windowed plugins in the page.
     rootPresContext->CollectPluginGeometryUpdates(layerManager);
   }
 
-  MaybeSetupTransactionIdAllocator(layerManager, view);
+  MaybeSetupTransactionIdAllocator(layerManager, presContext);
 
   layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
                                aBuilder, flags);
   aBuilder->SetIsCompositingCheap(temp);
   layerBuilder->DidEndTransaction();
 
   if (document && widgetTransaction) {
     TriggerPendingAnimations(document, layerManager->GetAnimationReadyTime());