// The descendant-dependent flags system is badly broken because we clean dirty
// bits in upward tree walks, which means we need to call updateDescendantDependentFlags
// at every node in the tree to fully clean all the dirty bits. While we'll in
// the process of fixing this issue, updateDescendantDependentFlagsForEntireSubtree
// provides a big hammer for actually cleaning all the dirty bits in a subtree.
//
// FIXME: Remove this function once the descendant-dependent flags system keeps
// its dirty bits scoped to subtrees.
void updateDescendantDependentFlagsForEntireSubtree(PaintLayer& layer)
{
    layer.updateDescendantDependentFlags();

    for (PaintLayer* child = layer.firstChild(); child; child = child->nextSibling())
        updateDescendantDependentFlagsForEntireSubtree(*child);
}
void InspectorLayerTreeAgent::buildLayerIdToNodeIdMap(
    PaintLayer* root,
    LayerIdToNodeIdMap& layerIdToNodeIdMap) {
  if (root->hasCompositedLayerMapping()) {
    if (Node* node = root->layoutObject()->generatingNode()) {
      GraphicsLayer* graphicsLayer =
          root->compositedLayerMapping()->childForSuperlayers();
      layerIdToNodeIdMap.set(graphicsLayer->platformLayer()->id(),
                             idForNode(node));
    }
  }
  for (PaintLayer* child = root->firstChild(); child;
       child = child->nextSibling())
    buildLayerIdToNodeIdMap(child, layerIdToNodeIdMap);
  if (!root->layoutObject()->isLayoutIFrame())
    return;
  FrameView* childFrameView =
      toFrameView(toLayoutPart(root->layoutObject())->widget());
  LayoutViewItem childLayoutViewItem = childFrameView->layoutViewItem();
  if (!childLayoutViewItem.isNull()) {
    if (PaintLayerCompositor* childCompositor =
            childLayoutViewItem.compositor())
      buildLayerIdToNodeIdMap(childCompositor->rootLayer(), layerIdToNodeIdMap);
  }
}
void PaintLayerClipper::clearClipRectsIncludingDescendants()
{
    m_cache = nullptr;

    for (PaintLayer* layer = m_layoutObject.layer()->firstChild(); layer; layer = layer->nextSibling()) {
        layer->clipper().clearClipRectsIncludingDescendants();
    }
}
void PaintLayerClipper::clearClipRectsIncludingDescendants(ClipRectsCacheSlot cacheSlot)
{
    if (m_cache)
        m_cache->clear(cacheSlot);

    for (PaintLayer* layer = m_layoutObject.layer()->firstChild(); layer; layer = layer->nextSibling()) {
        layer->clipper().clearClipRectsIncludingDescendants(cacheSlot);
    }
}
Beispiel #5
0
void PaintLayerClipper::clearClipRectsIncludingDescendants() {
  if (m_geometryMapper)
    m_geometryMapper.reset(new GeometryMapper);
  m_layer.clearClipRectsCache();

  for (PaintLayer* layer = m_layer.firstChild(); layer;
       layer = layer->nextSibling()) {
    layer->clipper().clearClipRectsIncludingDescendants();
  }
}
static void fullyInvalidatePaintRecursive(PaintLayer* layer)
{
    if (layer->compositingState() == PaintsIntoOwnBacking) {
        layer->compositedLayerMapping()->setContentsNeedDisplay();
        layer->compositedLayerMapping()->setSquashingContentsNeedDisplay();
    }

    for (PaintLayer* child = layer->firstChild(); child; child = child->nextSibling())
        fullyInvalidatePaintRecursive(child);
}
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;
}
static void paintLayers(PaintLayer& layer, SimDisplayItemList& displayList)
{
    if (layer.isAllowedToQueryCompositingState() && layer.compositingState() == PaintsIntoOwnBacking) {
        CompositedLayerMapping* mapping = layer.compositedLayerMapping();
        GraphicsLayer* graphicsLayer = mapping->mainGraphicsLayer();
        if (graphicsLayer->hasTrackedPaintInvalidations()) {
            ContentLayerDelegate* delegate = graphicsLayer->contentLayerDelegateForTesting();
            delegate->paintContents(&displayList, WebRect(0, 0, layer.size().width(), layer.size().height()));
            graphicsLayer->resetTrackedPaintInvalidations();
        }
    }
    for (PaintLayer* child = layer.firstChild(); child; child = child->nextSibling())
        paintLayers(*child, displayList);
}
void PaintLayerStackingNode::collectLayers(
    std::unique_ptr<Vector<PaintLayerStackingNode*>>& posBuffer,
    std::unique_ptr<Vector<PaintLayerStackingNode*>>& negBuffer) {
  if (layer()->isInTopLayer())
    return;

  if (isStacked()) {
    std::unique_ptr<Vector<PaintLayerStackingNode*>>& buffer =
        (zIndex() >= 0) ? posBuffer : negBuffer;
    if (!buffer)
      buffer = wrapUnique(new Vector<PaintLayerStackingNode*>);
    buffer->append(this);
  }

  if (!isStackingContext()) {
    for (PaintLayer* child = layer()->firstChild(); child;
         child = child->nextSibling())
      child->stackingNode()->collectLayers(posBuffer, negBuffer);
  }
}