[CSS Regions] RenderRegions should have a RenderLayer+Backing when they contain a...
authorachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2013 21:36:05 +0000 (21:36 +0000)
committerachicu@adobe.com <achicu@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2013 21:36:05 +0000 (21:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117365

Reviewed by David Hyatt.

Source/WebCore:

After the RenderFlowThread has a new layout we need to check if any of the children layers
had been moved to a new render region. We are only checking for the first level of layers,
as they are the only ones supported right now. Also, added code to make Regions require a layer
based on the layers that fit in their clipping area.

Tests: fast/regions/layers/dynamic-layer-added-with-no-layout.html
       fast/regions/layers/dynamic-layer-removed-with-no-layout.html
       fast/regions/layers/float-region-promoted-to-layer.html
       fast/regions/layers/regions-promoted-to-layers-horizontal-bt.html
       fast/regions/layers/regions-promoted-to-layers-vertical-lr.html
       fast/regions/layers/regions-promoted-to-layers-vertical-rl.html
       fast/regions/layers/regions-promoted-to-layers.html

* rendering/FlowThreadController.cpp:
(WebCore::FlowThreadController::updateRenderFlowThreadLayersIfNeeded): Iterate on all the flow threads and updateLayerToRegionMappings if needed.
* rendering/FlowThreadController.h:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateLocalFloatingObjectsForPaintingContainer): Checks if the FloatingObject
needs to be painted by the current block or not.
(WebCore::RenderBlock::updateFloatingObjectsPaintingContainer): Helper function to lookup what is the right
container that would need to paint a FloatingObject.
(WebCore::RenderBlock::updateAllDescendantsFloatingObjectsPaintingContainer):
* rendering/RenderBlock.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::outermostBlockContainingFloatingObject): Looks up the ancestor RenderBlock that contains all
the FloatingObjects of a float.
(WebCore::RenderBox::removeFloatingOrPositionedChildFromBlockLists): Extracted the code for outermostBlockContainingFloatingObject
into its own method.
(WebCore::RenderBox::updatePaintingContainerForFloatingObject): Helper method to update the "m_shouldPaint" flag
of all the FloatingObjects created for a floating RenderObject. Normally, that flag is maintained during layout,
but we need to patch it for the floating RenderRegions after the layout is already finished.
(WebCore::RenderBox::updateLayerIfNeeded): Overwrite of the RenderLayerModelObject::updateLayerIfNeeded that is also
calling updatePaintingContainerForFloatingObject if a new layer was created or destroyed.
* rendering/RenderBox.h:
* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::layout): Added code to call updateLayerToRegionMappings when needed.
(WebCore::RenderFlowThread::regionForCompositedLayer): Looks up the first RenderRegion to display a specific layer.
It only cares about the top most point of the element and ignores transforms.
(WebCore::RenderFlowThread::updateRegionForRenderLayer): Helper method to update the mapped region of a layer.
(WebCore::RenderFlowThread::updateLayerToRegionMappings): Iterates all the first level layers of the flow thread
and updates the region. Will return true if there was any change.
* rendering/RenderFlowThread.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::dirtyZOrderLists): When new layers are added or removed we need to update the layer map in the flow thread.
(WebCore::RenderLayer::dirtyNormalFlowList):
(WebCore::RenderLayer::shouldBeNormalFlowOnly): CSS Regions might become layers because they contain RenderLayers,
but they should not become stacking contexts for that reason. This will prevent the RenderRegions from rendering
in front of other layers.
(WebCore::RenderLayer::shouldBeSelfPaintingLayer):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateCompositingLayers): Call updateRenderFlowThreadLayersIfNeeded when there's a layer hierarchy update.
(WebCore::RenderLayerCompositor::updateRenderFlowThreadLayersIfNeeded): Update the render flow thread layer maps when they are dirty.
* rendering/RenderLayerCompositor.h:
* rendering/RenderLayer.h:
(WebCore::RenderLayer::isDirtyRenderFlowThread): Used to check if the RenderLayers had changed their order,
so that we can update the list of layers associated with a region. In a following patch we will need to
rebuild the composited layers.
* rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::updateLayerIfNeeded): Adds or removes a layer when the "requiresLayer" changes
after the styleDidChange already happened. This is needed for Regions as we only know if they still require a layer,
only after the content of the flow thread is computed.
* rendering/RenderLayerModelObject.h:
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::RenderRegion):
(WebCore::RenderRegion::setRequiresLayerForCompositing):
* rendering/RenderRegion.h:
(WebCore::RenderRegion::requiresLayer):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeRenderRegionList): Updated the output to print the fact that the layer has a layer.

LayoutTests:

Added new tests for cases when CSS Regions are promoted to RenderLayers because
they contain elements that might need to become composited.

* fast/regions/layers/dynamic-layer-added-with-no-layout-expected.png: Added.
* fast/regions/layers/dynamic-layer-added-with-no-layout-expected.txt: Added.
* fast/regions/layers/dynamic-layer-added-with-no-layout.html: Added.
* fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.png: Added.
* fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.txt: Added.
* fast/regions/layers/dynamic-layer-removed-with-no-layout.html: Added.
* fast/regions/layers/float-region-promoted-to-layer-expected.html: Added.
* fast/regions/layers/float-region-promoted-to-layer.html: Added.
* fast/regions/layers/regions-promoted-to-layers-expected.txt: Added.
* fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.txt: Added.
* fast/regions/layers/regions-promoted-to-layers-horizontal-bt.html: Added.
* fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.txt: Added.
* fast/regions/layers/regions-promoted-to-layers-vertical-lr.html: Added.
* fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.txt: Added.
* fast/regions/layers/regions-promoted-to-layers-vertical-rl.html: Added.
* fast/regions/layers/regions-promoted-to-layers.html: Added.

Updated existing tests that now have CSS Regions that require a RenderLayer.
* fast/regions/autoheight-regions-mark-expected.txt:
* fast/repaint/overflow-flipped-writing-mode-block-in-regions-expected.txt:
* fast/repaint/region-painting-via-layout-expected.txt:
* platform/mac/fast/regions/overflow-in-uniform-regions-dynamic-expected.txt:
* platform/mac/fast/regions/overflow-in-variable-width-regions-expected.txt:
* platform/mac/fast/regions/overflow-moving-below-floats-in-variable-width-regions-expected.txt:
* platform/mac/fast/regions/overflow-not-moving-below-floats-in-variable-width-regions-expected.txt:
* platform/mac/fast/regions/overflow-rtl-in-variable-width-regions-expected.txt:
* platform/mac/fast/regions/overflow-size-change-in-variable-width-regions-expected.txt:
* platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.txt:
* platform/mac/fast/repaint/line-flow-with-floats-in-regions-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@154072 268f45cc-cd09-0410-ab3c-d52691b4dbfc

