[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-abspos-expected.html b/LayoutTests/fast/regions/autowidth-abspos-expected.html
new file mode 100644
index 0000000..94a9419
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-abspos-expected.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #green { position: absolute; width: 50px; height: 50px; top: 150px; background-color: green; }
+        </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 an absolutely positioned, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="green"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-abspos-regionchain-expected.html b/LayoutTests/fast/regions/autowidth-abspos-regionchain-expected.html
new file mode 100644
index 0000000..81f0eef
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-abspos-regionchain-expected.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #green1 { position: absolute; background-color: green; width: 100px; height: 50px; top: 150px; }
+            #green2 { position: absolute; background-color: green; width: 100px; height: 50px; top: 250px; }
+        </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 regions are absolutely positioned, non replaced element.</p>
+        <p>In this case, the regions have the same width, based on the same flow thread min/max content.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="green1"></div>
+        <div id="green2"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-abspos-regionchain.html b/LayoutTests/fast/regions/autowidth-abspos-regionchain.html
new file mode 100644
index 0000000..c4274ef
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-abspos-regionchain.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #article { -webkit-flow-into: flow; }
+            #box1 { width: 50px; height: 50px; background-color: green; }
+            #box2 { width: 100px; height: 50px; background-color: green; }
+            #container { width: 200px; height: 200px; position: absolute; top: 150px; }
+            #region { -webkit-flow-from: flow; height: 50px; position: absolute; background-color: green; }
+            #region2 { -webkit-flow-from: flow; height: 50px; position: absolute; top: 100px; background-color: green; }
+            #red1 { position: absolute; background-color: red; width: 100px; height: 50px; top: 150px; }
+            #red2 { position: absolute; background-color: red; width: 100px; height: 50px; top: 250px; }
+        </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 regions are absolutely positioned, non replaced element.</p>
+        <p>In this case, the regions have the same width, based on the same flow thread min/max content.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+
+        <div id="article">
+            <div id="box1"></div>
+            <div id="box2"></div>
+        </div>
+        <div id="red1"></div>
+        <div id="red2"></div>
+        <div id="container">
+            <div id="region"></div>
+            <div id="region2"></div>
+        <div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-abspos.html b/LayoutTests/fast/regions/autowidth-abspos.html
new file mode 100644
index 0000000..299a732f
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-abspos.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #article { -webkit-flow-into: flow; width: 40px; height: 50px; background-color: green; }
+            #container { width: 200px; height: 200px; position: absolute; top: 150px; }
+            #region { -webkit-flow-from: flow; height: 50px; padding-left: 5px; padding-right: 5px; position: absolute; background-color: green; box-sizing: border-box; }
+            #red { position: absolute; width: 50px; height: 50px; top: 150px; background-color: red; }
+        </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 an absolutely positioned, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="red"></div>
+        <div id="article"></div>
+        <div id="container">
+            <div id="region"></div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-attachedinvalidregion-expected.txt b/LayoutTests/fast/regions/autowidth-attachedinvalidregion-expected.txt
new file mode 100644
index 0000000..6c73ecc
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-attachedinvalidregion-expected.txt
@@ -0,0 +1,11 @@
+Test for Auto width is not working for regions.
+
+The region is an absolutely positioned, non replaced element, attached to a flow thread.
+
+Due to flow thread dependencies, the region is not valid and width computation should not take the associated flow thread into account.
+
+On success, it should not crash.
+
+PASS
+
+
diff --git a/LayoutTests/fast/regions/autowidth-attachedinvalidregion.html b/LayoutTests/fast/regions/autowidth-attachedinvalidregion.html
new file mode 100644
index 0000000..f260152
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-attachedinvalidregion.html
@@ -0,0 +1,37 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            .flowB { -webkit-flow-into: flowB; }
+            .flowC { -webkit-flow-into: flowC; }
+
+            .regionFlowB { -webkit-flow-from: flowB; }
+            .regionFlowC { -webkit-flow-from: flowC; }
+
+            #container { width: 200px; height: 200px; position: absolute; }
+            #region { height: 50px; position: absolute; }
+        </style>
+    </head>
+    <body>
+        <script>
+            if (window.testRunner)
+                window.testRunner.dumpAsText();
+        </script>
+        <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 an absolutely positioned, non replaced element, attached to a flow thread.</p>
+        <p>Due to flow thread dependencies, the region is not valid and width computation should not take the associated flow thread into account.</p>
+        <p>On success, it should not crash.</p>
+        <p>PASS</p>
+        <div class="flowB">
+            <div class="regionFlowC"></div>
+        </div>
+
+        <div class="flowC">
+            <div class="regionFlowB"></div>
+        </div>
+
+        <div id="container">
+	        <div class="regionFlowB" id="region"></div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-float-expected.html b/LayoutTests/fast/regions/autowidth-float-expected.html
new file mode 100644
index 0000000..a8e45bd
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-float-expected.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #green { position: absolute; width: 50px; height: 50px; top: 150px; background-color: green; }
+        </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 floating, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="green"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-float.html b/LayoutTests/fast/regions/autowidth-float.html
new file mode 100644
index 0000000..edb482e
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-float.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #article { -webkit-flow-into: flow; width: 40px; height: 50px; background-color: green; }
+            #container { width: 200px; height: 200px; position: absolute; top: 150px; }
+            #region { -webkit-flow-from: flow; height: 50px; padding-left: 5px; padding-right: 5px; float: left; background-color: green; }
+            #red { position: absolute; width: 50px; height: 50px; top: 150px; background-color: red; }
+        </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 floating, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="red"></div>
+        <div id="article"></div>
+        <div id="container">
+            <div id="region"></div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-inlineblock-expected.html b/LayoutTests/fast/regions/autowidth-inlineblock-expected.html
new file mode 100644
index 0000000..b38946f
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-inlineblock-expected.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #green { position: absolute; width: 50px; height: 50px; top: 150px; background-color: green; }
+        </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 an inline-block, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="green"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-inlineblock.html b/LayoutTests/fast/regions/autowidth-inlineblock.html
new file mode 100644
index 0000000..2398d10
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-inlineblock.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #article { -webkit-flow-into: flow; width: 30px; height: 50px; background-color: green; }
+            #container { width: 200px; height: 200px; position: absolute; top: 150px; }
+            #region { -webkit-flow-from: flow; height: 50px; padding-left: 5px; padding-right: 5px;
+                border-left: 5px solid green; border-right: 5px solid green;
+                display: inline-block; background-color: green; box-sizing: border-box; }
+            #red { position: absolute; width: 50px; height: 50px; top: 150px; background-color: red; }
+        </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 an inline-block, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="red"></div>
+        <div id="article"></div>
+        <div id="container">
+            <div id="region"></div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-nonreplaced-abspos-expected.html b/LayoutTests/fast/regions/autowidth-nonreplaced-abspos-expected.html
new file mode 100644
index 0000000..94a9419
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-nonreplaced-abspos-expected.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #green { position: absolute; width: 50px; height: 50px; top: 150px; background-color: green; }
+        </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 an absolutely positioned, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="green"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-nonreplaced-abspos.html b/LayoutTests/fast/regions/autowidth-nonreplaced-abspos.html
new file mode 100644
index 0000000..299a732f
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-nonreplaced-abspos.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #article { -webkit-flow-into: flow; width: 40px; height: 50px; background-color: green; }
+            #container { width: 200px; height: 200px; position: absolute; top: 150px; }
+            #region { -webkit-flow-from: flow; height: 50px; padding-left: 5px; padding-right: 5px; position: absolute; background-color: green; box-sizing: border-box; }
+            #red { position: absolute; width: 50px; height: 50px; top: 150px; background-color: red; }
+        </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 an absolutely positioned, non replaced element.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="red"></div>
+        <div id="article"></div>
+        <div id="container">
+            <div id="region"></div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-nonreplacedblock-normalflow-expected.html b/LayoutTests/fast/regions/autowidth-nonreplacedblock-normalflow-expected.html
new file mode 100644
index 0000000..ac90290
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-nonreplacedblock-normalflow-expected.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            body { margin: 0px; }
+            #green { position: absolute; top: 150px; width: 50px; height: 50px; background-color: green; }
+        </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.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="green"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-nonreplacedblock-normalflow.html b/LayoutTests/fast/regions/autowidth-nonreplacedblock-normalflow.html
new file mode 100644
index 0000000..fe02f9b
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-nonreplacedblock-normalflow.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            body { margin: 0px; }
+            #article { -webkit-flow-into: flow; width: 50px; height: 50px; background-color: green; }
+            #container { width: 50px; height: 100px; position: absolute; top: 150px; }
+            #region { -webkit-flow-from: flow; height: 50px; }
+            #red { position: absolute; top: 150px; width: 50px; height: 50px; background-color: red; }
+        </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.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="red"></div>
+        <div id="article"></div>
+        <div id="container">
+            <div id="region"></div>
+        <div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-expected.html b/LayoutTests/fast/regions/autowidth-normalflow-expected.html
new file mode 100644
index 0000000..ac90290
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-expected.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            body { margin: 0px; }
+            #green { position: absolute; top: 150px; width: 50px; height: 50px; background-color: green; }
+        </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.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="green"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-maxwidth-expected.html b/LayoutTests/fast/regions/autowidth-normalflow-maxwidth-expected.html
new file mode 100644
index 0000000..7be6259
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-maxwidth-expected.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            body { font-family: monospace; }
+            #gray { width: 200px; height: 400px; font-size: 25px; line-height: 2; text-align: justify; color: #a0a0a0; }
+        </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 max-width specified.</p>
+        <p>On success, you should see more than one gray line below.</p>
+        <div id="gray">
+            <span style="background-color:#a0a0a0">
+            This is some content This is some content
+            This is some content This is some content
+            This is some content
+        </span>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-maxwidth.html b/LayoutTests/fast/regions/autowidth-normalflow-maxwidth.html
new file mode 100644
index 0000000..72bbbe9
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-maxwidth.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            body { font-family: monospace; }
+            #article { -webkit-flow-into: flow; font-size: 25px; line-height: 2; text-align: justify; color:#a0a0a0; }
+            #region { -webkit-flow-from: flow; height: 400px; max-width: 200px; }
+        </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 max-width specified.</p>
+        <p>On success, you should see more than one gray line below.</p>
+        <div id="article">
+            <span style="background-color:#a0a0a0">
+            This is some content This is some content
+            This is some content This is some content
+            This is some content
+        </span>
+        </div>
+        <div id="region"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-minmaxwidth-expected.html b/LayoutTests/fast/regions/autowidth-normalflow-minmaxwidth-expected.html
new file mode 100644
index 0000000..bd1364d
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-minmaxwidth-expected.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #gray { width: 200px; height: 400px; font-size: 25px; line-height: 2;
+            text-align: justify; color: #a0a0a0; font-family: Ahem;
+            padding-left: 25px; padding-right: 25px; box-sizing: border-box; }
+        </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 and max-width specified.</p>
+        <p>On success, you should see 2 gray lines below.</p>
+        <div id="gray">
+            <span style="background-color:#a0a0a0">
+            aaa aaa
+            </span>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-minmaxwidth.html b/LayoutTests/fast/regions/autowidth-normalflow-minmaxwidth.html
new file mode 100644
index 0000000..9f31b87
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-minmaxwidth.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; max-width: 300px; padding-left: 25px; padding-right: 25px; box-sizing: border-box; }
+            #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 and max-width specified.</p>
+        <p>On success, you should see 2 gray lines below.</p>
+        <div id="article">
+            <span style="background-color: #a0a0a0">
+            aaa aaa
+            </span>
+        </div>
+        <div id="container">
+            <div id="region"></div>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-minwidth-expected.html b/LayoutTests/fast/regions/autowidth-normalflow-minwidth-expected.html
new file mode 100644
index 0000000..04380f5
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-minwidth-expected.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            #gray { width: 200px; height: 400px; font-size: 25px; line-height: 2; text-align: justify; color: #a0a0a0; font-family: Ahem; }
+        </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="gray">
+            <span style="background-color:#a0a0a0">
+            aa aa aa
+            </span>
+        </div>
+    </body>
+</html>
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>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-vertrl-expected.html b/LayoutTests/fast/regions/autowidth-normalflow-vertrl-expected.html
new file mode 100644
index 0000000..5704288
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-vertrl-expected.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<html style="-webkit-writing-mode: vertical-rl;">
+    <head>
+        <style>
+            body { font-family: monospace; }
+            #gray { height: 200px; font-size: 25px; line-height: 2; text-align: justify; font-family: Ahem; color: #a0a0a0; }
+        </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, vertical rl writing mode.</p>
+        <p>On success, you should see more than one gray line below.</p>
+        <div id="gray">
+            <span style="background-color:#a0a0a0">
+            aaaa aaaa aaaa
+            </span>
+        </div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow-vertrl.html b/LayoutTests/fast/regions/autowidth-normalflow-vertrl.html
new file mode 100644
index 0000000..867dd9b
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow-vertrl.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<html style="-webkit-writing-mode: vertical-rl;">
+    <head>
+        <style>
+            body { font-family: monospace; }
+            #article { -webkit-flow-into: flow; font-size: 25px; line-height: 2;
+                text-align: justify; font-family: Ahem; color: #a0a0a0; }
+            #region { -webkit-flow-from: flow; width: 400px; max-height: 200px; }
+        </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, vertical rl writing mode.</p>
+        <p>On success, you should see more than one gray line below.</p>
+        <div id="article">
+            <span style="background-color:#a0a0a0">
+            aaaa aaaa aaaa
+            </span>
+        </div>
+        <div id="region"></div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/autowidth-normalflow.html b/LayoutTests/fast/regions/autowidth-normalflow.html
new file mode 100644
index 0000000..fe02f9b
--- /dev/null
+++ b/LayoutTests/fast/regions/autowidth-normalflow.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+    <head>
+        <style>
+            body { margin: 0px; }
+            #article { -webkit-flow-into: flow; width: 50px; height: 50px; background-color: green; }
+            #container { width: 50px; height: 100px; position: absolute; top: 150px; }
+            #region { -webkit-flow-from: flow; height: 50px; }
+            #red { position: absolute; top: 150px; width: 50px; height: 50px; background-color: red; }
+        </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.</p>
+        <p>On success, you should not see a red rectangle below.</p>
+        <div id="red"></div>
+        <div id="article"></div>
+        <div id="container">
+            <div id="region"></div>
+        <div>
+    </body>
+</html>
diff --git a/LayoutTests/fast/regions/bottom-overflow-out-of-first-region.html b/LayoutTests/fast/regions/bottom-overflow-out-of-first-region.html
index df7322a6a8..250ec36 100644
--- a/LayoutTests/fast/regions/bottom-overflow-out-of-first-region.html
+++ b/LayoutTests/fast/regions/bottom-overflow-out-of-first-region.html
@@ -33,6 +33,10 @@
         height: 100px;
     }
 
