Changeset 157725 in webkit


Ignore:
Timestamp:
Oct 21, 2013 12:38:30 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Regions] The layers from the flow thread should be collected under the regions' layers.
https://bugs.webkit.org/show_bug.cgi?id=120457

Patch by Mihai Maerean <Mihai Maerean> on 2013-10-21
Reviewed by David Hyatt.

Source/WebCore:

This patch is based on the work of Alexandru Chiculita at https://bugs.webkit.org/attachment.cgi?id=203872&action=review

The composited layers inside the named flow threads are collected as part of the regions (as children of the
GraphicsLayer of the layer that corresponds to the region (which is attached to the parent renderer of
RenderNameFlowFragment)).
When a region displays a layer that needs accelerated compositing we activate the accelerated compositing for
that region too (inside RenderLayerCompositor::computeRegionCompositingRequirements).

This patch has landed before (as http://trac.webkit.org/changeset/156451), but was reverted because
fast/multicol/mixed-positioning-stacking-order.html failed. The fix is inside RenderLayerCompositor::canBeComposited
that only enables compositing for layers inside flow threads that collect the graphics layers under the regions.

Another change from changeset #156451 is that now the region renderers are created as anonymous renderers under
the element that has the flow-from property. When a composited layer is needed for the region, it sits in it's
parent renderer, not in the region renderer (RenderNamedFlowFragment).

Tests: compositing/regions/crash-transform-inside-region.html

compositing/regions/floated-region-with-transformed-child.html
compositing/regions/move-layer-from-one-region-to-another.html
compositing/regions/propagate-region-box-shadow-border-padding-for-video.html
compositing/regions/propagate-region-box-shadow-border-padding.html
compositing/regions/region-as-layer-in-another-flowthread.html
compositing/regions/transform-transparent-positioned-video-inside-region.html
compositing/regions/transformed-layer-inside-transformed-layer.html
compositing/regions/z-index-update.html
compositing/regions/z-index.html

  • rendering/FlowThreadController.cpp:

(WebCore::FlowThreadController::updateRenderFlowThreadLayersIfNeeded):

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::propagateStyleToAnonymousChildren): Not for RenderFlowThreads, as they are updated
through the RenderView::styleDidChange function.

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::layout): When the layout of the flow thread is over (including the 2 phase layout),
we update all the mappings between the layers inside the flow thread and the regions where those layers will be
painted.
(WebCore::RenderFlowThread::hasCompositingRegionDescendant): Whether any of the regions has a compositing descendant.
(WebCore::RenderFlowThread::getLayerListForRegion):
(WebCore::RenderFlowThread::regionForCompositedLayer):
(WebCore::RenderFlowThread::cachedRegionForCompositedLayer):
(WebCore::RenderFlowThread::collectsGraphicsLayersUnderRegions):
(WebCore::RenderFlowThread::updateLayerToRegionMappings): Triggers an update of the layers if a layer has moved
from a region to another since the last update.
(WebCore::RenderFlowThread::updateAllLayerToRegionMappings):

  • rendering/RenderFlowThread.h:
  • rendering/RenderGeometryMap.cpp:

(WebCore::RenderGeometryMap::pushRenderFlowThread):

  • rendering/RenderGeometryMap.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::enclosingFlowThreadAncestor):
(WebCore::RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions):
(WebCore::RenderLayer::hitTestList):
(WebCore::RenderLayer::calculateLayerBounds): When we calculate the bounds of the RenderView, we ignore those
flow threads that collect the graphics layers under the regions.
(WebCore::RenderLayer::dirtyZOrderLists):
(WebCore::RenderLayer::dirtyNormalFlowList):

  • rendering/RenderLayer.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::shouldClipCompositedBounds): Not if it's a flow thread that collects the graphics
layers under the regions
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): Now adjusts the ancestorCompositingBounds for the FlowThread.
(WebCore::RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread): Make sure that the region propagates
its borders, paddings, outlines or box-shadows to layers inside it.
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):

  • rendering/RenderLayerBacking.h:
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::computeCompositingRequirements): Now calls computeRegionCompositingRequirements.
(WebCore::RenderLayerCompositor::computeRegionCompositingRequirements):
(WebCore::RenderLayerCompositor::rebuildCompositingLayerTree): Do not iterate the RenderFlowThread directly if
we are going to collect the composited layers as part of regions.
(WebCore::RenderLayerCompositor::rebuildRegionCompositingLayerTree):
(WebCore::RenderLayerCompositor::canBeComposited): CSS Regions flow threads do not need to be composited as we
use composited RenderRegions to render the background of the RenderFlowThread.
(WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason): If it's a container of a css region.

  • rendering/RenderLayerCompositor.h:
  • rendering/RenderMultiColumnSet.cpp:

(WebCore::RenderMultiColumnSet::adjustRegionBoundsFromFlowThreadPortionRect):

  • rendering/RenderMultiColumnSet.h:
  • rendering/RenderNamedFlowFragment.h:

(WebCore::RenderNamedFlowFragment::layerOwner): When the content inside the region requires the region to have a
layer, the layer will be created on the region's parent renderer instead. This method returns that renderer
holding the layer. The return value may be null.

  • rendering/RenderNamedFlowThread.cpp:

(WebCore::RenderNamedFlowThread::RenderNamedFlowThread):
(WebCore::RenderNamedFlowThread::nextRendererForNode):
(WebCore::RenderNamedFlowThread::previousRendererForNode):
(WebCore::RenderNamedFlowThread::addFlowChild):
(WebCore::RenderNamedFlowThread::removeFlowChild):
(WebCore::RenderNamedFlowThread::collectsGraphicsLayersUnderRegions):

  • rendering/RenderNamedFlowThread.h: m_flowThreadChildList is now allocated through an OwnPtr to keep the render

arena under the size limit.

  • rendering/RenderRegion.cpp:

(WebCore::RenderRegion::adjustRegionBoundsFromFlowThreadPortionRect):

  • rendering/RenderRegion.h:

(WebCore::toRenderRegion):

  • rendering/RenderTreeAsText.cpp:

(WebCore::writeLayers):

  • WebCore.exp.in: WebCore::RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions

LayoutTests:

  • compositing/regions/crash-transform-inside-region-expected.html: Added.
  • compositing/regions/crash-transform-inside-region.html: Added.
  • compositing/regions/floated-region-with-transformed-child-expected.html: Added.
  • compositing/regions/floated-region-with-transformed-child.html: Added.
  • compositing/regions/move-layer-from-one-region-to-another-expected.html: Added.
  • compositing/regions/move-layer-from-one-region-to-another.html: Added.
  • compositing/regions/propagate-region-box-shadow-border-padding-expected.html: Added.
  • compositing/regions/propagate-region-box-shadow-border-padding-for-video-expected.html: Added.
  • compositing/regions/propagate-region-box-shadow-border-padding-for-video.html: Added.
  • compositing/regions/propagate-region-box-shadow-border-padding.html: Added.
  • compositing/regions/region-as-layer-in-another-flowthread-expected.html: Added.
  • compositing/regions/region-as-layer-in-another-flowthread.html: Added.
  • compositing/regions/transform-transparent-positioned-video-inside-region-expected.html: Added.
  • compositing/regions/transform-transparent-positioned-video-inside-region.html: Added.
  • compositing/regions/transformed-layer-inside-transformed-layer-expected.html: Added.
  • compositing/regions/transformed-layer-inside-transformed-layer.html: Added.
  • compositing/regions/webkit-flow-renderer-layer-compositing-expected.html:
  • compositing/regions/webkit-flow-renderer-layer-compositing.html:
  • compositing/regions/z-index-expected.html: Added.
  • compositing/regions/z-index-update-expected.html: Added.
  • compositing/regions/z-index-update.html: Added.
  • compositing/regions/z-index.html: Added.
  • fast/multicol/mixed-positioning-stacking-order-expected.html:
  • fast/multicol/mixed-positioning-stacking-order.html:
  • fast/repaint/region-painting-composited-element-expected.html:
  • fast/repaint/region-painting-composited-element.html:
  • platform/mac-wk2/TestExpectations:
