Title: [151570] trunk
Revision
151570
Author
[email protected]
Date
2013-06-13 14:09:43 -0700 (Thu, 13 Jun 2013)

Log Message

[CSS Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes
https://bugs.webkit.org/show_bug.cgi?id=117599

Reviewed by David Hyatt.

In r150478 I added support for multiple positioned shape-insides on regions, this patch covers the cases when a shape
is positioned to the bottom of the region or the region contains a shape which forces the content to be adjusted inside
the shape (e.g. we have a triangle shape and the first line needs to be started at the first position where it fits).
I introduced a new helper function to update the current shape and the current line segments in the flow thread cases. With
this new helper function all the logic which calculates the segments for shape-inside on regions is located in one function.

Source/WebCore:

Tests: fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes.html
       fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment.html
       fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes.html
       fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment.html

* rendering/RenderBlock.h: Add new helper's declaration
* rendering/RenderBlockLineLayout.cpp:
(WebCore::LineLayoutState::LineLayoutState): Add a member to carry adjustment for flow thread cases.
(WebCore::LineLayoutState::adjustedLogicalLineTop): Add new member.
(WebCore::LineLayoutState::setAdjustedLogicalLineTop): Add new setter for the new member.
(WebCore::RenderBlock::updateShapeAndSegmentsForCurrentLine): Move flow thread case to its helper function.
(WebCore::RenderBlock::updateShapeAndSegmentsForCurrentLineInFlowThread): Added new helper for flow thread cases.
(WebCore::RenderBlock::adjustLogicalLineTopAndLogicalHeightIfNeeded): Save adjustment for flow thread cases.

LayoutTests:

* fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes-expected.html: Added.
* fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes.html: Added.
* fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment-expected.html: Added.
* fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment.html: Added.
* fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes-expected.html: Added.
* fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes.html: Added.
* fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment-expected.html: Added.
* fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (151569 => 151570)


--- trunk/LayoutTests/ChangeLog	2013-06-13 20:51:25 UTC (rev 151569)
+++ trunk/LayoutTests/ChangeLog	2013-06-13 21:09:43 UTC (rev 151570)
@@ -1,3 +1,25 @@
+2013-06-13  Zoltan Horvath  <[email protected]>
+
+        [CSS Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes
+        https://bugs.webkit.org/show_bug.cgi?id=117599
+
+        Reviewed by David Hyatt.
+
+        In r150478 I added support for multiple positioned shape-insides on regions, this patch covers the cases when a shape
+        is positioned to the bottom of the region or the region contains a shape which forces the content to be adjusted inside
+        the shape (e.g. we have a triangle shape and the first line needs to be started at the first position where it fits).
+        I introduced a new helper function to update the current shape and the current line segments in the flow thread cases. With
+        this new helper function all the logic which calculates the segments for shape-inside on regions is located in one function.
+
+        * fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes-expected.html: Added.
+        * fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes.html: Added.
+        * fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment-expected.html: Added.
+        * fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment.html: Added.
+        * fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes-expected.html: Added.
+        * fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes.html: Added.
+        * fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment-expected.html: Added.
+        * fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment.html: Added.
+
 2013-06-13  Mihai Tica  <[email protected]>
 
         Add tests to validate CSS Background Blending

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes-expected.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes-expected.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <style>
+        #page {
+            font: 20px Ahem, sans-serif;
+            line-height: 20px;
+        }
+        .region {
+            width: 200px;
+            height: 200px;
+            border: 2px solid green;
+        }
+        #region2 { margin-top: 10px; }
+        #border1 {
+            position: absolute;
+            top: 108px;
+            left: 58px;
+            width: 100px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+        #border2 {
+            position: absolute;
+            top: 322px;
+            left: 33px;
+            width: 140px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+        #overflow {
+            width: 200px;
+            margin-left: 2px;
+            margin-top: -2px;
+        }
+    </style>
+</head>
+<body>
+    <div id="page">
+        <div id="border1">X X <p>X X X X X<p></div>
+        <div id="region1" class="region"></div>
+        <div id="border2">X<p>X X X X</p><p>X X X X</p></div>
+        <div id="region2" class="region"></div>
+        <div id="overflow">X X X X X X X</div>
+    </div>
+    <p style="margin-top: 12px;">Requires Ahem font. There are two regions with two ractangle shape-insides, the shape-insides are smaller and have top and left offsets inside the content box. The rectangular shapes boundaries are represented by the blue rectangles. The block content should flow inside the blue ractangles, the overflow should be pushed down below the last region's content box.</p>
+    <p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <script>
+        if (window.internals)
+            window.internals.settings.setCSSShapesEnabled(true);
+    </script>
+    <style>
+        #rectangle {
+            font: 20px Ahem, sans-serif;
+            line-height: 20px;
+            -webkit-flow-into: flow;
+        }
+        .region {
+            -webkit-flow-from: flow;
+            width: 200px;
+            height: 200px;
+            border: 2px solid green;
+        }
+        #region1 { -webkit-shape-inside: rectangle(50px, 100px, 100px, 100px); }
+        #region2 {
+            margin-top: 10px;
+            -webkit-shape-inside: rectangle(25px, 100px, 150px, 100px);
+        }
+        #border1 {
+            position: absolute;
+            top: 108px;
+            left: 58px;
+            width: 100px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+        #border2 {
+            position: absolute;
+            top: 322px;
+            left: 33px;
+            width: 140px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+    </style>
+</head>
+<body>
+    <div id="rectangle">
+       X X <p>X X X X X<p> X</p></p> X X X X<p> X X X X X X X X X X X
+    </div>
+
+    <div id="page">
+        <div id="border1"></div>
+        <div id="region1" class="region"></div>
+        <div id="border2"></div>
+        <div id="region2" class="region"></div>
+    </div>
+    <p style="margin-top: 50px;">Requires Ahem font. There are two regions with two ractangle shape-insides, the shape-insides are smaller and have top and left offsets inside the content box. The rectangular shapes boundaries are represented by the blue rectangles. The block content should flow inside the blue ractangles, the overflow should be pushed down below the last region's content box.</p>
+    <p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment-expected.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment-expected.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    #content {
+        font: 13px Ahem, sans-serif;
+        line-height: 15px;
+    }
+    .region1 {
+        width: 200px;
+        height: 200px;
+        border: 5px solid black;
+        border-top: 10px solid green;
+        border-bottom: 15px solid yellow;
+        margin-top: 10px;
+    }
+    .region2 {
+        width: 400px;
+        height: 400px;
+        border: 15px solid black;
+        border-top: 30px solid green;
+        border-left: 0px; /* FIXME: Content gets extra left offset when there is left-border on the content box:  http://webkit.org/b/117573 */
+        margin-top: 10px;
+        -webkit-shape-inside: polygon(30px 30px, 380px 380px, 10px 380px);
+    }
+</style>
+</head>
+<body>
+<div id="content">
+    <div class="region1">
+        The Culture and <p>the Idiran <p>Empire</p> are </p>at war in a galaxy-spanning conflict. Horza, a mercenary
+    </div>
+    <div class="region2">
+        <p>capable of altering his appearance</p>at will <p>(a Changer),</p> is assigned the task of retrieving a dispossessed Culture Mind by his Idiran handlers.
+    </div>
+</div>
+
+<p style="margin-top: 30px;">Requires Ahem font. There are two regions, there is a polygon shape-inside on the second region. The shape is positioned and it forces the content to be adjusted (pushed down from the top of the shape) inside the shape. The content should fill out the first region and it should fill out the polygon shape on the second region.</p>
+<p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    #content {
+        -webkit-flow-into: flow;
+        font: 13px Ahem, sans-serif;
+        line-height: 15px;
+    }
+    .region1 {
+        -webkit-flow-from: flow;
+        width: 200px;
+        height: 200px;
+        border: 5px solid black;
+        border-top: 10px solid green;
+        border-bottom: 15px solid yellow;
+        margin-top: 10px;
+    }
+    .region2 {
+        -webkit-flow-from: flow;
+        width: 400px;
+        height: 400px;
+        border: 15px solid black;
+        border-top: 30px solid green;
+        border-left: 0px;  /* FIXME: Content gets extra left offset when there is left-border on the content box:  http://webkit.org/b/117573 */
+        margin-top: 10px;
+        -webkit-shape-inside: polygon(30px 30px, 380px 380px, 10px 380px);
+    }
+</style>
+</head>
+<body>
+<div class="region1"></div>
+<div class="region2"></div>
+
+<div id="content">
+The Culture and <p>the Idiran <p>Empire</p> are </p>at war in a galaxy-spanning conflict. Horza, a mercenary <p>capable of altering his appearance</p>at will <p>(a Changer),</p> is assigned the task of retrieving a dispossessed Culture Mind by his Idiran handlers.
+</div>
+
+<p style="margin-top: 30px;">Requires Ahem font. There are two regions, there is a polygon shape-inside on the second region. The shape is positioned and it forces the content to be adjusted (pushed down from the top of the shape) inside the shape. The content should fill out the first region and it should fill out the polygon shape on the second region.</p>
+<p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes-expected.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes-expected.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <style>
+        #page {
+            font: 20px Ahem, sans-serif;
+            line-height: 20px;
+        }
+        .region {
+            width: 200px;
+            height: 200px;
+            border: 2px solid green;
+        }
+        #region2 { margin-top: 10px; }
+        #border1 {
+            position: absolute;
+            top: 108px;
+            left: 58px;
+            width: 100px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+        #border2 {
+            position: absolute;
+            top: 322px;
+            left: 33px;
+            width: 140px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+        #overflow {
+            width: 200px;
+            margin-left: 2px;
+            margin-top: -2px;
+        }
+    </style>
+</head>
+<body>
+    <div id="page">
+        <div id="border1">X X X X X X X X X X X X X X X</div>
+        <div id="region1" class="region"></div>
+        <div id="border2">X X X X X X X X X X X X X X X X X X X X</div>
+        <div id="region2" class="region"></div>
+        <div id="overflow">X X X X X X X</div>
+    </div>
+    <p style="margin-top: 12px;">Requires Ahem font. There are two regions with two ractangle shape-insides, the shape-insides are smaller and have top and left offsets inside the content box. The rectangular shapes boundaries are represented by the blue rectangles. The inline content should flow inside the blue ractangles, the overflow should be pushed down below the last region's content box</p>
+    <p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <script>
+        if (window.internals)
+            window.internals.settings.setCSSShapesEnabled(true);
+    </script>
+    <style>
+        #rectangle {
+            font: 20px Ahem, sans-serif;
+            line-height: 20px;
+            -webkit-flow-into: flow;
+        }
+        .region {
+            -webkit-flow-from: flow;
+            width: 200px;
+            height: 200px;
+            border: 2px solid green;
+        }
+        #region1 { -webkit-shape-inside: rectangle(50px, 100px, 100px, 100px); }
+        #region2 {
+            margin-top: 10px;
+            -webkit-shape-inside: rectangle(25px, 100px, 140px, 100px);
+        }
+        #border1 {
+            position: absolute;
+            top: 108px;
+            left: 58px;
+            width: 100px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+        #border2 {
+            position: absolute;
+            top: 322px;
+            left: 33px;
+            width: 140px;
+            height: 100px;
+            border: 2px solid blue;
+        }
+    </style>
+</head>
+<body>
+    <div id="rectangle">
+       X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
+    </div>
+
+    <div id="page">
+        <div id="border1"></div>
+        <div id="region1" class="region"></div>
+        <div id="border2"></div>
+        <div id="region2" class="region"></div>
+    </div>
+    <p style="margin-top: 50px;">Requires Ahem font. There are two regions with two ractangle shape-insides, the shape-insides are smaller and have top and left offsets inside the content box. The rectangular shapes boundaries are represented by the blue rectangles. The inline content should flow inside the blue ractangles, the overflow should be pushed down below the last region's content box</p>
+    <p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment-expected.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment-expected.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    #content {
+        font: 13px Ahem, sans-serif;
+        line-height: 15px;
+    }
+    .region1 {
+        width: 200px;
+        height: 200px;
+        border: 5px solid black;
+        border-top: 10px solid green;
+        border-bottom: 15px solid yellow;
+        margin-top: 10px;
+    }
+    .region2 {
+        width: 400px;
+        height: 400px;
+        border: 15px solid black;
+        margin-top: 10px;
+        border-top: 30px solid green;
+        -webkit-shape-inside: polygon(30px 30px, 380px 380px, 10px 380px);
+    }
+</style>
+</head>
+<body>
+<div id="content">
+    <div class="region1">
+        The Culture and the Idiran Empire are at war in a galaxy-spanning conflict. Horza, a mercenary capable of altering his appearance at will (a Changer), is
+    </div>
+    <div class="region2">
+        assigned the task of retrieving a dispossessed Culture Mind by his Idiran handlers. The Mind, while fleeing attacking Idirans who consider its existence an abomination, has taken...
+    </div>
+</div>
+
+<p style="margin-top: 30px;">Requires Ahem font. There are two regions, there is a polygon shape-inside on the second region. The shape is positioned and it forces the content to be adjusted (pushed down from the top of the shape) inside the shape. The content should fill out the first region and it should fill out the polygon shape on the second region.</p>
+<p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment.html (0 => 151570)


--- trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment.html	                        (rev 0)
+++ trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment.html	2013-06-13 21:09:43 UTC (rev 151570)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+    if (window.internals)
+        window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+    #content {
+        -webkit-flow-into: flow;
+        font: 13px Ahem, sans-serif;
+        line-height: 15px;
+    }
+    .region1 {
+        -webkit-flow-from: flow;
+        width: 200px;
+        height: 200px;
+        border: 5px solid black;
+        border-top: 10px solid green;
+        border-bottom: 15px solid yellow;
+        margin-top: 10px;
+    }
+    .region2 {
+        -webkit-flow-from: flow;
+        width: 400px;
+        height: 400px;
+        border: 15px solid black;
+        border-top: 30px solid green;
+        margin-top: 10px;
+        -webkit-shape-inside: polygon(30px 30px, 380px 380px, 10px 380px);
+    }
+</style>
+</head>
+<body>
+<div class="region1"></div>
+<div class="region2"></div>
+
+<div id="content">
+The Culture and the Idiran Empire are at war in a galaxy-spanning conflict. Horza, a mercenary capable of altering his appearance at will (a Changer), is assigned the task of retrieving a dispossessed Culture Mind by his Idiran handlers. The Mind, while fleeing attacking Idirans who consider its existence an abomination, has taken...
+</div>
+
+<p style="margin-top: 30px;">Requires Ahem font. There are two regions, there is a polygon shape-inside on the second region. The shape is positioned and it forces the content to be adjusted (pushed down from the top of the shape) inside the shape. The content should fill out the first region and it should fill out the polygon shape on the second region.</p>
+<p>Bug <a href="" Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes</p>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (151569 => 151570)


