[CSS Regions] Auto width is not working for Regions
https://bugs.webkit.org/show_bug.cgi?id=74135
Reviewed by Julien Chaffraix.
Source/WebCore:
It was not possible to flow content into a region having { width: auto; } since in such case, the region width was computed to 0.
Now, a region having auto width, will have its width computed following the rules for calculation of widths and margins
(http://www.w3.org/TR/CSS2/visudet.html#Computing_widths_and_margins).
For those cases in which resolving the width requires measuring of content's min/max-content values, we use the associated named flow min/max-content
values (the same for all regions with width auto in a region chain).
When a region has width:auto, the computation of width should be done using normal block/box sizing code, instead of replaced element code.
Contains code contributed by Alexandru Chiculita(achicu@adobe.com).
Tests: fast/regions/autowidth-abspos-regionchain.html
fast/regions/autowidth-abspos.html
fast/regions/autowidth-attachedinvalidregion.html
fast/regions/autowidth-float.html
fast/regions/autowidth-inlineblock.html
fast/regions/autowidth-nonreplaced-abspos.html
fast/regions/autowidth-nonreplacedblock-normalflow.html
fast/regions/autowidth-normalflow-maxwidth.html
fast/regions/autowidth-normalflow-minmaxwidth.html
fast/regions/autowidth-normalflow-minwidth.html
fast/regions/autowidth-normalflow-vertrl.html
fast/regions/autowidth-normalflow.html
* rendering/RenderBox.cpp:
(WebCore::RenderBox::computePositionedLogicalWidth): For positioned auto-width regions, skip the code path for replaced elements.
* rendering/RenderRegion.cpp:
(WebCore): Override min/maxPreferredLogicalWidth as they are used in the process of computing width for regions with auto width.
As this moment, a region is still a RenderReplaced element, so this code needs to be revisited when the region will become a RenderBlock.
Also, for min/max-width, we support only <length> values. We will extend support for other values in a following patch.
We only attempt to use the flowThread min/maxPreferredLogicalWidth if the region is valid (there are no circular dependencies).
(WebCore::RenderRegion::minPreferredLogicalWidth):
(WebCore::RenderRegion::maxPreferredLogicalWidth):
* rendering/RenderRegion.h:
(RenderRegion): Override isInlineBlockOrInlineTable() and shouldComputeSizeAsReplaced() to ensure that computation for width auto follows the normal
block/box sizing code.
(WebCore::RenderRegion::expandToEncompassFlowThreadContentsIfNeeded):
LayoutTests:
Add tests for width: auto and modify the existing region tests that were having width: auto so that they do not fail after the changes.
* fast/regions/autowidth-abspos-expected.html: Added.
* fast/regions/autowidth-abspos-regionchain-expected.html: Added.
* fast/regions/autowidth-abspos-regionchain.html: Added.
* fast/regions/autowidth-abspos.html: Added.
* fast/regions/autowidth-attachedinvalidregion-expected.txt: Added.
* fast/regions/autowidth-attachedinvalidregion.html: Added.
* fast/regions/autowidth-float-expected.html: Added.
* fast/regions/autowidth-float.html: Added.
* fast/regions/autowidth-inlineblock-expected.html: Added.
* fast/regions/autowidth-inlineblock.html: Added.
* fast/regions/autowidth-nonreplaced-abspos-expected.html: Added.
* fast/regions/autowidth-nonreplaced-abspos.html: Added.
* fast/regions/autowidth-nonreplacedblock-normalflow-expected.html: Added.
* fast/regions/autowidth-nonreplacedblock-normalflow.html: Added.
* fast/regions/autowidth-normalflow-expected.html: Added.
* fast/regions/autowidth-normalflow-maxwidth-expected.html: Added.
* fast/regions/autowidth-normalflow-maxwidth.html: Added.
* fast/regions/autowidth-normalflow-minmaxwidth-expected.html: Added.
* fast/regions/autowidth-normalflow-minmaxwidth.html: Added.
* fast/regions/autowidth-normalflow-minwidth-expected.html: Added.
* fast/regions/autowidth-normalflow-minwidth.html: Added.
* fast/regions/autowidth-normalflow-vertrl-expected.html: Added.
* fast/regions/autowidth-normalflow-vertrl.html: Added.
* fast/regions/autowidth-normalflow.html: Added.
* fast/regions/bottom-overflow-out-of-first-region.html:
* fast/regions/flows-dependency-dynamic-remove.html:
* fast/regions/flows-dependency-same-flow.html:
* fast/regions/render-region-renderer-expected.html:
* fast/regions/top-overflow-out-of-second-region.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@128155 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-minwidth.html b/LayoutTests/fast/regions/autowidth-normalflow-minwidth.html
new file mode 100644
index 0000000..02ef0f2
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-minwidth.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+ <head>
+ <style>
+ #article { -webkit-flow-into: flow; font-size: 25px; line-height: 2; text-align: justify; color:#a0a0a0; font-family: Ahem; }
+ #region { -webkit-flow-from: flow; height: 400px; min-width: 200px; }
+ #container { width: 100px; }
+ </style>
+ </head>
+ <body>
+ <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=74135"> Auto width is not working for regions</a>.</p>
+ <p>The region is a block level, non replaced element in normal flow, having min-width specified.</p>
+ <p>On success, you should see a single gray line below.</p>
+ <div id="article">
+ <span style="background-color:#a0a0a0">
+ aa aa aa
+ </span>
+ </div>
+ <div id="container">
+ <div id="region"></div>
+ </div>
+ </body>
+</html>