Ejemplo n.º 1
0
void GraphicsLayerChromium::updateChildList()
{
    Vector<WebLayer> newChildren;

    if (!m_transformLayer.isNull()) {
        // Add the primary layer first. Even if we have negative z-order children, the primary layer always comes behind.
        newChildren.append(m_layer);
    } else if (!m_contentsLayer.isNull()) {
        // FIXME: add the contents layer in the correct order with negative z-order children.
        // This does not cause visible rendering issues because currently contents layers are only used
        // for replaced elements that don't have children.
        newChildren.append(m_contentsLayer);
    }

    const Vector<GraphicsLayer*>& childLayers = children();
    size_t numChildren = childLayers.size();
    for (size_t i = 0; i < numChildren; ++i) {
        GraphicsLayerChromium* curChild = static_cast<GraphicsLayerChromium*>(childLayers[i]);

        newChildren.append(curChild->layerForParent());
    }

    if (m_linkHighlight)
        newChildren.append(m_linkHighlight->contentLayer());

    for (size_t i = 0; i < newChildren.size(); ++i)
        newChildren[i].removeFromParent();

    WebVector<WebLayer> newWebChildren;
    newWebChildren.assign(newChildren.data(), newChildren.size());

    if (!m_transformLayer.isNull()) {
        m_transformLayer.setChildren(newWebChildren);

        if (!m_contentsLayer.isNull()) {
            // If we have a transform layer, then the contents layer is parented in the
            // primary layer (which is itself a child of the transform layer).
            m_layer.removeAllChildren();
            m_layer.addChild(m_contentsLayer);
        }
    } else
        m_layer.setChildren(newWebChildren);
}