+    #region3 {
+        width: 0px;
+        height: 0px;
+    }
 </style>
 
 <body>
diff --git a/LayoutTests/fast/regions/flows-dependency-dynamic-remove.html b/LayoutTests/fast/regions/flows-dependency-dynamic-remove.html
index caec535..9558cbf 100644
--- a/LayoutTests/fast/regions/flows-dependency-dynamic-remove.html
+++ b/LayoutTests/fast/regions/flows-dependency-dynamic-remove.html
@@ -8,6 +8,8 @@
 .regionFlowA { -webkit-flow-from: flowA; }
 .regionFlowB { -webkit-flow-from: flowB; }
 .regionFlowC { -webkit-flow-from: flowC; }
+
+.regionFlowA, .regionFlowB, .regionFlowC { width: 0px; height: 0px; }
 </style>
 
 <div class="flowA">
diff --git a/LayoutTests/fast/regions/flows-dependency-same-flow.html b/LayoutTests/fast/regions/flows-dependency-same-flow.html
index b729868..fc61740 100644
--- a/LayoutTests/fast/regions/flows-dependency-same-flow.html
+++ b/LayoutTests/fast/regions/flows-dependency-same-flow.html
@@ -8,6 +8,8 @@
 .regionFlowA { -webkit-flow-from: flowA; }
 .regionFlowB { -webkit-flow-from: flowB; }
 .regionFlowC { -webkit-flow-from: flowC; }
+
+.regionFlowA, .regionFlowB, .regionFlowC { width: 0px; height: 0px; }
 </style>
 
 <div class="flowA">
diff --git a/LayoutTests/fast/regions/render-region-renderer-expected.html b/LayoutTests/fast/regions/render-region-renderer-expected.html
index a9e9f1f..893acc0 100644
--- a/LayoutTests/fast/regions/render-region-renderer-expected.html
+++ b/LayoutTests/fast/regions/render-region-renderer-expected.html
@@ -14,7 +14,6 @@
     }
     .size1
     {
-        width:0.5px;
         height:0.5px;
     }
 
diff --git a/LayoutTests/fast/regions/top-overflow-out-of-second-region.html b/LayoutTests/fast/regions/top-overflow-out-of-second-region.html
index 4aa58d2..9858cda 100644
--- a/LayoutTests/fast/regions/top-overflow-out-of-second-region.html
+++ b/LayoutTests/fast/regions/top-overflow-out-of-second-region.html
@@ -33,6 +33,10 @@
         height: 200px;
     }
 
+    #region3 {
+        width: 0px;
+        height: 0px;
+    }
 </style>
 
 <body>