--- trunk/Source/WebCore/ChangeLog	2013-06-13 20:51:25 UTC (rev 151569)
+++ trunk/Source/WebCore/ChangeLog	2013-06-13 21:09:43 UTC (rev 151570)
@@ -1,3 +1,30 @@
+2013-06-13  Zoltan Horvath  <[email protected]>
+
+        [CSS Shapes][CSS Regions] Respect bottom positioned shapes and content adjustment inside shapes
+        https://bugs.webkit.org/show_bug.cgi?id=117599
+
+        Reviewed by David Hyatt.
+
+        In r150478 I added support for multiple positioned shape-insides on regions, this patch covers the cases when a shape
+        is positioned to the bottom of the region or the region contains a shape which forces the content to be adjusted inside
+        the shape (e.g. we have a triangle shape and the first line needs to be started at the first position where it fits).
+        I introduced a new helper function to update the current shape and the current line segments in the flow thread cases. With
+        this new helper function all the logic which calculates the segments for shape-inside on regions is located in one function.
+
+        Tests: fast/regions/shape-inside/shape-inside-on-regions-block-content-overflow-bottom-positioned-multiple-shapes.html
+               fast/regions/shape-inside/shape-inside-on-regions-block-content-polygon-with-adjustment.html
+               fast/regions/shape-inside/shape-inside-on-regions-inline-content-overflow-bottom-positioned-multiple-shapes.html
+               fast/regions/shape-inside/shape-inside-on-regions-inline-content-polygon-with-adjustment.html
+
+        * rendering/RenderBlock.h: Add new helper's declaration
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::LineLayoutState::LineLayoutState): Add a member to carry adjustment for flow thread cases.
+        (WebCore::LineLayoutState::adjustedLogicalLineTop): Add new member.
+        (WebCore::LineLayoutState::setAdjustedLogicalLineTop): Add new setter for the new member.
+        (WebCore::RenderBlock::updateShapeAndSegmentsForCurrentLine): Move flow thread case to its helper function.
+        (WebCore::RenderBlock::updateShapeAndSegmentsForCurrentLineInFlowThread): Added new helper for flow thread cases.
+        (WebCore::RenderBlock::adjustLogicalLineTopAndLogicalHeightIfNeeded): Save adjustment for flow thread cases.
+
 2013-06-13  Mihai Tica  <[email protected]>
 
         [CSS Background Blending] Enable CSS Background blending for layers with SVGs.

Modified: trunk/Source/WebCore/rendering/RenderBlock.h (151569 => 151570)


--- trunk/Source/WebCore/rendering/RenderBlock.h	2013-06-13 20:51:25 UTC (rev 151569)
+++ trunk/Source/WebCore/rendering/RenderBlock.h	2013-06-13 21:09:43 UTC (rev 151570)
@@ -1085,7 +1085,8 @@
     void layoutRunsAndFloats(LineLayoutState&, bool hasInlineChild);
     void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines);
 #if ENABLE(CSS_SHAPES)
-    void updateShapeAndSegmentsForCurrentLine(ShapeInsideInfo*, LayoutUnit&, LineLayoutState&, bool&);
+    void updateShapeAndSegmentsForCurrentLine(ShapeInsideInfo*&, LayoutUnit&, LineLayoutState&, bool&);
+    void updateShapeAndSegmentsForCurrentLineInFlowThread(ShapeInsideInfo*&, LineLayoutState&, bool&);
     bool adjustLogicalLineTopAndLogicalHeightIfNeeded(ShapeInsideInfo*, LayoutUnit, LineLayoutState&, InlineBidiResolver&, FloatingObject*, InlineIterator&, WordMeasurements&);
 #endif
     const InlineIterator& restartLayoutRunsAndFloatsInRange(LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight,  FloatingObject* lastFloatFromPreviousLine, InlineBidiResolver&,  const InlineIterator&);

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (151569 => 151570)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-06-13 20:51:25 UTC (rev 151569)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-06-13 21:09:43 UTC (rev 151570)
@@ -1458,6 +1458,7 @@
         , m_isFullLayout(fullLayout)
         , m_repaintLogicalTop(repaintLogicalTop)
         , m_repaintLogicalBottom(repaintLogicalBottom)
