void RenderLayerStackingNode::rebuildZOrderLists(OwnPtr<Vector<RenderLayerStackingNode*> >& posZOrderList, OwnPtr<Vector<RenderLayerStackingNode*> >& negZOrderList, const RenderLayerStackingNode* nodeToForceAsStackingContainer, CollectLayersBehavior collectLayersBehavior) { for (RenderLayer* child = layer()->firstChild(); child; child = child->nextSibling()) { if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child) child->stackingNode()->collectLayers(posZOrderList, negZOrderList, nodeToForceAsStackingContainer, collectLayersBehavior); } // Sort the two lists. if (posZOrderList) std::stable_sort(posZOrderList->begin(), posZOrderList->end(), compareZIndex); if (negZOrderList) std::stable_sort(negZOrderList->begin(), negZOrderList->end(), compareZIndex); // Append layers for top layer elements after normal layer collection, to ensure they are on top regardless of z-indexes. // The renderers of top layer elements are children of the view, sorted in top layer stacking order. if (layer()->isRootLayer()) { RenderObject* view = renderer()->view(); for (RenderObject* child = view->firstChild(); child; child = child->nextSibling()) { Element* childElement = (child->node() && child->node()->isElementNode()) ? toElement(child->node()) : 0; if (childElement && childElement->isInTopLayer()) { RenderLayer* layer = toRenderLayerModelObject(child)->layer(); // Create the buffer if it doesn't exist yet. if (!posZOrderList) posZOrderList = adoptPtr(new Vector<RenderLayerStackingNode*>); posZOrderList->append(layer->stackingNode()); } } } }
RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingNode() const { RenderLayer* ancestor = layer()->parent(); while (ancestor && !ancestor->stackingNode()->isStackingContext()) ancestor = ancestor->parent(); if (ancestor) return ancestor->stackingNode(); return 0; }
void RenderLayerStackingNode::updateLayerListsIfNeeded() { updateZOrderLists(); updateNormalFlowList(); if (!layer()->reflectionInfo()) return; RenderLayer* reflectionLayer = layer()->reflectionInfo()->reflectionLayer(); reflectionLayer->stackingNode()->updateZOrderLists(); reflectionLayer->stackingNode()->updateNormalFlowList(); }
void GraphicsLayerTreeBuilder::rebuild(RenderLayer& layer, AncestorInfo info) { // Make the layer compositing if necessary, and set up clipping and content layers. // Note that we can only do work here that is independent of whether the descendant layers // have been processed. computeCompositingRequirements() will already have done the paint invalidation if necessary. layer.stackingNode()->updateLayerListsIfNeeded(); const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); CompositedLayerMapping* currentCompositedLayerMapping = layer.compositedLayerMapping(); // If this layer has a compositedLayerMapping, then that is where we place subsequent children GraphicsLayers. // Otherwise children continue to append to the child list of the enclosing layer. GraphicsLayerVector layerChildren; AncestorInfo infoForChildren(info); if (hasCompositedLayerMapping) { infoForChildren.childLayersOfEnclosingCompositedLayer = &layerChildren; infoForChildren.enclosingCompositedLayer = &layer; } #if ENABLE(ASSERT) LayerListMutationDetector mutationChecker(layer.stackingNode()); #endif if (layer.stackingNode()->isStackingContext()) { RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NegativeZOrderChildren); while (RenderLayerStackingNode* curNode = iterator.next()) rebuild(*curNode->layer(), infoForChildren); // If a negative z-order child is compositing, we get a foreground layer which needs to get parented. if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregroundLayer()) infoForChildren.childLayersOfEnclosingCompositedLayer->append(currentCompositedLayerMapping->foregroundLayer()); } RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowChildren | PositiveZOrderChildren); while (RenderLayerStackingNode* curNode = iterator.next()) rebuild(*curNode->layer(), infoForChildren); if (hasCompositedLayerMapping) { currentCompositedLayerMapping->parentForSublayers()->setChildren(layerChildren); info.childLayersOfEnclosingCompositedLayer->append(currentCompositedLayerMapping->childForSuperlayers()); } if (layer.scrollParent() && layer.scrollParent()->hasCompositedLayerMapping() && layer.scrollParent()->compositedLayerMapping()->needsToReparentOverflowControls() && layer.scrollParent()->scrollableArea()->topmostScrollChild() == &layer) info.childLayersOfEnclosingCompositedLayer->append(layer.scrollParent()->compositedLayerMapping()->detachLayerForOverflowControls(*info.enclosingCompositedLayer)); }
RenderLayerStackingNode* RenderLayerStackingNode::ancestorStackingContextNode() const { for (RenderLayer* ancestor = layer()->parent(); ancestor; ancestor = ancestor->parent()) { RenderLayerStackingNode* stackingNode = ancestor->stackingNode(); if (stackingNode->isStackingContext()) return stackingNode; } return 0; }
void RenderLayerStackingNode::collectLayers(OwnPtr<Vector<RenderLayerStackingNode*> >& posBuffer, OwnPtr<Vector<RenderLayerStackingNode*> >& negBuffer, const RenderLayerStackingNode* nodeToForceAsStackingContainer, CollectLayersBehavior collectLayersBehavior) { if (layer()->isInTopLayer()) return; layer()->updateDescendantDependentFlags(); bool isStacking = false; bool isNormalFlow = false; switch (collectLayersBehavior) { case ForceLayerToStackingContainer: ASSERT(nodeToForceAsStackingContainer); if (this == nodeToForceAsStackingContainer) { isStacking = true; isNormalFlow = false; } else { isStacking = isStackingContext(); isNormalFlow = shouldBeNormalFlowOnlyIgnoringCompositedScrolling(); } break; case OverflowScrollCanBeStackingContainers: ASSERT(!nodeToForceAsStackingContainer); isStacking = isStackingContainer(); isNormalFlow = isNormalFlowOnly(); break; case OnlyStackingContextsCanBeStackingContainers: isStacking = isStackingContext(); isNormalFlow = shouldBeNormalFlowOnlyIgnoringCompositedScrolling(); break; } // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists. if (!isNormalFlow && !layer()->isOutOfFlowRenderFlowThread()) { // Determine which buffer the child should be in. OwnPtr<Vector<RenderLayerStackingNode*> >& buffer = (zIndex() >= 0) ? posBuffer : negBuffer; // Create the buffer if it doesn't exist yet. if (!buffer) buffer = adoptPtr(new Vector<RenderLayerStackingNode*>); // Append ourselves at the end of the appropriate buffer. buffer->append(this); } // Recur into our children to collect more layers, but only if we don't establish // a stacking context/container. if (!isStacking) { for (RenderLayer* child = layer()->firstChild(); child; child = child->nextSibling()) { // Ignore reflections. if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child) child->stackingNode()->collectLayers(posBuffer, negBuffer, nodeToForceAsStackingContainer, collectLayersBehavior); } } }
UpdateContext(const UpdateContext& other, const RenderLayer& layer) : m_compositingStackingContext(other.m_compositingStackingContext) , m_compositingAncestor(other.compositingContainer(layer)) { CompositingState compositingState = layer.compositingState(); if (compositingState != NotComposited && compositingState != PaintsIntoGroupedBacking) { m_compositingAncestor = &layer; if (layer.stackingNode()->isStackingContext()) m_compositingStackingContext = &layer; } }
void RenderLayerStackingNode::updateNormalFlowList() { if (!m_normalFlowListDirty) return; ASSERT(m_layerListMutationAllowed); for (RenderLayer* child = layer()->firstChild(); child; child = child->nextSibling()) { if (child->stackingNode()->isNormalFlowOnly() && (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child)) { if (!m_normalFlowList) m_normalFlowList = adoptPtr(new Vector<RenderLayerStackingNode*>); m_normalFlowList->append(child->stackingNode()); } } #if ASSERT_ENABLED updateStackingParentForNormalFlowList(this); #endif m_normalFlowListDirty = false; }
void RenderLayerStackingNode::rebuildZOrderLists() { ASSERT(m_layerListMutationAllowed); ASSERT(isDirtyStackingContext()); for (RenderLayer* child = layer()->firstChild(); child; child = child->nextSibling()) { if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child) child->stackingNode()->collectLayers(m_posZOrderList, m_negZOrderList); } // Sort the two lists. if (m_posZOrderList) std::stable_sort(m_posZOrderList->begin(), m_posZOrderList->end(), compareZIndex); if (m_negZOrderList) std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), compareZIndex); // Append layers for top layer elements after normal layer collection, to ensure they are on top regardless of z-indexes. // The renderers of top layer elements are children of the view, sorted in top layer stacking order. if (layer()->isRootLayer()) { RenderView* view = renderer()->view(); for (RenderObject* child = view->firstChild(); child; child = child->nextSibling()) { Element* childElement = (child->node() && child->node()->isElementNode()) ? toElement(child->node()) : 0; if (childElement && childElement->isInTopLayer()) { RenderLayer* layer = toRenderLayerModelObject(child)->layer(); // Create the buffer if it doesn't exist yet. if (!m_posZOrderList) m_posZOrderList = adoptPtr(new Vector<RenderLayerStackingNode*>); m_posZOrderList->append(layer->stackingNode()); } } } #if ASSERT_ENABLED updateStackingParentForZOrderLists(this); #endif m_zOrderListsDirty = false; }
void RenderLayerStackingNode::collectLayers(OwnPtr<Vector<RenderLayerStackingNode*> >& posBuffer, OwnPtr<Vector<RenderLayerStackingNode*> >& negBuffer) { if (layer()->isInTopLayer()) return; layer()->updateDescendantDependentFlags(); if (!isNormalFlowOnly()) { OwnPtr<Vector<RenderLayerStackingNode*> >& buffer = (zIndex() >= 0) ? posBuffer : negBuffer; if (!buffer) buffer = adoptPtr(new Vector<RenderLayerStackingNode*>); buffer->append(this); } if (!isStackingContext()) { for (RenderLayer* child = layer()->firstChild(); child; child = child->nextSibling()) { if (!layer()->reflectionInfo() || layer()->reflectionInfo()->reflectionLayer() != child) child->stackingNode()->collectLayers(posBuffer, negBuffer); } } }
void GraphicsLayerTreeBuilder::rebuild(RenderLayer& layer, GraphicsLayerVector& childLayersOfEnclosingLayer) { // Make the layer compositing if necessary, and set up clipping and content layers. // Note that we can only do work here that is independent of whether the descendant layers // have been processed. computeCompositingRequirements() will already have done the repaint if necessary. layer.stackingNode()->updateLayerListsIfNeeded(); const bool hasCompositedLayerMapping = layer.hasCompositedLayerMapping(); CompositedLayerMappingPtr currentCompositedLayerMapping = layer.compositedLayerMapping(); // If this layer has a compositedLayerMapping, then that is where we place subsequent children GraphicsLayers. // Otherwise children continue to append to the child list of the enclosing layer. GraphicsLayerVector layerChildren; GraphicsLayerVector& childList = hasCompositedLayerMapping ? layerChildren : childLayersOfEnclosingLayer; #if !ASSERT_DISABLED LayerListMutationDetector mutationChecker(layer.stackingNode()); #endif if (layer.stackingNode()->isStackingContext()) { RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NegativeZOrderChildren); while (RenderLayerStackingNode* curNode = iterator.next()) rebuild(*curNode->layer(), childList); // If a negative z-order child is compositing, we get a foreground layer which needs to get parented. if (hasCompositedLayerMapping && currentCompositedLayerMapping->foregroundLayer()) childList.append(currentCompositedLayerMapping->foregroundLayer()); } RenderLayerStackingNodeIterator iterator(*layer.stackingNode(), NormalFlowChildren | PositiveZOrderChildren); while (RenderLayerStackingNode* curNode = iterator.next()) rebuild(*curNode->layer(), childList); if (hasCompositedLayerMapping) { bool parented = false; if (layer.renderer()->isRenderPart()) parented = RenderLayerCompositor::parentFrameContentLayers(toRenderPart(layer.renderer())); if (!parented) currentCompositedLayerMapping->parentForSublayers()->setChildren(layerChildren); // If the layer has a clipping layer the overflow controls layers will be siblings of the clipping layer. // Otherwise, the overflow control layers are normal children. if (!currentCompositedLayerMapping->hasClippingLayer() && !currentCompositedLayerMapping->hasScrollingLayer()) { if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapping->layerForHorizontalScrollbar()) { overflowControlLayer->removeFromParent(); currentCompositedLayerMapping->parentForSublayers()->addChild(overflowControlLayer); } if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapping->layerForVerticalScrollbar()) { overflowControlLayer->removeFromParent(); currentCompositedLayerMapping->parentForSublayers()->addChild(overflowControlLayer); } if (GraphicsLayer* overflowControlLayer = currentCompositedLayerMapping->layerForScrollCorner()) { overflowControlLayer->removeFromParent(); currentCompositedLayerMapping->parentForSublayers()->addChild(overflowControlLayer); } } if (shouldAppendLayer(layer)) childLayersOfEnclosingLayer.append(currentCompositedLayerMapping->childForSuperlayers()); } }