[CSS Exclusions] Enable shape-inside for simple rectangles
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2012 18:48:49 +0000 (18:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Aug 2012 18:48:49 +0000 (18:48 +0000)
commit0c370c846282b7fafcbd47240dfb8983eeca0b79
tree792fc2faa37b8dfc308b398647ce1b21c2bb6c5d
parent9ef06a382f9df5d75e90a1b2a276ffc4dbc17970
[CSS Exclusions] Enable shape-inside for simple rectangles
https://bugs.webkit.org/show_bug.cgi?id=89259

Patch by Bear Travis <betravis@adobe.com> on 2012-08-24
Reviewed by Levi Weintraub.

Source/WebCore:

This patch is the first in a series enabling shape-inside. It adds
support for inline layout within a single render block with a
rectangular shape-inside.
Each RenderBlock with a valid shape-inside maintains a WrapShapeInfo,
which can calculate the areas, or LineSegments, where inline content
can flow on a line. The WrapShapeInfo class maintains a static map of
RenderBlocks to WrapShapeInfos. The basic algorithm involves three stages:
1. Determine if the RenderBlock has a valid shape-inside, and store it
in a WrapShapeInfo if necessary.
2. If the inline content is affected by a shape-inside, use the
corresponding WrapShapeInfo to break the content into line segments.
3. Lay out the line segments.

Tests: fast/exclusions/shape-inside/shape-inside-floats-simple.html
       fast/exclusions/shape-inside/shape-inside-inline-elements.html
       fast/exclusions/shape-inside/shape-inside-overflow.html
       fast/exclusions/shape-inside/shape-inside-percentage-auto.html
       fast/exclusions/shape-inside/shape-inside-text.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::willBeDestroyed): Remove WrapShapeInfo when destroyed.
(WebCore::RenderBlock::styleDidChange): Detect modifications to style()->wrapShapeInside.
(WebCore):
(WebCore::RenderBlock::updateWrapShapeInfoAfterStyleChange): Update WrapShapeInfo
when style()->wrapShapeInside changes.
(WebCore::RenderBlock::layoutBlock): Notify WrapShapeInfo of changes in logicalWidth
and logicalHeight before laying out inline content.
* rendering/RenderBlock.h:
(RenderBlock):
(WebCore::RenderBlock::wrapShapeInfo): Return the wrapShapeInfo associated with a
RenderBlock.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::LineWidth::LineWidth): Determine the WrapShapeInfo::LineSegment this LineWidth
corresponds to, if any.
(LineWidth):
(WebCore::LineWidth::updateAvailableWidth): The width's LineSegment boundaries affect
the available width.
(WebCore::RenderBlock::computeInlineDirectionPositionsForLine): The current LineSegment
affects the left & right positioning of inline boxes.
(WebCore::RenderBlock::layoutRunsAndFloatsInRange): Move to the top of the inside wrap
shape before beginning inline layout, and update the line segments for each line.
* rendering/WrapShapeInfo.cpp: Added.
(WebCore):
(WebCore::WrapShapeInfo::WrapShapeInfo): Create an empty WrapShapeInfo.
(WebCore::WrapShapeInfo::~WrapShapeInfo): No additional cleanup.
(WebCore::WrapShapeInfo::create): Create a WrapShapeInfo reference.
(WebCore::WrapShapeInfo::ensureWrapShapeInfoForRenderBlock): Create a WrapShapeInfo
for a RenderBlock with an inside WrapShape and place it in the WrapShapeInfo map.
(WebCore::WrapShapeInfo::wrapShapeInfoForRenderBlock): Lookup the WrapShapeInfo for
a RenderBlock in the WrapShapeInfo map.
(WebCore::WrapShapeInfo::isWrapShapeInfoEnabledForBlock): Determine if a RenderBlock
has an inside wrap shape that we can use for inline layout.
(WebCore::WrapShapeInfo::removeWrapShapeInfoForRenderBlock): Remove a RenderBlock's
WrapShapeInfo from the WrapShapeInfo map.
(WebCore::WrapShapeInfo::hasSegments): Returns true if there are any line segments
for the current line.
(WebCore::WrapShapeInfo::computeShapeSize): Compute the dimensions of the wrap shape
based on a block's logical width & height.
(WebCore::WrapShapeInfo::computeSegmentsForLine): Sets the current line and computes
its line segments.
* rendering/WrapShapeInfo.h: Added.
(WebCore):
(LineSegment):
(WrapShapeInfo):
(WebCore::WrapShapeInfo::shapeTop): The top of a wrap shape, where the inline content
area begins.
(WebCore::WrapShapeInfo::segments): The list of line segments for the current line.
(WebCore::WrapShapeInfo::wrapShapeSizeNeedsRecomputing): Mark a WrapShapeInfo as
needing to recompute its WrapShape dimensions.
(WebCore::WrapShapeInfo::lineState): The current line state: above, inside, or below
the wrap shape.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff): Changes to shape inside require relayout.

LayoutTests:

Test that inline content correctly wraps for a simple rectangular
shape-inside. Text and inline content should wrap inside the
rectangular shape-inside, and overflow to its containing block.
Inline content inside a shape-inside should also avoid floats.

* fast/exclusions/shape-inside/shape-inside-floats-simple-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-floats-simple.html: Added.
* fast/exclusions/shape-inside/shape-inside-inline-elements-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-inline-elements.html: Added.
* fast/exclusions/shape-inside/shape-inside-overflow-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-overflow.html: Added.
* fast/exclusions/shape-inside/shape-inside-percentage-auto-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-percentage-auto.html: Added.
* fast/exclusions/shape-inside/shape-inside-text-expected.html: Added.
* fast/exclusions/shape-inside/shape-inside-text.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126605 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/exclusions/shape-inside/shape-inside-floats-simple-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-floats-simple.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-inline-elements-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-inline-elements.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-overflow-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-overflow.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage-auto-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-percentage-auto.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-text-expected.html [new file with mode: 0644]
LayoutTests/fast/exclusions/shape-inside/shape-inside-text.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/WrapShapeInfo.cpp [new file with mode: 0644]
Source/WebCore/rendering/WrapShapeInfo.h [new file with mode: 0644]
Source/WebCore/rendering/style/RenderStyle.cpp