Diff
Modified: trunk/LayoutTests/ChangeLog (152571 => 152572)
--- trunk/LayoutTests/ChangeLog 2013-07-11 15:43:53 UTC (rev 152571)
+++ trunk/LayoutTests/ChangeLog 2013-07-11 16:17:37 UTC (rev 152572)
@@ -1,3 +1,17 @@
+2013-07-11 Andrei Bucur <[email protected]>
+
+ [CSS Regions] In a region chain with auto-height regions, lines get their length based only on the first region
+ https://bugs.webkit.org/show_bug.cgi?id=118531
+
+ Reviewed by Alexandru Chiculita.
+
+ Add tests verifying the lines widths are correctly computed in auto-height regions with and without a max-height set.
+
+ * fast/regions/autoheight-correct-region-for-lines-2-expected.html: Added.
+ * fast/regions/autoheight-correct-region-for-lines-2.html: Added.
+ * fast/regions/autoheight-correct-region-for-lines-expected.html: Added.
+ * fast/regions/autoheight-correct-region-for-lines.html: Added.
+
2013-07-11 Radu Stavila <[email protected]>
NamedFlowCollection getters should follow the same pattern as HTMLCollection
Added: trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-2-expected.html (0 => 152572)
--- trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-2-expected.html (rev 0)
+++ trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-2-expected.html 2013-07-11 16:17:37 UTC (rev 152572)
@@ -0,0 +1,30 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <style>
+ .region {
+ height: auto;
+ width: 200px;
+ border: 2px solid blue;
+ margin: .5em;
+ overflow: hidden;
+ }
+
+ #r1 {
+ width: 300px;
+ }
+
+ #r3 {
+ width: 100px;
+ }
+ </style>
+</head>
+<body>
+ <p>Test for <a href="" Regions] In a region chain with auto-height regions, lines get their length based only on the first region</a>.</p>
+ <p>Verify lines are correctly computed in regions with a huge max-height set on them.</p>
+ <div class="region" id="r1"><p>Lorem ipsum scurtum est.</p></div>
+ <div class="region"><p>Lorem ipsum lungum est, yet not that lungum, only slighter.</p></div>
+ <div class="region" id="r3"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque, sint dolorum optio perferendis quam delectus fuga soluta itaque quisquam inventore.</p></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-2.html (0 => 152572)
--- trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-2.html (rev 0)
+++ trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-2.html 2013-07-11 16:17:37 UTC (rev 152572)
@@ -0,0 +1,44 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <style>
+ .content {
+ -webkit-flow-into: f;
+ }
+ .content p {
+ -webkit-region-break-after: always;
+ }
+
+ .region {
+ -webkit-flow-from: f;
+ height: auto;
+ width: 200px;
+ border: 2px solid blue;
+ margin: .5em;
+ overflow: hidden;
+ max-height: 2000000000px;
+ }
+
+ #r1 {
+ width: 300px;
+ }
+
+ #r3 {
+ width: 100px;
+ }
+ </style>
+</head>
+<body>
+ <p>Test for <a href="" Regions] In a region chain with auto-height regions, lines get their length based only on the first region</a>.</p>
+ <p>Verify lines are correctly computed in regions with a huge max-height set on them.</p>
+ <div class="content">
+ <p>Lorem ipsum scurtum est.</p>
+ <p>Lorem ipsum lungum est, yet not that lungum, only slighter.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque, sint dolorum optio perferendis quam delectus fuga soluta itaque quisquam inventore.</p>
+ </div>
+ <div class="region" id="r1"></div>
+ <div class="region"></div>
+ <div class="region" id="r3"></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-expected.html (0 => 152572)
--- trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-expected.html (rev 0)
+++ trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines-expected.html 2013-07-11 16:17:37 UTC (rev 152572)
@@ -0,0 +1,30 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <style>
+ .region {
+ height: auto;
+ width: 200px;
+ border: 2px solid blue;
+ margin: .5em;
+ overflow: hidden;
+ }
+
+ #r1 {
+ width: 300px;
+ }
+
+ #r3 {
+ width: 100px;
+ }
+ </style>
+</head>
+<body>
+ <p>Test for <a href="" Regions] In a region chain with auto-height regions, lines get their length based only on the first region</a>.</p>
+ <p>Verify lines are correctly computed in regions.</p>
+ <div class="region" id="r1"><p>Lorem ipsum scurtum est.</p></div>
+ <div class="region"><p>Lorem ipsum lungum est, yet not that lungum, only slighter.</p></div>
+ <div class="region" id="r3"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque, sint dolorum optio perferendis quam delectus fuga soluta itaque quisquam inventore.</p></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines.html (0 => 152572)
--- trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines.html (rev 0)
+++ trunk/LayoutTests/fast/regions/autoheight-correct-region-for-lines.html 2013-07-11 16:17:37 UTC (rev 152572)
@@ -0,0 +1,43 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <style>
+ .content {
+ -webkit-flow-into: f;
+ }
+ .content p {
+ -webkit-region-break-after: always;
+ }
+
+ .region {
+ -webkit-flow-from: f;
+ height: auto;
+ width: 200px;
+ border: 2px solid blue;
+ margin: .5em;
+ overflow: hidden;
+ }
+
+ #r1 {
+ width: 300px;
+ }
+
+ #r3 {
+ width: 100px;
+ }
+ </style>
+</head>
+<body>
+ <p>Test for <a href="" Regions] In a region chain with auto-height regions, lines get their length based only on the first region</a>.</p>
+ <p>Verify lines are correctly computed in regions.</p>
+ <div class="content">
+ <p>Lorem ipsum scurtum est.</p>
+ <p>Lorem ipsum lungum est, yet not that lungum, only slighter.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque, sint dolorum optio perferendis quam delectus fuga soluta itaque quisquam inventore.</p>
+ </div>
+ <div class="region" id="r1"></div>
+ <div class="region"></div>
+ <div class="region" id="r3"></div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (152571 => 152572)
--- trunk/Source/WebCore/ChangeLog 2013-07-11 15:43:53 UTC (rev 152571)
+++ trunk/Source/WebCore/ChangeLog 2013-07-11 16:17:37 UTC (rev 152572)
@@ -1,3 +1,34 @@
+2013-07-11 Andrei Bucur <[email protected]>
+
+ [CSS Regions] In a region chain with auto-height regions, lines get their length based only on the first region
+ https://bugs.webkit.org/show_bug.cgi?id=118531
+
+ Reviewed by Alexandru Chiculita.
+
+ When computing the height a flow thread it's possible to overflow the maximum LayoutUnit and obtain a negative value.
+ This leads to invalid results during layout when computing the region range and the RenderBoxRegion info for the
+ descendant boxes of the flow thread.
+
+ This issue appears especially during the auto-height algorithm because it initializes the auto-height regions
+ height with the LayoutUnit::max() / 2 value. Summing two such regions overflows and results in a negative value.
+
+ The fix clamps the maximum height of the flow thread to LayoutUnit::max() / 2. This doesn't affect the auto-height
+ algorithm because regionAtBlockOffset() will still return the correct values as the auto-height regions content
+ is established and their height updated.
+
+ Tests: fast/regions/autoheight-correct-region-for-lines-2.html
+ fast/regions/autoheight-correct-region-for-lines.html
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::updateRegionsAndShapesBeforeChildLayout):
+ * rendering/RenderFlowThread.cpp:
+ (WebCore::RenderFlowThread::computeLogicalHeight):
+ (WebCore::RenderFlowThread::setRegionRangeForBox):
+ (WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
+ * rendering/RenderFlowThread.h:
+ * rendering/RenderRegion.cpp:
+ (WebCore::RenderRegion::maxPageLogicalHeight):
+
2013-07-11 Timothy Hatcher <[email protected]>
Revert r152267 and soft link WebInspectorUI.framework again.
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (152571 => 152572)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-07-11 15:43:53 UTC (rev 152571)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-07-11 16:17:37 UTC (rev 152572)
@@ -1496,7 +1496,7 @@
// Compute the maximum logical height content may cause this block to expand to
// FIXME: These should eventually use the const computeLogicalHeight rather than updateLogicalHeight
- setLogicalHeight(LayoutUnit::max() / 2);
+ setLogicalHeight(RenderFlowThread::maxLogicalHeight());
updateLogicalHeight();
#if ENABLE(CSS_SHAPES)
Modified: trunk/Source/WebCore/rendering/RenderFlowThread.cpp (152571 => 152572)
--- trunk/Source/WebCore/rendering/RenderFlowThread.cpp 2013-07-11 15:43:53 UTC (rev 152571)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.cpp 2013-07-11 16:17:37 UTC (rev 152572)
@@ -251,11 +251,17 @@
computedValues.m_position = logicalTop;
computedValues.m_extent = 0;
+ const LayoutUnit maxFlowSize = RenderFlowThread::maxLogicalHeight();
for (RenderRegionList::const_iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {
RenderRegion* region = *iter;
ASSERT(!region->needsLayout() || region->isRenderRegionSet());
- computedValues.m_extent += region->logicalHeightOfAllFlowThreadContent();
+ LayoutUnit distanceToMaxSize = maxFlowSize - computedValues.m_extent;
+ computedValues.m_extent += std::min(distanceToMaxSize, region->logicalHeightOfAllFlowThreadContent());
+
+ // If we reached the maximum size there's no point in going further.
+ if (computedValues.m_extent == maxFlowSize)
+ return;
}
}
@@ -685,6 +691,8 @@
if (!hasRegions())
return;
+ ASSERT(box->logicalHeight() >= 0);
+
// FIXME: Not right for differing writing-modes.
RenderRegion* startRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstPage, true);
RenderRegion* endRegion = regionAtBlockOffset(offsetFromLogicalTopOfFirstPage + box->logicalHeight(), true);
@@ -875,7 +883,7 @@
region->clearComputedAutoHeight();
LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
- LayoutUnit regionLogicalHeight = std::min<LayoutUnit>(LayoutUnit::max() / 2 - logicalHeight, region->logicalHeightOfAllFlowThreadContent());
+ LayoutUnit regionLogicalHeight = std::min<LayoutUnit>(RenderFlowThread::maxLogicalHeight() - logicalHeight, region->logicalHeightOfAllFlowThreadContent());
LayoutRect regionRect(style()->direction() == LTR ? LayoutUnit() : logicalWidth() - regionLogicalWidth, logicalHeight, regionLogicalWidth, regionLogicalHeight);
Modified: trunk/Source/WebCore/rendering/RenderFlowThread.h (152571 => 152572)
--- trunk/Source/WebCore/rendering/RenderFlowThread.h 2013-07-11 15:43:53 UTC (rev 152571)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.h 2013-07-11 16:17:37 UTC (rev 152572)
@@ -168,6 +168,9 @@
void popFlowThreadLayoutState();
LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const;
+ // Used to estimate the maximum height of the flow thread.
+ static LayoutUnit maxLogicalHeight() { return LayoutUnit::max() / 2; }
+
protected:
virtual const char* renderName() const = 0;
Modified: trunk/Source/WebCore/rendering/RenderRegion.cpp (152571 => 152572)
--- trunk/Source/WebCore/rendering/RenderRegion.cpp 2013-07-11 15:43:53 UTC (rev 152571)
+++ trunk/Source/WebCore/rendering/RenderRegion.cpp 2013-07-11 16:17:37 UTC (rev 152572)
@@ -81,7 +81,7 @@
{
ASSERT(m_flowThread);
ASSERT(hasAutoLogicalHeight() && !m_flowThread->inConstrainedLayoutPhase());
- return style()->logicalMaxHeight().isUndefined() ? LayoutUnit::max() / 2 : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight());
+ return style()->logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight());
}
LayoutUnit RenderRegion::logicalHeightOfAllFlowThreadContent() const