No subject


Fri Mar 7 15:32:22 PST 2014


Source/WebCore:

Floats Don't Overhang Their Block Formatting Context Per
http://www.w3.org/TR/CSS2/visuren.html#float-position: "References
to [the elements] in the [rules that govern the behaviour of
floats] refer only to other elements in the same block formatting
context as the float."

This means we don't need to look for intruding or overhanging
floats in boxes that establish a new block formatting
context. Even that we don't have a test breaking this rule it
seems we are doing unnecessary work in
rebuildFloatsFromIntruding() so make sure we avoid adding floats
from different block formatting contexts.

Test:
fast/block/float/floats-do-not-overhang-from-block-formatting-context.html

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::addIntrudingFloats):

LayoutTests:

Tests to verify that float elements don't overhang blocks with a
different formatting context.

* fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt: Added.
* fast/block/float/floats-do-not-overhang-from-block-formatting-context.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastblockfloatfloatsdonotoverhangfromblockformattingcontextexpectedtxt">trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastblockfloatfloatsdonotoverhangfromblockformattingcontexthtml">trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (177307 => 177308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog	2014-12-15 20:45:53 UTC (rev 177307)
+++ trunk/LayoutTests/ChangeLog	2014-12-15 21:07:30 UTC (rev 177308)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-12-15  Javier Fernandez  &lt;jfernandez at igalia.com&gt;
+
+        Floats Don't Overhang Their Block Formatting Contex
+        https://bugs.webkit.org/show_bug.cgi?id=139476
+
+        Reviewed by David Hyatt.
+
+        From Blink r172530 by &lt;robhogan at gmail.com&gt;
+
+        Tests to verify that float elements don't overhang blocks with a
+        different formatting context.
+
+        * fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt: Added.
+        * fast/block/float/floats-do-not-overhang-from-block-formatting-context.html: Added.
+
</ins><span class="cx"> 2014-12-15  Myles C. Maxfield  &lt;mmaxfield at apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Delete Notation because we don't use it
</span></span></pre></div>
<a id="trunkLayoutTestsfastblockfloatfloatsdonotoverhangfromblockformattingcontextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt (0 => 177308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt	2014-12-15 21:07:30 UTC (rev 177308)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+http://www.w3.org/TR/CSS2/visuren.html#float-position: &quot;References to [the elements] in the [rules that govern the behaviour of floats] refer only to other elements in the same block formatting context as the float.&quot; 
+ PASS
+ 
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+
+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestsfastblockfloatfloatsdonotoverhangfromblockformattingcontexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html (0 => 177308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html	2014-12-15 21:07:30 UTC (rev 177308)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+&lt;!DOCTYPE HTML&gt;
+&lt;html&gt;
+&lt;style&gt;
+body {
+    margin: 0px;
+    padding: 0px;
+}
+.item {
+    height: 40px;
+    width: 40px;
+}
+fieldset {
+    border: 0px;
+    padding: 0px;
+    margin: 0px;
+}
+.test {
+    width: 40px;
+    height:40px;
+    background-color: red;
+}
+.container {
+    position: relative;
+    margin: 0px;
+    padding: 0px;
+}
+.float {
+    float: left;
+    width: 40px;
+    height:80px;
+    background-color: blue;
+}
+&lt;/style&gt;
+&lt;script src=&quot;../../../resources/check-layout.js&quot;&gt;&lt;/script&gt;
+&lt;body onload=&quot;checkLayout('.test')&quot;&gt;
+http://www.w3.org/TR/CSS2/visuren.html#float-position:
+&quot;References to [the elements] in the [rules that govern the behaviour of floats] refer only to other elements in the same block formatting context as the float.&quot;
+&lt;br&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;div class=&quot;item&quot; style=&quot;display: inline-block;&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/div&gt;
+    &lt;div class=&quot;test&quot; data-total-x=0&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;div class=&quot;item&quot; style=&quot;display: inline-table;&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/div&gt;
+    &lt;div class=&quot;test&quot; data-total-x=0&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;div class=&quot;item&quot; style=&quot;display: table-caption;&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/div&gt;
+    &lt;div class=&quot;test&quot; data-total-x=0 data-offset-y=40&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;div class=&quot;item&quot; style=&quot;overflow:hidden;&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/div&gt;
+    &lt;div class=&quot;test&quot; data-total-x=0 data-offset-y=40&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;div class=&quot;item&quot; style=&quot;-webkit-columns: 10px 2;&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/div&gt;
+    &lt;div class=&quot;test&quot; data-total-x=0 data-offset-y=40&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;div class=&quot;item&quot; style=&quot;-webkit-column-span: all;&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/div&gt;
+    &lt;div class=&quot;test&quot; data-total-x=0 data-offset-y=40&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;div style=&quot;display: flex; -webkit-flex-direction: column;&quot;&gt;
+        &lt;div class=&quot;item&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/div&gt;
+        &lt;div class=&quot;test&quot; data-total-x=0 data-offset-y=40&gt;&lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+&lt;div class=&quot;container&quot;&gt;
+    &lt;fieldset class=&quot;item&quot;&gt;&lt;div class=&quot;float&quot;&gt;&lt;/div&gt;&lt;/fieldset&gt;
+    &lt;div class=&quot;test&quot; data-total-x=0 data-offset-y=40&gt;&lt;/div&gt;
+&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (177307 => 177308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog	2014-12-15 20:45:53 UTC (rev 177307)
+++ trunk/Source/WebCore/ChangeLog	2014-12-15 21:07:30 UTC (rev 177308)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2014-12-15  Javier Fernandez  &lt;jfernandez at igalia.com&gt;
+
+        Floats Don't Overhang Their Block Formatting Contex
+        https://bugs.webkit.org/show_bug.cgi?id=139476
+
+        Reviewed by David Hyatt.
+
+        From Blink r172530 by &lt;robhogan at gmail.com&gt;
+
+        Floats Don't Overhang Their Block Formatting Context Per
+        http://www.w3.org/TR/CSS2/visuren.html#float-position: &quot;References
+        to [the elements] in the [rules that govern the behaviour of
+        floats] refer only to other elements in the same block formatting
+        context as the float.&quot;
+
+        This means we don't need to look for intruding or overhanging
+        floats in boxes that establish a new block formatting
+        context. Even that we don't have a test breaking this rule it
+        seems we are doing unnecessary work in
+        rebuildFloatsFromIntruding() so make sure we avoid adding floats
+        from different block formatting contexts.
+
+        Test:
+        fast/block/float/floats-do-not-overhang-from-block-formatting-context.html
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::addIntrudingFloats):
+
</ins><span class="cx"> 2014-12-15  Myles C. Maxfield  &lt;mmaxfield at apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed build fix after r177301
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (177307 => 177308)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2014-12-15 20:45:53 UTC (rev 177307)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2014-12-15 21:07:30 UTC (rev 177308)
</span><span class="lines">@@ -2668,6 +2668,10 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!avoidsFloats());
</span><span class="cx"> 
</span><ins>+    // If we create our own block formatting context then our contents don't interact with floats outside it, even those from our parent.
+    if (createsNewFormattingContext())
+        return;
+
</ins><span class="cx">     // If the parent or previous sibling doesn't have any floats to add, don't bother.
</span><span class="cx">     if (!prev-&gt;m_floatingObjects)
</span><span class="cx">         return;
</span></span></pre>
</div>
</div>

</body>
</html>


More information about the webkit-changes mailing list