[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)
commit7c5365cb0d7795d44f8cf074c663374d7599e942
tree8a675b4fa81e7ea85a60da49b3a4d2196d5d295b
parentf4227c48cb80d8d9ff50356e3a34ef31a48a68e1
[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.

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