Bug 1519546, part 1 - Simplify layer casts in nsDisplayRemote::BuildLayer. r=mattwoodrow
authorRyan Hunt <rhunt@eqrion.net>
Mon, 20 May 2019 15:14:13 -0500
changeset 476558 2ced46502b550e82b1d3e8a5abc3580b9954c2bc
parent 476549 afb588ff09317067dcc2558d8f14546a332d1162
child 476559 1ba5519d5970dde2c36c17ef15475cd043212885
push id36100
push userapavel@mozilla.com
push dateSun, 02 Jun 2019 22:10:35 +0000
treeherdermozilla-central@6d71d3ca0124 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1519546
milestone69.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
Bug 1519546, part 1 - Simplify layer casts in nsDisplayRemote::BuildLayer. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D32475
layout/ipc/RenderFrame.cpp
--- a/layout/ipc/RenderFrame.cpp
+++ b/layout/ipc/RenderFrame.cpp
@@ -218,38 +218,35 @@ already_AddRefed<Layer> nsDisplayRemote:
   }
 
   RefPtr<Layer> layer =
       aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, this);
 
   if (!layer) {
     layer = aManager->CreateRefLayer();
   }
-
-  if (!layer) {
+  if (!layer || !layer->AsRefLayer()) {
     // Probably a temporary layer manager that doesn't know how to
     // use ref layers.
     return nullptr;
   }
+  RefLayer* refLayer = layer->AsRefLayer();
 
-  static_cast<RefLayer*>(layer.get())->SetReferentId(mLayersId);
   LayoutDeviceIntPoint offset = GetContentRectLayerOffset(Frame(), aBuilder);
   // We can only have an offset if we're a child of an inactive
   // container, but our display item is LAYER_ACTIVE_FORCE which
   // forces all layers above to be active.
   MOZ_ASSERT(aContainerParameters.mOffset == nsIntPoint());
   Matrix4x4 m = Matrix4x4::Translation(offset.x, offset.y, 0.0);
   // Remote content can't be repainted by us, so we multiply down
   // the resolution that our container expects onto our container.
   m.PreScale(aContainerParameters.mXScale, aContainerParameters.mYScale, 1.0);
-  layer->SetBaseTransform(m);
-
-  if (layer->AsRefLayer()) {
-    layer->AsRefLayer()->SetEventRegionsOverride(mEventRegionsOverride);
-  }
+  refLayer->SetBaseTransform(m);
+  refLayer->SetEventRegionsOverride(mEventRegionsOverride);
+  refLayer->SetReferentId(mLayersId);
 
   return layer.forget();
 }
 
 void nsDisplayRemote::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) {
   DrawTarget* target = aCtx->GetDrawTarget();
   if (!target->IsRecording() || mTabId == 0) {
     NS_WARNING("Remote iframe not rendered");