Source/WebCore: Implement the CSS3 line-box-contain property. This property provides...
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2011 19:03:50 +0000 (19:03 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2011 19:03:50 +0000 (19:03 +0000)
commit47021a8815bdfdecd32290647cd7e8daa1ab71c3
treed0a18f92dfd17e70325422d4ffeb5d37964fa98d
parent6470402f3482e3cd8b7dbf2ab0b514aca4d545bd
Source/WebCore: Implement the CSS3 line-box-contain property. This property provides authors with more control over spacing between lines. For example,
you can fix the height of lines and cause all line contents to be ignored. You can make lines fit to glyphs. You can ignore leading and
fit to the font size. You can ignore replaced elements, etc.

Reviewed by Simon Fraser.

Refactor the code in computeLogicalBoxHeights into helper methods on RootInlineBox. verticalPositionForBox moved over to RootInlineBox
so that it could be called from RenderBlockLineLayout. ascentAndDescentForBox is the new method that computes the appropriate box
height based off the block's line-box-contain value.

GlyphOverflow can now have a computeBounds parameter set, in which case glyph bounds will be computed and stored in the overflow struct.

RenderInline no longer returns 0 margins in the block direction, since line-box-contain can size around the margin box.

Added new tests in fast/block/lineboxcontain

* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::createLineBoxContainValue):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSLineBoxContainValue.cpp: Added.
(WebCore::CSSLineBoxContainValue::CSSLineBoxContainValue):
(WebCore::CSSLineBoxContainValue::cssText):
* css/CSSLineBoxContainValue.h: Added.
(WebCore::CSSLineBoxContainValue::create):
(WebCore::CSSLineBoxContainValue::value):
(WebCore::CSSLineBoxContainValue::isCSSLineBoxContainValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseLineBoxContain):
* css/CSSParser.h:
* css/CSSPropertyNames.in:
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* css/CSSValue.h:
(WebCore::CSSValue::isCSSLineBoxContainValue):
* css/CSSValueKeywords.in:
* platform/graphics/Font.cpp:
(WebCore::Font::width):
* platform/graphics/Font.h:
(WebCore::GlyphOverflow::GlyphOverflow):
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::floatWidthForSimpleText):
* platform/graphics/mac/FontComplexTextMac.cpp:
(WebCore::Font::floatWidthForComplexText):
* platform/graphics/win/FontWin.cpp:
(WebCore::Font::floatWidthForComplexText):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::computeLogicalBoxHeights):
* rendering/InlineFlowBox.h:
* rendering/RenderBlock.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::computeInlineDirectionPositionsForLine):
(WebCore::RenderBlock::layoutInlineChildren):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::marginLeft):
(WebCore::RenderInline::marginRight):
(WebCore::RenderInline::marginTop):
(WebCore::RenderInline::marginBottom):
(WebCore::RenderInline::marginBefore):
(WebCore::RenderInline::marginAfter):
* rendering/RenderInline.h:
* rendering/RenderText.cpp:
(WebCore::RenderText::widthFromCache):
(WebCore::RenderText::width):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::alignBoxesInBlockDirection):
(WebCore::setAscentAndDescent):
(WebCore::RootInlineBox::ascentAndDescentForBox):
(WebCore::RootInlineBox::verticalPositionForBox):
(WebCore::RootInlineBox::includeLeadingForBox):
(WebCore::RootInlineBox::includeFontForBox):
(WebCore::RootInlineBox::includeGlyphsForBox):
(WebCore::RootInlineBox::includeMarginForBox):
(WebCore::RootInlineBox::fitsToGlyphs):
(WebCore::RootInlineBox::includesRootLineBoxFontOrLeading):
* rendering/RootInlineBox.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::lineBoxContain):
(WebCore::InheritedFlags::setLineBoxContain):
(WebCore::InheritedFlags::initialLineBoxContain):
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):
* rendering/style/StyleRareInheritedData.h:

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=56388