+        , m_adjustedLogicalLineTop(0)
         , m_usesRepaintBounds(false)
         , m_flowThread(flowThread)
     { }
@@ -1503,6 +1504,9 @@
     unsigned floatIndex() const { return m_floatIndex; }
     void setFloatIndex(unsigned floatIndex) { m_floatIndex = floatIndex; }
     
+    LayoutUnit adjustedLogicalLineTop() const { return m_adjustedLogicalLineTop; }
+    void setAdjustedLogicalLineTop(LayoutUnit value) { m_adjustedLogicalLineTop = value; }
+
     RenderFlowThread* flowThread() const { return m_flowThread; }
     void setFlowThread(RenderFlowThread* thread) { m_flowThread = thread; }
 
@@ -1522,6 +1526,8 @@
     LayoutUnit& m_repaintLogicalTop;
     LayoutUnit& m_repaintLogicalBottom;
 
+    LayoutUnit m_adjustedLogicalLineTop;
+
     bool m_usesRepaintBounds;
     
     RenderFlowThread* m_flowThread;
@@ -1646,58 +1652,98 @@
     return shapeInsideInfo->shapeLogicalBottom();
 }
 
-void RenderBlock::updateShapeAndSegmentsForCurrentLine(ShapeInsideInfo* shapeInsideInfo, LayoutUnit& absoluteLogicalTop, LineLayoutState& layoutState, bool& lineOverflowsFromShapeInside)
+void RenderBlock::updateShapeAndSegmentsForCurrentLine(ShapeInsideInfo*& shapeInsideInfo, LayoutUnit& absoluteLogicalTop, LineLayoutState& layoutState, bool& lineOverflowsFromShapeInside)
 {
-    LayoutUnit logicalHeight = this->logicalHeight();
-    RenderRegion* currentRegion = regionAtBlockOffset(logicalHeight);
-    if (currentRegion)
-        shapeInsideInfo = layoutShapeInsideInfo();
+    if (layoutState.flowThread())
+        return updateShapeAndSegmentsForCurrentLineInFlowThread(shapeInsideInfo, layoutState, lineOverflowsFromShapeInside);
+
     if (!shapeInsideInfo)
         return;
 
-    LayoutUnit lineTop = logicalHeight + absoluteLogicalTop;
-    LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
-
-    if (layoutState.flowThread()) {
-        RenderRegion* nextRegion = regionAtBlockOffset(logicalHeight + lineHeight - LayoutUnit(1));
-        lineTop += shapeInsideInfo->owner()->borderAndPaddingBefore();
-        // Content in a flow thread is relative to the beginning of the thread, but the shape calculation should be relative to the current region.
-        if (currentRegion == nextRegion)
-            lineTop -= currentRegion->logicalTopForFlowThreadContent();
-    }
-
+    LayoutUnit lineTop = logicalHeight() + absoluteLogicalTop;
     // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight, in which case these segments may be incorrect.
-    shapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight);
+    shapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes));
 
     // The overflow should be pushed below the content box
     LayoutUnit shapeContainingBlockHeight = shapeInsideInfo->shapeContainingBlockHeight();
     if (!shapeInsideInfo->lineWithinShapeBounds() && !lineOverflowsFromShapeInside && shapeContainingBlockHeight) {
         lineOverflowsFromShapeInside = true;
-        LayoutUnit newLogicalHeight = shapeContainingBlockHeight;
+        setLogicalHeight(shapeContainingBlockHeight);
+    }
+}
 