Location:
trunk
Files:
20 added
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r157724 r157725  
     12013-10-21  Mihai Maerean  <mmaerean@adobe.com>
     2
     3        [CSS Regions] The layers from the flow thread should be collected under the regions' layers.
     4        https://bugs.webkit.org/show_bug.cgi?id=120457
     5
     6        Reviewed by David Hyatt.
     7
     8        * compositing/regions/crash-transform-inside-region-expected.html: Added.
     9        * compositing/regions/crash-transform-inside-region.html: Added.
     10        * compositing/regions/floated-region-with-transformed-child-expected.html: Added.
     11        * compositing/regions/floated-region-with-transformed-child.html: Added.
     12        * compositing/regions/move-layer-from-one-region-to-another-expected.html: Added.
     13        * compositing/regions/move-layer-from-one-region-to-another.html: Added.
     14        * compositing/regions/propagate-region-box-shadow-border-padding-expected.html: Added.
     15        * compositing/regions/propagate-region-box-shadow-border-padding-for-video-expected.html: Added.
     16        * compositing/regions/propagate-region-box-shadow-border-padding-for-video.html: Added.
     17        * compositing/regions/propagate-region-box-shadow-border-padding.html: Added.
     18        * compositing/regions/region-as-layer-in-another-flowthread-expected.html: Added.
     19        * compositing/regions/region-as-layer-in-another-flowthread.html: Added.
     20        * compositing/regions/transform-transparent-positioned-video-inside-region-expected.html: Added.
     21        * compositing/regions/transform-transparent-positioned-video-inside-region.html: Added.
     22        * compositing/regions/transformed-layer-inside-transformed-layer-expected.html: Added.
     23        * compositing/regions/transformed-layer-inside-transformed-layer.html: Added.
     24        * compositing/regions/webkit-flow-renderer-layer-compositing-expected.html:
     25        * compositing/regions/webkit-flow-renderer-layer-compositing.html:
     26        * compositing/regions/z-index-expected.html: Added.
     27        * compositing/regions/z-index-update-expected.html: Added.
     28        * compositing/regions/z-index-update.html: Added.
     29        * compositing/regions/z-index.html: Added.
     30        * fast/multicol/mixed-positioning-stacking-order-expected.html:
     31        * fast/multicol/mixed-positioning-stacking-order.html:
     32        * fast/repaint/region-painting-composited-element-expected.html:
     33        * fast/repaint/region-painting-composited-element.html:
     34        * platform/mac-wk2/TestExpectations:
     35
    1362013-10-21  Oliver Hunt  <oliver@apple.com>
    237
  • trunk/LayoutTests/compositing/regions/webkit-flow-renderer-layer-compositing-expected.html

    r129304 r157725  
    66        height:50px;
    77        width:50px;
    8         background-color: green
     8        background-color: green;
     9        -webkit-transform: scale3d(1, 1, 1);/* Force a composited RenderLayer. */
    910    }
    1011</style>
     
    1415<p>Test that an element requiring a composited layer, collected in a flow thread, is displayed correctly inside a region.</p>
    1516<p>On success, you should not see a red rectangle below.</p>
    16 <div class="region">
    17 </div>
     17<div class="region">region</div>
    1818</body>
    1919</html>
  • trunk/LayoutTests/compositing/regions/webkit-flow-renderer-layer-compositing.html

    r129304 r157725  
    2525<p>Test that an element requiring a composited layer, collected in a flow thread, is displayed correctly inside a region.</p>
    2626<p>On success, you should not see a red rectangle below.</p>
    27 <div id="div1" class="elementSize"></div>
     27<div id="div1" class="elementSize">region</div>
    2828<div id="region1" class="elementSize"></div>
    2929</body>
  • trunk/LayoutTests/fast/multicol/mixed-positioning-stacking-order-expected.html

    r144318 r157725  
    11<!doctype html>
    22<html>
    3 <div style="height:200px;border:5px solid black;position:relative;width:210px">
    4 <div style="width:210px;height:200px;background-color:purple;">3</div>
    5 <div style="position:absolute;background-color:gold;left:55px;top:0px;height:200px;width:100px">2</div>
    6 <div style="position:absolute;background-color:lightblue;width:100px;height:100px;left:0;bottom:0">1</div>
    7 <div style="position:absolute;background-color:lightblue;width:100px;left:110px;top:0;height:100px"></div>
     3<div style="height:200px;width:210px;position:relative;border:5px solid black">
     4        <div style="width:210px;height:200px;background-color:purple;">3</div>
     5        <div style="position:absolute;background-color:gold;left:55px;top:0px;height:200px;width:100px">2</div>
     6        <div style="position:absolute;background-color:lightblue;width:100px;height:100px;left:0;bottom:0">1</div>
     7        <div style="position:absolute;background-color:lightblue;width:100px;left:110px;top:0;height:100px"></div>
    88</div>
  • trunk/LayoutTests/fast/multicol/mixed-positioning-stacking-order.html

    r157458 r157725  
    77</head>
    88<body>
    9 <div style="width:210px; height:200px; border:5px solid black; -moz-column-width:100px; -moz-column-gap:10px; -webkit-column-width:100px; -webkit-column-gap:10px; -webkit-column-fill:auto; column-width:100px; column-gap:10px; column-fill:auto;">
    10 
    11 <div style="position:relative;">
    12 <div style="position:absolute;top:0;left:0; height:400px; width:100px">
    13 <div style="width:100px;height:100px;background-color:purple;">3</div>
    14 <div style="height:200px"></div>
    15 <div style="width:100px;height:100px;background-color:purple;">3</div>
     9<div style="-moz-column-width:100px; -moz-column-gap:10px; width:210px; height:200px;border:5px solid black; -webkit-column-width:100px; -webkit-column-gap:10px; -webkit-column-fill:auto; column-width:100px; column-gap:10px; column-fill:auto;">
     10        <div style="position:relative;">
     11                <div style="position:absolute;top:0;left:0; height:400px; width:100px">
     12                        <div style="width:100px;height:100px;background-color:purple;">3</div>
     13                        <div style="height:200px"></div>
     14                        <div style="width:100px;height:100px;background-color:purple;">3</div>
     15                </div>
     16                <div style="position:relative; z-index:1; background-color:lightblue; width:100%; height:200px; top:100px">1</div>
     17                <div style="position:fixed;background-color:gold;left:68px;top:13px;height:200px;width:100px">2</div>
     18        </div>
    1619</div>
    17 <div style="position:relative; z-index:1; background-color:lightblue; width:100%; height:200px; top:100px">1</div>
    18 
    19 <div style="position:fixed;background-color:gold;left:68px;top:13px;height:200px;width:100px">2</div>
    20 </div>
    21 </div>
  • trunk/LayoutTests/fast/repaint/region-painting-composited-element-expected.html

    r156767 r157725  
    1313    position: relative; z-index: 1; /*create Stacking Context*/
    1414}
     15#region1 {
     16    -webkit-transform: translate3d(0,0,0); /*activate accelerated compositing*/
     17}
    1518</style>
    1619</head>
    1720<body>
    18     <div id="region1"></div><br />
     21    <div id="region1">region</div><br />
    1922    <div id="region2"></div>
    2023</body>
  • trunk/LayoutTests/fast/repaint/region-painting-composited-element.html

    r136037 r157725  
    4141        The test should paint two green rectangles. There should be no red. -->
    4242    <div id="content">
    43         <div id="target"></div>
     43        <div id="target">region</div>
    4444    </div>
    4545    <div id="region1"></div><br />
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r157691 r157725  
    324324webkit.org/b/118925 [ Debug ] css3/filters/custom/effect-custom-transform-parameters.html  [ ImageOnlyFailure ]
    325325webkit.org/b/118925 [ Debug ] fast/layers/no-clipping-overflow-hidden-added-after-transition.html  [ ImageOnlyFailure ]
    326 webkit.org/b/118925 [ Debug ] fast/multicol/mixed-opacity-fixed-test.html  [ ImageOnlyFailure ]
     326webkit.org/b/118925 [ Debug ] fast/multicol/mixed-opacity-fixed-test.html  [ ImageOnlyFailure Pass ]
    327327webkit.org/b/118925 [ Debug ] fast/regions/fixed-pos-elem-in-region.html  [ ImageOnlyFailure ]
    328328webkit.org/b/118925 [ Debug ] svg/repaint/buffered-rendering-static-image.html  [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r157723 r157725  
     12013-10-21  Mihai Maerean  <mmaerean@adobe.com>
     2
     3        [CSS Regions] The layers from the flow thread should be collected under the regions' layers.
     4        https://bugs.webkit.org/show_bug.cgi?id=120457
     5
     6        Reviewed by David Hyatt.
     7
     8        This patch is based on the work of Alexandru Chiculita at https://bugs.webkit.org/attachment.cgi?id=203872&action=review
     9
     10        The composited layers inside the named flow threads are collected as part of the regions (as children of the
     11        GraphicsLayer of the layer that corresponds to the region (which is attached to the parent renderer of
     12        RenderNameFlowFragment)).
     13        When a region displays a layer that needs accelerated compositing we activate the accelerated compositing for
     14        that region too (inside RenderLayerCompositor::computeRegionCompositingRequirements).
     15
     16        This patch has landed before (as http://trac.webkit.org/changeset/156451), but was reverted because
     17        fast/multicol/mixed-positioning-stacking-order.html failed. The fix is inside RenderLayerCompositor::canBeComposited
     18        that only enables compositing for layers inside flow threads that collect the graphics layers under the regions.
     19
     20        Another change from changeset #156451 is that now the region renderers are created as anonymous renderers under
     21        the element that has the flow-from property. When a composited layer is needed for the region, it sits in it's
     22        parent renderer, not in the region renderer (RenderNamedFlowFragment).
     23
     24        Tests: compositing/regions/crash-transform-inside-region.html
     25               compositing/regions/floated-region-with-transformed-child.html
     26               compositing/regions/move-layer-from-one-region-to-another.html
     27               compositing/regions/propagate-region-box-shadow-border-padding-for-video.html
     28               compositing/regions/propagate-region-box-shadow-border-padding.html
     29               compositing/regions/region-as-layer-in-another-flowthread.html
     30               compositing/regions/transform-transparent-positioned-video-inside-region.html
     31               compositing/regions/transformed-layer-inside-transformed-layer.html
     32               compositing/regions/z-index-update.html
     33               compositing/regions/z-index.html
     34
     35        * rendering/FlowThreadController.cpp:
     36        (WebCore::FlowThreadController::updateRenderFlowThreadLayersIfNeeded):
     37        * rendering/RenderElement.cpp:
     38        (WebCore::RenderElement::propagateStyleToAnonymousChildren): Not for RenderFlowThreads, as they are updated
     39        through the RenderView::styleDidChange function.
     40        * rendering/RenderFlowThread.cpp:
     41        (WebCore::RenderFlowThread::layout): When the layout of the flow thread is over (including the 2 phase layout),
     42        we update all the mappings between the layers inside the flow thread and the regions where those layers will be
     43        painted.
     44        (WebCore::RenderFlowThread::hasCompositingRegionDescendant): Whether any of the regions has a compositing descendant.
     45        (WebCore::RenderFlowThread::getLayerListForRegion):
     46        (WebCore::RenderFlowThread::regionForCompositedLayer):
     47        (WebCore::RenderFlowThread::cachedRegionForCompositedLayer):
     48        (WebCore::RenderFlowThread::collectsGraphicsLayersUnderRegions):
     49        (WebCore::RenderFlowThread::updateLayerToRegionMappings): Triggers an update of the layers if a layer has moved
     50        from a region to another since the last update.
     51        (WebCore::RenderFlowThread::updateAllLayerToRegionMappings):
     52        * rendering/RenderFlowThread.h:
     53        * rendering/RenderGeometryMap.cpp:
     54        (WebCore::RenderGeometryMap::pushRenderFlowThread):
     55        * rendering/RenderGeometryMap.h:
     56        * rendering/RenderLayer.cpp:
     57        (WebCore::RenderLayer::paintList):
     58        (WebCore::RenderLayer::enclosingFlowThreadAncestor):
     59        (WebCore::RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions):
     60        (WebCore::RenderLayer::hitTestList):
     61        (WebCore::RenderLayer::calculateLayerBounds): When we calculate the bounds of the RenderView, we ignore those
     62        flow threads that collect the graphics layers under the regions.
     63        (WebCore::RenderLayer::dirtyZOrderLists):
     64        (WebCore::RenderLayer::dirtyNormalFlowList):
     65        * rendering/RenderLayer.h:
     66        * rendering/RenderLayerBacking.cpp:
     67        (WebCore::RenderLayerBacking::shouldClipCompositedBounds): Not if it's a flow thread that collects the graphics
     68        layers under the regions
     69        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): Now adjusts the ancestorCompositingBounds for the FlowThread.
     70        (WebCore::RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread): Make sure that the region propagates
     71        its borders, paddings, outlines or box-shadows to layers inside it.
     72        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
     73        * rendering/RenderLayerBacking.h:
     74        * rendering/RenderLayerCompositor.cpp:
     75        (WebCore::RenderLayerCompositor::computeCompositingRequirements): Now calls computeRegionCompositingRequirements.
     76        (WebCore::RenderLayerCompositor::computeRegionCompositingRequirements):
     77        (WebCore::RenderLayerCompositor::rebuildCompositingLayerTree): Do not iterate the RenderFlowThread directly if
     78        we are going to collect the composited layers as part of regions.
     79        (WebCore::RenderLayerCompositor::rebuildRegionCompositingLayerTree):
     80        (WebCore::RenderLayerCompositor::canBeComposited): CSS Regions flow threads do not need to be composited as we
     81        use composited RenderRegions to render the background of the RenderFlowThread.
     82        (WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason): If it's a container of a css region.
     83        * rendering/RenderLayerCompositor.h:
     84        * rendering/RenderMultiColumnSet.cpp:
     85        (WebCore::RenderMultiColumnSet::adjustRegionBoundsFromFlowThreadPortionRect):
     86        * rendering/RenderMultiColumnSet.h:
     87        * rendering/RenderNamedFlowFragment.h:
     88        (WebCore::RenderNamedFlowFragment::layerOwner): When the content inside the region requires the region to have a
     89        layer, the layer will be created on the region's parent renderer instead. This method returns that renderer
     90        holding the layer. The return value may be null.
     91        * rendering/RenderNamedFlowThread.cpp:
     92        (WebCore::RenderNamedFlowThread::RenderNamedFlowThread):
     93        (WebCore::RenderNamedFlowThread::nextRendererForNode):
     94        (WebCore::RenderNamedFlowThread::previousRendererForNode):
     95        (WebCore::RenderNamedFlowThread::addFlowChild):
     96        (WebCore::RenderNamedFlowThread::removeFlowChild):
     97        (WebCore::RenderNamedFlowThread::collectsGraphicsLayersUnderRegions):
     98        * rendering/RenderNamedFlowThread.h: m_flowThreadChildList is now allocated through an OwnPtr to keep the render
     99        arena under the size limit.
     100        * rendering/RenderRegion.cpp:
     101        (WebCore::RenderRegion::adjustRegionBoundsFromFlowThreadPortionRect):
     102        * rendering/RenderRegion.h:
     103        (WebCore::toRenderRegion):
     104        * rendering/RenderTreeAsText.cpp:
     105        (WebCore::writeLayers):
     106        * WebCore.exp.in: WebCore::RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions
     107
    11082013-10-21  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
    2109
  • trunk/Source/WebCore/rendering/FlowThreadController.cpp

    r157535 r157725  
    271271    for (RenderNamedFlowThreadList::reverse_iterator iter = m_renderNamedFlowThreadList->rbegin(); iter != m_renderNamedFlowThreadList->rend(); ++iter) {
    272272        RenderNamedFlowThread* flowRenderer = *iter;
    273         flowRenderer->updateLayerToRegionMappingsIfNeeded();
     273        flowRenderer->updateAllLayerToRegionMappingsIfNeeded();
    274274    }
    275275}
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r157665 r157725  
    756756#endif
    757757
     758        // RenderFlowThreads are updated through the RenderView::styleDidChange function.
     759        if (child->isRenderFlowThread())
     760            continue;
     761
    758762        auto newStyle = RenderStyle::createAnonymousStyleWithDisplay(style(), child->style()->display());
    759763        if (style()->specifiesColumns()) {
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r157683 r157725  
    4242#include "RenderLayer.h"
    4343#include "RenderLayerCompositor.h"
     44#include "RenderNamedFlowFragment.h"
    4445#include "RenderRegion.h"
    4546#include "RenderTheme.h"
     
    236237    // containers, but just adjusting the position of the RenderLayerBacking.
    237238    if (!m_needsTwoPhasesLayout) {
    238         updateLayerToRegionMappings();
    239         // FIXME: If we have layers that moved from one region to another, we should trigger
     239        // If we have layers that moved from one region to another, we trigger
    240240        // a composited layers rebuild in here to make sure that the regions will collect the right layers.
     241        if (updateAllLayerToRegionMappings())
     242            layer()->compositor().setCompositingLayersNeedRebuild();
    241243    }
    242244#endif
     
    250252
    251253#if USE(ACCELERATED_COMPOSITING)
    252 RenderRegion* RenderFlowThread::regionForCompositedLayer(RenderLayer* childLayer)
    253 {
    254     LayoutPoint leftTopLocation = childLayer->renderBox() ? childLayer->renderBox()->flipForWritingMode(LayoutPoint()) : LayoutPoint();
    255     LayoutPoint flowThreadOffset = flooredLayoutPoint(childLayer->renderer().localToContainerPoint(leftTopLocation, this, ApplyContainerFlip));
    256     return regionAtBlockOffset(0, flipForWritingMode(isHorizontalWritingMode() ? flowThreadOffset.y() : flowThreadOffset.x()), true, DisallowRegionAutoGeneration);
    257 }
    258 
    259 void RenderFlowThread::updateRegionForRenderLayer(RenderLayer* layer, LayerToRegionMap& layerToRegionMap, RegionToLayerListMap& regionToLayerListMap, bool& needsLayerUpdate)
    260 {
    261     RenderRegion* region = regionForCompositedLayer(layer);
     254bool RenderFlowThread::hasCompositingRegionDescendant() const
     255{
     256    for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter)
     257        if (RenderLayerModelObject* layerOwner = toRenderNamedFlowFragment(*iter)->layerOwner())
     258            if (layerOwner->hasLayer() && layerOwner->layer()->hasCompositingDescendant())
     259                return true;
     260
     261    return false;
     262}
     263
     264const RenderLayerList* RenderFlowThread::getLayerListForRegion(RenderNamedFlowFragment* region)
     265{
     266    if (!m_regionToLayerListMap)
     267        return 0;
     268    updateAllLayerToRegionMappingsIfNeeded();
     269    RegionToLayerListMap::const_iterator iterator = m_regionToLayerListMap->find(region);
     270    return iterator == m_regionToLayerListMap->end() ? 0 : &iterator->value;
     271}
     272
     273RenderNamedFlowFragment* RenderFlowThread::regionForCompositedLayer(RenderLayer& childLayer)
     274{
     275    if (childLayer.renderBox()) {
     276        RenderRegion* startRegion = 0;
     277        RenderRegion* endRegion = 0;
     278        getRegionRangeForBox(childLayer.renderBox(), startRegion, endRegion);
     279        // The video tag is such a box that doesn't have a region range because it's inline (by default).
     280        if (startRegion)
     281            return toRenderNamedFlowFragment(startRegion);
     282    }
     283
     284    // FIXME: remove this when we'll have region ranges for inlines as well.
     285    LayoutPoint flowThreadOffset = flooredLayoutPoint(childLayer.renderer().localToContainerPoint(LayoutPoint(), this, ApplyContainerFlip));
     286    return toRenderNamedFlowFragment(regionAtBlockOffset(0, flipForWritingMode(isHorizontalWritingMode() ? flowThreadOffset.y() : flowThreadOffset.x()), true, DisallowRegionAutoGeneration));
     287}
     288
     289RenderNamedFlowFragment* RenderFlowThread::cachedRegionForCompositedLayer(RenderLayer& childLayer)
     290{
     291    if (!m_layerToRegionMap)
     292        return 0;
     293    updateAllLayerToRegionMappingsIfNeeded();
     294    return m_layerToRegionMap->get(&childLayer);
     295}
     296
     297void RenderFlowThread::updateLayerToRegionMappings(RenderLayer& layer, LayerToRegionMap& layerToRegionMap, RegionToLayerListMap& regionToLayerListMap, bool& needsLayerUpdate)
     298{
     299    RenderNamedFlowFragment* region = regionForCompositedLayer(layer);
    262300    if (!needsLayerUpdate) {
    263         ASSERT(m_layerToRegionMap);
    264301        // Figure out if we moved this layer from a region to the other.
    265         RenderRegion* previousRegion = m_layerToRegionMap->get(layer);
     302        RenderNamedFlowFragment* previousRegion = cachedRegionForCompositedLayer(layer);
    266303        if (previousRegion != region)
    267304            needsLayerUpdate = true;
    268305    }
     306
    269307    if (!region)
    270308        return;
    271     layerToRegionMap.set(layer, region);
     309
     310    layerToRegionMap.set(&layer, region);
     311
    272312    RegionToLayerListMap::iterator iterator = regionToLayerListMap.find(region);
    273313    RenderLayerList& list = iterator == regionToLayerListMap.end() ? regionToLayerListMap.set(region, RenderLayerList()).iterator->value : iterator->value;
    274     list.append(layer);
    275 }
    276 
    277 bool RenderFlowThread::updateLayerToRegionMappings()
    278 {
    279     // We only need to map layers to regions for named flow threads.
    280     // Multi-column threads are displayed on top of the regions and do not require
    281     // distributing the layers.
    282     if (!isOutOfFlowRenderFlowThread())
     314    ASSERT(!list.contains(&layer));
     315    list.append(&layer);
     316}
     317
     318bool RenderFlowThread::updateAllLayerToRegionMappings()
     319{
     320    if (!collectsGraphicsLayersUnderRegions())
    283321        return false;
    284322
     
    288326
    289327    // If the RenderFlowThread had a z-index layer update, then we need to update the composited layers too.
    290     bool needsLayerUpdate = m_layersToRegionMappingsDirty || !m_layerToRegionMap.get();
     328    bool needsLayerUpdate = layer()->isDirtyRenderFlowThread() || m_layersToRegionMappingsDirty || !m_layerToRegionMap.get();
    291329    layer()->updateLayerListsIfNeeded();
    292330
     
    294332    RegionToLayerListMap regionToLayerListMap;
    295333
    296     if (Vector<RenderLayer*>* negZOrderList = layer()->negZOrderList()) {
    297         size_t listSize = negZOrderList->size();
    298         for (size_t i = 0; i < listSize; ++i)
    299             updateRegionForRenderLayer(negZOrderList->at(i), layerToRegionMap, regionToLayerListMap, needsLayerUpdate);
    300     }
    301 
    302     if (Vector<RenderLayer*>* normalFlowList = layer()->normalFlowList()) {
    303         size_t listSize = normalFlowList->size();
    304         for (size_t i = 0; i < listSize; ++i)
    305             updateRegionForRenderLayer(normalFlowList->at(i), layerToRegionMap, regionToLayerListMap, needsLayerUpdate);
    306     }
    307    
    308     if (Vector<RenderLayer*>* posZOrderList = layer()->posZOrderList()) {
    309         size_t listSize = posZOrderList->size();
    310         for (size_t i = 0; i < listSize; ++i)
    311             updateRegionForRenderLayer(posZOrderList->at(i), layerToRegionMap, regionToLayerListMap, needsLayerUpdate);
    312     }
     334    RenderLayerList* lists[] = { layer()->negZOrderList(), layer()->normalFlowList(), layer()->posZOrderList()};
     335    for (size_t listIndex = 0; listIndex < sizeof(lists) / sizeof(lists[0]); ++listIndex)
     336        if (RenderLayerList* list = lists[listIndex])
     337            for (size_t i = 0, listSize = list->size(); i < listSize; ++i)
     338                updateLayerToRegionMappings(*list->at(i), layerToRegionMap, regionToLayerListMap, needsLayerUpdate);
    313339
    314340    if (needsLayerUpdate) {
     
    316342            m_layerToRegionMap = adoptPtr(new LayerToRegionMap());
    317343        m_layerToRegionMap->swap(layerToRegionMap);
     344
     345        if (!m_regionToLayerListMap)
     346            m_regionToLayerListMap = adoptPtr(new RegionToLayerListMap());
     347        m_regionToLayerListMap->swap(regionToLayerListMap);
    318348    }
    319349
     
    323353}
    324354#endif
     355
     356bool RenderFlowThread::collectsGraphicsLayersUnderRegions() const
     357{
     358    // We only need to map layers to regions for named flow threads.
     359    // Multi-column threads are displayed on top of the regions and do not require
     360    // distributing the layers.
     361
     362    return false;
     363}
    325364
    326365void RenderFlowThread::updateLogicalWidth()
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r157665 r157725  
    4242typedef Vector<LayerFragment, 1> LayerFragments;
    4343class RenderFlowThread;
     44class RenderNamedFlowFragment;
    4445class RenderStyle;
    4546class RenderRegion;
    4647
     48#if USE(ACCELERATED_COMPOSITING)
    4749typedef ListHashSet<RenderRegion*> RenderRegionList;
    4850typedef Vector<RenderLayer*> RenderLayerList;
    49 typedef HashMap<RenderRegion*, RenderLayerList> RegionToLayerListMap;
    50 typedef HashMap<RenderLayer*, RenderRegion*> LayerToRegionMap;
     51typedef HashMap<RenderNamedFlowFragment*, RenderLayerList> RegionToLayerListMap;
     52typedef HashMap<RenderLayer*, RenderNamedFlowFragment*> LayerToRegionMap;
     53#endif
    5154
    5255// RenderFlowThread is used to collect all the render objects that participate in a
     
    117120
    118121    RenderRegion* regionAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastRegion = false, RegionAutoGenerationPolicy = AllowRegionAutoGeneration);
    119 
    120     const RenderLayerList* getLayerListForRegion(RenderRegion*) const;
    121122
    122123    bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
     
    182183
    183184#if USE(ACCELERATED_COMPOSITING)
     185    // Whether any of the regions has a compositing descendant.
     186    bool hasCompositingRegionDescendant() const;
     187
    184188    void setNeedsLayerToRegionMappingsUpdate() { m_layersToRegionMappingsDirty = true; }
    185     void updateLayerToRegionMappingsIfNeeded()
     189    void updateAllLayerToRegionMappingsIfNeeded()
    186190    {
    187191        if (m_layersToRegionMappingsDirty)
    188             updateLayerToRegionMappings();
     192            updateAllLayerToRegionMappings();
    189193    }
    190 #endif
     194
     195    const RenderLayerList* getLayerListForRegion(RenderNamedFlowFragment*);
     196
     197    RenderNamedFlowFragment* regionForCompositedLayer(RenderLayer&); // By means of getRegionRangeForBox or regionAtBlockOffset.
     198    RenderNamedFlowFragment* cachedRegionForCompositedLayer(RenderLayer&);
     199
     200#endif
     201    virtual bool collectsGraphicsLayersUnderRegions() const;
    191202
    192203    void pushFlowThreadLayoutState(const RenderObject*);
     
    223234
    224235#if USE(ACCELERATED_COMPOSITING)
    225     RenderRegion* regionForCompositedLayer(RenderLayer*);
     236    bool updateAllLayerToRegionMappings();
     237
     238    // Triggers a layers' update if a layer has moved from a region to another since the last update.
     239    void updateLayerToRegionMappings(RenderLayer&, LayerToRegionMap&, RegionToLayerListMap&, bool& needsLayerUpdate);
     240    RenderNamedFlowFragment* regionForCompositedLayer(RenderLayer*);
    226241    bool updateLayerToRegionMappings();
    227242    void updateRegionForRenderLayer(RenderLayer*, LayerToRegionMap&, RegionToLayerListMap&, bool& needsLayerUpdate);
     
    305320
    306321#if USE(ACCELERATED_COMPOSITING)
     322    // To easily find the region where a layer should be painted.
    307323    OwnPtr<LayerToRegionMap> m_layerToRegionMap;
     324
     325    // To easily find the list of layers that paint in a region.
     326    OwnPtr<RegionToLayerListMap> m_regionToLayerListMap;
    308327#endif
    309328
  • trunk/Source/WebCore/rendering/RenderGeometryMap.cpp

    r156478 r157725  
    2727#include "RenderGeometryMap.h"
    2828
     29#include "RenderFlowThread.h"
    2930#include "RenderLayer.h"
    3031#include "RenderView.h"
     
    252253}
    253254
     255void RenderGeometryMap::pushRenderFlowThread(const RenderFlowThread* flowThread)
     256{
     257    m_mapping.append(RenderGeometryMapStep(flowThread, false, false, false, false));
     258    stepInserted(m_mapping.last());
     259}
     260
    254261void RenderGeometryMap::popMappingsToAncestor(const RenderLayerModelObject* ancestorRenderer)
    255262{
  • trunk/Source/WebCore/rendering/RenderGeometryMap.h

    r156478 r157725  
    3737namespace WebCore {
    3838
     39class RenderFlowThread;
    3940class RenderLayer;
    4041class RenderLayerModelObject;
     
    111112    // RenderView gets special treatment, because it applies the scroll offset only for elements inside in fixed position.
    112113    void pushView(const RenderView*, const LayoutSize& scrollOffset, const TransformationMatrix* = 0);
     114    void pushRenderFlowThread(const RenderFlowThread*);
    113115
    114116private:
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r157665 r157725  
    8585#include "RenderMarquee.h"
    8686#include "RenderNamedFlowThread.h"
     87#include "RenderRegion.h"
    8788#include "RenderReplica.h"
    8889#include "RenderSVGResourceClipper.h"
     
    40324033    for (size_t i = 0; i < list->size(); ++i) {
    40334034        RenderLayer* childLayer = list->at(i);
    4034         if (childLayer->isOutOfFlowRenderFlowThread())
     4035        if (childLayer->isFlowThreadCollectingGraphicsLayersUnderRegions())
    40354036            continue;
    40364037
     
    44444445    ASSERT_NOT_REACHED();
    44454446    return 0;
     4447}
     4448
     4449RenderLayer* RenderLayer::enclosingFlowThreadAncestor() const
     4450{
     4451    RenderLayer* curr = parent();
     4452    for (; curr && !curr->isRenderFlowThread(); curr = curr->parent()) {
     4453        if (curr->isStackingContainer() && curr->isComposited()) {
     4454            // We only adjust the position of the first level of layers.
     4455            return 0;
     4456        }
     4457    }
     4458    return curr;
     4459}
     4460
     4461bool RenderLayer::isFlowThreadCollectingGraphicsLayersUnderRegions() const
     4462{
     4463    return renderer().isRenderFlowThread() && toRenderFlowThread(renderer()).collectsGraphicsLayersUnderRegions();
    44464464}
    44474465
     
    48914909    for (int i = list->size() - 1; i >= 0; --i) {
    48924910        RenderLayer* childLayer = list->at(i);
    4893         if (childLayer->isOutOfFlowRenderFlowThread())
     4911        if (childLayer->isFlowThreadCollectingGraphicsLayersUnderRegions())
    48944912            continue;
    48954913        RenderLayer* hitLayer = 0;
     
    54985516        for (size_t i = 0; i < listSize; ++i) {
    54995517            RenderLayer* curLayer = posZOrderList->at(i);
    5500             if (flags & IncludeCompositedDescendants || !curLayer->isComposited()) {
     5518            // The RenderNamedFlowThread is ignored when we calculate the bounds of the RenderView.
     5519            if ((flags & IncludeCompositedDescendants || !curLayer->isComposited()) && !curLayer->isFlowThreadCollectingGraphicsLayersUnderRegions()) {
    55015520                LayoutRect childUnionBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
    55025521                unionBounds.unite(childUnionBounds);
     
    55115530            // RenderView will always return the size of the document, before reaching this point,
    55125531            // so there's no way we could hit a RenderNamedFlowThread here.
    5513             ASSERT(!curLayer->isOutOfFlowRenderFlowThread());
     5532            ASSERT(!curLayer->isFlowThreadCollectingGraphicsLayersUnderRegions());
    55145533            if (flags & IncludeCompositedDescendants || !curLayer->isComposited()) {
    55155534                LayoutRect curAbsBounds = curLayer->calculateLayerBounds(this, 0, descendantFlags);
     
    57345753#if USE(ACCELERATED_COMPOSITING)
    57355754    if (!renderer().documentBeingDestroyed()) {
    5736         if (renderer().isOutOfFlowRenderFlowThread())
     5755        if (isFlowThreadCollectingGraphicsLayersUnderRegions())
    57375756            toRenderFlowThread(renderer()).setNeedsLayerToRegionMappingsUpdate();
    57385757        compositor().setCompositingLayersNeedRebuild();
     
    57605779#if USE(ACCELERATED_COMPOSITING)
    57615780    if (!renderer().documentBeingDestroyed()) {
    5762         if (renderer().isOutOfFlowRenderFlowThread())
     5781        if (isFlowThreadCollectingGraphicsLayersUnderRegions())
    57635782            toRenderFlowThread(renderer()).setNeedsLayerToRegionMappingsUpdate();
    57645783        compositor().setCompositingLayersNeedRebuild();
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r157653 r157725  
    751751#if USE(ACCELERATED_COMPOSITING)
    752752    bool isComposited() const { return m_backing != 0; }
     753    bool hasCompositingDescendant() const { return m_hasCompositingDescendant; }
    753754    bool hasCompositedMask() const;
    754755    RenderLayerBacking* backing() const { return m_backing.get(); }
     
    814815#endif
    815816   
     817    bool isRenderFlowThread() const { return renderer().isRenderFlowThread(); }
    816818    bool isOutOfFlowRenderFlowThread() const { return renderer().isOutOfFlowRenderFlowThread(); }
     819    bool isInsideFlowThread() const { return renderer().flowThreadState() != RenderObject::NotInsideFlowThread; }
     820    bool isInsideOutOfFlowThread() const { return renderer().flowThreadState() == RenderObject::InsideOutOfFlowThread; }
     821    bool isDirtyRenderFlowThread() const
     822    {
     823        ASSERT(isRenderFlowThread());
     824        return m_zOrderListsDirty || m_normalFlowListDirty;
     825    }
     826
     827    bool isFlowThreadCollectingGraphicsLayersUnderRegions() const;
     828
     829    RenderLayer* enclosingFlowThreadAncestor() const;
    817830
    818831private:
     
    10831096   
    10841097#if USE(ACCELERATED_COMPOSITING)   
    1085     bool hasCompositingDescendant() const { return m_hasCompositingDescendant; }
    10861098    void setHasCompositingDescendant(bool b)  { m_hasCompositingDescendant = b; }
    10871099   
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r157378 r157725  
    4949#include "PluginViewBase.h"
    5050#include "ProgressTracker.h"
     51#include "RenderFlowThread.h"
    5152#include "RenderIFrame.h"
    5253#include "RenderImage.h"
    5354#include "RenderLayerCompositor.h"
    5455#include "RenderEmbeddedObject.h"
     56#include "RenderNamedFlowFragment.h"
     57#include "RenderRegion.h"
    5558#include "RenderVideo.h"
    5659#include "RenderView.h"
     
    407410
    408411    if (layerOrAncestorIsTransformedOrUsingCompositedScrolling(m_owningLayer))
     412        return false;
     413
     414    if (m_owningLayer.isFlowThreadCollectingGraphicsLayersUnderRegions())
    409415        return false;
    410416
     
    645651    relativeCompositingBounds.moveBy(delta);
    646652
     653    adjustAncestorCompositingBoundsForFlowThread(ancestorCompositingBounds, compAncestor);
     654
    647655    IntPoint graphicsLayerParentLocation;
    648656    if (compAncestor && compAncestor->backing()->hasClippingLayer()) {
     
    842850}
    843851
     852void RenderLayerBacking::adjustAncestorCompositingBoundsForFlowThread(IntRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const
     853{
     854    if (!m_owningLayer.isInsideFlowThread())
     855        return;
     856
     857    RenderLayer* flowThreadLayer = m_owningLayer.isInsideOutOfFlowThread() ? m_owningLayer.stackingContainer() : m_owningLayer.enclosingFlowThreadAncestor();
     858    if (flowThreadLayer && flowThreadLayer->isRenderFlowThread()) {
     859        RenderFlowThread& flowThread = toRenderFlowThread(flowThreadLayer->renderer());
     860        if (m_owningLayer.isFlowThreadCollectingGraphicsLayersUnderRegions()) {
     861            // The RenderNamedFlowThread is not composited, as we need it to paint the
     862            // background layer of the regions. We need to compensate for that by manually
     863            // subtracting the position of the flow-thread.
     864            IntPoint flowPosition;
     865            flowThreadLayer->convertToPixelSnappedLayerCoords(compositingAncestor, flowPosition);
     866            ancestorCompositingBounds.moveBy(flowPosition);
     867        }
     868
     869        // Move the ancestor position at the top of the region where the composited layer is going to display.
     870        RenderNamedFlowFragment* parentRegion = flowThread.cachedRegionForCompositedLayer(m_owningLayer);
     871        if (parentRegion) {
     872            IntPoint flowDelta;
     873            m_owningLayer.convertToPixelSnappedLayerCoords(flowThreadLayer, flowDelta);
     874            parentRegion->adjustRegionBoundsFromFlowThreadPortionRect(flowDelta, ancestorCompositingBounds);
     875            RenderBoxModelObject* layerOwner = toRenderBoxModelObject(parentRegion->layerOwner());
     876            if (layerOwner->hasLayer() && layerOwner->layer()->backing()) {
     877                // Make sure that the region propagates its borders, paddings, outlines or box-shadows to layers inside it.
     878                // Note that the composited bounds of the RenderRegion are already calculated
     879                // because RenderLayerCompositor::rebuildCompositingLayerTree will only
     880                // iterate on the content of the region after the region itself is computed.
     881                ancestorCompositingBounds.moveBy(roundedIntPoint(layerOwner->layer()->backing()->compositedBounds().location()));
     882                ancestorCompositingBounds.move(-layerOwner->borderAndPaddingStart(), -layerOwner->borderAndPaddingBefore());
     883            }
     884        }
     885    }
     886}
     887
    844888void RenderLayerBacking::updateDirectlyCompositedContents(bool isSimpleContainer, bool& didUpdateContentsRect)
    845889{
     
    15711615        return false;
    15721616
    1573     if (renderer().isRenderRegion())
     1617    if (renderer().isRenderNamedFlowFragmentContainer())
    15741618        return false;
    15751619
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r157378 r157725  
    279279    void paintIntoLayer(const GraphicsLayer*, GraphicsContext*, const IntRect& paintDirtyRect, PaintBehavior, GraphicsLayerPaintingPhase);
    280280
     281    // Helper function for updateGraphicsLayerGeometry.
     282    void adjustAncestorCompositingBoundsForFlowThread(IntRect& ancestorCompositingBounds, const RenderLayer* compositingAncestor) const;
     283
    281284    static CSSPropertyID graphicsLayerToCSSProperty(AnimatedPropertyID);
    282285    static AnimatedPropertyID cssToGraphicsLayerProperty(CSSPropertyID);
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r157333 r157725  
    4747#include "Page.h"
    4848#include "RenderEmbeddedObject.h"
     49#include "RenderFlowThread.h"
    4950#include "RenderFullScreen.h"
    5051#include "RenderGeometryMap.h"
    5152#include "RenderIFrame.h"
    5253#include "RenderLayerBacking.h"
     54#include "RenderNamedFlowFragment.h"
    5355#include "RenderReplica.h"
    5456#include "RenderVideo.h"
     
    932934    layer.updateLayerListsIfNeeded();
    933935
    934     if (layer.isOutOfFlowRenderFlowThread())
    935         return;
     936    if (layer.isFlowThreadCollectingGraphicsLayersUnderRegions()) {
     937        RenderFlowThread& flowThread = toRenderFlowThread(layer.renderer());
     938        layer.setHasCompositingDescendant(flowThread.hasCompositingRegionDescendant());
     939        return;
     940    }
    936941
    937942    if (overlapMap)
     
    10141019        }
    10151020    }
     1021
     1022    if (layer.renderer().isRenderNamedFlowFragmentContainer()) {
     1023        // We are going to collect layers from the RenderFlowThread into the GraphicsLayer of the parent of the
     1024        // anonymous RenderRegion, but first we need to make sure that the parent itself of the region is going to
     1025        // have a composited layer. We only want to make regions composited when there's an actual layer that we
     1026        // need to move to that region.
     1027        computeRegionCompositingRequirements(toRenderBlockFlow(layer.renderer()).renderNamedFlowFragment(), overlapMap, childState, layersChanged, anyDescendantHas3DTransform);
     1028    }
     1029
    10161030   
    10171031    if (Vector<RenderLayer*>* normalFlowList = layer.normalFlowList()) {
     
    11171131}
    11181132
     1133void RenderLayerCompositor::computeRegionCompositingRequirements(RenderNamedFlowFragment* region, OverlapMap* overlapMap, CompositingState& childState, bool& layersChanged, bool& anyDescendantHas3DTransform)
     1134{
     1135    if (!region->isValid())
     1136        return;
     1137
     1138    RenderFlowThread* flowThread = region->flowThread();
     1139   
     1140    if (overlapMap)
     1141        overlapMap->geometryMap().pushRenderFlowThread(flowThread);
     1142
     1143    if (const RenderLayerList* layerList = flowThread->getLayerListForRegion(region)) {
     1144        for (size_t i = 0, listSize = layerList->size(); i < listSize; ++i) {
     1145            RenderLayer& curLayer = *layerList->at(i);
     1146            ASSERT(flowThread->regionForCompositedLayer(curLayer) == region);
     1147            computeCompositingRequirements(flowThread->layer(), curLayer, overlapMap, childState, layersChanged, anyDescendantHas3DTransform);
     1148        }
     1149    }
     1150
     1151    if (overlapMap)
     1152        overlapMap->geometryMap().popMappingsToAncestor(region->layerOwner());
     1153}
     1154
    11191155void RenderLayerCompositor::setCompositingParent(RenderLayer& childLayer, RenderLayer* parentLayer)
    11201156{
     
    11601196    // have been processed. computeCompositingRequirements() will already have done the repaint if necessary.
    11611197
    1162     if (layer.isOutOfFlowRenderFlowThread())
     1198    // Do not iterate the RenderFlowThread directly. We are going to collect composited layers as part of regions.
     1199    if (layer.isFlowThreadCollectingGraphicsLayersUnderRegions())
    11631200        return;
    11641201   
     
    12101247            childList.append(layerBacking->foregroundLayer());
    12111248    }
     1249
     1250    if (layer.renderer().isRenderNamedFlowFragmentContainer())
     1251        rebuildRegionCompositingLayerTree(toRenderBlockFlow(layer.renderer()).renderNamedFlowFragment(), layerChildren, depth + 1);
    12121252
    12131253    if (Vector<RenderLayer*>* normalFlowList = layer.normalFlowList()) {
     
    12511291
    12521292        childLayersOfEnclosingLayer.append(layerBacking->childForSuperlayers());
     1293    }
     1294}
     1295
     1296void RenderLayerCompositor::rebuildRegionCompositingLayerTree(RenderNamedFlowFragment* region, Vector<GraphicsLayer*>& childList, int depth)
     1297{
     1298    if (!region->isValid())
     1299        return;
     1300
     1301    RenderFlowThread* flowThread = region->flowThread();
     1302    ASSERT(flowThread->collectsGraphicsLayersUnderRegions());
     1303    if (const RenderLayerList* layerList = flowThread->getLayerListForRegion(region)) {
     1304        for (size_t i = 0, listSize = layerList->size(); i < listSize; ++i) {
     1305            RenderLayer& curLayer = *layerList->at(i);
     1306            ASSERT(flowThread->regionForCompositedLayer(curLayer) == region);
     1307            rebuildCompositingLayerTree(curLayer, childList, depth + 1);
     1308        }
    12531309    }
    12541310}
     
    17721828bool RenderLayerCompositor::canBeComposited(const RenderLayer& layer) const
    17731829{
    1774     // FIXME: We disable accelerated compositing for elements in a RenderFlowThread as it doesn't work properly.
    1775     // See http://webkit.org/b/84900 to re-enable it.
    1776     return m_hasAcceleratedCompositing && layer.isSelfPaintingLayer() && layer.renderer().flowThreadState() == RenderElement::NotInsideFlowThread;
     1830    if (m_hasAcceleratedCompositing && layer.isSelfPaintingLayer()) {
     1831        if (!layer.isInsideFlowThread())
     1832            return true;
     1833
     1834        // CSS Regions flow threads do not need to be composited as we use composited RenderRegions
     1835        // to render the background of the RenderFlowThread.
     1836        if (layer.isRenderFlowThread())
     1837            return false;
     1838
     1839        // A faster way of saying layer.enclosingFlowThreadLayer()->isFlowThreadCollectingGraphicsLayersUnderRegions()
     1840        return layer.isInsideOutOfFlowThread();
     1841    }
     1842    return false;
    17771843}
    17781844
     
    21552221
    21562222    // When a layer has composited descendants, some effects, like 2d transforms, filters, masks etc must be implemented
    2157     // via compositing so that they also apply to those composited descdendants.
    2158     if (hasCompositedDescendants && (layer.transform() || renderer.createsGroup() || renderer.hasReflection())) {
     2223    // via compositing so that they also apply to those composited descendants.
     2224    if (hasCompositedDescendants && (layer.transform() || renderer.createsGroup() || renderer.hasReflection() || renderer.isRenderNamedFlowFragmentContainer())) {
    21592225        reason = RenderLayer::IndirectCompositingForGraphicalEffect;
    21602226        return true;
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r156622 r157725  
    4141class GraphicsLayerUpdater;
    4242class RenderEmbeddedObject;
     43class RenderNamedFlowFragment;
    4344class RenderVideo;
    4445class RenderWidget;
     
    142143    void scheduleCompositingLayerUpdate();
    143144
    144     // Update the maps that we use to distribute layers to coresponding RenderRegions.
     145    // Update the maps that we use to distribute layers to coresponding regions.
    145146    void updateRenderFlowThreadLayersIfNeeded();
    146147   
     
    324325    // Returns true if any layer's compositing changed
    325326    void computeCompositingRequirements(RenderLayer* ancestorLayer, RenderLayer&, OverlapMap*, struct CompositingState&, bool& layersChanged, bool& descendantHas3DTransform);
     327
     328    void computeRegionCompositingRequirements(RenderNamedFlowFragment*, OverlapMap*, CompositingState&, bool& layersChanged, bool& anyDescendantHas3DTransform);
    326329   
    327330    // Recurses down the tree, parenting descendant compositing layers and collecting an array of child layers for the current compositing layer.
    328331    void rebuildCompositingLayerTree(RenderLayer&, Vector<GraphicsLayer*>& childGraphicsLayersOfEnclosingLayer, int depth);
     332
     333    // Recurses down the RenderFlowThread tree, parenting descendant compositing layers and collecting an array of child
     334    // layers for the current compositing layer corresponding to the anonymous region (that belongs to the region's parent).
     335    void rebuildRegionCompositingLayerTree(RenderNamedFlowFragment*, Vector<GraphicsLayer*>& childList, int depth);
    329336
    330337    // Recurses down the tree, updating layer geometry only.
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp

    r157408 r157725  
    509509}
    510510
     511void RenderMultiColumnSet::adjustRegionBoundsFromFlowThreadPortionRect(const IntPoint& layerOffset, IntRect& regionBounds)
     512{
     513    LayoutUnit layerLogicalTop = isHorizontalWritingMode() ? layerOffset.y() : layerOffset.x();
     514    unsigned startColumn = columnIndexAtOffset(layerLogicalTop);
     515   
     516    LayoutUnit colGap = columnGap();
     517    LayoutUnit colLogicalWidth = computedColumnWidth();
     518   
     519    LayoutRect flowThreadPortion = flowThreadPortionRectAt(startColumn);
     520    LayoutPoint translationOffset;
     521
     522    LayoutUnit inlineOffset = startColumn * (colLogicalWidth + colGap);
     523    if (!style()->isLeftToRightDirection())
     524        inlineOffset = -inlineOffset;
     525    translationOffset.setX(inlineOffset);
     526       
     527    LayoutUnit blockOffset = isHorizontalWritingMode() ? -flowThreadPortion.y() : -flowThreadPortion.x();
     528    if (isFlippedBlocksWritingMode(style()->writingMode()))
     529        blockOffset = -blockOffset;
     530    translationOffset.setY(blockOffset);
     531   
     532    if (!isHorizontalWritingMode())
     533        translationOffset = translationOffset.transposedPoint();
     534
     535    // FIXME: The translation needs to include the multicolumn set's content offset within the
     536    // multicolumn block as well. This won't be an issue until we start creating multiple multicolumn sets.
     537   
     538    regionBounds.moveBy(roundedIntPoint(-translationOffset));
     539}
     540
    511541const char* RenderMultiColumnSet::renderName() const
    512542{   
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.h

    r157408 r157725  
    119119    virtual void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) OVERRIDE;
    120120
     121    virtual void adjustRegionBoundsFromFlowThreadPortionRect(const IntPoint& layerOffset, IntRect& regionBounds) OVERRIDE;
     122
    121123    virtual const char* renderName() const;
    122124   
  • trunk/Source/WebCore/rendering/RenderNamedFlowFragment.h

    r157567 r157725  
    5252    bool isPseudoElementRegion() const { return parent() && parent()->isPseudoElement(); }
    5353
     54    // When the content inside the region requires the region to have a layer, the layer will be created on the region's
     55    // parent renderer instead.
     56    // This method returns that renderer holding the layer.
     57    // The return value may be null.
     58    RenderLayerModelObject* layerOwner() const { return parent() && parent()->isRenderLayerModelObject() ?
     59        toRenderLayerModelObject(parent()) : nullptr; }
     60
    5461protected:
    5562    virtual bool shouldHaveAutoLogicalHeight() const;
  • trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp

    r157665 r157725  
    4747RenderNamedFlowThread::RenderNamedFlowThread(Document& document, PassRefPtr<WebKitNamedFlow> namedFlow)
    4848    : RenderFlowThread(document)
     49    , m_flowThreadChildList(adoptPtr(new FlowThreadChildList()))
    4950    , m_overset(true)
    5051    , m_namedFlow(namedFlow)
     
    100101RenderObject* RenderNamedFlowThread::nextRendererForNode(Node* node) const
    101102{
    102     FlowThreadChildList::const_iterator it = m_flowThreadChildList.begin();
    103     FlowThreadChildList::const_iterator end = m_flowThreadChildList.end();
     103    FlowThreadChildList::const_iterator it = m_flowThreadChildList->begin();
     104    FlowThreadChildList::const_iterator end = m_flowThreadChildList->end();
    104105
    105106    for (; it != end; ++it) {
     
    116117RenderObject* RenderNamedFlowThread::previousRendererForNode(Node* node) const
    117118{
    118     if (m_flowThreadChildList.isEmpty())
     119    if (m_flowThreadChildList->isEmpty())
    119120        return 0;
    120121
    121     FlowThreadChildList::const_iterator begin = m_flowThreadChildList.begin();
    122     FlowThreadChildList::const_iterator end = m_flowThreadChildList.end();
     122    FlowThreadChildList::const_iterator begin = m_flowThreadChildList->begin();
     123    FlowThreadChildList::const_iterator end = m_flowThreadChildList->end();
    123124    FlowThreadChildList::const_iterator it = end;
    124125
     
    150151    RenderObject* beforeChild = nextRendererForNode(childNode);
    151152    if (beforeChild)
    152         m_flowThreadChildList.insertBefore(beforeChild, newChild);
     153        m_flowThreadChildList->insertBefore(beforeChild, newChild);
    153154    else
    154         m_flowThreadChildList.add(newChild);
     155        m_flowThreadChildList->add(newChild);
    155156}
    156157
    157158void RenderNamedFlowThread::removeFlowChild(RenderObject* child)
    158159{
    159     m_flowThreadChildList.remove(child);
     160    m_flowThreadChildList->remove(child);
    160161}
    161162
     
    728729}
    729730
    730 }
     731#if USE(ACCELERATED_COMPOSITING)
     732bool RenderNamedFlowThread::collectsGraphicsLayersUnderRegions() const
     733{
     734    // We only need to map layers to regions for named flow threads.
     735    // Multi-column threads are displayed on top of the regions and do not require
     736    // distributing the layers.
     737
     738    return true;
     739}
     740#endif
     741
     742}
  • trunk/Source/WebCore/rendering/RenderNamedFlowThread.h

    r157653 r157725  
    5858    void addFlowChild(RenderObject* newChild);
    5959    void removeFlowChild(RenderObject*);
    60     bool hasChildren() const { return !m_flowThreadChildList.isEmpty(); }
     60    bool hasChildren() const { return !m_flowThreadChildList->isEmpty(); }
    6161#ifndef NDEBUG
    62     bool hasChild(RenderObject* child) const { return m_flowThreadChildList.contains(child); }
     62    bool hasChild(RenderObject* child) const { return m_flowThreadChildList->contains(child); }
    6363#endif
    6464
     
    8080    bool isMarkedForDestruction() const;
    8181    void getRanges(Vector<RefPtr<Range>>&, const RenderRegion*) const;
     82
     83#if USE(ACCELERATED_COMPOSITING)
     84    virtual bool collectsGraphicsLayersUnderRegions() const OVERRIDE;
     85#endif
    8286
    8387protected:
     
    120124    // Holds the sorted children of a named flow. This is the only way we can get the ordering right.
    121125    typedef ListHashSet<RenderObject*> FlowThreadChildList;
    122     FlowThreadChildList m_flowThreadChildList;
     126    OwnPtr<FlowThreadChildList> m_flowThreadChildList;
    123127
    124128    NamedFlowContentElements m_contentElements;
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r157653 r157725  
    731731}
    732732
     733void RenderRegion::adjustRegionBoundsFromFlowThreadPortionRect(const IntPoint& layerOffset, IntRect& regionBounds)
     734{
     735    LayoutRect flippedFlowThreadPortionRect = flowThreadPortionRect();
     736    flowThread()->flipForWritingMode(flippedFlowThreadPortionRect);
     737    regionBounds.moveBy(roundedIntPoint(flippedFlowThreadPortionRect.location()));
     738
     739    UNUSED_PARAM(layerOffset);
     740}
     741
     742
    733743RenderOverflow* RenderRegion::ensureOverflowForBox(const RenderBox* box)
    734744{
  • trunk/Source/WebCore/rendering/RenderRegion.h

    r157653 r157725  
    138138    virtual void collectLayerFragments(LayerFragments&, const LayoutRect&, const LayoutRect&) { }
    139139
     140    virtual void adjustRegionBoundsFromFlowThreadPortionRect(const IntPoint& layerOffset, IntRect& regionBounds); // layerOffset is needed for multi-column.
     141
    140142    void addLayoutOverflowForBox(const RenderBox*, const LayoutRect&);
    141143    void addVisualOverflowForBox(const RenderBox*, const LayoutRect&);
     
    246248}
    247249
     250inline RenderRegion& toRenderRegion(RenderObject& object)
     251{
     252    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderRegion());
     253    return static_cast<RenderRegion&>(object);
     254}
     255
     256inline const RenderRegion& toRenderRegion(const RenderObject& object)
     257{
     258    ASSERT_WITH_SECURITY_IMPLICATION(object.isRenderRegion());
     259    return static_cast<const RenderRegion&>(object);
     260}
     261
    248262// This will catch anyone doing an unnecessary cast.
    249263void toRenderRegion(const RenderRegion*);
     264void toRenderRegion(const RenderRegion&);
    250265
    251266} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderTreeAsText.cpp

    r157567 r157725  
    778778        size_t layerCount = 0;
    779779        for (unsigned i = 0; i != posList->size(); ++i)
    780             if (!posList->at(i)->isOutOfFlowRenderFlowThread())
     780            if (!posList->at(i)->isFlowThreadCollectingGraphicsLayersUnderRegions())
    781781                ++layerCount;
    782782        if (layerCount) {
    783783            int currIndent = indent;
    784             if (behavior & RenderAsTextShowLayerNesting) {
    785                 writeIndent(ts, indent);
    786                 ts << " positive z-order list(" << layerCount << ")\n";
    787                 ++currIndent;
    788             }
    789             for (unsigned i = 0; i != posList->size(); ++i) {
    790                 if (!posList->at(i)->isOutOfFlowRenderFlowThread())
    791                     writeLayers(ts, rootLayer, posList->at(i), paintDirtyRect, currIndent, behavior);
     784            // We only print the header if there's at list a non-RenderNamedFlowThread part of the list.
     785            if (!posList->size() || !posList->at(0)->isFlowThreadCollectingGraphicsLayersUnderRegions()) {
     786                if (behavior & RenderAsTextShowLayerNesting) {
     787                    writeIndent(ts, indent);
     788                    ts << " positive z-order list(" << posList->size() << ")\n";
     789                    ++currIndent;
     790                }
     791                for (unsigned i = 0; i != posList->size(); ++i) {
     792                    // Do not print named flows twice.
     793                    if (!posList->at(i)->isFlowThreadCollectingGraphicsLayersUnderRegions())
     794                        writeLayers(ts, rootLayer, posList->at(i), paintDirtyRect, currIndent, behavior);
     795                }
    792796            }
    793797        }
Note: See TracChangeset for help on using the changeset viewer.