51 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/regions/autoheight-regions-mark-expected.txt
LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout-expected.png [new file with mode: 0644]
LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout.html [new file with mode: 0644]
LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.png [new file with mode: 0644]
LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout.html [new file with mode: 0644]
LayoutTests/fast/regions/layers/float-region-promoted-to-layer-expected.html [new file with mode: 0644]
LayoutTests/fast/regions/layers/float-region-promoted-to-layer.html [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-expected.png [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.png [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt.html [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.png [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr.html [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.png [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.txt [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl.html [new file with mode: 0644]
LayoutTests/fast/regions/layers/regions-promoted-to-layers.html [new file with mode: 0644]
LayoutTests/fast/repaint/overflow-flipped-writing-mode-block-in-regions-expected.txt
LayoutTests/fast/repaint/region-painting-via-layout-expected.txt
LayoutTests/platform/mac/fast/regions/overflow-in-uniform-regions-dynamic-expected.txt
LayoutTests/platform/mac/fast/regions/overflow-in-variable-width-regions-expected.txt
LayoutTests/platform/mac/fast/regions/overflow-moving-below-floats-in-variable-width-regions-expected.txt
LayoutTests/platform/mac/fast/regions/overflow-not-moving-below-floats-in-variable-width-regions-expected.txt
LayoutTests/platform/mac/fast/regions/overflow-rtl-in-variable-width-regions-expected.txt
LayoutTests/platform/mac/fast/regions/overflow-size-change-in-variable-width-regions-expected.txt
LayoutTests/platform/mac/fast/regions/region-dynamic-after-before-expected.txt
LayoutTests/platform/mac/fast/regions/region-generated-content-before-after-expected.txt
LayoutTests/platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.txt
LayoutTests/platform/mac/fast/repaint/line-flow-with-floats-in-regions-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/FlowThreadController.cpp
Source/WebCore/rendering/FlowThreadController.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebCore/rendering/RenderLayerModelObject.cpp
Source/WebCore/rendering/RenderLayerModelObject.h
Source/WebCore/rendering/RenderRegion.cpp
Source/WebCore/rendering/RenderRegion.h
Source/WebCore/rendering/RenderTreeAsText.cpp

index 397c0c3..8e90d70 100644 (file)
@@ -1,3 +1,43 @@
+2013-08-14  Alexandru Chiculita  <achicu@adobe.com>
+
+        [CSS Regions] RenderRegions should have a RenderLayer+Backing when they contain a Composited RenderLayer
+        https://bugs.webkit.org/show_bug.cgi?id=117365
+
+        Reviewed by David Hyatt.
+
+        Added new tests for cases when CSS Regions are promoted to RenderLayers because
+        they contain elements that might need to become composited.
+
+        * fast/regions/layers/dynamic-layer-added-with-no-layout-expected.png: Added.
+        * fast/regions/layers/dynamic-layer-added-with-no-layout-expected.txt: Added.
+        * fast/regions/layers/dynamic-layer-added-with-no-layout.html: Added.
+        * fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.png: Added.
+        * fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.txt: Added.
+        * fast/regions/layers/dynamic-layer-removed-with-no-layout.html: Added.
+        * fast/regions/layers/float-region-promoted-to-layer-expected.html: Added.
+        * fast/regions/layers/float-region-promoted-to-layer.html: Added.
+        * fast/regions/layers/regions-promoted-to-layers-expected.txt: Added.
+        * fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.txt: Added.
+        * fast/regions/layers/regions-promoted-to-layers-horizontal-bt.html: Added.
+        * fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.txt: Added.
+        * fast/regions/layers/regions-promoted-to-layers-vertical-lr.html: Added.
+        * fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.txt: Added.
+        * fast/regions/layers/regions-promoted-to-layers-vertical-rl.html: Added.
+        * fast/regions/layers/regions-promoted-to-layers.html: Added.
+
+        Updated existing tests that now have CSS Regions that require a RenderLayer.
+        * fast/regions/autoheight-regions-mark-expected.txt:
+        * fast/repaint/overflow-flipped-writing-mode-block-in-regions-expected.txt:
+        * fast/repaint/region-painting-via-layout-expected.txt:
+        * platform/mac/fast/regions/overflow-in-uniform-regions-dynamic-expected.txt:
+        * platform/mac/fast/regions/overflow-in-variable-width-regions-expected.txt:
+        * platform/mac/fast/regions/overflow-moving-below-floats-in-variable-width-regions-expected.txt:
+        * platform/mac/fast/regions/overflow-not-moving-below-floats-in-variable-width-regions-expected.txt:
+        * platform/mac/fast/regions/overflow-rtl-in-variable-width-regions-expected.txt:
+        * platform/mac/fast/regions/overflow-size-change-in-variable-width-regions-expected.txt:
+        * platform/mac/fast/repaint/japanese-rl-selection-repaint-in-regions-expected.txt:
+        * platform/mac/fast/repaint/line-flow-with-floats-in-regions-expected.txt:
+
 2013-08-14  Andreas Kling  <akling@apple.com>
 
         <http://webkit.org/b/119520> REGRESSION(154062): fast/repaint/caret-jump-between-nodes.html flakes on bots.
index fa58258..bc4164c 100644 (file)
@@ -24,12 +24,12 @@ Flow Threads
     layer at (0,0) size 50x450
       RenderNamedFlowThread at (0,0) size 50x450
   Regions for flow 'flow3'
-    RenderRegion {DIV} #region3
+    RenderRegion {DIV} #region3 hasLayer
   Thread with flow-name 'flow4'
     layer at (0,0) size 650x50
       RenderNamedFlowThread at (0,0) size 650x50
   Regions for flow 'flow4'
-    RenderRegion {DIV} #region4
+    RenderRegion {DIV} #region4 hasLayer
   Thread with flow-name 'flow5'
   Regions for flow 'flow5'
     RenderRegion {DIV} #region5 hasAutoLogicalHeight
diff --git a/LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout-expected.png b/LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout-expected.png
new file mode 100644 (file)
index 0000000..e51db95
Binary files /dev/null and b/LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout-expected.png differ
diff --git a/LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout-expected.txt b/LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout-expected.txt
new file mode 100644 (file)
index 0000000..9e9b6e0
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x60
+  RenderBlock {HTML} at (0,0) size 800x60
+    RenderBody {BODY} at (8,8) size 784x0
+      RenderRegion {DIV} at (0,0) size 52x52 [border: (1px solid #000000)]
+      RenderRegion {DIV} at (104,0) size 52x52 [border: (1px solid #000000)]
+layer at (60,8) size 52x52
+  RenderRegion {DIV} at (52,0) size 52x52 [border: (1px solid #000000)]
+Flow Threads
+  Thread with flow-name 'article'
+    layer at (0,0) size 50x150
+      RenderNamedFlowThread at (0,0) size 50x150
+        RenderBlock {DIV} at (0,0) size 50x150
+          RenderBlock {DIV} at (0,0) size 50x50 [bgcolor=#008000]
+          RenderBlock {DIV} at (0,100) size 50x50 [bgcolor=#FFA500]
+    layer at (0,50) size 50x50
+      RenderBlock {DIV} at (0,50) size 50x50 [bgcolor=#0000FF]
+  Regions for flow 'article'
+    RenderRegion {DIV}
+    RenderRegion {DIV} #should-have-layer hasLayer
+    RenderRegion {DIV}
diff --git a/LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout.html b/LayoutTests/fast/regions/layers/dynamic-layer-added-with-no-layout.html
new file mode 100644 (file)
index 0000000..abc00f6
--- /dev/null
@@ -0,0 +1,33 @@
+<!doctype html>
+<html>
+    <!--
+    Testing that regions become layers as required by the content that display in those regions. 
+    There should be three boxes (green, blue, orange) with black borders. 
+    The test passes if the second region becomes a RenderLayer.
+    -->
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            .layer
+            {
+                -webkit-transform: translateZ(0px);
+            }
+        </style>
+    </head>
+    <body>
+        <div class="flowArticle">
+            <div class="greenBox"></div>
+            <div id="test-box" class="blueBox"></div>
+            <div class="orangeBox"></div>
+        </div>
+        <div class="regionArticle borderBox"></div>
+        <div id="should-have-layer" class="regionArticle borderBox"></div>
+        <div class="regionArticle borderBox"></div>
+        <script>
+            // Force a layout
+            document.body.offsetTop;
+            // The following line will make a layer for the test-box, but will not trigger a new layout.
+            document.getElementById("test-box").classList.add("layer");
+        </script>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.png b/LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.png
new file mode 100644 (file)
index 0000000..8c0ced2
Binary files /dev/null and b/LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.png differ
diff --git a/LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.txt b/LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout-expected.txt
new file mode 100644 (file)
index 0000000..2fcc178
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x60
+  RenderBlock {HTML} at (0,0) size 800x60
+    RenderBody {BODY} at (8,8) size 784x0
+      RenderRegion {DIV} at (52,0) size 52x52 [border: (1px solid #000000)]
+      RenderRegion {DIV} at (104,0) size 52x52 [border: (1px solid #000000)]
+layer at (8,8) size 52x52
+  RenderRegion {DIV} at (0,0) size 52x52 [border: (1px solid #000000)]
+Flow Threads
+  Thread with flow-name 'article'
+    layer at (0,0) size 50x150
+      RenderNamedFlowThread at (0,0) size 50x150
+        RenderBlock {DIV} at (0,0) size 50x150
+          RenderBlock {DIV} at (0,50) size 50x50 [bgcolor=#0000FF]
+          RenderBlock {DIV} at (0,100) size 50x50 [bgcolor=#FFA500]
+    layer at (0,0) size 50x50
+      RenderBlock {DIV} at (0,0) size 50x50 [bgcolor=#008000]
+  Regions for flow 'article'
+    RenderRegion {DIV} #should-have-layer hasLayer
+    RenderRegion {DIV}
+    RenderRegion {DIV}
diff --git a/LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout.html b/LayoutTests/fast/regions/layers/dynamic-layer-removed-with-no-layout.html
new file mode 100644 (file)
index 0000000..3f20b9f
--- /dev/null
@@ -0,0 +1,33 @@
+<!doctype html>
+<html>
+    <!--
+    Testing that regions become layers as required by the content that display in those regions. 
+    There should be three boxes (green, blue, orange) with black borders. 
+    The test passes if only the first region becomes a RenderLayer.
+    -->
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            .layer
+            {
+                -webkit-transform: translateZ(0px);
+            }
+        </style>
+    </head>
+    <body>
+        <div class="flowArticle">
+            <div class="greenBox layer"></div>
+            <div id="test-box" class="blueBox layer"></div>
+            <div class="orangeBox"></div>
+        </div>
+        <div id="should-have-layer" class="regionArticle borderBox"></div>
+        <div class="regionArticle borderBox"></div>
+        <div class="regionArticle borderBox"></div>
+        <script>
+            // Force a layout
+            document.body.offsetTop;
+            // The following line will remove the layer for the test-box, but will not trigger a new layout.
+            document.getElementById("test-box").classList.remove("layer");
+        </script>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/layers/float-region-promoted-to-layer-expected.html b/LayoutTests/fast/regions/layers/float-region-promoted-to-layer-expected.html
new file mode 100644 (file)
index 0000000..d72c048
--- /dev/null
@@ -0,0 +1,42 @@
+<!doctype html>
+<html>
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            .dummyFloat
+            {
+                float: left;
+                width: 1px;
+                height: 10px;
+            }
+            .box1
+            {
+                width: 52px;
+                height: 1px;
+            }
+            .box2
+            {
+                /* The following border will be painted on top of the first region */
+                border-left: gray 52px solid;
+                /* Making box2 have its own layer */
+                position: relative;
+                width: 200px;
+                height: 61px;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="box1">
+            <div class="dummyFloat"></div>
+            <div class="borderBox" style="position: relative">
+                <div class="redBox"></div>
+            </div>
+        </div>
+
+        <div class="box2">
+            <div class="borderBox">
+                <div class="orangeBox"></div>
+            </div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/layers/float-region-promoted-to-layer.html b/LayoutTests/fast/regions/layers/float-region-promoted-to-layer.html
new file mode 100644 (file)
index 0000000..36e615f
--- /dev/null
@@ -0,0 +1,56 @@
+<!doctype html>
+<html>
+    <!--
+    Testing that regions become layers as required by the content that display in those regions.
+    In this case the region is also a float and we are testing that the correct enclosing
+    layer will paint the region as needed. In this case box1 is responsible of painting
+    the first region, even though the whole element fits inside box2.
+    There should be two boxes: one taller gray box and one orange box. The orange box has a black border.
+    The test fails if there's any red on screen.
+    -->
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            .redBox
+            {
+                position: relative;
+            }
+            .dummyFloat
+            {
+                float: left;
+                width: 1px;
+                height: 10px;
+            }
+            .box1
+            {
+                width: 52px;
+                height: 1px;
+            }
+            .box2
+            {
+                /* The following border will be painted on top of the first region */
+                border-left: gray 52px solid;
+                /* Making box2 have its own layer. */
+                position: relative;
+                width: 200px;
+                height: 61px;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="flowArticle">
+            <div class="redBox"></div>
+            <div class="orangeBox"></div>
+        </div>
+       
+        <div class="box1">
+            <div class="dummyFloat"></div>
+            <!-- The following element will get its own layer. -->
+            <div class="regionArticle borderBox"></div>
+        </div>
+
+        <div class="box2">
+            <div class="regionArticle borderBox"></div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-expected.png b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-expected.png
new file mode 100644 (file)
index 0000000..8c0ced2
Binary files /dev/null and b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-expected.png differ
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-expected.txt b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-expected.txt
new file mode 100644 (file)
index 0000000..69b3b6b
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x60
+  RenderBlock {HTML} at (0,0) size 800x60
+    RenderBody {BODY} at (8,8) size 784x0
+      RenderRegion {DIV} at (0,0) size 52x52 [border: (1px solid #000000)]
+      RenderRegion {DIV} at (104,0) size 52x52 [border: (1px solid #000000)]
+layer at (60,8) size 52x52
+  RenderRegion {DIV} at (52,0) size 52x52 [border: (1px solid #000000)]
+Flow Threads
+  Thread with flow-name 'article'
+    layer at (0,0) size 50x150
+      RenderNamedFlowThread at (0,0) size 50x150
+        RenderBlock {DIV} at (0,0) size 50x150
+          RenderBlock {DIV} at (0,0) size 50x50 [bgcolor=#008000]
+          RenderBlock {DIV} at (0,100) size 50x50 [bgcolor=#FFA500]
+    layer at (0,50) size 50x50
+      RenderBlock (relative positioned) {DIV} at (0,50) size 50x50 [bgcolor=#0000FF]
+  Regions for flow 'article'
+    RenderRegion {DIV}
+    RenderRegion {DIV} #should-have-layer hasLayer
+    RenderRegion {DIV}
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.png b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.png
new file mode 100644 (file)
index 0000000..a771cd7
Binary files /dev/null and b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.png differ
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.txt b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt-expected.txt
new file mode 100644 (file)
index 0000000..4d55542
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,540) size 800x60
+  RenderBlock {HTML} at (0,0) size 800x60
+    RenderBody {BODY} at (8,8) size 784x0
+      RenderRegion {DIV} at (0,0) size 52x52 [border: (1px solid #000000)]
+      RenderRegion {DIV} at (104,0) size 52x52 [border: (1px solid #000000)]
+layer at (60,540) size 52x52
+  RenderRegion {DIV} at (52,0) size 52x52 [border: (1px solid #000000)]
+Flow Threads
+  Thread with flow-name 'article'
+    layer at (0,450) size 50x150
+      RenderNamedFlowThread at (0,0) size 50x150
+        RenderBlock {DIV} at (0,0) size 50x150
+          RenderBlock {DIV} at (0,0) size 50x50 [bgcolor=#008000]
+          RenderBlock {DIV} at (0,100) size 50x50 [bgcolor=#FFA500]
+    layer at (0,500) size 50x50
+      RenderBlock (relative positioned) {DIV} at (0,50) size 50x50 [bgcolor=#0000FF]
+  Regions for flow 'article'
+    RenderRegion {DIV}
+    RenderRegion {DIV} #should-have-layer hasLayer
+    RenderRegion {DIV}
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt.html b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-horizontal-bt.html
new file mode 100644 (file)
index 0000000..e09b013
--- /dev/null
@@ -0,0 +1,31 @@
+<!doctype html>
+<html>
+    <!--
+    Testing that regions become layers as required by the content that display in those regions. 
+    There should be three boxes (green, blue, orange) with black borders. 
+    The test passes if the second region becomes a RenderLayer.
+    -->
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            html
+            {
+                -webkit-writing-mode: horizontal-bt;
+            }
+            .blueBox
+            {
+                position: relative;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="flowArticle">
+            <div class="greenBox"></div>
+            <div class="blueBox"></div>
+            <div class="orangeBox"></div>
+        </div>
+        <div class="regionArticle borderBox"></div>
+        <div id="should-have-layer" class="regionArticle borderBox"></div>
+        <div class="regionArticle borderBox"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.png b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.png
new file mode 100644 (file)
index 0000000..249a770
Binary files /dev/null and b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.png differ
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.txt b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr-expected.txt
new file mode 100644 (file)
index 0000000..1b7ed71
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 60x600
+  RenderBlock {HTML} at (0,0) size 60x600
+    RenderBody {BODY} at (8,8) size 0x584
+      RenderRegion {DIV} at (0,0) size 52x52 [border: (1px solid #000000)]
+      RenderRegion {DIV} at (0,104) size 52x52 [border: (1px solid #000000)]
+layer at (8,60) size 52x52
+  RenderRegion {DIV} at (0,52) size 52x52 [border: (1px solid #000000)]
+Flow Threads
+  Thread with flow-name 'article'
+    layer at (0,0) size 150x50
+      RenderNamedFlowThread at (0,0) size 150x50
+        RenderBlock {DIV} at (0,0) size 150x50
+          RenderBlock {DIV} at (0,0) size 50x50 [bgcolor=#008000]
+          RenderBlock {DIV} at (100,0) size 50x50 [bgcolor=#FFA500]
+    layer at (50,0) size 50x50
+      RenderBlock (relative positioned) {DIV} at (50,0) size 50x50 [bgcolor=#0000FF]
+  Regions for flow 'article'
+    RenderRegion {DIV}
+    RenderRegion {DIV} #should-have-layer hasLayer
+    RenderRegion {DIV}
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr.html b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-lr.html
new file mode 100644 (file)
index 0000000..669b418
--- /dev/null
@@ -0,0 +1,31 @@
+<!doctype html>
+<html>
+    <!--
+    Testing that regions become layers as required by the content that display in those regions. 
+    There should be three boxes (green, blue, orange) with black borders. 
+    The test passes if the second region becomes a RenderLayer.
+    -->
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            html
+            {
+                -webkit-writing-mode: vertical-lr;
+            }
+            .blueBox
+            {
+                position: relative;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="flowArticle">
+            <div class="greenBox"></div>
+            <div class="blueBox"></div>
+            <div class="orangeBox"></div>
+        </div>
+        <div class="regionArticle borderBox"></div>
+        <div id="should-have-layer" class="regionArticle borderBox"></div>
+        <div class="regionArticle borderBox"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.png b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.png
new file mode 100644 (file)
index 0000000..f35f13c
Binary files /dev/null and b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.png differ
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.txt b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl-expected.txt
new file mode 100644 (file)
index 0000000..d1595c9
--- /dev/null
@@ -0,0 +1,22 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (740,0) size 60x600
+  RenderBlock {HTML} at (0,0) size 60x600
+    RenderBody {BODY} at (8,8) size 0x584
+      RenderRegion {DIV} at (0,0) size 52x52 [border: (1px solid #000000)]
+      RenderRegion {DIV} at (0,104) size 52x52 [border: (1px solid #000000)]
+layer at (740,60) size 52x52
+  RenderRegion {DIV} at (0,52) size 52x52 [border: (1px solid #000000)]
+Flow Threads
+  Thread with flow-name 'article'
+    layer at (650,0) size 150x50
+      RenderNamedFlowThread at (0,0) size 150x50
+        RenderBlock {DIV} at (0,0) size 150x50
+          RenderBlock {DIV} at (0,0) size 50x50 [bgcolor=#008000]
+          RenderBlock {DIV} at (100,0) size 50x50 [bgcolor=#FFA500]
+    layer at (700,0) size 50x50
+      RenderBlock (relative positioned) {DIV} at (50,0) size 50x50 [bgcolor=#0000FF]
+  Regions for flow 'article'
+    RenderRegion {DIV}
+    RenderRegion {DIV} #should-have-layer hasLayer
+    RenderRegion {DIV}
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl.html b/LayoutTests/fast/regions/layers/regions-promoted-to-layers-vertical-rl.html
new file mode 100644 (file)
index 0000000..b7b5761
--- /dev/null
@@ -0,0 +1,31 @@
+<!doctype html>
+<html>
+    <!--
+    Testing that regions become layers as required by the content that display in those regions. 
+    There should be three boxes (green, blue, orange) with black borders. 
+    The test passes if the second region becomes a RenderLayer.
+    -->
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            html
+            {
+                -webkit-writing-mode: vertical-rl;
+            }
+            .blueBox
+            {
+                position: relative;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="flowArticle">
+            <div class="greenBox"></div>
+            <div class="blueBox"></div>
+            <div class="orangeBox"></div>
+        </div>
+        <div class="regionArticle borderBox"></div>
+        <div id="should-have-layer" class="regionArticle borderBox"></div>
+        <div class="regionArticle borderBox"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/layers/regions-promoted-to-layers.html b/LayoutTests/fast/regions/layers/regions-promoted-to-layers.html
new file mode 100644 (file)
index 0000000..1944371
--- /dev/null
@@ -0,0 +1,27 @@
+<!doctype html>
+<html>
+    <!--
+    Testing that regions become layers as required by the content that display in those regions. 
+    There should be three boxes (green, blue, orange) with black borders. 
+    The test passes if the second region becomes a RenderLayer.
+    -->
+    <head>
+        <link rel="stylesheet" href="../resources/region-style.css">
+        <style>
+            .blueBox
+            {
+                position: relative;
+            }
+        </style>
+    </head>
+    <body>
+        <div class="flowArticle">
+            <div class="greenBox"></div>
+            <div class="blueBox"></div>
+            <div class="orangeBox"></div>
+        </div>
+        <div class="regionArticle borderBox"></div>
+        <div id="should-have-layer" class="regionArticle borderBox"></div>
+        <div class="regionArticle borderBox"></div>
+    </body>
+</html>
index 13a946b..8d4ce36 100644 (file)
@@ -14,4 +14,4 @@ Flow Threads
             RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
         RenderBlock {DIV} at (0,0) size 100x50 [bgcolor=#FF0000]
   Regions for flow 'thread'
-    RenderRegion {DIV}
+    RenderRegion {DIV} hasLayer
index c41ebdf..10d97fe 100644 (file)
@@ -13,5 +13,5 @@ Flow Threads
         RenderBlock {DIV} at (0,1000) size 784x200
           RenderBlock {DIV} at (0,0) size 784x200 [bgcolor=#008000]
   Regions for flow 'flow1'
-    RenderRegion {DIV} #region1
+    RenderRegion {DIV} #region1 hasLayer
     RenderRegion {DIV} #region2
index c89e7a4..cb15a75 100644 (file)
@@ -8,9 +8,10 @@ layer at (0,0) size 800x532
           text run at (0,0) width 772: "The first and last lines of text in the regions below should be clipped to the green box. The overflow section sizes itself and"
           text run at (0,18) width 692: "clips differently in each region. The green box should be even with the lime floats at the top of the first region."
       RenderBlock {DIV} at (0,52) size 784x456
-        RenderRegion {DIV} at (0,0) size 402x152 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,152) size 402x152 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,304) size 402x152 [border: (1px solid #000000)]
+layer at (8,68) size 402x152
+  RenderRegion {DIV} at (0,0) size 402x152 [border: (1px solid #000000)]
 Flow Threads
   Thread with flow-name 'flow1'
     layer at (0,0) size 400x450
@@ -35,6 +36,6 @@ Flow Threads
             text run at (0,52) width 376: "not spill out of the regions. These lines will not spill out of"
             text run at (0,70) width 73: "the regions."
   Regions for flow 'flow1'
-    RenderRegion {DIV} #region1
+    RenderRegion {DIV} #region1 hasLayer
     RenderRegion {DIV} #region2
     RenderRegion {DIV} #region3
index e8dfc0c..9615ccd 100644 (file)
@@ -8,9 +8,10 @@ layer at (0,0) size 800x482
           text run at (0,0) width 745: "The first and last lines of text in the regions below should be clipped to the green box. The overflow section sizes itself"
           text run at (0,18) width 186: "independently in each region."
       RenderBlock {DIV} at (0,52) size 784x406
-        RenderRegion {DIV} at (0,0) size 202x102 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,102) size 302x182 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,284) size 122x122 [border: (1px solid #000000)]
+layer at (8,68) size 202x102
+  RenderRegion {DIV} at (0,0) size 202x102 [border: (1px solid #000000)]
 Flow Threads
   Thread with flow-name 'flow1'
     layer at (0,0) size 300x400
@@ -34,6 +35,6 @@ Flow Threads
           RenderText {#text} at (0,0) size 286x18
             text run at (0,0) width 286: "Clipped line of text that should not be visible."
   Regions for flow 'flow1'
-    RenderRegion {DIV} #region1
+    RenderRegion {DIV} #region1 hasLayer
     RenderRegion {DIV} #region2
     RenderRegion {DIV} #region3
index 67917e7..ee44a20 100644 (file)
@@ -8,9 +8,10 @@ layer at (0,0) size 800x482
           text run at (0,0) width 772: "The first and last lines of text in the regions below should be clipped to the green box. The overflow section sizes itself and"
           text run at (0,18) width 506: "clips differently in each region. The green box should start below the lime floats."
       RenderBlock {DIV} at (0,52) size 784x406
-        RenderRegion {DIV} at (0,0) size 302x102 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,102) size 402x182 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,284) size 222x122 [border: (1px solid #000000)]
+layer at (8,68) size 302x102
+  RenderRegion {DIV} at (0,0) size 302x102 [border: (1px solid #000000)]
 Flow Threads
   Thread with flow-name 'flow1'
     layer at (0,0) size 400x400
@@ -40,6 +41,6 @@ Flow Threads
           RenderText {#text} at (-22,0) size 286x18
             text run at (-22,0) width 286: "Clipped line of text that should not be visible."
   Regions for flow 'flow1'
-    RenderRegion {DIV} #region1
+    RenderRegion {DIV} #region1 hasLayer
     RenderRegion {DIV} #region2
     RenderRegion {DIV} #region3
index f3407da..161788f 100644 (file)
@@ -8,9 +8,10 @@ layer at (0,0) size 800x482
           text run at (0,0) width 772: "The first and last lines of text in the regions below should be clipped to the green box. The overflow section sizes itself and"
           text run at (0,18) width 692: "clips differently in each region. The green box should be even with the lime floats at the top of the first region."
       RenderBlock {DIV} at (0,52) size 784x406
-        RenderRegion {DIV} at (0,0) size 302x102 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,102) size 402x182 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,284) size 222x122 [border: (1px solid #000000)]
+layer at (8,68) size 302x102
+  RenderRegion {DIV} at (0,0) size 302x102 [border: (1px solid #000000)]
 Flow Threads
   Thread with flow-name 'flow1'
     layer at (0,0) size 400x400
@@ -42,6 +43,6 @@ Flow Threads
           RenderText {#text} at (47,0) size 286x18
             text run at (47,0) width 286: "Clipped line of text that should not be visible."
   Regions for flow 'flow1'
-    RenderRegion {DIV} #region1
+    RenderRegion {DIV} #region1 hasLayer
     RenderRegion {DIV} #region2
     RenderRegion {DIV} #region3
index 7671fc3..d328710 100644 (file)
@@ -8,9 +8,10 @@ layer at (0,0) size 800x482
           text run at (0,0) width 745: "The first and last lines of text in the regions below should be clipped to the green box. The overflow section sizes itself"
           text run at (0,18) width 186: "independently in each region."
       RenderBlock {DIV} at (0,52) size 784x406
-        RenderRegion {DIV} at (582,0) size 202x102 [border: (1px solid #000000)]
         RenderRegion {DIV} at (482,102) size 302x182 [border: (1px solid #000000)]
         RenderRegion {DIV} at (662,284) size 122x122 [border: (1px solid #000000)]
+layer at (590,68) size 202x102
+  RenderRegion {DIV} at (582,0) size 202x102 [border: (1px solid #000000)]
 Flow Threads
   Thread with flow-name 'flow1'
     layer at (0,0) size 300x400
@@ -34,6 +35,6 @@ Flow Threads
           RenderText {#text} at (0,0) size 286x18
             text run at (0,0) width 286: "Clipped line of text that should not be visible."
   Regions for flow 'flow1'
-    RenderRegion {DIV} #region1
+    RenderRegion {DIV} #region1 hasLayer
     RenderRegion {DIV} #region2
     RenderRegion {DIV} #region3
index 871a7eb..4380ddb 100644 (file)
@@ -8,9 +8,10 @@ layer at (0,0) size 800x482
           text run at (0,0) width 772: "The first and last lines of text in the regions below should be clipped to the green box. The overflow section sizes itself and"
           text run at (0,18) width 195: "clips differently in each region."
       RenderBlock {DIV} at (0,52) size 784x406
-        RenderRegion {DIV} at (0,0) size 202x102 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,102) size 302x182 [border: (1px solid #000000)]
         RenderRegion {DIV} at (0,284) size 122x122 [border: (1px solid #000000)]
+layer at (8,68) size 202x102
+  RenderRegion {DIV} at (0,0) size 202x102 [border: (1px solid #000000)]
 Flow Threads
   Thread with flow-name 'flow1'
     layer at (0,0) size 300x400
@@ -45,6 +46,6 @@ Flow Threads
           RenderText {#text} at (-23,0) size 286x18
             text run at (-23,0) width 286: "Clipped line of text that should not be visible."
   Regions for flow 'flow1'
-    RenderRegion {DIV} #region1
+    RenderRegion {DIV} #region1 hasLayer
     RenderRegion {DIV} #region2
     RenderRegion {DIV} #region3
index ad7f2ae..cb275d3 100644 (file)
@@ -22,4 +22,4 @@ Flow Threads
             text run at (0,0) width 76: "some text to"
             text run at (0,18) width 29: "flow"
   Regions for flow 'namedFlow'
-    RenderRegion {DIV} #region
+    RenderRegion {DIV} #region hasLayer
index ad7f2ae..cb275d3 100644 (file)
@@ -22,4 +22,4 @@ Flow Threads
             text run at (0,0) width 76: "some text to"
             text run at (0,18) width 29: "flow"
   Regions for flow 'namedFlow'
-    RenderRegion {DIV} #region
+    RenderRegion {DIV} #region hasLayer
index 6d7eb27..af15e75 100644 (file)
@@ -26,6 +26,6 @@ Flow Threads
             text run at (302,0) width 367: "\x{307E}\x{3059}\x{304B} \x{306A}\x{3089}\x{30BF}\x{30A4}\x{30C8}\x{30EB}\x{3068}\x{30A2}\x{30C9}\x{30EC}\x{30B9}\x{3060}\x{3051}\x{3067}\x{306A}"
             text run at (327,0) width 80: "\x{304F}\x{3001}\x{8A2A}\x{554F}"
   Regions for flow 'thread'
-    RenderRegion {DIV}
+    RenderRegion {DIV} hasLayer
 selection start: position 70 of child 0 {#text} of child 1 {DIV} of body
 selection end:   position 230 of child 0 {#text} of child 1 {DIV} of body
index 1ed98e5..05110ee 100644 (file)
@@ -85,4 +85,4 @@ Flow Threads
                     text run at (6,474) width 93: "here; the great "
                     text run at (99,474) width 261: "wonder is, that there\x{2018}s any one left alive!\x{2019}"
   Regions for flow 'thread'
-    RenderRegion {DIV}
+    RenderRegion {DIV} hasLayer
index 7e30f6a..8cb61b4 100644 (file)
@@ -1,3 +1,80 @@
+2013-08-14  Alexandru Chiculita  <achicu@adobe.com>
+
+        [CSS Regions] RenderRegions should have a RenderLayer+Backing when they contain a Composited RenderLayer
+        https://bugs.webkit.org/show_bug.cgi?id=117365
+
+        Reviewed by David Hyatt.
+
+        After the RenderFlowThread has a new layout we need to check if any of the children layers
+        had been moved to a new render region. We are only checking for the first level of layers,
+        as they are the only ones supported right now. Also, added code to make Regions require a layer
+        based on the layers that fit in their clipping area.
+
+        Tests: fast/regions/layers/dynamic-layer-added-with-no-layout.html
+               fast/regions/layers/dynamic-layer-removed-with-no-layout.html
+               fast/regions/layers/float-region-promoted-to-layer.html
+               fast/regions/layers/regions-promoted-to-layers-horizontal-bt.html
+               fast/regions/layers/regions-promoted-to-layers-vertical-lr.html
+               fast/regions/layers/regions-promoted-to-layers-vertical-rl.html
+               fast/regions/layers/regions-promoted-to-layers.html
+
+        * rendering/FlowThreadController.cpp:
+        (WebCore::FlowThreadController::updateRenderFlowThreadLayersIfNeeded): Iterate on all the flow threads and updateLayerToRegionMappings if needed. 
+        * rendering/FlowThreadController.h:
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::updateLocalFloatingObjectsForPaintingContainer): Checks if the FloatingObject
+        needs to be painted by the current block or not.
+        (WebCore::RenderBlock::updateFloatingObjectsPaintingContainer): Helper function to lookup what is the right
+        container that would need to paint a FloatingObject.
+        (WebCore::RenderBlock::updateAllDescendantsFloatingObjectsPaintingContainer):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::outermostBlockContainingFloatingObject): Looks up the ancestor RenderBlock that contains all
+        the FloatingObjects of a float.
+        (WebCore::RenderBox::removeFloatingOrPositionedChildFromBlockLists): Extracted the code for outermostBlockContainingFloatingObject
+        into its own method.
+        (WebCore::RenderBox::updatePaintingContainerForFloatingObject): Helper method to update the "m_shouldPaint" flag
+        of all the FloatingObjects created for a floating RenderObject. Normally, that flag is maintained during layout,
+        but we need to patch it for the floating RenderRegions after the layout is already finished.
+        (WebCore::RenderBox::updateLayerIfNeeded): Overwrite of the RenderLayerModelObject::updateLayerIfNeeded that is also
+        calling updatePaintingContainerForFloatingObject if a new layer was created or destroyed.
+        * rendering/RenderBox.h:
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::layout): Added code to call updateLayerToRegionMappings when needed.
+        (WebCore::RenderFlowThread::regionForCompositedLayer): Looks up the first RenderRegion to display a specific layer.
+        It only cares about the top most point of the element and ignores transforms.
+        (WebCore::RenderFlowThread::updateRegionForRenderLayer): Helper method to update the mapped region of a layer.
+        (WebCore::RenderFlowThread::updateLayerToRegionMappings): Iterates all the first level layers of the flow thread
+        and updates the region. Will return true if there was any change.
+        * rendering/RenderFlowThread.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::dirtyZOrderLists): When new layers are added or removed we need to update the layer map in the flow thread.
+        (WebCore::RenderLayer::dirtyNormalFlowList):
+        (WebCore::RenderLayer::shouldBeNormalFlowOnly): CSS Regions might become layers because they contain RenderLayers,
+        but they should not become stacking contexts for that reason. This will prevent the RenderRegions from rendering
+        in front of other layers.
+        (WebCore::RenderLayer::shouldBeSelfPaintingLayer):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateCompositingLayers): Call updateRenderFlowThreadLayersIfNeeded when there's a layer hierarchy update.
+        (WebCore::RenderLayerCompositor::updateRenderFlowThreadLayersIfNeeded): Update the render flow thread layer maps when they are dirty.
+        * rendering/RenderLayerCompositor.h:
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::isDirtyRenderFlowThread): Used to check if the RenderLayers had changed their order,
+        so that we can update the list of layers associated with a region. In a following patch we will need to 
+        rebuild the composited layers.
+        * rendering/RenderLayerModelObject.cpp:
+        (WebCore::RenderLayerModelObject::updateLayerIfNeeded): Adds or removes a layer when the "requiresLayer" changes
+        after the styleDidChange already happened. This is needed for Regions as we only know if they still require a layer,
+        only after the content of the flow thread is computed.
+        * rendering/RenderLayerModelObject.h:
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::RenderRegion):
+        (WebCore::RenderRegion::setRequiresLayerForCompositing):
+        * rendering/RenderRegion.h:
+        (WebCore::RenderRegion::requiresLayer):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::writeRenderRegionList): Updated the output to print the fact that the layer has a layer.
+
 2013-08-14  Bem Jones-Bey  <bjonesbe@adobe.com>
 
         Finish making FloatingObject a real class with private members
index 2802a76..8a8872e 100644 (file)
@@ -266,6 +266,15 @@ void FlowThreadController::updateFlowThreadsIntoFinalPhase()
     }
 }
 
+void FlowThreadController::updateRenderFlowThreadLayersIfNeeded()
+{
+    // Walk the flow chain in reverse order because RenderRegions might become RenderLayers for the following flow threads.
+    for (RenderNamedFlowThreadList::reverse_iterator iter = m_renderNamedFlowThreadList->rbegin(); iter != m_renderNamedFlowThreadList->rend(); ++iter) {
+        RenderNamedFlowThread* flowRenderer = *iter;
+        flowRenderer->updateLayerToRegionMappingsIfNeeded();
+    }
+}
+
 bool FlowThreadController::isContentNodeRegisteredWithAnyNamedFlow(const Node* contentNode) const
 {
     return m_mapNamedFlowContentNodes.contains(contentNode);
index 6a17c85..2b45f67 100644 (file)
@@ -79,6 +79,8 @@ public:
     void updateFlowThreadsIntoMeasureContentPhase();
     void updateFlowThreadsIntoFinalPhase();
 
+    void updateRenderFlowThreadLayersIfNeeded();
+
 #ifndef NDEBUG
     bool isAutoLogicalHeightRegionsCountConsistent() const;
 #endif
index f905c25..fd5e404 100644 (file)
@@ -4996,6 +4996,64 @@ void RenderBlock::markSiblingsWithFloatsForLayout(RenderBox* floatToRemove)
     }
 }
 
+void RenderBlock::updateFloatingObjectsPaintingContainer(RenderBox* floatToUpdate)
+{
+    bool didFindPaintContainer = false;
+    updateFloatingObjectsPaintingContainer(floatToUpdate, didFindPaintContainer);
+    ASSERT(didFindPaintContainer || floatToUpdate->hasSelfPaintingLayer());
+}
+
+void RenderBlock::updateFloatingObjectsPaintingContainer(RenderBox* floatToUpdate, bool& didFindPaintContainer)
+{
+    if (needsLayout()) {
+        // The floating object update should only be required after the layout is already complete.
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    if (!m_floatingObjects)
+        return;
+    updateAllDescendantsFloatingObjectsPaintingContainer(floatToUpdate, didFindPaintContainer);
+    for (RenderObject* next = nextSibling(); next; next = next->nextSibling()) {
+        if (!next->isRenderBlock() || next->isFloatingOrOutOfFlowPositioned() || toRenderBlock(next)->avoidsFloats())
+            continue;
+        RenderBlock* nextBlock = toRenderBlock(next);
+        if (nextBlock->containsFloat(floatToUpdate))
+            nextBlock->updateAllDescendantsFloatingObjectsPaintingContainer(floatToUpdate, didFindPaintContainer);
+    }
+}
+
+void RenderBlock::updateLocalFloatingObjectsForPaintingContainer(RenderBox* floatToUpdate, bool& foundPaintContainer)
+{
+    ASSERT(!needsLayout());
+    if (!m_floatingObjects)
+        return;
+    FloatingObjectSetIterator iterator = m_floatingObjects->set().find<RenderBox*, FloatingObjectHashTranslator>(floatToUpdate);
+    if (iterator != m_floatingObjects->set().end()) {
+        bool shouldPaint = !foundPaintContainer && !floatToUpdate->hasSelfPaintingLayer() && floatToUpdate->enclosingFloatPaintingLayer() == enclosingFloatPaintingLayer();
+        foundPaintContainer |= shouldPaint;
+        (*iterator)->setShouldPaint(shouldPaint);
+    }
+}
+
+void RenderBlock::updateAllDescendantsFloatingObjectsPaintingContainer(RenderBox* floatToUpdate, bool& didFindPaintContainer)
+{
+    if (needsLayout()) {
+        // The floating object update should only be required after the layout is already complete.
+        ASSERT_NOT_REACHED();
+        return;
+    }
+    updateLocalFloatingObjectsForPaintingContainer(floatToUpdate, didFindPaintContainer);
+    if (childrenInline())
+        return;
+    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
+        if (!child->isRenderBlock())
+            continue;
+        RenderBlock* childBlock = toRenderBlock(child);
+        if (childBlock->containsFloat(floatToUpdate))
+            childBlock->updateAllDescendantsFloatingObjectsPaintingContainer(floatToUpdate, didFindPaintContainer);
+    }
+}
+
 LayoutUnit RenderBlock::getClearDelta(RenderBox* child, LayoutUnit logicalTop)
 {
     // There is no need to compute clearance if we have no floats.
index 1072a1e..3a27559 100644 (file)
@@ -156,6 +156,8 @@ public:
 
     bool generatesLineBoxesForInlineChild(RenderObject*);
 
+    void updateFloatingObjectsPaintingContainer(RenderBox* floatToUpdate);
+
     void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, bool inLayout = true);
     void markSiblingsWithFloatsForLayout(RenderBox* floatToRemove = 0);
     void markPositionedObjectsForLayout();
@@ -932,6 +934,11 @@ private:
 
     LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatLeftRight) const; 
     LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit) const;
+
+    void updateLocalFloatingObjectsForPaintingContainer(RenderBox* floatToUpdate, bool& didFindPaintContainer);
+    void updateFloatingObjectsPaintingContainer(RenderBox* floatToUpdate, bool& didFindPaintContainer);
+    void updateAllDescendantsFloatingObjectsPaintingContainer(RenderBox* floatToUpdate, bool& didFindPaintContainer);
+
     
     bool hitTestColumns(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
     virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
index 18463cf..85272de 100644 (file)
@@ -211,6 +211,25 @@ void RenderBox::willBeDestroyed()
     RenderBoxModelObject::willBeDestroyed();
 }
 
+RenderBlock* RenderBox::outermostBlockContainingFloatingObject()
+{
+    ASSERT(isFloating());
+    RenderBlock* parentBlock = 0;
+    for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) {
+        if (curr->isRenderBlock()) {
+            RenderBlock* currBlock = toRenderBlock(curr);
+            if (!parentBlock || currBlock->containsFloat(this))
+                parentBlock = currBlock;
+        }
+    }
+    if (parentBlock) {
+        RenderObject* parent = parentBlock->parent();
+        if (parent && parent->isFlexibleBoxIncludingDeprecated())
+            parentBlock = toRenderBlock(parent);
+    }
+    return parentBlock;
+}
+
 void RenderBox::removeFloatingOrPositionedChildFromBlockLists()
 {
     ASSERT(isFloatingOrOutOfFlowPositioned());
@@ -219,20 +238,7 @@ void RenderBox::removeFloatingOrPositionedChildFromBlockLists()
         return;
 
     if (isFloating()) {
-        RenderBlock* parentBlock = 0;
-        for (RenderObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) {
-            if (curr->isRenderBlock()) {
-                RenderBlock* currBlock = toRenderBlock(curr);
-                if (!parentBlock || currBlock->containsFloat(this))
-                    parentBlock = currBlock;
-            }
-        }
-
-        if (parentBlock) {
-            RenderObject* parent = parentBlock->parent();
-            if (parent && parent->isFlexibleBoxIncludingDeprecated())
-                parentBlock = toRenderBlock(parent);
-
+        if (RenderBlock* parentBlock = outermostBlockContainingFloatingObject()) {
             parentBlock->markSiblingsWithFloatsForLayout(this);
             parentBlock->markAllDescendantsWithFloatsForLayout(this, false);
         }
@@ -242,6 +248,21 @@ void RenderBox::removeFloatingOrPositionedChildFromBlockLists()
         RenderBlock::removePositionedObject(this);
 }
 
+void RenderBox::updatePaintingContainerForFloatingObject()
+{
+    ASSERT(isFloating());
+    if (RenderBlock* parentBlock = outermostBlockContainingFloatingObject())
+        parentBlock->updateFloatingObjectsPaintingContainer(this);
+}
+
+bool RenderBox::updateLayerIfNeeded()
+{
+    bool didUpdateLayer = RenderBoxModelObject::updateLayerIfNeeded();
+    if (didUpdateLayer && isFloating())
+        updatePaintingContainerForFloatingObject();
+    return didUpdateLayer;
+}
+
 void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyle)
 {
     s_hadOverflowClip = hasOverflowClip();
index 6b2216b..f71b70a 100644 (file)
@@ -500,6 +500,10 @@ public:
 
     virtual VisiblePosition positionForPoint(const LayoutPoint&);
 
+    RenderBlock* outermostBlockContainingFloatingObject();
+    void updatePaintingContainerForFloatingObject();
+    virtual bool updateLayerIfNeeded();
+
     void removeFloatingOrPositionedChildFromBlockLists();
     
     RenderLayer* enclosingFloatPaintingLayer() const;
index 599bdf3..831330a 100644 (file)
@@ -40,6 +40,7 @@
 #include "RenderBoxRegionInfo.h"
 #include "RenderInline.h"
 #include "RenderLayer.h"
+#include "RenderLayerCompositor.h"
 #include "RenderRegion.h"
 #include "RenderView.h"
 #include "TransformState.h"
@@ -61,6 +62,9 @@ RenderFlowThread::RenderFlowThread()
     , m_pageLogicalSizeChanged(false)
     , m_layoutPhase(LayoutPhaseMeasureContent)
     , m_needsTwoPhasesLayout(false)
+#if USE(ACCELERATED_COMPOSITING)
+    , m_layersToRegionMappingsDirty(true)
+#endif
 {
     setFlowThreadState(InsideOutOfFlowThread);
 }
@@ -224,6 +228,19 @@ void RenderFlowThread::layout()
     if (lastRegion())
         lastRegion()->expandToEncompassFlowThreadContentsIfNeeded();
 
+#if USE(ACCELERATED_COMPOSITING)
+    // If there are children layers in the RenderFlowThread then we need to make sure that the
+    // composited children layers will land in the right RenderRegions. Also, the parent RenderRegions
+    // will get RenderLayers and become composited as needed.
+    // Note that there's no need to do so for the inline multi-column as we are not moving layers into different
+    // containers, but just adjusting the position of the RenderLayerBacking.
+    if (!m_needsTwoPhasesLayout) {
+        updateLayerToRegionMappings();
+        // FIXME: If we have layers that moved from one region to another, we should trigger
+        // a composited layers rebuild in here to make sure that the regions will collect the right layers.
+    }
+#endif
+
     if (shouldDispatchRegionLayoutUpdateEvent())
         dispatchRegionLayoutUpdateEvent();
     
@@ -231,6 +248,86 @@ void RenderFlowThread::layout()
         dispatchRegionOversetChangeEvent();
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+RenderRegion* RenderFlowThread::regionForCompositedLayer(RenderLayer* childLayer)
+{
+    LayoutPoint leftTopLocation = childLayer->renderBox() ? childLayer->renderBox()->flipForWritingMode(LayoutPoint()) : LayoutPoint();
+    LayoutPoint flowThreadOffset = flooredLayoutPoint(childLayer->renderer()->localToContainerPoint(leftTopLocation, this, ApplyContainerFlip));
+    return regionAtBlockOffset(0, flipForWritingMode(isHorizontalWritingMode() ? flowThreadOffset.y() : flowThreadOffset.x()), true, DisallowRegionAutoGeneration);
+}
+
+void RenderFlowThread::updateRegionForRenderLayer(RenderLayer* layer, LayerToRegionMap& layerToRegionMap, RegionToLayerListMap& regionToLayerListMap, bool& needsLayerUpdate)
+{
+    RenderRegion* region = regionForCompositedLayer(layer);
+    if (!needsLayerUpdate) {
+        ASSERT(m_layerToRegionMap);
+        // Figure out if we moved this layer from a region to the other.
+        RenderRegion* previousRegion = m_layerToRegionMap->get(layer);
+        if (previousRegion != region)
+            needsLayerUpdate = true;
+    }
+    if (!region)
+        return;
+    layerToRegionMap.set(layer, region);
+    RegionToLayerListMap::iterator iterator = regionToLayerListMap.find(region);
+    RenderLayerList& list = iterator == regionToLayerListMap.end() ? regionToLayerListMap.set(region, RenderLayerList()).iterator->value : iterator->value;
+    list.append(layer);
+}
+
+bool RenderFlowThread::updateLayerToRegionMappings()
+{
+    // We only need to map layers to regions for named flow threads.
+    // Multi-column threads are displayed on top of the regions and do not require
+    // distributing the layers.
+    if (!isOutOfFlowRenderFlowThread())
+        return false;
+
+    // We can't use currentFlowThread as it is possible to have interleaved flow threads and the wrong one could be used.
+    // Let each region figure out the proper enclosing flow thread.
+    CurrentRenderFlowThreadDisabler disabler(view());
+
+    // If the RenderFlowThread had a z-index layer update, then we need to update the composited layers too.
+    bool needsLayerUpdate = m_layersToRegionMappingsDirty || !m_layerToRegionMap.get();
+    layer()->updateLayerListsIfNeeded();
+
+    LayerToRegionMap layerToRegionMap;
+    RegionToLayerListMap regionToLayerListMap;
+
+    if (Vector<RenderLayer*>* negZOrderList = layer()->negZOrderList()) {
+        size_t listSize = negZOrderList->size();
+        for (size_t i = 0; i < listSize; ++i)
+            updateRegionForRenderLayer(negZOrderList->at(i), layerToRegionMap, regionToLayerListMap, needsLayerUpdate);
+    }
+
+    if (Vector<RenderLayer*>* normalFlowList = layer()->normalFlowList()) {
+        size_t listSize = normalFlowList->size();
+        for (size_t i = 0; i < listSize; ++i)
+            updateRegionForRenderLayer(normalFlowList->at(i), layerToRegionMap, regionToLayerListMap, needsLayerUpdate);
+    }
+    
+    if (Vector<RenderLayer*>* posZOrderList = layer()->posZOrderList()) {
+        size_t listSize = posZOrderList->size();
+        for (size_t i = 0; i < listSize; ++i)
+            updateRegionForRenderLayer(posZOrderList->at(i), layerToRegionMap, regionToLayerListMap, needsLayerUpdate);
+    }
+
+    if (needsLayerUpdate) {
+        if (!m_layerToRegionMap)
+            m_layerToRegionMap = adoptPtr(new LayerToRegionMap());
+        m_layerToRegionMap->swap(layerToRegionMap);
+
+        for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
+            RenderRegion* region = *iter;
+            region->setRequiresLayerForCompositing(regionToLayerListMap.contains(region));
+        }
+    }
+
+    m_layersToRegionMappingsDirty = false;
+
+    return needsLayerUpdate;
+}
+#endif
+
 void RenderFlowThread::updateLogicalWidth()
 {
     LayoutUnit logicalWidth = initialLogicalWidth();
index c177e8b..1b5b256 100644 (file)
@@ -45,6 +45,9 @@ class RenderStyle;
 class RenderRegion;
 
 typedef ListHashSet<RenderRegion*> RenderRegionList;
+typedef Vector<RenderLayer*> RenderLayerList;
+typedef HashMap<RenderRegion*, RenderLayerList> RegionToLayerListMap;
+typedef HashMap<RenderLayer*, RenderRegion*> LayerToRegionMap;
 
 // RenderFlowThread is used to collect all the render objects that participate in a
 // flow thread. It will also help in doing the layout. However, it will not render
@@ -113,6 +116,8 @@ public:
 
     RenderRegion* regionAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastRegion = false, RegionAutoGenerationPolicy = AllowRegionAutoGeneration);
 
+    const RenderLayerList* getLayerListForRegion(RenderRegion*) const;
+
     bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
     bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLogicalHeight; }
 
@@ -174,6 +179,15 @@ public:
     bool needsTwoPhasesLayout() const { return m_needsTwoPhasesLayout; }
     void clearNeedsTwoPhasesLayout() { m_needsTwoPhasesLayout = false; }
 
+#if USE(ACCELERATED_COMPOSITING)
+    void setNeedsLayerToRegionMappingsUpdate() { m_layersToRegionMappingsDirty = true; }
+    void updateLayerToRegionMappingsIfNeeded()
+    {
+        if (m_layersToRegionMappingsDirty)
+            updateLayerToRegionMappings();
+    }
+#endif
+
     void pushFlowThreadLayoutState(const RenderObject*);
     void popFlowThreadLayoutState();
     LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const;
@@ -197,6 +211,12 @@ protected:
 
     LayoutRect computeRegionClippingRect(const LayoutPoint&, const LayoutRect&, const LayoutRect&) const;
 
+#if USE(ACCELERATED_COMPOSITING)
+    RenderRegion* regionForCompositedLayer(RenderLayer*);
+    bool updateLayerToRegionMappings();
+    void updateRegionForRenderLayer(RenderLayer*, LayerToRegionMap&, RegionToLayerListMap&, bool& needsLayerUpdate);
+#endif
+
     void setDispatchRegionLayoutUpdateEvent(bool value) { m_dispatchRegionLayoutUpdateEvent = value; }
     bool shouldDispatchRegionLayoutUpdateEvent() { return m_dispatchRegionLayoutUpdateEvent; }
     
@@ -273,6 +293,10 @@ protected:
         RenderRegion* m_result;
     };
 
+#if USE(ACCELERATED_COMPOSITING)
+    OwnPtr<LayerToRegionMap> m_layerToRegionMap;
+#endif
+
     // A maps from RenderBox
     typedef HashMap<const RenderBox*, RenderRegionRange> RenderRegionRangeMap;
     RenderRegionRangeMap m_regionRangeMap;
@@ -299,6 +323,7 @@ protected:
     bool m_pageLogicalSizeChanged : 1;
     unsigned m_layoutPhase : 2;
     bool m_needsTwoPhasesLayout : 1;
+    bool m_layersToRegionMappingsDirty : 1;
 };
 
 inline RenderFlowThread* toRenderFlowThread(RenderObject* object)
index 8ade70e..1218fa4 100644 (file)
@@ -5705,6 +5705,8 @@ void RenderLayer::dirtyZOrderLists()
 
 #if USE(ACCELERATED_COMPOSITING)
     if (!renderer()->documentBeingDestroyed()) {
+        if (renderer()->isOutOfFlowRenderFlowThread())
+            toRenderFlowThread(renderer())->setNeedsLayerToRegionMappingsUpdate();
         compositor()->setCompositingLayersNeedRebuild();
         if (acceleratedCompositingForOverflowScrollEnabled())
             compositor()->setShouldReevaluateCompositingAfterLayout();
@@ -5729,6 +5731,8 @@ void RenderLayer::dirtyNormalFlowList()
 
 #if USE(ACCELERATED_COMPOSITING)
     if (!renderer()->documentBeingDestroyed()) {
+        if (renderer()->isOutOfFlowRenderFlowThread())
+            toRenderFlowThread(renderer())->setNeedsLayerToRegionMappingsUpdate();
         compositor()->setCompositingLayersNeedRebuild();
         if (acceleratedCompositingForOverflowScrollEnabled())
             compositor()->setShouldReevaluateCompositingAfterLayout();
@@ -5927,6 +5931,7 @@ bool RenderLayer::shouldBeNormalFlowOnly() const
                 || renderer()->isVideo()
                 || renderer()->isEmbeddedObject()
                 || renderer()->isRenderIFrame()
+                || renderer()->isRenderRegion()
                 || (renderer()->style()->specifiesColumns() && !isRootLayer()))
             && !renderer()->isPositioned()
             && !renderer()->hasTransform()
@@ -5953,7 +5958,8 @@ bool RenderLayer::shouldBeSelfPaintingLayer() const
         || renderer()->isCanvas()
         || renderer()->isVideo()
         || renderer()->isEmbeddedObject()
-        || renderer()->isRenderIFrame();
+        || renderer()->isRenderIFrame()
+        || renderer()->isRenderRegion();
 }
 
 void RenderLayer::updateSelfPaintingLayer()
index 6f1fd3e..9ef8741 100644 (file)
@@ -33,6 +33,7 @@
 #include "CSSPropertyNames.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
+#include "FlowThreadController.h"
 #include "Frame.h"
 #include "FrameView.h"
 #include "GraphicsLayer.h"
@@ -566,6 +567,8 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
 #endif
 
     if (checkForHierarchyUpdate) {
+        if (isFullUpdate)
+            updateRenderFlowThreadLayersIfNeeded();
         // Go through the layers in presentation order, so that we can compute which RenderLayers need compositing layers.
         // FIXME: we could maybe do this and the hierarchy udpate in one pass, but the parenting logic would be more complex.
         CompositingState compState(updateRoot);
@@ -628,6 +631,12 @@ void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType update
     InspectorInstrumentation::layerTreeDidChange(page());
 }
 
+void RenderLayerCompositor::updateRenderFlowThreadLayersIfNeeded()
+{
+    if (m_renderView->hasRenderNamedFlowThreads())
+        m_renderView->flowThreadController()->updateRenderFlowThreadLayersIfNeeded();
+}
+
 void RenderLayerCompositor::layerBecameNonComposited(const RenderLayer* renderLayer)
 {
     // Inform the inspector that the given RenderLayer was destroyed.
index b0ea17d..8955bfa 100644 (file)
@@ -141,6 +141,9 @@ public:
     // This is only used when state changes and we do not exepect a style update or layout to happen soon (e.g. when
     // we discover that an iframe is overlapped during painting).
     void scheduleCompositingLayerUpdate();
+
+    // Update the maps that we use to distribute layers to coresponding RenderRegions.
+    void updateRenderFlowThreadLayersIfNeeded();
     
     // Update the compositing state of the given layer. Returns true if that state changed.
     enum CompositingChangeRepaint { CompositingChangeRepaintNow, CompositingChangeWillRepaintLater };
index bf32d15..18a7f35 100644 (file)
@@ -184,5 +184,32 @@ void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderSt
     }
 }
 
+bool RenderLayerModelObject::updateLayerIfNeeded()
+{
+    LayoutStateDisabler layoutStateDisabler(view());
+
+    bool hadLayer = hasLayer();
+    if (requiresLayer()) {
+        if (!layer() && layerCreationAllowedForSubtree()) {
+            ensureLayer();
+            if (parent() && containingBlock()) {
+                layer()->setRepaintStatus(NeedsFullRepaint);
+                // There is only one layer to update, it is not worth using |cachedOffset| since
+                // we are not sure the value will be used.
+                layer()->updateLayerPositions(0);
+            }
+        }
+    } else if (layer() && layer()->parent())
+        layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer
+
+    if (hadLayer == hasLayer())
+        return false;
+
+    if (layer())
+        layer()->styleChanged(StyleDifferenceEqual, 0);
+
+    return true;
+}
+
 } // namespace WebCore
 
index 8c198b0..f57e669 100644 (file)
@@ -55,6 +55,7 @@ public:
 
 protected:
     void ensureLayer();
+    virtual bool updateLayerIfNeeded();
 
     virtual void willBeDestroyed() OVERRIDE;
 
index 7ed3be1..2d2c1e0 100644 (file)
@@ -54,6 +54,9 @@ RenderRegion::RenderRegion(Element* element, RenderFlowThread* flowThread)
     , m_isValid(false)
     , m_hasCustomRegionStyle(false)
     , m_hasAutoLogicalHeight(false)
+#if USE(ACCELERATED_COMPOSITING)
+    , m_requiresLayerForCompositing(false)
+#endif
     , m_hasComputedAutoHeight(false)
     , m_computedAutoHeight(0)
 {
@@ -723,4 +726,22 @@ void RenderRegion::updateLogicalHeight()
     }
 }
 
+#if USE(ACCELERATED_COMPOSITING)
+void RenderRegion::setRequiresLayerForCompositing(bool requiresLayerForCompositing)
+{
+    // This function is called when the regions had already
+    // been laid out, after the flow thread decides there are 
+    // composited layers that will display in this region.
+    ASSERT(!needsLayout());
+    if (m_requiresLayerForCompositing == requiresLayerForCompositing)
+        return;
+    
+    bool requiredLayer = requiresLayer();
+    m_requiresLayerForCompositing = requiresLayerForCompositing;
+
+    if (requiredLayer != requiresLayer())
+        updateLayerIfNeeded();
+}
+#endif
+
 } // namespace WebCore
index 22fef68..644f833 100644 (file)
@@ -138,6 +138,11 @@ public:
 
     virtual void collectLayerFragments(LayerFragments&, const LayoutRect&, const LayoutRect&) { }
 
+#if USE(ACCELERATED_COMPOSITING)
+    void setRequiresLayerForCompositing(bool);
+    virtual bool requiresLayer() const { return m_requiresLayerForCompositing || RenderBlock::requiresLayer(); }
+#endif
+
 protected:
     void setRegionObjectsRegionStyle();
     void restoreRegionObjectsOriginalStyle();
@@ -215,6 +220,9 @@ private:
     bool m_isValid : 1;
     bool m_hasCustomRegionStyle : 1;
     bool m_hasAutoLogicalHeight : 1;
+#if USE(ACCELERATED_COMPOSITING)
+    bool m_requiresLayerForCompositing : 1;
+#endif
     bool m_hasComputedAutoHeight : 1;
 
     LayoutUnit m_computedAutoHeight;
index dc6fcd4..008843d 100644 (file)
@@ -676,6 +676,8 @@ static void writeRenderRegionList(const RenderRegionList& flowThreadRegionList,
                 Element* element = toElement(renderRegion->generatingNode());
                 ts << " #" << element->idForStyleResolution();
             }
+            if (renderRegion->hasLayer())
+                ts << " hasLayer";
             if (renderRegion->hasCustomRegionStyle())
                 ts << " region style: 1";
             if (renderRegion->hasAutoLogicalHeight())