Skip to content
Commit 516f09b7 authored by mmaxfield@apple.com's avatar mmaxfield@apple.com
Browse files

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: http://svn.webkit.org/repository/webkit/trunk@161696 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f557658f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment