Changeset 150027 in webkit
- Timestamp:
- May 13, 2013 12:11:33 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 10 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r150025 r150027 1 2013-05-13 Zoltan Horvath <zoltan@webkit.org> 2 3 [CSS Regions][CSS Exclusions] Shape-inside on regions should respect region borders and paddings 4 https://bugs.webkit.org/show_bug.cgi?id=115456 5 6 Reviewed by David Hyatt. 7 8 I refactored the computation logic of shape-inside on regions by removing access to RenderFlowThread from ExclusionShapeInfo's logicalTopOffset 9 function, this means all the logic is now existing in RenderBlockLineLayout.cpp. By modifying the logicalTopOffset it turned out that the borders 10 and padding hadn't worked correctly, since borders and paddings were counted twice in the shape-inside's computation. This patch adds the necessary 11 modifications to let it respect the borders and padding in the correct way. I created 2 new helper functions to prevent increasing the code size of 12 the layoutRunsAndFloatsInRange function. 13 14 * fast/regions/shape-inside/shape-inside-on-additional-regions-expected.html: Modify to not use shape-inside for testing. 15 * fast/regions/shape-inside/shape-inside-on-additional-regions.html: Fix the shape-inside's dimension. 16 * fast/regions/shape-inside/shape-inside-on-first-region-block-content-expected.html: Added. 17 * fast/regions/shape-inside/shape-inside-on-first-region-block-content.html: Added. 18 * fast/regions/shape-inside/shape-inside-on-first-region-inline-content-expected.html: Added. 19 * fast/regions/shape-inside/shape-inside-on-first-region-inline-content.html: Added. 20 * fast/regions/shape-inside/shape-inside-on-regions-expected.html: Match the shape-inside height to the container's height. 21 * fast/regions/shape-inside/shape-inside-on-regions-inline-content-expected.html: Added. 22 * fast/regions/shape-inside/shape-inside-on-regions.html: Match the shape-inside height to the container's height. 23 * fast/regions/shape-inside/shape-inside-on-second-region-block-content-expected.html: Added. 24 * fast/regions/shape-inside/shape-inside-on-second-region-block-content.html: Added. 25 * fast/regions/shape-inside/shape-inside-on-second-region-inline-content-expected.html: Added. 26 * fast/regions/shape-inside/shape-inside-on-second-region-inline-content.html: Added. 27 * fast/regions/shape-inside/shape-inside-with-region-borders-expected.html: Added. 28 * fast/regions/shape-inside/shape-inside-with-region-borders.html: Added. 29 * fast/regions/shape-inside/shape-inside-with-region-padding-expected.html: Added. 30 * fast/regions/shape-inside/shape-inside-with-region-padding.html: Added. 31 1 32 2013-05-13 Bear Travis <betravis@adobe.com> 2 33 -
trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-additional-regions-expected.html
r148975 r150027 2 2 <html> 3 3 <head> 4 <script>5 if (window.internals)6 window.internals.settings.setCSSExclusionsEnabled(true);7 </script>8 4 <style> 9 5 .region { … … 18 14 #region_with_shape_inside { 19 15 border: 1px solid black; 20 -webkit-shape-inside: rectangle(50px, 0px, 300px, 300px);21 16 overflow: hidden; 22 17 background-color: orange; 18 } 19 #placeholder { 20 float: left; 21 width: 50px; 22 height: 300px; 23 23 } 24 24 </style> … … 27 27 28 28 <div class="region"> 29 <p>Despite the passage of time, Major Quilan still suffers grief and bereavement from the death of his wife, killed during the Chelgrian civil war that resulted from the Culture's interference. <p>Quilan is offered the chance to avenge the lost Chelgrians who died in the civil war and is inducted into a plot to strike back29 <p>Despite the passage of time, Major Quilan still suffers grief and bereavement from the death of his wife, killed during the Chelgrian civil war that resulted from the Culture's interference. <p>Quilan is offered the chance to avenge the lost Chelgrians who died in the civil war and is inducted into a plot to strike back at the Culture.</p> 30 30 </div> 31 31 <div id="region_with_shape_inside" class="region"> 32 at the Culture.</p>As part of the plot, his <p>"soulkeeper"</p> (a device normally used to store its owner's personality upon their death) is equipped with both the mind of a long-dead Chelgrian general and a device... 32 <div id="placeholder"></div> 33 <p>As part of the plot, his <p>"soulkeeper"</p> (a device normally used to store its owner's personality upon their death) is equipped with both the mind of a long-dead Chelgrian general and a device... 33 34 </div> 34 35 -
trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-additional-regions.html
r148975 r150027 22 22 #region_with_shape_inside { 23 23 border: 1px solid black; 24 -webkit-shape-inside: rectangle(50px, 0px, 300px, 300px);24 -webkit-shape-inside: rectangle(50px, 0px, 250px, 300px); 25 25 overflow: hidden; 26 26 background-color: orange; -
trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-expected.html
r147155 r150027 17 17 #region2 { 18 18 width: 300px; 19 height: 1 45px;19 height: 150px; 20 20 -webkit-shape-inside: rectangle(0, 0, 220px, 150px); 21 21 margin-top: 60px; -
trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions-inline-content.html
r150026 r150027 8 8 <style> 9 9 #rectangle { 10 font: 16px Ahem, sans-serif;10 font: 20px Ahem, sans-serif; 11 11 -webkit-flow-into: rectangle; 12 12 } … … 17 17 width: 180px; 18 18 height: 100px; 19 border: 1px solid green; 19 20 -webkit-shape-inside: rectangle(0, 0, 130px, 100px); 20 21 margin-top: 10px; … … 22 23 #region2 { 23 24 width: 300px; 24 height: 145px; 25 height: 150px; 26 border: 1px solid green; 25 27 -webkit-shape-inside: rectangle(0, 0, 220px, 150px); 26 28 margin-top: 60px; … … 29 31 width: 300px; 30 32 height: 50px; 33 border: 1px solid green; 31 34 margin-top: 60px; 32 35 } … … 35 38 <body> 36 39 <div id="rectangle"> 37 X X X X X 38 <p>X X</p> 39 <p style="color: green">X X X X X X</p> 40 <p style="color: orange">X X X X</p> 41 <p>X X X X X X X X<p style="color: yellow">X X X X X X X X X X</p> X X</p> 42 <div style="color: red"> X X X X X X X X X</div> 43 </div> 40 X X X X X X X X X X X X X X X X X X X X X X X X 41 X X X X X X X X X X X X X X X X X X X X X X X X 42 X X X X X X X X X X X X X X X X X X X X X X X X 43 </div> 44 44 <div id="page"> 45 45 <div id="region1" class="region"></div> … … 48 48 </div> 49 49 <p>Requires Ahem font. Two different -shape-inside property are applied to the first and second region. The third region is a simple region without -shape-inside. 50 The rectangles should flow through the regions and the shape-insides should be applied to the first two regions.</p>51 <p> Bug <a href="http://webkit.org/b/107880">107880</a>: Regions should respect shape-inside</p>50 The inline content should flow through the regions and the shape-insides should be applied to the first two regions thus the content should be only 130px wide in the first (original width: 180px) and only 220px wide in the second (original width: 300px) region.</p> 51 <p>Bug <a href="http://webkit.org/b/115456">115456</a>: [CSS Regions][CSS Exclusions] Shape-inside on regions should respect region borders and paddings</p> 52 52 </body> 53 53 </html> -
trunk/LayoutTests/fast/regions/shape-inside/shape-inside-on-regions.html
r147155 r150027 22 22 #region2 { 23 23 width: 300px; 24 height: 1 45px;24 height: 150px; 25 25 -webkit-shape-inside: rectangle(0, 0, 220px, 150px); 26 26 margin-top: 60px; -
trunk/Source/WebCore/ChangeLog
r150025 r150027 1 2013-05-13 Zoltan Horvath <zoltan@webkit.org> 2 3 [CSS Regions][CSS Exclusions] Shape-inside on regions should respect region borders and paddings 4 https://bugs.webkit.org/show_bug.cgi?id=115456 5 6 Reviewed by David Hyatt. 7 8 I refactored the computation logic of shape-inside on regions by removing access to RenderFlowThread from ExclusionShapeInfo's logicalTopOffset 9 function, this means all the logic is now existing in RenderBlockLineLayout.cpp. By modifying the logicalTopOffset it turned out that the borders 10 and padding hadn't worked correctly, since borders and paddings were counted twice in the shape-inside's computation. This patch adds the necessary 11 modifications to let it respect the borders and padding in the correct way. I created 2 new helper functions to prevent increasing the code size of 12 the layoutRunsAndFloatsInRange function. 13 14 I introduced 7 new tests to test for testing the correct behavior. 15 16 Tests: fast/regions/shape-inside/shape-inside-on-first-region-block-content.html 17 fast/regions/shape-inside/shape-inside-on-first-region-inline-content.html 18 fast/regions/shape-inside/shape-inside-on-second-region-block-content.html 19 fast/regions/shape-inside/shape-inside-on-second-region-inline-content.html 20 fast/regions/shape-inside/shape-inside-on-regions-inline-content.html 21 fast/regions/shape-inside/shape-inside-with-region-borders.html 22 fast/regions/shape-inside/shape-inside-with-region-padding.html 23 24 * rendering/ExclusionShapeInfo.cpp: 25 (WebCore): Remove FlowThread logic from logicalTopOffset move definition to header. 26 * rendering/ExclusionShapeInfo.h: 27 (WebCore::ExclusionShapeInfo::logicalTopOffset): Moved from cpp. 28 (WebCore::ExclusionShapeInfo::logicalLeftOffset): Add condition for RenderRegions. 29 * rendering/RenderBlock.h: 30 (RenderBlock): Add definition to the new helper members. 31 * rendering/RenderBlockLineLayout.cpp: 32 (WebCore::RenderBlock::layoutExclusionShapeInsideInfo): Modified the flow thread case to return the appropriate region. 33 (WebCore::RenderBlock::updateLineBoundariesForExclusions): Added new helper function. Modify the shape-inside on regions 34 line boundaries and position computation logic. 35 (WebCore::RenderBlock::adjustLogicalLineTopAndLogicalHeightIfNeeded): Added new helper function which handles the flow thread case also. 36 (WebCore::RenderBlock::layoutRunsAndFloatsInRange): Modified the code to use the helper functions. 37 1 38 2013-05-13 Bear Travis <betravis@adobe.com> 2 39 -
trunk/Source/WebCore/rendering/ExclusionShapeInfo.cpp
r149226 r150027 57 57 58 58 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() const, void (ExclusionShape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&) const> 59 LayoutUnit ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter>::logicalTopOffset() const60 {61 LayoutUnit logicalTopOffset = m_renderer->style()->boxSizing() == CONTENT_BOX ? m_renderer->borderBefore() + m_renderer->paddingBefore() : LayoutUnit();62 // Content in a flow thread is relative to the beginning of the thread, but the shape calculation should be relative to the current region.63 if (m_renderer->isRenderRegion())64 logicalTopOffset += toRenderRegion(m_renderer)->logicalTopForFlowThreadContent();65 return logicalTopOffset;66 }67 68 template<class RenderType, ExclusionShapeValue* (RenderStyle::*shapeGetter)() const, void (ExclusionShape::*intervalGetter)(LayoutUnit, LayoutUnit, SegmentList&) const>69 59 bool ExclusionShapeInfo<RenderType, shapeGetter, intervalGetter>::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) 70 60 { -
trunk/Source/WebCore/rendering/ExclusionShapeInfo.h
r149226 r150027 113 113 virtual LayoutRect computedShapeLogicalBoundingBox() const = 0; 114 114 115 LayoutUnit logicalTopOffset() const ;116 LayoutUnit logicalLeftOffset() const { return m_renderer->style()->boxSizing() == CONTENT_BOX ? m_renderer->borderStart() + m_renderer->paddingStart() : LayoutUnit(); }115 LayoutUnit logicalTopOffset() const { return m_renderer->style()->boxSizing() == CONTENT_BOX ? m_renderer->borderAndPaddingBefore() : LayoutUnit(); }; 116 LayoutUnit logicalLeftOffset() const { return (m_renderer->style()->boxSizing() == CONTENT_BOX && !m_renderer->isRenderRegion()) ? m_renderer->borderAndPaddingStart() : LayoutUnit(); } 117 117 118 118 LayoutUnit m_shapeLineTop; -
trunk/Source/WebCore/rendering/RenderBlock.h
r149967 r150027 1074 1074 void layoutRunsAndFloats(LineLayoutState&, bool hasInlineChild); 1075 1075 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines); 1076 #if ENABLE(CSS_EXCLUSIONS) 1077 void updateLineBoundariesForExclusions(ExclusionShapeInsideInfo*, LayoutUnit&, LineLayoutState&, bool&); 1078 bool adjustLogicalLineTopAndLogicalHeightIfNeeded(ExclusionShapeInsideInfo*, LayoutUnit, LineLayoutState&, InlineBidiResolver&, FloatingObject*, InlineIterator&, WordMeasurements&); 1079 #endif 1076 1080 const InlineIterator& restartLayoutRunsAndFloatsInRange(LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastFloatFromPreviousLine, InlineBidiResolver&, const InlineIterator&); 1077 1081 void linkToEndLineIfNeeded(LineLayoutState&); -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r149897 r150027 85 85 86 86 if (!shapeInsideInfo && flowThreadContainingBlock() && allowsExclusionShapeInsideInfoSharing()) { 87 LayoutUnit offset = logicalHeight() + logicalHeightForLine(this, false); 87 // regionAtBlockOffset returns regions like an array first={0,N-1}, second={N,M-1}, ... 88 LayoutUnit offset = logicalHeight() + logicalHeightForLine(this, false) - LayoutUnit(1); 88 89 RenderRegion* region = regionAtBlockOffset(offset); 89 90 if (region) … … 1646 1647 return exclusionShapeInsideInfo->shapeLogicalBottom(); 1647 1648 } 1649 1650 void RenderBlock::updateLineBoundariesForExclusions(ExclusionShapeInsideInfo* exclusionShapeInsideInfo, LayoutUnit& absoluteLogicalTop, LineLayoutState& layoutState, bool& lineOverflowsFromShapeInside) 1651 { 1652 LayoutUnit logicalHeight = this->logicalHeight(); 1653 RenderRegion* currentRegion = regionAtBlockOffset(logicalHeight); 1654 if (currentRegion) 1655 exclusionShapeInsideInfo = layoutExclusionShapeInsideInfo(); 1656 if (!exclusionShapeInsideInfo) 1657 return; 1658 1659 LayoutUnit lineTop = logicalHeight + absoluteLogicalTop; 1660 LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); 1661 1662 if (layoutState.flowThread()) { 1663 RenderRegion* nextRegion = regionAtBlockOffset(logicalHeight + lineHeight - LayoutUnit(1)); 1664 lineTop += exclusionShapeInsideInfo->owner()->borderAndPaddingBefore(); 1665 // Content in a flow thread is relative to the beginning of the thread, but the shape calculation should be relative to the current region. 1666 if (currentRegion == nextRegion) 1667 lineTop -= currentRegion->logicalTopForFlowThreadContent(); 1668 } 1669 1670 // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight, in which case these segments may be incorrect. 1671 exclusionShapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight); 1672 1673 // The overflow should be pushed below the content box 1674 LayoutUnit shapeContainingBlockHeight = exclusionShapeInsideInfo->shapeContainingBlockHeight(); 1675 if (!flowThreadContainingBlock() && !exclusionShapeInsideInfo->lineWithinShapeBounds() && !lineOverflowsFromShapeInside && shapeContainingBlockHeight) { 1676 setLogicalHeight(shapeContainingBlockHeight); 1677 lineOverflowsFromShapeInside = true; 1678 } 1679 } 1680 1681 bool RenderBlock::adjustLogicalLineTopAndLogicalHeightIfNeeded(ExclusionShapeInsideInfo* exclusionShapeInsideInfo, LayoutUnit absoluteLogicalTop, LineLayoutState& layoutState, InlineBidiResolver& resolver, FloatingObject* lastFloatFromPreviousLine, InlineIterator& end, WordMeasurements& wordMeasurements) 1682 { 1683 LayoutUnit adjustedLogicalLineTop = adjustLogicalLineTop(exclusionShapeInsideInfo, resolver.position(), end, wordMeasurements); 1684 if (!adjustedLogicalLineTop) 1685 return false; 1686 1687 LayoutUnit newLogicalHeight = adjustedLogicalLineTop - absoluteLogicalTop; 1688 RenderRegion* currentRegion = regionAtBlockOffset(logicalHeight()); 1689 if (layoutState.flowThread()) 1690 newLogicalHeight -= currentRegion->logicalTopForFlowThreadContent(); 1691 1692 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), newLogicalHeight, lastFloatFromPreviousLine, resolver, end); 1693 return true; 1694 } 1648 1695 #endif 1649 1696 … … 1671 1718 } 1672 1719 // Begin layout at the logical top of our shape inside. 1673 if (logicalHeight() + absoluteLogicalTop < exclusionShapeInsideInfo->shapeLogicalTop() )1720 if (logicalHeight() + absoluteLogicalTop < exclusionShapeInsideInfo->shapeLogicalTop() && !layoutState.flowThread()) 1674 1721 setLogicalHeight(exclusionShapeInsideInfo->shapeLogicalTop() - absoluteLogicalTop); 1675 1722 } 1676 1723 1677 if (layoutState.flowThread()) {1678 // In a flow thread we need to update absoluteLogicalTop in every run to match to the current logical top increased by the height of the current line to calculate the right values for the1679 // actual shape when a line is beginning in a new region which has a shape on it. Usecase: shape-inside is applied not on the first, but on either of the following regions in the region chain.1680 absoluteLogicalTop = logicalTop() + lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes);1681 }1682 1724 bool lineOverflowsFromShapeInside = false; 1683 1725 #endif … … 1701 1743 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly(); 1702 1744 FloatingObject* lastFloatFromPreviousLine = (containsFloats()) ? m_floatingObjects->set().last() : 0; 1745 1703 1746 #if ENABLE(CSS_EXCLUSIONS) 1704 // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight, in which 1705 // case these segments may be incorrect. 1706 if (layoutState.flowThread()) 1707 exclusionShapeInsideInfo = layoutExclusionShapeInsideInfo(); 1708 if (exclusionShapeInsideInfo) { 1709 LayoutUnit lineTop = logicalHeight() + absoluteLogicalTop; 1710 exclusionShapeInsideInfo->computeSegmentsForLine(lineTop, lineHeight(layoutState.lineInfo().isFirstLine(), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes)); 1711 1712 LayoutUnit shapeContainingBlockHeight = exclusionShapeInsideInfo->shapeContainingBlockHeight(); 1713 if (!flowThreadContainingBlock() && !exclusionShapeInsideInfo->lineWithinShapeBounds() && !lineOverflowsFromShapeInside && shapeContainingBlockHeight) { 1714 setLogicalHeight(shapeContainingBlockHeight); 1715 lineOverflowsFromShapeInside = true; 1716 } 1717 } 1747 updateLineBoundariesForExclusions(exclusionShapeInsideInfo, absoluteLogicalTop, layoutState, lineOverflowsFromShapeInside); 1718 1748 #endif 1719 1749 WordMeasurements wordMeasurements; … … 1731 1761 1732 1762 #if ENABLE(CSS_EXCLUSIONS) 1733 if (LayoutUnit adjustedLogicalLineTop = adjustLogicalLineTop(exclusionShapeInsideInfo, resolver.position(), end, wordMeasurements)) { 1734 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), adjustedLogicalLineTop - absoluteLogicalTop, lastFloatFromPreviousLine, resolver, oldEnd); 1763 if (adjustLogicalLineTopAndLogicalHeightIfNeeded(exclusionShapeInsideInfo, absoluteLogicalTop, layoutState, resolver, lastFloatFromPreviousLine, end, wordMeasurements)) 1735 1764 continue; 1736 }1737 1765 #endif 1738 1739 1766 ASSERT(end != resolver.position()); 1740 1767
Note: See TracChangeset
for help on using the changeset viewer.