Esempio n. 1
0
void PaintLayerStackingNode::rebuildZOrderLists() {
#if DCHECK_IS_ON()
  DCHECK(m_layerListMutationAllowed);
#endif
  DCHECK(isDirtyStackingContext());

  for (PaintLayer* child = layer()->firstChild(); child;
       child = child->nextSibling())
    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 layoutObjects of top
  // layer elements are children of the view, sorted in top layer stacking
  // order.
  if (layer()->isRootLayer()) {
    LayoutBlockFlow* rootBlock = layoutObject()->view();
    // If the viewport is paginated, everything (including "top-layer" elements)
    // gets redirected to the flow thread. So that's where we have to look, in
    // that case.
    if (LayoutBlockFlow* multiColumnFlowThread =
            rootBlock->multiColumnFlowThread())
      rootBlock = multiColumnFlowThread;
    for (LayoutObject* child = rootBlock->firstChild(); child;
         child = child->nextSibling()) {
      Element* childElement = (child->node() && child->node()->isElementNode())
                                  ? toElement(child->node())
                                  : 0;
      if (childElement && childElement->isInTopLayer()) {
        PaintLayer* layer = toLayoutBoxModelObject(child)->layer();
        // Create the buffer if it doesn't exist yet.
        if (!m_posZOrderList)
          m_posZOrderList = wrapUnique(new Vector<PaintLayerStackingNode*>);
        m_posZOrderList->append(layer->stackingNode());
      }
    }
  }

#if ENABLE(ASSERT)
  updateStackingParentForZOrderLists(this);
#endif

  m_zOrderListsDirty = 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;
}