Changeset 213435 in webkit


Ignore:
Timestamp:
Mar 5, 2017, 11:14:12 AM (9 years ago)
Author:
Simon Fraser
Message:

Make some RenderLayer tree traversal in RenderLayerBacking more generic
https://bugs.webkit.org/show_bug.cgi?id=169177

Reviewed by Zalan Bujtas.

The real goal of this patch is reduce the number of callers of
RenderLayerBacking::isPaintDestinationForDescendantLayers() to one. To achieve that,
have the setContentsVisible() logic (which is really just about the CSS 'visibility' property)
do its own tree traversal which just consults layer.hasVisibleContent(). So
make descendantLayerPaintsIntoAncestor() a generic traversal function which walks
descendant layers which may paint into the target layer. The "Visible" in the name
reflects the fact that it can bypass a subtree for a layer with !hasVisibleDescendant().

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateAfterDescendants):
(WebCore::traverseVisibleNonCompositedDescendantLayers):
(WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers):
(WebCore::RenderLayerBacking::hasVisibleNonCompositedDescendants):
(WebCore::descendantLayerPaintsIntoAncestor): Deleted.

  • rendering/RenderLayerBacking.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r213429 r213435  
     12017-03-05  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make some RenderLayer tree traversal in RenderLayerBacking more generic
     4        https://bugs.webkit.org/show_bug.cgi?id=169177
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        The real goal of this patch is reduce the number of callers of
     9        RenderLayerBacking::isPaintDestinationForDescendantLayers() to one. To achieve that,
     10        have the setContentsVisible() logic (which is really just about the CSS 'visibility' property)
     11        do its own tree traversal which just consults layer.hasVisibleContent(). So
     12        make descendantLayerPaintsIntoAncestor() a generic traversal function which walks
     13        descendant layers which may paint into the target layer. The "Visible" in the name
     14        reflects the fact that it can bypass a subtree for a layer with !hasVisibleDescendant().
     15
     16        * rendering/RenderLayerBacking.cpp:
     17        (WebCore::RenderLayerBacking::updateAfterDescendants):
     18        (WebCore::traverseVisibleNonCompositedDescendantLayers):
     19        (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers):
     20        (WebCore::RenderLayerBacking::hasVisibleNonCompositedDescendants):
     21        (WebCore::descendantLayerPaintsIntoAncestor): Deleted.
     22        * rendering/RenderLayerBacking.h:
     23
    1242017-03-04  Simon Fraser  <simon.fraser@apple.com>
    225
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r213429 r213435  
    11051105    updateDrawsContent(isSimpleContainer);
    11061106
    1107     m_graphicsLayer->setContentsVisible(m_owningLayer.hasVisibleContent() || isPaintDestinationForDescendantLayers());
     1107    m_graphicsLayer->setContentsVisible(m_owningLayer.hasVisibleContent() || hasVisibleNonCompositedDescendants());
    11081108    if (m_scrollingLayer) {
    11091109        m_scrollingLayer->setContentsVisible(renderer().style().visibility() == VISIBLE);
     
    19491949}
    19501950
    1951 static bool descendantLayerPaintsIntoAncestor(RenderLayer& parent)
     1951enum class LayerTraversal { Continue, Stop };
     1952
     1953static LayerTraversal traverseVisibleNonCompositedDescendantLayers(RenderLayer& parent, std::function<LayerTraversal (const RenderLayer&)> layerFunc)
    19521954{
    19531955    // FIXME: We shouldn't be called with a stale z-order lists. See bug 85512.
     
    19601962    if (auto* normalFlowList = parent.normalFlowList()) {
    19611963        for (auto* childLayer : *normalFlowList) {
    1962             if (!compositedWithOwnBackingStore(*childLayer) && (childLayer->isVisuallyNonEmpty() || descendantLayerPaintsIntoAncestor(*childLayer)))
    1963                 return true;
     1964            if (compositedWithOwnBackingStore(*childLayer))
     1965                continue;
     1966
     1967            if (layerFunc(*childLayer) == LayerTraversal::Stop)
     1968                return LayerTraversal::Stop;
     1969           
     1970            if (traverseVisibleNonCompositedDescendantLayers(*childLayer, layerFunc) == LayerTraversal::Stop)
     1971                return LayerTraversal::Stop;
    19641972        }
    19651973    }
     
    19671975    if (parent.isStackingContainer()) {
    19681976        if (!parent.hasVisibleDescendant())
    1969             return false;
     1977            return LayerTraversal::Continue;
    19701978
    19711979        // Use the m_hasCompositingDescendant bit to optimize?
    19721980        if (auto* negZOrderList = parent.negZOrderList()) {
    19731981            for (auto* childLayer : *negZOrderList) {
    1974                 if (!compositedWithOwnBackingStore(*childLayer) && (childLayer->isVisuallyNonEmpty() || descendantLayerPaintsIntoAncestor(*childLayer)))
    1975                     return true;
     1982                if (compositedWithOwnBackingStore(*childLayer))
     1983                    continue;
     1984
     1985                if (layerFunc(*childLayer) == LayerTraversal::Stop)
     1986                    return LayerTraversal::Stop;
     1987
     1988                if (traverseVisibleNonCompositedDescendantLayers(*childLayer, layerFunc) == LayerTraversal::Stop)
     1989                    return LayerTraversal::Stop;
    19761990            }
    19771991        }
     
    19791993        if (auto* posZOrderList = parent.posZOrderList()) {
    19801994            for (auto* childLayer : *posZOrderList) {
    1981                 if (!compositedWithOwnBackingStore(*childLayer) && (childLayer->isVisuallyNonEmpty() || descendantLayerPaintsIntoAncestor(*childLayer)))
    1982                     return true;
     1995                if (compositedWithOwnBackingStore(*childLayer))
     1996                    continue;
     1997
     1998                if (layerFunc(*childLayer) == LayerTraversal::Stop)
     1999                    return LayerTraversal::Stop;
     2000
     2001                if (traverseVisibleNonCompositedDescendantLayers(*childLayer, layerFunc) == LayerTraversal::Stop)
     2002                    return LayerTraversal::Stop;
    19832003            }
    19842004        }
    19852005    }
    19862006
    1987     return false;
     2007    return LayerTraversal::Continue;
    19882008}
    19892009
     
    19912011bool RenderLayerBacking::isPaintDestinationForDescendantLayers() const
    19922012{
    1993     return descendantLayerPaintsIntoAncestor(m_owningLayer);
     2013    bool hasPaintingDescendant = false;
     2014    traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasPaintingDescendant](const RenderLayer& layer) {
     2015        hasPaintingDescendant = layer.isVisuallyNonEmpty();
     2016        return hasPaintingDescendant ? LayerTraversal::Stop : LayerTraversal::Continue;
     2017    });
     2018
     2019    return hasPaintingDescendant;
     2020}
     2021
     2022bool RenderLayerBacking::hasVisibleNonCompositedDescendants() const
     2023{
     2024    bool hasVisibleDescendant = false;
     2025    traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasVisibleDescendant](const RenderLayer& layer) {
     2026        hasVisibleDescendant = layer.hasVisibleContent();
     2027        return hasVisibleDescendant ? LayerTraversal::Stop : LayerTraversal::Continue;
     2028    });
     2029
     2030    return hasVisibleDescendant;
    19942031}
    19952032
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r213429 r213435  
    330330
    331331    bool isPaintDestinationForDescendantLayers() const;
     332    bool hasVisibleNonCompositedDescendants() const;
    332333
    333334    bool shouldClipCompositedBounds() const;
Note: See TracChangeset for help on using the changeset viewer.