Floats Don't Overhang Their Block Formatting Contex
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 21:07:30 +0000 (21:07 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Dec 2014 21:07:30 +0000 (21:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139476

Reviewed by David Hyatt.

From Blink r172530 by <robhogan@gmail.com>

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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177308 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockFlow.cpp

index af45f8b..9fa90ba 100644 (file)
@@ -1,3 +1,18 @@
+2014-12-15  Javier Fernandez  <jfernandez@igalia.com>
+
+        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 <robhogan@gmail.com>
+
+        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.
+
 2014-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Delete Notation because we don't use it
diff --git a/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt b/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context-expected.txt
new file mode 100644 (file)
index 0000000..5c0b817
--- /dev/null
@@ -0,0 +1,11 @@
+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." 
+ PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+PASS
+
+PASS
diff --git a/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html b/LayoutTests/fast/block/float/floats-do-not-overhang-from-block-formatting-context.html
new file mode 100644 (file)
index 0000000..9359ccf
--- /dev/null
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<style>
+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;
+}
+</style>
+<script src="../../../resources/check-layout.js"></script>
+<body onload="checkLayout('.test')">
+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."
+<br>
+<div class="container">
+    <div class="item" style="display: inline-block;"><div class="float"></div></div>
+    <div class="test" data-total-x=0></div>
+</div>
+<div class="container">
+    <div class="item" style="display: inline-table;"><div class="float"></div></div>
+    <div class="test" data-total-x=0></div>
+</div>
+<div class="container">
+    <div class="item" style="display: table-caption;"><div class="float"></div></div>
+    <div class="test" data-total-x=0 data-offset-y=40></div>
+</div>
+<div class="container">
+    <div class="item" style="overflow:hidden;"><div class="float"></div></div>
+    <div class="test" data-total-x=0 data-offset-y=40></div>
+</div>
+<div class="container">
+    <div class="item" style="-webkit-columns: 10px 2;"><div class="float"></div></div>
+    <div class="test" data-total-x=0 data-offset-y=40></div>
+</div>
+<div class="container">
+    <div class="item" style="-webkit-column-span: all;"><div class="float"></div></div>
+    <div class="test" data-total-x=0 data-offset-y=40></div>
+</div>
+<div class="container">
+    <div style="display: flex; -webkit-flex-direction: column;">
+        <div class="item"><div class="float"></div></div>
+        <div class="test" data-total-x=0 data-offset-y=40></div>
+    </div>
+</div>
+<div class="container">
+    <fieldset class="item"><div class="float"></div></fieldset>
+    <div class="test" data-total-x=0 data-offset-y=40></div>
+</div>
+</body>
+</html>
index d02c5ab..25e92df 100644 (file)
@@ -1,3 +1,31 @@
+2014-12-15  Javier Fernandez  <jfernandez@igalia.com>
+
+        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 <robhogan@gmail.com>
+
+        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):
+
 2014-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Unreviewed build fix after r177301
index 1a37006..0a3ba4b 100644 (file)
@@ -2668,6 +2668,10 @@ void RenderBlockFlow::addIntrudingFloats(RenderBlockFlow* prev, LayoutUnit logic
 {
     ASSERT(!avoidsFloats());
 
+    // 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;
+
     // If the parent or previous sibling doesn't have any floats to add, don't bother.
     if (!prev->m_floatingObjects)
         return;