already_AddRefed<Layer> RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, LayerManager* aManager, const nsIntRect& aVisibleRect, nsDisplayItem* aItem, const ContainerLayerParameters& aContainerParameters) { MOZ_ASSERT(aFrame, "makes no sense to have a shadow tree without a frame"); MOZ_ASSERT(!mContainer || IsTempLayerManager(aManager) || mContainer->Manager() == aManager, "retaining manager changed out from under us ... HELP!"); if (IsTempLayerManager(aManager) || (mContainer && mContainer->Manager() != aManager)) { // This can happen if aManager is a "temporary" manager, or if the // widget's layer manager changed out from under us. We need to // FIXME handle the former case somehow, probably with an API to // draw a manager's subtree. The latter is bad bad bad, but the the // MOZ_ASSERT() above will flag it. Returning nullptr here will just // cause the shadow subtree not to be rendered. if (!aContainerParameters.mForEventsOnly) { NS_WARNING("Remote iframe not rendered"); } return nullptr; } uint64_t id = GetLayerTreeId(); if (!id) { return nullptr; } RefPtr<Layer> layer = (aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem)); if (!layer) { layer = aManager->CreateRefLayer(); } if (!layer) { // Probably a temporary layer manager that doesn't know how to // use ref layers. return nullptr; } static_cast<RefLayer*>(layer.get())->SetReferentId(id); nsIntPoint offset = GetContentRectLayerOffset(aFrame, 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()); gfx::Matrix4x4 m = gfx::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); return layer.forget(); }
already_AddRefed<Layer> RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame, LayerManager* aManager, const nsIntRect& aVisibleRect) { NS_ABORT_IF_FALSE(aFrame, "makes no sense to have a shadow tree without a frame"); NS_ABORT_IF_FALSE(!mContainer || IsTempLayerManager(aManager) || mContainer->Manager() == aManager, "retaining manager changed out from under us ... HELP!"); if (mContainer && mContainer->Manager() != aManager) { // This can happen if aManager is a "temporary" manager, or if the // widget's layer manager changed out from under us. We need to // FIXME handle the former case somehow, probably with an API to // draw a manager's subtree. The latter is bad bad bad, but the // the NS_ABORT_IF_FALSE() above will flag it. Returning NULL // here will just cause the shadow subtree not to be rendered. return nsnull; } if (mContainer) { ClearContainer(mContainer); } ContainerLayer* shadowRoot = GetRootLayer(); if (!shadowRoot) { mContainer = nsnull; return nsnull; } NS_ABORT_IF_FALSE(!shadowRoot || shadowRoot->Manager() == aManager, "retaining manager changed out from under us ... HELP!"); // Wrap the shadow layer tree in mContainer. if (!mContainer) { mContainer = aManager->CreateContainerLayer(); } NS_ABORT_IF_FALSE(!mContainer->GetFirstChild(), "container of shadow tree shouldn't have a 'root' here"); mContainer->InsertAfter(shadowRoot, nsnull); AssertInTopLevelChromeDoc(mContainer, aFrame); ViewTransform transform; TransformShadowTree(aBuilder, mFrameLoader, aFrame, shadowRoot, transform); mContainer->SetClipRect(nsnull); if (mFrameLoader->AsyncScrollEnabled()) { const nsContentView* view = GetContentView(FrameMetrics::ROOT_SCROLL_ID); BuildBackgroundPatternFor(mContainer, shadowRoot, view->GetViewConfig(), mBackgroundColor, aManager, aFrame); } mContainer->SetVisibleRegion(aVisibleRect); return nsRefPtr<Layer>(mContainer).forget(); }