Reviewed by Simon Fraser.

Implement the CSS3 line-box-contain property. This property provides authors with more control over spacing between lines. For example,
you can fix the height of lines and cause all line contents to be ignored. You can make lines fit to glyphs. You can ignore leading and
fit to the font size. You can ignore replaced elements, etc.

Refactor the code in computeLogicalBoxHeights into helper methods on RootInlineBox. verticalPositionForBox moved over to RootInlineBox
so that it could be called from RenderBlockLineLayout. ascentAndDescentForBox is the new method that computes the appropriate box
height based off the block's line-box-contain value.

GlyphOverflow can now have a computeBounds parameter set, in which case glyph bounds will be computed and stored in the overflow struct.

RenderInline no longer returns 0 margins in the block direction, since line-box-contain can size around the margin box.

* fast/block/lineboxcontain: Added.
* fast/block/lineboxcontain/block-font.html: Added.
* fast/block/lineboxcontain/block-glyphs-replaced.html: Added.
* fast/block/lineboxcontain/block-glyphs.html: Added.
* fast/block/lineboxcontain/block-replaced.html: Added.
* fast/block/lineboxcontain/block.html: Added.
* fast/block/lineboxcontain/font-replaced.html: Added.
* fast/block/lineboxcontain/font.html: Added.
* fast/block/lineboxcontain/glyphs.html: Added.
* fast/block/lineboxcontain/inline-box-replaced.html: Added.
* fast/block/lineboxcontain/inline-box-vertical.html: Added.
* fast/block/lineboxcontain/inline-box.html: Added.
* fast/block/lineboxcontain/inline-replaced.html: Added.
* fast/block/lineboxcontain/inline.html: Added.
* fast/block/lineboxcontain/none.html: Added.
* fast/block/lineboxcontain/replaced.html: Added.
* platform/mac/fast/block/lineboxcontain: Added.
* platform/mac/fast/block/lineboxcontain/block-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-font-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-font-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-font-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/block-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/block-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/block-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/font-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/font-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/font-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/font-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/font-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/font-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/glyphs-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/glyphs-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/glyphs-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/inline-replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/inline-replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/inline-replaced-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/none-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/none-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/none-expected.txt: Added.
* platform/mac/fast/block/lineboxcontain/replaced-expected.checksum: Added.
* platform/mac/fast/block/lineboxcontain/replaced-expected.png: Added.
* platform/mac/fast/block/lineboxcontain/replaced-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@81684 268f45cc-cd09-0410-ab3c-d52691b4dbfc
98 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/block/lineboxcontain/block-font.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/block-glyphs-replaced.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/block-glyphs.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/block-replaced.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/block.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/font-replaced.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/font.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/glyphs.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/inline-box-replaced.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/inline-box-vertical.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/inline-box.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/inline-replaced.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/inline.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/none.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/parsing-invalid.html [new file with mode: 0644]
LayoutTests/fast/block/lineboxcontain/replaced.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-font-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-font-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-font-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-glyphs-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-glyphs-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-glyphs-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-glyphs-replaced-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-replaced-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-replaced-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/block-replaced-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/font-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/font-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/font-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/font-replaced-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/font-replaced-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/font-replaced-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/glyphs-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/glyphs-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/glyphs-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-replaced-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-box-vertical-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-replaced-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-replaced-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/inline-replaced-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/none-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/none-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/none-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/parsing-invalid-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/parsing-invalid-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/parsing-invalid-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/replaced-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/replaced-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/block/lineboxcontain/replaced-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSLineBoxContainValue.cpp [new file with mode: 0644]
Source/WebCore/css/CSSLineBoxContainValue.h [new file with mode: 0644]
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/FontFastPath.cpp
Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
Source/WebCore/platform/graphics/win/FontWin.cpp
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineFlowBox.h
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/rendering/RootInlineBox.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h