Parsing support for text-underline-offset and text-decoration-thickness
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 00:11:15 +0000 (00:11 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 00:11:15 +0000 (00:11 +0000)
commite1f7ced2be11043be2c75b1e5c99ac24c663a60f
tree38d28967777db0551d044bed9e6362ea88d848ae
parentd1f44ffe3735ce3cf490e7e7906750a91b36bbca
Parsing support for text-underline-offset and text-decoration-thickness
https://bugs.webkit.org/show_bug.cgi?id=191242

Reviewed by Simon Fraser.

Source/WebCore:

Before we can implement the properties properly, we have to parse them.

https://github.com/w3c/csswg-drafts/issues/3118#issuecomment-432297480 describes the grammar:
text-underline-position: auto | [ [ under | from-font] || [ left | right ] ]
text-underline-offset: auto | <length>
text-decoration-thickness: auto | from-font | <length>

This patch also takes the opportunity to update the grammar of text-underline-position to match the spec,
and to add an alias to the unprefixed version.

We still don't support the left and right values on text-underline-position. We should add those eventually.

Tests: fast/css3-text/css3-text-decoration/text-decoration-thickness-parse.html
       fast/css3-text/css3-text-decoration/text-underline-offset-parse.html

* WebCore.xcodeproj/project.pbxproj:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::textUnderlineOffsetToCSSValue):
(WebCore::textDecorationThicknessToCSSValue):
(WebCore::ComputedStyleExtractor::valueForPropertyinStyle):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator TextUnderlinePosition const):
(WebCore::CSSPrimitiveValue::operator OptionSet<TextUnderlinePosition> const): Deleted.
* css/CSSProperties.json:
* css/CSSValueKeywords.in:
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
(WebCore::StyleBuilderConverter::convertTextUnderlineOffset):
(WebCore::StyleBuilderConverter::convertTextDecorationThickness):
* css/StyleResolver.cpp:
(WebCore::shouldApplyPropertyInParseOrder):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeTextUnderlineOffset):
(WebCore::consumeTextDecorationThickness):
(WebCore::CSSPropertyParser::parseSingleValue):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::textUnderlinePosition const):
(WebCore::RenderStyle::textUnderlineOffset const):
(WebCore::RenderStyle::textDecorationThickness const):
(WebCore::RenderStyle::setTextUnderlinePosition):
(WebCore::RenderStyle::setTextUnderlineOffset):
(WebCore::RenderStyle::setTextDecorationThickness):
(WebCore::RenderStyle::initialTextUnderlinePosition):
(WebCore::RenderStyle::initialTextUnderlineOffset):
(WebCore::RenderStyle::initialTextDecorationThickness):
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator== const):
* rendering/style/StyleRareInheritedData.h:
* rendering/style/TextDecorationThickness.h: Added.
(WebCore::TextDecorationThickness::createWithAuto):
(WebCore::TextDecorationThickness::createFromFont):
(WebCore::TextDecorationThickness::createWithLength):
(WebCore::TextDecorationThickness::isAuto const):
(WebCore::TextDecorationThickness::isFromFont const):
(WebCore::TextDecorationThickness::isLength const):
(WebCore::TextDecorationThickness::setLengthValue):
(WebCore::TextDecorationThickness::lengthValue const):
(WebCore::TextDecorationThickness::operator== const):
(WebCore::TextDecorationThickness::operator!= const):
(WebCore::TextDecorationThickness::TextDecorationThickness):
(WebCore::operator<<):
* rendering/style/TextUnderlineOffset.h: Added.
(WebCore::TextUnderlineOffset::createWithAuto):
(WebCore::TextUnderlineOffset::createWithLength):
(WebCore::TextUnderlineOffset::isAuto const):
(WebCore::TextUnderlineOffset::isLength const):
(WebCore::TextUnderlineOffset::setLengthValue):
(WebCore::TextUnderlineOffset::lengthValue const):
(WebCore::TextUnderlineOffset::lengthOr const):
(WebCore::TextUnderlineOffset::operator== const):
(WebCore::TextUnderlineOffset::operator!= const):
(WebCore::TextUnderlineOffset::TextUnderlineOffset):
(WebCore::operator<<):
* style/InlineTextBoxStyle.cpp:
(WebCore::computeUnderlineOffset):
* style/InlineTextBoxStyle.h:

LayoutTests:

* fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position-expected.txt:
* fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position.html: Update the
test for the new grammar of text-underline-position
* fast/css3-text/css3-text-decoration/text-decoration-thickness-parse-expected.txt: Added.
* fast/css3-text/css3-text-decoration/text-decoration-thickness-parse.html: Added.
* fast/css3-text/css3-text-decoration/text-underline-offset-parse-expected.txt: Added.
* fast/css3-text/css3-text-decoration/text-underline-offset-parse.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237835 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position-expected.txt
LayoutTests/fast/css3-text/css3-text-decoration/getComputedStyle/getComputedStyle-text-underline-position.html
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness-parse-expected.txt [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-thickness-parse.html [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/text-underline-offset-parse-expected.txt [new file with mode: 0644]
LayoutTests/fast/css3-text/css3-text-decoration/text-underline-offset-parse.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSProperties.json
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/StyleBuilderConverter.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h
Source/WebCore/rendering/style/TextDecorationThickness.h [new file with mode: 0644]
Source/WebCore/rendering/style/TextUnderlineOffset.h [new file with mode: 0644]
Source/WebCore/style/InlineTextBoxStyle.cpp
Source/WebCore/style/InlineTextBoxStyle.h