No subject


Fri Mar 7 15:32:22 PST 2014


pecified
by ancestor elements. However, implementing this is a larger change that =
will require
a fundamental new approach in handling break avoidance. This patch just b=
rings
consistency to the API.

Test: fast/regions/forced-break-inside-avoid-break.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::childBoxIsUnsplittableForFragmentation):
(WebCore::RenderBlock::computeRegionRangeForBoxChild):
(WebCore::RenderBlock::estimateRegionRangeForBoxChild):
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::adjustForUnsplittableChild): Move the avoidanc=
e conditions inside
a helper method RenderBlock::childBoxIsUnsplittableForFragmentation.

LayoutTests:

The test verifies that elements specifying break-inside: avoid can't
be splitted by forced breaks applied inside of them.

* fast/regions/forced-break-inside-avoid-break-expected.txt: Added.
* fast/regions/forced-break-inside-avoid-break.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a=
></li>
<li><a href=3D"#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeL=
og</a></li>
<li><a href=3D"#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/W=
ebCore/rendering/RenderBlock.cpp</a></li>
<li><a href=3D"#trunkSourceWebCorerenderingRenderBlockh">trunk/Source/Web=
Core/rendering/RenderBlock.h</a></li>
<li><a href=3D"#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Sour=
ce/WebCore/rendering/RenderBlockFlow.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href=3D"#trunkLayoutTestsfastregionsforcedbreakinsideavoidbreakexp=
ectedtxt">trunk/LayoutTests/fast/regions/forced-break-inside-avoid-break-=
expected.txt</a></li>
<li><a href=3D"#trunkLayoutTestsfastregionsforcedbreakinsideavoidbreakhtm=
l">trunk/LayoutTests/fast/regions/forced-break-inside-avoid-break.html</a=
></li>
</ul>

</div>
<div id=3D"patch">
<h3>Diff</h3>
<a id=3D"trunkLayoutTestsChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (165872 =
=3D> 165873)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/ChangeLog	2014-03-19 06:55:29 =
UTC (rev 165872)
+++ trunk/LayoutTests/ChangeLog	2014-03-19 06:57:17 UTC (rev 165873)
</span><span class=3D"lines">@@ -1,3 +1,16 @@
</span><ins>+2014-03-18  Andrei Bucur  &lt;abucur at adobe.com&gt;
+
+        [CSS Regions] Strange layout for content with region breaks
+        https://bugs.webkit.org/show_bug.cgi?id=3D121318
+
+        Reviewed by Mihnea Ovidenie.
+
+        The test verifies that elements specifying break-inside: avoid c=
an't
+        be splitted by forced breaks applied inside of them.
+
+        * fast/regions/forced-break-inside-avoid-break-expected.txt: Add=
ed.
+        * fast/regions/forced-break-inside-avoid-break.html: Added.
+
</ins><span class=3D"cx"> 2014-03-18  Samuel White  &lt;samuel_white at appl=
e.com&gt;
</span><span class=3D"cx">=20
</span><span class=3D"cx">         AX: Not able to use arrow keys to read=
 text with VoiceOver before selection is set someplace (anyplace).
