CSS word-spacing property does not obey percentages
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jan 2014 00:31:19 +0000 (00:31 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jan 2014 00:31:19 +0000 (00:31 +0000)
commitd4725f5a711c8dcae86024c32f6f3137f7919545
tree9f3053950fc7cd5801f592c7b8fd9c55a136acb0
parentd8bd56518cf909b3f64a8871dacfabd2b5decbb0
CSS word-spacing property does not obey percentages
https://bugs.webkit.org/show_bug.cgi?id=126674

Reviewed by Simon Fraser.

Source/WebCore:

One change between CSS2.1 and CSS3 is that the word-spacing CSS property can
take percentages (of the width of the space character) in CSS3. In order to
implement this, the datatype must be changed from a float to a Length, which
can hold percentage values. Then, during layout, we can query the width of
the space character and update the Font's word-spacing value appropriately.
However, the RenderStyle still holds on to the Length (as a rare inherited
value).

Tests: fast/css3-text/css3-word-spacing-percentage/word-spacing-change-font.html
       fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-parse.html
       fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue): Use Font's computed value instead
of style's Length value.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): word-spacing and letter-spacing no longer are
parsed the same way.
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyWordSpacing::applyValue): Construct a length from a given
CSSValue and set the style's word spacing with it.
(WebCore::ApplyPropertyWordSpacing::createHandler):
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder): Use ApplyPropertyWordSpacing.
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun): Use Font's computed value instead
of style's Length value.
* rendering/RenderText.cpp:
(WebCore::RenderText::computePreferredLogicalWidths): Ditto.
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseFor): Opt-out of the SimpleLineLayout
if either the percentage or the length is nonzero.
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::BreakingContext::handleText): Use Font's computed value instead
of style's Length value.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::wordSpacing):
(WebCore::RenderStyle::setWordSpacing): Consult the Font's space with to compute
percentage values, but hold on to the original Length.
* rendering/style/RenderStyle.h:
* rendering/style/StyleRareInheritedData.cpp:
* rendering/style/StyleRareInheritedData.h: Hold on to the specified Length

LayoutTests:

See per-file description

* fast/css3-text/css3-word-spacing-percentage/word-spacing-change-font-expected.html: Added.
* fast/css3-text/css3-word-spacing-percentage/word-spacing-change-font.html: Added.
Make sure that if Javascript changes the font after initial layout, that the word-spacing
value gets appropriately updated.
* fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-expected.html: Added.
* fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-parse-expected.txt: Added.
* fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-parse.html: Added.
Make sure that the CSSOM yields the correct percentage values when queried.
* fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage.html: Added.
Try some specific values of percentages (-100%, 0%, and 100%).
* css1/text_properties/word_spacing.html: Updated to not disregard percentages
* css2.1/20110323/c541-word-sp-001-expected.html:
* css2.1/20110323/c541-word-sp-001.htm: Ditto
* platform/mac/css1/text_properties/word_spacing-expected.png:
* platform/mac/css1/text_properties/word_spacing-expected.txt: Ditto

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161696 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
LayoutTests/ChangeLog
LayoutTests/css1/text_properties/word_spacing.html
LayoutTests/css2.1/20110323/c541-word-sp-001-expected.html
LayoutTests/css2.1/20110323/c541-word-sp-001.htm
LayoutTests/fast/css3-text/css3-word-spacing-percentage/word-spacing-change-font-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-word-spacing-percentage/word-spacing-change-font.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-expected.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-parse-expected.txt [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-parse.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage.html [new file with mode: 0644]
LayoutTests/platform/mac/css1/text_properties/word_spacing-expected.png
LayoutTests/platform/mac/css1/text_properties/word_spacing-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/DeprecatedStyleBuilder.cpp
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/SimpleLineLayout.cpp
Source/WebCore/rendering/line/BreakingContextInlineHeaders.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