- Revision
- 128786
- Author
- [email protected]
- Date
- 2012-09-17 11:44:51 -0700 (Mon, 17 Sep 2012)
Log Message
[CSS Exclusions] Enable shape-inside for percentage lengths based on logical height
https://bugs.webkit.org/show_bug.cgi?id=93547
Patch by Bear Travis <[email protected]> on 2012-09-17
Reviewed by Levi Weintraub.
Source/WebCore:
Shape-inside needs to be passed the logical size to use when computing percentage
based coordinates. The CSS Regions-specific method computeInitialRegionRangeForBlock
has been generalized to updateRegionsAndExclusionsLogicalSize. This method takes
the pre-child-layout logical width and height, and uses them to compute the logical
width and height that regions and exclusions should use for layout. Regions use a
block's maximum possible logical height to compute a region's maximum extent.
Exclusions use a block's fixed logical width and height, or 0 if one does not exist,
to resolve percentage-based shape lengths. The default logical size used for resolving
percentage based coordinates is tested in shape-inside-percentage-auto.html.
Test: fast/exclusions/shape-inside/shape-inside-percentage.html
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateRegionsAndExclusionsLogicalSize): Calculates the logical
height regions and exclusions should use, and updates their layout sizes through
computeExclusionShapeSize and computeRegionRangeForBlock.
(WebCore):
(WebCore::RenderBlock::computeExclusionShapeSize): Pass the appropriate logical size
to exclusion shapes so they can resolve percentage based coordinates.
(WebCore::RenderBlock::layoutBlock): Call the new updateRegionsAndExclusionsLogicalSize
method.
* rendering/RenderBlock.h:
(RenderBlock):
* rendering/RenderBox.cpp:
(WebCore::percentageLogicalHeightIsResolvable): Determine if percentage lengths
based on logical height can be resolved.
(WebCore):
(WebCore::RenderBox::percentageLogicalHeightIsResolvableFromBlock): Added declaration.
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock): Calling
updateRegionsAndExclusionsLogicalSize rather than computeInitialRegionRangeForBlock.
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutBlock): Ditto.
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutBlock): Ditto.
LayoutTests:
Test that shape percentage-based measurements resolve correctly. Some testing is
already covered by shape-inside-percentage-auto.html.
* fast/exclusions/shape-inside/shape-inside-percentage-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-percentage.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (128785 => 128786)
--- trunk/LayoutTests/ChangeLog 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/LayoutTests/ChangeLog 2012-09-17 18:44:51 UTC (rev 128786)
@@ -1,3 +1,16 @@
+2012-09-17 Bear Travis <[email protected]>
+
+ [CSS Exclusions] Enable shape-inside for percentage lengths based on logical height
+ https://bugs.webkit.org/show_bug.cgi?id=93547
+
+ Reviewed by Levi Weintraub.
+
+ Test that shape percentage-based measurements resolve correctly. Some testing is
+ already covered by shape-inside-percentage-auto.html.
+
+ * fast/exclusions/shape-inside/shape-inside-percentage-expected.html: Added.
+ * fast/exclusions/shape-inside/shape-inside-percentage.html: Added.
+
2012-09-17 Ojan Vafai <[email protected]>
Cleanup the final instance of BUGUSERNAME.
Added: trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage-expected.html (0 => 128786)
--- trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage-expected.html (rev 0)
+++ trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage-expected.html 2012-09-17 18:44:51 UTC (rev 128786)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ #container {
+ border: 2px solid blue;
+ position: relative;
+ width: 200px;
+ height: 200px;
+ }
+ #border {
+ position: absolute;
+ left: 48px;
+ width: 100px;
+ height: 50px;
+ border: 2px solid green;
+ }
+ .spacer {
+ width: 50px;
+ height: 50px;
+ }
+</style>
+</head>
+<body>
+ <div id="container">
+ <div id="border"></div>
+ <div id="shape-inside">
+ <div class="spacer" style="float:left"></div>
+ <div class="spacer" style="float:right"></div>
+ This text should wrap inside the green rectangle, and overflow should wrap
+ inside the blue rectangle.
+ </div>
+ </div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage.html (0 => 128786)
--- trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage.html (rev 0)
+++ trunk/LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage.html 2012-09-17 18:44:51 UTC (rev 128786)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+ if (window.internals)
+ window.internals.settings.setCSSExclusionsEnabled(true);
+</script>
+<style>
+ #container {
+ border: 2px solid blue;
+ position: relative;
+ width: 200px;
+ height: 200px;
+ }
+ #shape-inside {
+ -webkit-shape-inside: rectangle(25%, 0, 50%, 25%);
+ height: 100%;
+ width: 100%;
+ }
+ #border {
+ position: absolute;
+ left: 48px;
+ width: 100px;
+ height: 50px;
+ border: 2px solid green;
+ }
+ #border-overflow {
+ position: absolute;
+ top: 50px;
+ width: 200px;
+ height: 150px;
+ border: 2px solid blue;
+ }
+</style>
+</head>
+<body>
+ <div id="container">
+ <div id="border"></div>
+ <div id="shape-inside">
+ This text should wrap inside the green rectangle, and overflow should wrap
+ inside the blue rectangle.
+ </div>
+ </div>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (128785 => 128786)
--- trunk/Source/WebCore/ChangeLog 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/ChangeLog 2012-09-17 18:44:51 UTC (rev 128786)
@@ -1,3 +1,48 @@
+2012-09-17 Bear Travis <[email protected]>
+
+ [CSS Exclusions] Enable shape-inside for percentage lengths based on logical height
+ https://bugs.webkit.org/show_bug.cgi?id=93547
+
+ Reviewed by Levi Weintraub.
+
+ Shape-inside needs to be passed the logical size to use when computing percentage
+ based coordinates. The CSS Regions-specific method computeInitialRegionRangeForBlock
+ has been generalized to updateRegionsAndExclusionsLogicalSize. This method takes
+ the pre-child-layout logical width and height, and uses them to compute the logical
+ width and height that regions and exclusions should use for layout. Regions use a
+ block's maximum possible logical height to compute a region's maximum extent.
+ Exclusions use a block's fixed logical width and height, or 0 if one does not exist,
+ to resolve percentage-based shape lengths. The default logical size used for resolving
+ percentage based coordinates is tested in shape-inside-percentage-auto.html.
+
+ Test: fast/exclusions/shape-inside/shape-inside-percentage.html
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::updateRegionsAndExclusionsLogicalSize): Calculates the logical
+ height regions and exclusions should use, and updates their layout sizes through
+ computeExclusionShapeSize and computeRegionRangeForBlock.
+ (WebCore):
+ (WebCore::RenderBlock::computeExclusionShapeSize): Pass the appropriate logical size
+ to exclusion shapes so they can resolve percentage based coordinates.
+ (WebCore::RenderBlock::layoutBlock): Call the new updateRegionsAndExclusionsLogicalSize
+ method.
+ * rendering/RenderBlock.h:
+ (RenderBlock):
+ * rendering/RenderBox.cpp:
+ (WebCore::percentageLogicalHeightIsResolvable): Determine if percentage lengths
+ based on logical height can be resolved.
+ (WebCore):
+ (WebCore::RenderBox::percentageLogicalHeightIsResolvableFromBlock): Added declaration.
+ * rendering/RenderBox.h:
+ (RenderBox):
+ * rendering/RenderDeprecatedFlexibleBox.cpp:
+ (WebCore::RenderDeprecatedFlexibleBox::layoutBlock): Calling
+ updateRegionsAndExclusionsLogicalSize rather than computeInitialRegionRangeForBlock.
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::layoutBlock): Ditto.
+ * rendering/RenderGrid.cpp:
+ (WebCore::RenderGrid::layoutBlock): Ditto.
+
2012-09-17 Vangelis Kokkevis <[email protected]>
[chromium] Add gpu_test trace events tracking the creation of a DrawingBuffer
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (128785 => 128786)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-09-17 18:44:51 UTC (rev 128786)
@@ -1394,20 +1394,45 @@
}
#endif
-void RenderBlock::computeInitialRegionRangeForBlock()
+void RenderBlock::updateRegionsAndExclusionsLogicalSize()
{
- if (inRenderFlowThread()) {
- // Set our start and end regions. No regions above or below us will be considered by our children. They are
- // effectively clamped to our region range.
- LayoutUnit oldHeight = logicalHeight();
- LayoutUnit oldLogicalTop = logicalTop();
- setLogicalHeight(MAX_LAYOUT_UNIT / 2);
- updateLogicalHeight();
- enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage());
- setLogicalHeight(oldHeight);
- setLogicalTop(oldLogicalTop);
+#if ENABLE(CSS_EXCLUSIONS)
+ if (!inRenderFlowThread() && !wrapShapeInfo())
+#else
+ if (!inRenderFlowThread())
+#endif
+ return;
+
+ LayoutUnit oldHeight = logicalHeight();
+ LayoutUnit oldTop = logicalTop();
+
+ // 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(MAX_LAYOUT_UNIT / 2);
+ updateLogicalHeight();
+
+#if ENABLE(CSS_EXCLUSIONS)
+ computeExclusionShapeSize();
+#endif
+
+ // Set our start and end regions. No regions above or below us will be considered by our children. They are
+ // effectively clamped to our region range.
+ computeRegionRangeForBlock();
+
+ setLogicalHeight(oldHeight);
+ setLogicalTop(oldTop);
+}
+
+#if ENABLE(CSS_EXCLUSIONS)
+void RenderBlock::computeExclusionShapeSize()
+{
+ WrapShapeInfo* wrapShapeInfo = this->wrapShapeInfo();
+ if (wrapShapeInfo) {
+ bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolvableFromBlock(this, false);
+ wrapShapeInfo->computeShapeSize(logicalWidth(), percentageLogicalHeightResolvable ? logicalHeight() : ZERO_LAYOUT_UNIT);
}
}
+#endif
void RenderBlock::computeRegionRangeForBlock()
{
@@ -1491,12 +1516,7 @@
if (logicalWidthChangedInRegions())
relayoutChildren = true;
}
- computeInitialRegionRangeForBlock();
-#if ENABLE(CSS_EXCLUSIONS)
- // FIXME: Bug 93547: Resolve logical height for percentage based vertical lengths
- if (WrapShapeInfo* wrapShapeInfo = this->wrapShapeInfo())
- wrapShapeInfo->computeShapeSize(logicalWidth(), 0);
-#endif
+ updateRegionsAndExclusionsLogicalSize();
// We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
// our current maximal positive and negative margins. These values are used when we
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (128785 => 128786)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2012-09-17 18:44:51 UTC (rev 128786)
@@ -491,13 +491,14 @@
}
#endif
- void computeInitialRegionRangeForBlock();
+ void updateRegionsAndExclusionsLogicalSize();
void computeRegionRangeForBlock();
virtual void checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight);
private:
#if ENABLE(CSS_EXCLUSIONS)
+ void computeExclusionShapeSize();
void updateWrapShapeInfoAfterStyleChange(const BasicShape*, const BasicShape* oldWrapShape);
#endif
virtual RenderObjectChildList* virtualChildren() { return children(); }
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (128785 => 128786)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-17 18:44:51 UTC (rev 128786)
@@ -3726,16 +3726,22 @@
m_overflow->setLayoutOverflow(borderBoxRect());
}
-static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
+inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
{
+ return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containingBlock(), box->isOutOfFlowPositioned());
+}
+
+bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool isOutOfFlowPositioned)
+{
// In quirks mode, blocks with auto height are skipped, and we keep looking for an enclosing
// block that may have a specified height and then use it. In strict mode, this violates the
// specification, which states that percentage heights just revert to auto if the containing
// block has an auto height. We still skip anonymous containing blocks in both modes, though, and look
// only at explicit containers.
- const RenderBlock* cb = box->containingBlock();
+ const RenderBlock* cb = containingBlock;
+ bool inQuirksMode = cb->document()->inQuirksMode();
while (!cb->isRenderView() && !cb->isBody() && !cb->isTableCell() && !cb->isOutOfFlowPositioned() && cb->style()->logicalHeight().isAuto()) {
- if (!box->document()->inQuirksMode() && !cb->isAnonymousBlock())
+ if (!inQuirksMode && !cb->isAnonymousBlock())
break;
cb = cb->containingBlock();
}
@@ -3757,10 +3763,10 @@
if (cb->style()->logicalHeight().isFixed())
return true;
if (cb->style()->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSpecifiedHeight)
- return percentageLogicalHeightIsResolvable(cb);
- if (cb->isRenderView() || (cb->isBody() && box->document()->inQuirksMode()) || isOutOfFlowPositionedWithSpecifiedHeight)
+ return percentageLogicalHeightIsResolvableFromBlock(cb->containingBlock(), cb->isOutOfFlowPositioned());
+ if (cb->isRenderView() || inQuirksMode || isOutOfFlowPositionedWithSpecifiedHeight)
return true;
- if (cb->isRoot() && box->isOutOfFlowPositioned()) {
+ if (cb->isRoot() && isOutOfFlowPositioned) {
// Match the positioned objects behavior, which is that positioned objects will fill their viewport
// always. Note we could only hit this case by recurring into computePercentageLogicalHeight on a positioned containing block.
return true;
Modified: trunk/Source/WebCore/rendering/RenderBox.h (128785 => 128786)
--- trunk/Source/WebCore/rendering/RenderBox.h 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2012-09-17 18:44:51 UTC (rev 128786)
@@ -399,6 +399,7 @@
virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
virtual LayoutUnit computeReplacedLogicalHeight() const;
+ static bool percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool outOfFlowPositioned);
LayoutUnit computePercentageLogicalHeight(const Length& height) const;
// Block flows subclass availableWidth/Height to handle multi column layout (shrinking the width/height available to children when laying out.)
Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (128785 => 128786)
--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp 2012-09-17 18:44:51 UTC (rev 128786)
@@ -243,7 +243,7 @@
if (logicalWidthChangedInRegions())
relayoutChildren = true;
}
- computeInitialRegionRangeForBlock();
+ updateRegionsAndExclusionsLogicalSize();
LayoutSize previousSize = size();
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (128785 => 128786)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2012-09-17 18:44:51 UTC (rev 128786)
@@ -249,7 +249,7 @@
if (logicalWidthChangedInRegions())
relayoutChildren = true;
}
- computeInitialRegionRangeForBlock();
+ updateRegionsAndExclusionsLogicalSize();
LayoutSize previousSize = size();
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (128785 => 128786)
--- trunk/Source/WebCore/rendering/RenderGrid.cpp 2012-09-17 18:36:11 UTC (rev 128785)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp 2012-09-17 18:44:51 UTC (rev 128786)
@@ -71,7 +71,7 @@
if (logicalWidthChangedInRegions())
relayoutChildren = true;
}
- computeInitialRegionRangeForBlock();
+ updateRegionsAndExclusionsLogicalSize();
LayoutSize previousSize = size();