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
+2014-01-10 Myles C. Maxfield <mmaxfield@apple.com>
+
+ CSS word-spacing property does not obey percentages
+ https://bugs.webkit.org/show_bug.cgi?id=126674
+
+ Reviewed by Simon Fraser.
+
+ 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
+
2014-01-10 Dean Jackson <dino@apple.com>
Implement OES texture half float linear
.seven {word-spacing: 1ex;}
.eight {word-spacing: 5px;}
.nine {word-spacing: normal;}
-.ten {word-spacing: 300%;}
-.eleven {word-spacing: -0.2em;}
+.ten {word-spacing: -0.2em;}
</STYLE>
</HEAD>
.seven {word-spacing: 1ex;}
.eight {word-spacing: 5px;}
.nine {word-spacing: normal;}
-.ten {word-spacing: 300%;}
-.eleven {word-spacing: -0.2em;}
+.ten {word-spacing: -0.2em;}
</PRE>
<HR>
This words in this sentence should have extra space between them, but the last few words in the sentence <SPAN class="nine">should have normal spacing</SPAN>.
</P>
<P class="ten">
-This sentence should have normal word-spacing, since percentage values are not allowed on this property.
-</P>
-<P class="eleven">
This words in this sentence should have reduced space between them, since negative values are allowed on this property.
</P>
This words in this sentence should have extra space between them, but the last few words in the sentence <SPAN class="nine">should have normal spacing</SPAN>.
</P>
<P class="ten">
-This sentence should have normal word-spacing, since percentage values are not allowed on this property.
-</P>
-<P class="eleven">
This words in this sentence should have reduced space between them, since negative values are allowed on this property.
</P>
</TD></TR></TABLE></BODY>
<p>There should be a stripy pattern of yellow and aqua below (each vertical stripe should be straight and unbroken).</p>
- <div><img src="support/swatch-yellow.png" width="50" height="150" alt="Image download support must be enabled" class="left-and-right-sides"><img src="support/swatch-yellow.png" width="50" height="150" alt="Image download support must be enabled" class="central"><img src="support/swatch-yellow.png" width="25" height="150" alt="Image download support must be enabled" class="central"><img src="support/swatch-yellow.png" width="25" height="150" alt="Image download support must be enabled" class="left-and-right-sides"></div>
+ <div><img src="support/swatch-yellow.png" width="50" height="125" alt="Image download support must be enabled" class="left-and-right-sides"><img src="support/swatch-yellow.png" width="50" height="125" alt="Image download support must be enabled" class="central"><img src="support/swatch-yellow.png" width="25" height="125" alt="Image download support must be enabled" class="central"><img src="support/swatch-yellow.png" width="25" height="125" alt="Image download support must be enabled" class="left-and-right-sides"></div>
</body>
-</html>
\ No newline at end of file
+</html>
div { font: 25px/1 Ahem; width: 12em; background: yellow; color: aqua; margin: 0 0 0 2em; }
.eight {word-spacing: 25px;}
.nine {word-spacing: normal;}
- .ten {word-spacing: 300%;}
- .eleven {word-spacing: -1em;}
+ .ten {word-spacing: -1em;}
.fill { color: yellow; }
</style>
<link rel="help" href="http://www.w3.org/TR/CSS21/text.html#spacing-props" title="16.4 Letter and word spacing: the 'letter-spacing' and 'word-spacing' properties">
<div class="test">x x xx xx</div>
<div class="test">x x xx xx</div>
<div class="eight"> x x <span class="nine">xx xx</span> </div>
- <div class="ten"> x x xx xx </div>
- <div class="eleven"> x <span class="nine"> </span>x <span class="fill">xx</span> xx <span class="fill">x</span>xx </div>
+ <div class="ten"> x <span class="nine"> </span>x <span class="fill">xx</span> xx <span class="fill">x</span>xx </div>
</body>
-</html>
\ No newline at end of file
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div id="cont" style="font-family: Courier New;">
+<div style="word-spacing: -100%;">word1 word2</div>
+<div style="word-spacing: 0px;">word1 word2</div>
+<div style="word-spacing: 100%;">word1 word2</div>
+</div>
+</script>
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div id="cont">
+<div style="word-spacing: -100%;">word1 word2</div>
+<div style="word-spacing: 0px;">word1 word2</div>
+<div style="word-spacing: 100%;">word1 word2</div>
+</div>
+<script>
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+window.setTimeout(function() {
+ var cont = document.getElementById("cont");
+ cont.setAttribute("style", "font-family: Courier New;");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}, 0);
+</script>
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div>word1word2</div>
+<div>word1 word2</div>
+<div>word1 word2</div>
+</body>
+</html>
--- /dev/null
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('word-spacing') is "100%"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('word-spacing') is "100.5%"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 0
+
--- /dev/null
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script type="text/javascript">
+ function testPercentageIsValid(stylesheet, percentage) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "1");
+ shouldBe("declaration.getPropertyValue('word-spacing')", '"' + percentage.toString() + '%' + '"');
+ stylesheet.deleteRule(0);
+ }
+
+ function testInvalidRule(stylesheet) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "0");
+ stylesheet.deleteRule(0);
+ }
+
+ var styleElement = document.createElement("style");
+ document.head.appendChild(styleElement);
+ stylesheet = styleElement.sheet;
+
+ stylesheet.insertRule(".p { word-spacing: 100%; }", 0);
+ testPercentageIsValid(stylesheet, 100);
+
+ stylesheet.insertRule(".p { word-spacing: 100.5%; }", 0);
+ testPercentageIsValid(stylesheet, 100.5);
+
+ stylesheet.insertRule(".p { word-spacing: garbage%; }", 0);
+ testInvalidRule(stylesheet);
+ </script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<div style="word-spacing: -100%">word1 word2</div>
+<div style="word-spacing: 0%">word1 word2</div>
+<div style="word-spacing: 100%">word1 word2</div>
+</body>
+</html>
-layer at (0,0) size 785x997
+layer at (0,0) size 785x914
RenderView at (0,0) size 785x600
-layer at (0,0) size 785x997
- RenderBlock {HTML} at (0,0) size 785x997
- RenderBody {BODY} at (8,8) size 769x981 [bgcolor=#CCCCCC]
+layer at (0,0) size 785x914
+ RenderBlock {HTML} at (0,0) size 785x914
+ RenderBody {BODY} at (8,8) size 769x898 [bgcolor=#CCCCCC]
RenderBlock {P} at (0,0) size 769x18
RenderText {#text} at (0,0) size 355x18
text run at (0,0) width 355: "The style declarations which apply to the text below are:"
- RenderBlock {PRE} at (0,34) size 769x180
- RenderText {#text} at (0,0) size 248x180
+ RenderBlock {PRE} at (0,34) size 769x165
+ RenderText {#text} at (0,0) size 232x165
text run at (0,0) width 216: ".one {word-spacing: 0.3in;}"
text run at (216,0) width 0: " "
text run at (0,15) width 216: ".two {word-spacing: 0.5cm;}"
text run at (216,105) width 0: " "
text run at (0,120) width 232: ".nine {word-spacing: normal;}"
text run at (232,120) width 0: " "
- text run at (0,135) width 208: ".ten {word-spacing: 300%;}"
- text run at (208,135) width 0: " "
- text run at (0,150) width 248: ".eleven {word-spacing: -0.2em;}"
- text run at (248,150) width 0: " "
- text run at (0,165) width 0: " "
- RenderBlock {HR} at (0,227) size 769x2 [border: (1px inset #000000)]
- RenderBlock {P} at (0,245) size 769x18
+ text run at (0,135) width 224: ".ten {word-spacing: -0.2em;}"
+ text run at (224,135) width 0: " "
+ text run at (0,150) width 0: " "
+ RenderBlock {HR} at (0,212) size 769x2 [border: (1px inset #000000)]
+ RenderBlock {P} at (0,230) size 769x18
RenderText {#text} at (0,0) size 709x18
text run at (0,0) width 709: "This words in this sentence should have extra space between them."
- RenderBlock {P} at (0,279) size 769x18
+ RenderBlock {P} at (0,264) size 769x18
RenderText {#text} at (0,0) size 610x18
text run at (0,0) width 610: "This words in this sentence should have extra space between them."
- RenderBlock {P} at (0,313) size 769x18
+ RenderBlock {P} at (0,298) size 769x18
RenderText {#text} at (0,0) size 610x18
text run at (0,0) width 610: "This words in this sentence should have extra space between them."
- RenderBlock {P} at (0,347) size 769x18
+ RenderBlock {P} at (0,332) size 769x18
RenderText {#text} at (0,0) size 461x18
text run at (0,0) width 461: "This words in this sentence should have extra space between them."
- RenderBlock {P} at (0,381) size 769x18
+ RenderBlock {P} at (0,366) size 769x18
RenderText {#text} at (0,0) size 461x18
text run at (0,0) width 461: "This words in this sentence should have extra space between them."
- RenderBlock {P} at (0,415) size 769x18
+ RenderBlock {P} at (0,400) size 769x18
RenderText {#text} at (0,0) size 581x18
text run at (0,0) width 581: "This words in this sentence should have extra space between them."
- RenderBlock {P} at (0,449) size 769x18
+ RenderBlock {P} at (0,434) size 769x18
RenderText {#text} at (0,0) size 493x18
text run at (0,0) width 493: "This words in this sentence should have extra space between them."
- RenderBlock {P} at (0,483) size 769x36
+ RenderBlock {P} at (0,468) size 769x36
RenderText {#text} at (0,0) size 751x18
text run at (0,0) width 751: "This words in this sentence should have extra space between them, but the last few words in the sentence"
RenderInline {SPAN} at (0,0) size 176x18
text run at (0,18) width 176: "should have normal spacing"
RenderText {#text} at (176,18) size 4x18
text run at (176,18) width 4: "."
- RenderBlock {P} at (0,535) size 769x18
- RenderText {#text} at (0,0) size 668x18
- text run at (0,0) width 668: "This sentence should have normal word-spacing, since percentage values are not allowed on this property."
- RenderBlock {P} at (0,569) size 769x18
+ RenderBlock {P} at (0,520) size 769x18
RenderText {#text} at (0,0) size 704x18
text run at (0,0) width 704: "This words in this sentence should have reduced space between them, since negative values are allowed on this property."
- RenderTable {TABLE} at (0,603) size 769x378 [border: (1px outset #808080)]
- RenderTableSection {TBODY} at (1,1) size 767x376
+ RenderTable {TABLE} at (0,554) size 769x344 [border: (1px outset #808080)]
+ RenderTableSection {TBODY} at (1,1) size 767x342
RenderTableRow {TR} at (0,0) size 767x26
RenderTableCell {TD} at (0,0) size 767x26 [bgcolor=#C0C0C0] [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=2]
RenderInline {STRONG} at (0,0) size 163x18
RenderText {#text} at (4,4) size 163x18
text run at (4,4) width 163: "TABLE Testing Section"
- RenderTableRow {TR} at (0,26) size 767x350
- RenderTableCell {TD} at (0,188) size 12x26 [bgcolor=#C0C0C0] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
+ RenderTableRow {TR} at (0,26) size 767x316
+ RenderTableCell {TD} at (0,171) size 12x26 [bgcolor=#C0C0C0] [border: (1px inset #808080)] [r=1 c=0 rs=1 cs=1]
RenderText {#text} at (4,4) size 4x18
text run at (4,4) width 4: " "
- RenderTableCell {TD} at (12,26) size 755x350 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
+ RenderTableCell {TD} at (12,26) size 755x316 [border: (1px inset #808080)] [r=1 c=1 rs=1 cs=1]
RenderBlock {P} at (4,4) size 747x18
RenderText {#text} at (0,0) size 709x18
text run at (0,0) width 709: "This words in this sentence should have extra space between them."
RenderText {#text} at (239,18) size 4x18
text run at (239,18) width 4: "."
RenderBlock {P} at (4,294) size 747x18
- RenderText {#text} at (0,0) size 668x18
- text run at (0,0) width 668: "This sentence should have normal word-spacing, since percentage values are not allowed on this property."
- RenderBlock {P} at (4,328) size 747x18
RenderText {#text} at (0,0) size 704x18
text run at (0,0) width 704: "This words in this sentence should have reduced space between them, since negative values are allowed on this property."
+2014-01-10 Myles C. Maxfield <mmaxfield@apple.com>
+
+ CSS word-spacing property does not obey percentages
+ https://bugs.webkit.org/show_bug.cgi?id=126674
+
+ Reviewed by Simon Fraser.
+
+ 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
+
2014-01-10 Simon Fraser <simon.fraser@apple.com>
Fix the iOS build.
case CSSPropertyWordBreak:
return cssValuePool().createValue(style->wordBreak());
case CSSPropertyWordSpacing:
- return zoomAdjustedPixelValue(style->wordSpacing(), style.get());
+ return zoomAdjustedPixelValue(style->font().wordSpacing(), style.get());
case CSSPropertyWordWrap:
return cssValuePool().createValue(style->overflowWrap());
case CSSPropertyWebkitLineBreak:
break;
case CSSPropertyLetterSpacing: // normal | <length> | inherit
- case CSSPropertyWordSpacing: // normal | <length> | inherit
if (id == CSSValueNormal)
validPrimitive = true;
else
validPrimitive = validUnit(value, FLength);
break;
+ case CSSPropertyWordSpacing: // normal | <length> | <percentage> | inherit
+ if (id == CSSValueNormal)
+ validPrimitive = true;
+ else
+ validPrimitive = validUnit(value, FLength | FPercent);
+ break;
+
case CSSPropertyTextIndent:
parsedValue = parseTextIndent();
break;
};
#endif
+class ApplyPropertyWordSpacing {
+public:
+ static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
+ {
+ if (!value->isPrimitiveValue())
+ return;
+
+ CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
+ Length wordSpacing;
+
+ if (primitiveValue->getValueID() == CSSValueNormal)
+ wordSpacing = RenderStyle::initialWordSpacing();
+ else if (primitiveValue->isLength()) {
+ double multiplier = styleResolver->style()->effectiveZoom();
+ if (Frame* frame = styleResolver->document().frame())
+ multiplier *= frame->textZoomFactor();
+ wordSpacing = primitiveValue->computeLength<Length>(styleResolver->style(), styleResolver->rootElementStyle(), multiplier);
+ } else if (primitiveValue->isPercentage())
+ wordSpacing = Length(primitiveValue->getDoubleValue(), Percent);
+ else if (primitiveValue->isNumber())
+ wordSpacing = Length(primitiveValue->getDoubleValue(), Fixed);
+ else if (primitiveValue->isViewportPercentageLength())
+ wordSpacing = Length(styleResolver->viewportPercentageValue(*primitiveValue, primitiveValue->getDoubleValue()), Fixed);
+ else
+ return;
+ styleResolver->style()->setWordSpacing(wordSpacing);
+ }
+ static PropertyHandler createHandler()
+ {
+ PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, &RenderStyle::wordSpacing, Length, &RenderStyle::setWordSpacing, Length, &RenderStyle::initialWordSpacing>::createHandler();
+ return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
+ }
+};
+
class ApplyPropertyPageSize {
private:
static Length mmLength(double mm)
setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto<short, &RenderStyle::widows, &RenderStyle::setWidows, &RenderStyle::hasAutoWidows, &RenderStyle::setHasAutoWidows>::createHandler());
setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicEnabled, NoneDisabled, UndefinedDisabled>::createHandler());
setPropertyHandler(CSSPropertyWordBreak, ApplyPropertyDefault<EWordBreak, &RenderStyle::wordBreak, EWordBreak, &RenderStyle::setWordBreak, EWordBreak, &RenderStyle::initialWordBreak>::createHandler());
- setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyComputeLength<float, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler());
+ setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyWordSpacing::createHandler());
// UAs must treat 'word-wrap' as an alternate name for the 'overflow-wrap' property. So using the same handlers.
setPropertyHandler(CSSPropertyWordWrap, ApplyPropertyDefault<EOverflowWrap, &RenderStyle::overflowWrap, EOverflowWrap, &RenderStyle::setOverflowWrap, EOverflowWrap, &RenderStyle::initialOverflowWrap>::createHandler());
new PropertyWrapper<int>(CSSPropertyOutlineOffset, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset),
new PropertyWrapper<unsigned short>(CSSPropertyOutlineWidth, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth),
new PropertyWrapper<float>(CSSPropertyLetterSpacing, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing),
- new PropertyWrapper<float>(CSSPropertyWordSpacing, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing),
+ new LengthPropertyWrapper<Length>(CSSPropertyWordSpacing, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing),
new LengthPropertyWrapper<Length>(CSSPropertyTextIndent, &RenderStyle::textIndent, &RenderStyle::setTextIndent),
new PropertyWrapper<float>(CSSPropertyWebkitPerspective, &RenderStyle::perspective, &RenderStyle::setPerspective),
&wordMeasurement.fallbackFonts, &overflow);
UChar c = renderer->characterAt(wordMeasurement.startOffset);
if (i > 0 && wordLength == 1 && (c == ' ' || c == '\t'))
- measuredWidth += renderer->style().wordSpacing();
+ measuredWidth += renderer->style().font().wordSpacing();
} else
measuredWidth += wordMeasurement.width;
if (!wordMeasurement.fallbackFonts.isEmpty()) {
m_hasEndWS = false;
const RenderStyle& style = this->style();
- const Font& f = style.font(); // FIXME: This ignores first-line.
- float wordSpacing = style.wordSpacing();
+ const Font& font = style.font(); // FIXME: This ignores first-line.
+ float wordSpacing = font.wordSpacing();
int len = textLength();
LazyLineBreakIterator breakIterator(m_text, style.locale());
bool needsWordSpacing = false;
// Non-zero only when kerning is enabled, in which case we measure words with their trailing
// space, then subtract its width.
- float wordTrailingSpaceWidth = f.typesettingFeatures() & Kerning ? f.width(RenderBlock::constructTextRun(this, f, &space, 1, style), &fallbackFonts) + wordSpacing : 0;
+ float wordTrailingSpaceWidth = font.typesettingFeatures() & Kerning ? font.width(RenderBlock::constructTextRun(this, font, &space, 1, style), &fallbackFonts) + wordSpacing : 0;
// If automatic hyphenation is allowed, we keep track of the width of the widest word (or word
// fragment) encountered so far, and only try hyphenating words that are wider.
lastWordBoundary++;
continue;
} else if (c == softHyphen && style.hyphens() != HyphensNone) {
- currMaxWidth += widthFromCache(f, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
+ currMaxWidth += widthFromCache(font, lastWordBoundary, i - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
if (firstGlyphLeftOverflow < 0)
firstGlyphLeftOverflow = glyphOverflow.left;
lastWordBoundary = i + 1;
bool isSpace = (j < len) && isSpaceAccordingToStyle(c, style);
float w;
if (wordTrailingSpaceWidth && isSpace)
- w = widthFromCache(f, i, wordLen + 1, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style) - wordTrailingSpaceWidth;
+ w = widthFromCache(font, i, wordLen + 1, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style) - wordTrailingSpaceWidth;
else {
- w = widthFromCache(f, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
+ w = widthFromCache(font, i, wordLen, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
if (c == softHyphen && style.hyphens() != HyphensNone)
- currMinWidth += hyphenWidth(this, f);
+ currMinWidth += hyphenWidth(this, font);
}
if (w > maxWordWidth) {
int suffixStart;
- float maxFragmentWidth = maxWordFragmentWidth(this, style, f, characters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
+ float maxFragmentWidth = maxWordFragmentWidth(this, style, font, characters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart, fallbackFonts, glyphOverflow);
if (suffixStart) {
float suffixWidth;
if (wordTrailingSpaceWidth && isSpace)
- suffixWidth = widthFromCache(f, i + suffixStart, wordLen - suffixStart + 1, leadWidth + currMaxWidth, 0, 0, style) - wordTrailingSpaceWidth;
+ suffixWidth = widthFromCache(font, i + suffixStart, wordLen - suffixStart + 1, leadWidth + currMaxWidth, 0, 0, style) - wordTrailingSpaceWidth;
else
- suffixWidth = widthFromCache(f, i + suffixStart, wordLen - suffixStart, leadWidth + currMaxWidth, 0, 0, style);
+ suffixWidth = widthFromCache(font, i + suffixStart, wordLen - suffixStart, leadWidth + currMaxWidth, 0, 0, style);
maxFragmentWidth = std::max(maxFragmentWidth, suffixWidth);
if (lastWordBoundary == i)
currMaxWidth += w;
else
- currMaxWidth += widthFromCache(f, lastWordBoundary, j - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
+ currMaxWidth += widthFromCache(font, lastWordBoundary, j - lastWordBoundary, leadWidth + currMaxWidth, &fallbackFonts, &glyphOverflow, style);
lastWordBoundary = j;
}
m_maxWidth = currMaxWidth;
currMaxWidth = 0;
} else {
- TextRun run = RenderBlock::constructTextRun(this, f, this, i, 1, style);
+ TextRun run = RenderBlock::constructTextRun(this, font, this, i, 1, style);
run.setCharactersLength(len - i);
ASSERT(run.charactersLength() >= run.length());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
run.setXPos(leadWidth + currMaxWidth);
- currMaxWidth += f.width(run, &fallbackFonts);
+ currMaxWidth += font.width(run, &fallbackFonts);
glyphOverflow.right = 0;
needsWordSpacing = isSpace && !previousCharacterIsSpace && i == len - 1;
}
return false;
if (!style.textIndent().isZero())
return false;
- if (style.wordSpacing() || style.letterSpacing())
+ if (!style.wordSpacing().isZero() || style.letterSpacing())
return false;
if (style.textTransform() != TTNONE)
return false;
bool canHyphenate = style.hyphens() == HyphensAuto && WebCore::canHyphenate(style.locale());
unsigned lastSpace = m_current.offset();
- float wordSpacing = m_currentStyle->wordSpacing();
+ float wordSpacing = m_currentStyle->font().wordSpacing();
float lastSpaceWordSpacing = 0;
float wordSpacingForWordMeasurement = 0;
float RenderStyle::computedFontSize() const { return fontDescription().computedSize(); }
int RenderStyle::fontSize() const { return inherited->font.pixelSize(); }
-float RenderStyle::wordSpacing() const { return inherited->font.wordSpacing(); }
+const Length& RenderStyle::wordSpacing() const { return rareInheritedData->wordSpacing; }
float RenderStyle::letterSpacing() const { return inherited->font.letterSpacing(); }
bool RenderStyle::setFontDescription(const FontDescription& v)
return lh.value();
}
-void RenderStyle::setWordSpacing(float v) { inherited.access()->font.setWordSpacing(v); }
+void RenderStyle::setWordSpacing(Length v)
+{
+ float fontWordSpacing;
+ if (v.isPercent())
+ fontWordSpacing = v.getFloatValue() * font().spaceWidth() / 100;
+ else {
+ ASSERT(v.isFixed());
+ fontWordSpacing = v.getFloatValue();
+ }
+ inherited.access()->font.setWordSpacing(fontWordSpacing);
+ rareInheritedData.access()->wordSpacing = std::move(v);
+}
+
void RenderStyle::setLetterSpacing(float v) { inherited.access()->font.setLetterSpacing(v); }
void RenderStyle::setFontSize(float size)
#else
TextDecorationStyle textDecorationStyle() const { return TextDecorationStyleSolid; }
#endif
- float wordSpacing() const;
+ const Length& wordSpacing() const;
float letterSpacing() const;
float zoom() const { return visual->m_zoom; }
void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; }
- void setWordSpacing(float);
+ void setWordSpacing(Length);
void setLetterSpacing(float);
void clearBackgroundLayers() { m_background.access()->m_background = FillLayer(BackgroundFillLayer); }
static unsigned short initialColumnRuleWidth() { return 3; }
static unsigned short initialOutlineWidth() { return 3; }
static float initialLetterSpacing() { return 0; }
- static float initialWordSpacing() { return 0; }
+ static Length initialWordSpacing() { return Length(Fixed); }
static Length initialSize() { return Length(); }
static Length initialMinSize() { return Length(Fixed); }
static Length initialMaxSize() { return Length(Undefined); }
void* ownPtrs[1];
AtomicString atomicStrings[5];
void* refPtrs[2];
- Length lengths[1];
+ Length lengths[2];
float secondFloat;
unsigned m_bitfields[2];
#if ENABLE(CSS3_TEXT_DECORATION) && ENABLE(CSS_IMAGE_ORIENTATION)
RefPtr<CursorList> cursorData;
Length indent;
float m_effectiveZoom;
+
+ Length wordSpacing;
// Paged media properties.
short widows;