</span></span></pre></div>
<a id=3D"trunkLayoutTestsfastregionsforcedbreakinsideavoidbreakexpectedtx=
t"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/fast/regions/forced-b=
reak-inside-avoid-break-expected.txt (0 =3D> 165873)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/regions/forced-break-insi=
de-avoid-break-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/forced-break-inside-avoid-break-expect=
ed.txt	2014-03-19 06:57:17 UTC (rev 165873)
</span><span class=3D"lines">@@ -0,0 +1,8 @@
</span><ins>+Test for [CSS Regions] Strange layout for content with regio=
n breaks.
+
+The green rectangle is flowed inside three regions with blue borders. Th=
e first region should contain the whole green rectangle. The second and t=
he third regions should have a height of 0px.
+
+PASS
+PASS
+PASS
+
</ins></span></pre></div>
<a id=3D"trunkLayoutTestsfastregionsforcedbreakinsideavoidbreakhtml"></a>
<div class=3D"addfile"><h4>Added: trunk/LayoutTests/fast/regions/forced-b=
reak-inside-avoid-break.html (0 =3D> 165873)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/LayoutTests/fast/regions/forced-break-insi=
de-avoid-break.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/forced-break-inside-avoid-break.html	2=
014-03-19 06:57:17 UTC (rev 165873)
</span><span class=3D"lines">@@ -0,0 +1,82 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+    &lt;style&gt;
+        .region {
+            -webkit-flow-from: article;
+            border: 1px solid blue;
+            float: left;
+            height: auto;
+        }
+
+        #article {
+            -webkit-flow-into: article;
+            width: 100%;
+            margin: 0px;
+        }
+
+        #region1 {
+            width: 20%;
+        }
+
+        #region2 {
+            width: 20%;
+        }
+
+        #region3 {
+            width: 30%;
+        }
+
+        #container {
+            margin: auto;
+            margin-top: 50px;
+            width: 50%;
+            background-color: rgb(42, 137, 57);
+            -webkit-region-break-inside: avoid;
+        }
+
+        #firstChild {
+            height: 31px;
+            margin-left: auto;
+            margin-top: 25px;
+            width: 70%;
+            background-color: rgb(255, 157, 0);
+            margin-right: auto;
+        }
+
+        #secondChild {
+            height: 27px;
+            margin-left: auto;
+            margin-top: 34px;
+            width: 70%;
+            background-color: rgb(255, 0, 0);
+            margin-right: auto;
+            -webkit-region-break-before: always;
+            -webkit-region-break-after: always;
+        }
+
+        #thirdChild {
+            height: 31px;
+            margin: auto;
+            width: 70%;
+            background-color: rgb(216, 0, 255);
+        }
+
+    &lt;/style&gt;
+    &lt;script src=3D&quot;../../resources/check-layout.js&quot;&gt;&lt;=
/script&gt;
+    &lt;/head&gt;
+    &lt;body onload=3D&quot;checkLayout('.region')&quot;&gt;
+        &lt;p&gt;Test for &lt;a href=3D&quot;https://bugs.webkit.org/sho=
w_bug.cgi?id=3D121318&quot;&gt;[CSS Regions] Strange layout for content w=
ith region breaks&lt;/a&gt;.&lt;/p&gt;
+        &lt;p&gt;The green rectangle is flowed inside three regions with=
 blue borders. The first region should contain the whole green rectangle.=
 The second and the third regions should have a height of 0px.&lt;/p&gt;
+        &lt;div id=3D'region1' class=3D'region' data-expected-height=3D'=
175px'&gt;&lt;/div&gt;
+        &lt;div id=3D'region2' class=3D'region' data-expected-height=3D'=
2px'&gt;&lt;/div&gt;
+        &lt;div id=3D'region3' class=3D'region' data-expected-height=3D'=
2px'&gt;&lt;/div&gt;
+        &lt;div id=3D'article'&gt;
+            &lt;div id=3D'container'&gt;
+                &lt;div id=3D'firstChild'&gt;&lt;/div&gt;
+                &lt;div id=3D'secondChild'&gt;&lt;/div&gt;
+                &lt;div id=3D'thirdChild'&gt;&lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id=3D"trunkSourceWebCoreChangeLog"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (1658=
72 =3D> 165873)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/ChangeLog	2014-03-19 06:55:=
29 UTC (rev 165872)
+++ trunk/Source/WebCore/ChangeLog	2014-03-19 06:57:17 UTC (rev 165873)
</span><span class=3D"lines">@@ -1,3 +1,37 @@
</span><ins>+2014-03-18  Andrei Bucur  &lt;abucur at adobe.com&gt;
+
+        [CSS Regions] Strange layout for content with region breaks
+        https://bugs.webkit.org/show_bug.cgi?id=3D121318
+
+        Reviewed by Mihnea Ovidenie.
+
+        When break-inside: avoid is used on an element, the implementati=
on tries to
+        force it inside a single fragmentation container even though the=
 descendants
+        of the element specify forced breaks. This leads to unexpected r=
esults and
+        unstable layout.
+
+        The change extends the definition of unsplittable elements for f=
low threads
+        using the same conditions found inside RenderBlockFlow::adjustFo=
rUnsplittableChild.
+        This change forces elements that require break avoidance to have=
 a single region
+        in the region range. As a result, forced breaks have no effect i=
nside them.
+
+        It should be noted this may not the behavior defined by the CSS3=
 Fragmentation spec.
+        From my understanding of the text, forced breaks override any av=
oidance specified
+        by ancestor elements. However, implementing this is a larger cha=
nge that will require
+        a fundamental new approach in handling break avoidance. This pat=
ch just brings
+        consistency to the API.
+
+        Test: fast/regions/forced-break-inside-avoid-break.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::childBoxIsUnsplittableForFragmentation):
+        (WebCore::RenderBlock::computeRegionRangeForBoxChild):
+        (WebCore::RenderBlock::estimateRegionRangeForBoxChild):
+        * rendering/RenderBlock.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::adjustForUnsplittableChild): Move the=
 avoidance conditions inside
+        a helper method RenderBlock::childBoxIsUnsplittableForFragmentat=
ion.
+
</ins><span class=3D"cx"> 2014-03-18  Samuel White  &lt;samuel_white at appl=
e.com&gt;
</span><span class=3D"cx">=20
</span><span class=3D"cx">         AX: Not able to use arrow keys to read=
 text with VoiceOver before selection is set someplace (anyplace).
</span></span></pre></div>
<a id=3D"trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/rendering/Rende=
rBlock.cpp (165872 =3D> 165873)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2=
014-03-19 06:55:29 UTC (rev 165872)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2014-03-19 06:57:17 UT=
C (rev 165873)
</span><span class=3D"lines">@@ -5054,6 +5054,18 @@
</span><span class=3D"cx">     return flowThreadContainingBlock-&gt;hasRe=
gionRangeForBox(parentBlock);
</span><span class=3D"cx"> }
</span><span class=3D"cx">=20
</span><ins>+bool RenderBlock::childBoxIsUnsplittableForFragmentation(con=
st RenderBox&amp; child) const
+{
+    RenderFlowThread* flowThread =3D flowThreadContainingBlock();
+    bool isInsideMulticolFlowThread =3D flowThread &amp;&amp; !flowThrea=
d-&gt;isRenderNamedFlowThread();
+    bool checkColumnBreaks =3D isInsideMulticolFlowThread || view().layo=
utState()-&gt;isPaginatingColumns();
+    bool checkPageBreaks =3D !checkColumnBreaks &amp;&amp; view().layout=
State()-&gt;m_pageLogicalHeight;
+    bool checkRegionBreaks =3D flowThread &amp;&amp; flowThread-&gt;isRe=
nderNamedFlowThread();
+    return child.isUnsplittableForPagination() || (checkColumnBreaks &am=
p;&amp; child.style().columnBreakInside() =3D=3D PBAVOID)
+        || (checkPageBreaks &amp;&amp; child.style().pageBreakInside() =3D=
=3D PBAVOID)
+        || (checkRegionBreaks &amp;&amp; child.style().regionBreakInside=
() =3D=3D PBAVOID);
+}
+
</ins><span class=3D"cx"> void RenderBlock::computeRegionRangeForBoxChild=
(const RenderBox&amp; box) const
</span><span class=3D"cx"> {
</span><span class=3D"cx">     RenderFlowThread* flowThread =3D flowThrea=
dContainingBlock();
</span><span class=3D"lines">@@ -5062,7 +5074,7 @@
</span><span class=3D"cx">     RenderRegion* startRegion;
</span><span class=3D"cx">     RenderRegion* endRegion;
</span><span class=3D"cx">     LayoutUnit offsetFromLogicalTopOfFirstRegi=
on =3D box.offsetFromLogicalTopOfFirstPage();
</span><del>-    if (box.isUnsplittableForPagination())
</del><ins>+    if (childBoxIsUnsplittableForFragmentation(box))
</ins><span class=3D"cx">         startRegion =3D endRegion =3D flowThrea=
d-&gt;regionAtBlockOffset(this, offsetFromLogicalTopOfFirstRegion, true);
</span><span class=3D"cx">     else {
</span><span class=3D"cx">         startRegion =3D flowThread-&gt;regionA=
tBlockOffset(this, offsetFromLogicalTopOfFirstRegion, true);
</span><span class=3D"lines">@@ -5078,7 +5090,7 @@
</span><span class=3D"cx">     if (!canComputeRegionRangeForBox(this, box=
, flowThread))
</span><span class=3D"cx">         return;
</span><span class=3D"cx">=20
</span><del>-    if (box.isUnsplittableForPagination()) {
</del><ins>+    if (childBoxIsUnsplittableForFragmentation(box)) {
</ins><span class=3D"cx">         computeRegionRangeForBoxChild(box);
</span><span class=3D"cx">         return;
</span><span class=3D"cx">     }
</span></span></pre></div>
<a id=3D"trunkSourceWebCorerenderingRenderBlockh"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/rendering/Rende=
rBlock.h (165872 =3D> 165873)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/rendering/RenderBlock.h	201=
4-03-19 06:55:29 UTC (rev 165872)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2014-03-19 06:57:17 UTC =
(rev 165873)
</span><span class=3D"lines">@@ -421,6 +421,8 @@
</span><span class=3D"cx">     // FIXME: Can de-virtualize this once old =
columns go away.
</span><span class=3D"cx">     virtual void setComputedColumnCountAndWidt=
h(int, LayoutUnit);
</span><span class=3D"cx">=20
</span><ins>+    bool childBoxIsUnsplittableForFragmentation(const Render=
Box&amp; child) const;
+
</ins><span class=3D"cx"> public:
</span><span class=3D"cx">     virtual void computeOverflow(LayoutUnit ol=
dClientAfterEdge, bool recomputeFloats =3D false);
</span><span class=3D"cx">     void clearLayoutOverflow();
</span></span></pre></div>
<a id=3D"trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class=3D"modfile"><h4>Modified: trunk/Source/WebCore/rendering/Rende=
rBlockFlow.cpp (165872 =3D> 165873)</h4>
<pre class=3D"diff"><span>
<span class=3D"info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.c=
pp	2014-03-19 06:55:29 UTC (rev 165872)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2014-03-19 06:57:1=
7 UTC (rev 165873)
</span><span class=3D"lines">@@ -1689,16 +1689,10 @@
</span><span class=3D"cx">=20
</span><span class=3D"cx"> LayoutUnit RenderBlockFlow::adjustForUnsplitta=
bleChild(RenderBox&amp; child, LayoutUnit logicalOffset, bool includeMarg=
ins)
</span><span class=3D"cx"> {
</span><del>-    RenderFlowThread* flowThread =3D flowThreadContainingBlo=
ck();
-    bool isInsideMulticolFlowThread =3D flowThread &amp;&amp; !flowThrea=
d-&gt;isRenderNamedFlowThread();
-    bool checkColumnBreaks =3D isInsideMulticolFlowThread || view().layo=
utState()-&gt;isPaginatingColumns();
-    bool checkPageBreaks =3D !checkColumnBreaks &amp;&amp; view().layout=
State()-&gt;m_pageLogicalHeight;
-    bool checkRegionBreaks =3D flowThread &amp;&amp; flowThread-&gt;isRe=
nderNamedFlowThread();
-    bool isUnsplittable =3D child.isUnsplittableForPagination() || (chec=
kColumnBreaks &amp;&amp; child.style().columnBreakInside() =3D=3D PBAVOID=
)
-        || (checkPageBreaks &amp;&amp; child.style().pageBreakInside() =3D=
=3D PBAVOID)
-        || (checkRegionBreaks &amp;&amp; child.style().regionBreakInside=
() =3D=3D PBAVOID);
-    if (!isUnsplittable)
</del><ins>+    if (!childBoxIsUnsplittableForFragmentation(child))
</ins><span class=3D"cx">         return logicalOffset;
</span><ins>+
+    RenderFlowThread* flowThread =3D flowThreadContainingBlock();
</ins><span class=3D"cx">     LayoutUnit childLogicalHeight =3D logicalHe=
ightForChild(child) + (includeMargins ? marginBeforeForChild(child) + mar=
ginAfterForChild(child) : LayoutUnit());
</span><span class=3D"cx">     LayoutUnit pageLogicalHeight =3D pageLogic=
alHeightForOffset(logicalOffset);
</span><span class=3D"cx">     bool hasUniformPageLogicalHeight =3D !flow=
Thread || flowThread-&gt;regionsHaveUniformLogicalHeight();
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list