-        if (layoutState.flowThread()) {
-            // If block contents flown across multiple regions and the shape-inside was applied on the second region we can end up with negative lineTop
-            if (lineTop < 0)
-                return;
+void RenderBlock::updateShapeAndSegmentsForCurrentLineInFlowThread(ShapeInsideInfo*& shapeInsideInfo, LineLayoutState& layoutState, bool& lineOverflowsFromShapeInside)
+{
+    ASSERT(layoutState.flowThread());
 
-            newLogicalHeight = logicalHeight + shapeContainingBlockHeight - lineTop - currentRegion->borderAndPaddingBefore();
+    LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);
 
-            RenderRegion* nextRegion = regionAtBlockOffset(newLogicalHeight);
-            ShapeInsideInfo* nextShapeInfo = 0;
-            if (nextRegion)
-                nextShapeInfo = nextRegion->shapeInsideInfo();
+    RenderRegion* currentRegion = regionAtBlockOffset(logicalHeight());
+    if (!currentRegion)
+        return;
 
-            // The overflow flows into another region with shape-inside
-            if (currentRegion != nextRegion && nextShapeInfo) {
-                newLogicalHeight += nextShapeInfo->shapeLogicalTop() - nextRegion->borderAndPaddingBefore();
+    shapeInsideInfo = currentRegion->shapeInsideInfo();
 
-                LayoutUnit offset = nextShapeInfo->shapeLogicalTop() - nextRegion->borderAndPaddingBefore();
-                nextShapeInfo->computeSegmentsForLine(offset, lineHeight);
+    LayoutUnit logicalLineTopInFlowThread = logicalHeight() + offsetFromLogicalTopOfFirstPage();
+    LayoutUnit logicalLineBottomInFlowThread = logicalLineTopInFlowThread + lineHeight;
+    LayoutUnit logicalRegionTopInFlowThread = currentRegion->logicalTopForFlowThreadContent();
+    LayoutUnit logicalRegionBottomInFlowThread = logicalRegionTopInFlowThread + currentRegion->logicalHeight() - currentRegion->borderAndPaddingBefore() - currentRegion->borderAfter() - currentRegion->paddingAfter();
 
-                shapeInsideInfo = nextShapeInfo;
-                lineOverflowsFromShapeInside = false;
-            }
-        }
+    // We only want to deal regions with shapes, so we look up for the next region whether it has a shape
+    if (!shapeInsideInfo && !currentRegion->isLastRegion()) {
+        LayoutUnit deltaToNextRegion = logicalHeight() + logicalRegionBottomInFlowThread - logicalLineTopInFlowThread;
+        RenderRegion* lookupForNextRegion = regionAtBlockOffset(logicalHeight() + deltaToNextRegion);
+        if (!lookupForNextRegion->shapeInsideInfo())
+            return;
+    }
+
+    LayoutUnit shapeBottomInFlowThread = LayoutUnit::max();
+    if (shapeInsideInfo)
+        shapeBottomInFlowThread = shapeInsideInfo->shapeLogicalBottom() + currentRegion->logicalTopForFlowThreadContent();
+
+    // If the line is between two shapes/regions we position the line to the top of the next shape/region
+    RenderRegion* nextRegion = regionAtBlockOffset(logicalHeight() + lineHeight);
+    if ((currentRegion != nextRegion && (logicalLineBottomInFlowThread > logicalRegionBottomInFlowThread)) || (!currentRegion->isLastRegion() && shapeBottomInFlowThread < logicalLineBottomInFlowThread)) {
+        LayoutUnit deltaToNextRegion = logicalRegionBottomInFlowThread - logicalLineTopInFlowThread;
+        nextRegion = regionAtBlockOffset(logicalHeight() + deltaToNextRegion);
+
+        ASSERT(currentRegion != nextRegion);
+
+        shapeInsideInfo = nextRegion->shapeInsideInfo();
+        setLogicalHeight(logicalHeight() + deltaToNextRegion);
+
+        currentRegion = nextRegion;
+
+        logicalLineTopInFlowThread = logicalHeight() + offsetFromLogicalTopOfFirstPage();
+        logicalLineBottomInFlowThread = logicalLineTopInFlowThread + lineHeight;
+        logicalRegionTopInFlowThread = currentRegion->logicalTopForFlowThreadContent();
+        logicalRegionBottomInFlowThread = logicalRegionTopInFlowThread + currentRegion->logicalHeight() - currentRegion->borderAndPaddingBefore() - currentRegion->borderAfter() - currentRegion->paddingAfter();
+    }
+
+    if (!shapeInsideInfo)
+        return;
+
+    // We position the first line to the top of the shape in the region or to the previously adjusted position in the shape
+    if (logicalLineBottomInFlowThread <= (logicalRegionTopInFlowThread + lineHeight) || (logicalLineTopInFlowThread - logicalRegionTopInFlowThread) < (layoutState.adjustedLogicalLineTop() - currentRegion->borderAndPaddingBefore())) {
+        LayoutUnit shapeTopOffset = layoutState.adjustedLogicalLineTop();
+        if (!shapeTopOffset)
+            shapeTopOffset = shapeInsideInfo->shapeLogicalTop();
+
+        LayoutUnit shapePositionInFlowThread = currentRegion->logicalTopForFlowThreadContent() + shapeTopOffset;
+        LayoutUnit shapeTopLineTopDelta = shapePositionInFlowThread - logicalLineTopInFlowThread - currentRegion->borderAndPaddingBefore();
+
+        setLogicalHeight(logicalHeight() + shapeTopLineTopDelta);
+        logicalLineTopInFlowThread += shapeTopLineTopDelta;
+        layoutState.setAdjustedLogicalLineTop(0);
+    }
+
+    LayoutUnit lineTop = logicalLineTopInFlowThread - currentRegion->logicalTopForFlowThreadContent() + currentRegion->borderAndPaddingBefore();
+    shapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight);
+
+    // Overflow from last shape on last region should be pushed below the content box
+    if (currentRegion->isLastRegion() && !lineOverflowsFromShapeInside && (lineTop + lineHeight) > shapeInsideInfo->shapeLogicalBottom()) {
+        lineOverflowsFromShapeInside = true;
+        LayoutUnit newLogicalHeight = this->logicalHeight() + (shapeInsideInfo->shapeContainingBlockHeight() - (lineTop + currentRegion->borderAfter() + currentRegion->paddingAfter()));
         setLogicalHeight(newLogicalHeight);
     }
 }
@@ -1709,9 +1755,13 @@
         return false;
 
     LayoutUnit newLogicalHeight = adjustedLogicalLineTop - absoluteLogicalTop;
-    if (layoutState.flowThread())
+
+    if (layoutState.flowThread()) {
+        layoutState.setAdjustedLogicalLineTop(adjustedLogicalLineTop);
         newLogicalHeight = logicalHeight();
+    }
 
+
     end = restartLayoutRunsAndFloatsInRange(logicalHeight(), newLogicalHeight, lastFloatFromPreviousLine, resolver, end);
     return true;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to