Skip to content

Commit

Permalink
[css-fonts] Implement font-variant-emoji CSS property
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=246911
rdar://101722745

Reviewed by Myles C. Maxfield.

This builds off existing code that Myles wrote in bug 259139 for platform support.

font-variant-emoji: normal | text | emoji | unicode

https://drafts.csswg.org/css-fonts-4/#font-variant-emoji-prop

* LayoutTests/TestExpectations:
* LayoutTests/fast/css/font-property-priority-expected.txt:
* LayoutTests/fast/css/font-shorthand-expected.txt:
* LayoutTests/fast/css/getComputedStyle/computed-style-font-family-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-shorthand-serialization-prevention-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-shorthand-subproperties-reset-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/inheritance-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-emoji-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/parsing/font-variant-emoji-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/font-variant-emoji-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/font-variant-emoji.html:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/font-shorthand-serialization-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/editing/run/removeformat-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-001-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/property-list.js:
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/ipad/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/wpe/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* Source/WebCore/css/CSSPrimitiveValueMappings.h:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/CSSValueKeywords.in:
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle const):
* Source/WebCore/css/ShorthandSerializer.cpp:
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeFontVariantShorthand):
(WebCore::initialValueForLonghand):
* Source/WebCore/platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::glyphDataForCharacter const):
* Source/WebCore/platform/graphics/FontCascadeCache.h:
(WebCore::FontDescriptionKey::makeFlagsKey):
* Source/WebCore/platform/graphics/FontCascadeDescription.h:
(WebCore::FontCascadeDescription::initialVariantEmoji):
* Source/WebCore/platform/graphics/FontDescription.cpp:
* Source/WebCore/platform/graphics/FontDescription.h:
(WebCore::FontDescription::variantEmoji const):
(WebCore::FontDescription::variantSettings const):
(WebCore::FontDescription::setVariantEmoji):
(WebCore::FontDescription::operator== const):
(WebCore::FontDescription::encode const):
(WebCore::FontDescription::decode):
* Source/WebCore/platform/text/TextFlags.h:
(WebCore::FontVariantSettings::FontVariantSettings):
(WebCore::FontVariantSettings::isAllNormal const):
(WebCore::FontVariantSettings::operator== const):

Canonical link: https://commits.webkit.org/267540@main
  • Loading branch information
nt1m committed Sep 1, 2023
1 parent 2e3f11b commit 19378f7
Show file tree
Hide file tree
Showing 38 changed files with 161 additions and 42 deletions.
1 change: 0 additions & 1 deletion LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -3858,7 +3858,6 @@ webkit.org/b/206881 imported/w3c/web-platform-tests/css/css-fonts/font-face-weig

# Triaged css-fonts failures
webkit.org/b/246564 imported/w3c/web-platform-tests/css/css-fonts/font-synthesis-small-caps-not-applied.html [ ImageOnlyFailure ]
webkit.org/b/246911 imported/w3c/web-platform-tests/css/css-fonts/font-variant-emoji-2.html [ ImageOnlyFailure ]

# vert font feature in vertical-text
webkit.org/b/182042 imported/w3c/web-platform-tests/css/css-fonts/font-default-04.html [ ImageOnlyFailure ]
Expand Down
1 change: 1 addition & 0 deletions LayoutTests/fast/css/font-property-priority-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ Property 'font-variant-alternates' has priority 'important'.
Property 'font-variant-numeric' has priority 'important'.
Property 'font-variant-east-asian' has priority 'important'.
Property 'font-variant-position' has priority 'important'.
Property 'font-variant-emoji' has priority 'important'.
Property 'font-style' has priority 'important'.

9 changes: 9 additions & 0 deletions LayoutTests/fast/css/font-shorthand-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -33,6 +34,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -52,6 +54,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -71,6 +74,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -90,6 +94,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -109,6 +114,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -128,6 +134,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -147,6 +154,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand All @@ -166,6 +174,7 @@ font-variant-ligatures: normal
font-variant-numeric: normal
font-variant-east-asian: normal
font-variant-position: normal
font-variant-emoji: normal
font-feature-settings: normal
font-optical-sizing: auto
font-variation-settings: normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ font-synthesis-weight: auto;
font-variant-alternates: normal;
font-variant-caps: normal;
font-variant-east-asian: normal;
font-variant-emoji: normal;
font-variant-ligatures: normal;
font-variant-numeric: normal;
font-variant-position: normal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ PASS font-synthesis-weight
PASS font-variant-alternates
PASS font-variant-caps
PASS font-variant-east-asian
PASS font-variant-emoji
PASS font-variant-ligatures
PASS font-variant-numeric
PASS font-variant-position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ PASS Setting font-variant-east-asian to normal should not prevent the font short
PASS Setting font-variant-east-asian to normal should not prevent the font shorthand from serializing in computed style
PASS Setting font-variant-east-asian to full-width should prevent the font shorthand from serializing in specified style
PASS Setting font-variant-east-asian to full-width should prevent the font shorthand from serializing in computed style
PASS Setting font-variant-emoji to initial should prevent the font shorthand from serializing in specified style
PASS Setting font-variant-emoji to initial should not prevent the font shorthand from serializing in computed style
PASS Setting font-variant-emoji to inherit should prevent the font shorthand from serializing in specified style
PASS Setting font-variant-emoji to inherit should not prevent the font shorthand from serializing in computed style
PASS Setting font-variant-emoji to unset should prevent the font shorthand from serializing in specified style
PASS Setting font-variant-emoji to unset should not prevent the font shorthand from serializing in computed style
PASS Setting font-variant-emoji to revert should prevent the font shorthand from serializing in specified style
PASS Setting font-variant-emoji to revert should not prevent the font shorthand from serializing in computed style
PASS Setting font-variant-emoji to revert-layer should prevent the font shorthand from serializing in specified style
PASS Setting font-variant-emoji to revert-layer should not prevent the font shorthand from serializing in computed style
PASS Setting font-variant-emoji to normal should not prevent the font shorthand from serializing in specified style
PASS Setting font-variant-emoji to normal should not prevent the font shorthand from serializing in computed style
PASS Setting font-variant-emoji to text should prevent the font shorthand from serializing in specified style
PASS Setting font-variant-emoji to text should prevent the font shorthand from serializing in computed style
PASS Setting font-feature-settings to initial should prevent the font shorthand from serializing in specified style
PASS Setting font-feature-settings to initial should not prevent the font shorthand from serializing in computed style
PASS Setting font-feature-settings to inherit should prevent the font shorthand from serializing in specified style
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PASS Property font-variant-position should be reset to its initial value.
PASS Property font-variant-numeric should be reset to its initial value.
PASS Property font-variant-alternates should be reset to its initial value.
PASS Property font-variant-east-asian should be reset to its initial value.
PASS Property font-variant-emoji should be reset to its initial value.
PASS Property font-feature-settings should be reset to its initial value.
PASS Property font-optical-sizing should be reset to its initial value.
PASS Property font-variation-settings should be reset to its initial value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ PASS Property font-variant-caps has initial value normal
PASS Property font-variant-caps inherits
PASS Property font-variant-east-asian has initial value normal
PASS Property font-variant-east-asian inherits
FAIL Property font-variant-emoji has initial value normal assert_true: font-variant-emoji doesn't seem to be supported in the computed style expected true got false
FAIL Property font-variant-emoji inherits assert_true: font-variant-emoji doesn't seem to be supported in the computed style expected true got false
PASS Property font-variant-emoji has initial value normal
PASS Property font-variant-emoji inherits
PASS Property font-variant-ligatures has initial value normal
PASS Property font-variant-ligatures inherits
PASS Property font-variant-numeric has initial value normal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

FAIL Property font-variant-emoji value 'normal' assert_true: font-variant-emoji doesn't seem to be supported in the computed style expected true got false
FAIL Property font-variant-emoji value 'text' assert_true: font-variant-emoji doesn't seem to be supported in the computed style expected true got false
FAIL Property font-variant-emoji value 'emoji' assert_true: font-variant-emoji doesn't seem to be supported in the computed style expected true got false
FAIL Property font-variant-emoji value 'unicode' assert_true: font-variant-emoji doesn't seem to be supported in the computed style expected true got false
PASS Property font-variant-emoji value 'normal'
PASS Property font-variant-emoji value 'text'
PASS Property font-variant-emoji value 'emoji'
PASS Property font-variant-emoji value 'unicode'

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

FAIL e.style['font-variant-emoji'] = "normal" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['font-variant-emoji'] = "text" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['font-variant-emoji'] = "emoji" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['font-variant-emoji'] = "unicode" should set the property value assert_not_equals: property should be set got disallowed value ""
PASS e.style['font-variant-emoji'] = "normal" should set the property value
PASS e.style['font-variant-emoji'] = "text" should set the property value
PASS e.style['font-variant-emoji'] = "emoji" should set the property value
PASS e.style['font-variant-emoji'] = "unicode" should set the property value

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

FAIL Can set 'font-variant-emoji' to CSS-wide keywords: initial Invalid property font-variant-emoji
FAIL Can set 'font-variant-emoji' to CSS-wide keywords: inherit Invalid property font-variant-emoji
FAIL Can set 'font-variant-emoji' to CSS-wide keywords: unset Invalid property font-variant-emoji
FAIL Can set 'font-variant-emoji' to CSS-wide keywords: revert Invalid property font-variant-emoji
FAIL Can set 'font-variant-emoji' to var() references: var(--A) Invalid property font-variant-emoji
FAIL Can set 'font-variant-emoji' to the 'auto' keyword: auto Invalid property font-variant-emoji
FAIL Can set 'font-variant-emoji' to the 'text' keyword: text Invalid property font-variant-emoji
FAIL Can set 'font-variant-emoji' to the 'emoji' keyword: emoji Invalid property font-variant-emoji
PASS Can set 'font-variant-emoji' to CSS-wide keywords: initial
PASS Can set 'font-variant-emoji' to CSS-wide keywords: inherit
PASS Can set 'font-variant-emoji' to CSS-wide keywords: unset
PASS Can set 'font-variant-emoji' to CSS-wide keywords: revert
PASS Can set 'font-variant-emoji' to var() references: var(--A)
PASS Can set 'font-variant-emoji' to the 'normal' keyword: normal
PASS Can set 'font-variant-emoji' to the 'text' keyword: text
PASS Can set 'font-variant-emoji' to the 'emoji' keyword: emoji
PASS Can set 'font-variant-emoji' to the 'unicode' keyword: unicode
PASS Setting 'font-variant-emoji' to a length: 0px throws TypeError
PASS Setting 'font-variant-emoji' to a length: -3.14em throws TypeError
PASS Setting 'font-variant-emoji' to a length: 3.14cm throws TypeError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
'use strict';

runPropertyTests('font-variant-emoji', [
{ syntax: 'auto' },
{ syntax: 'normal' },
{ syntax: 'text' },
{ syntax: 'emoji' },
{ syntax: 'unicode' },
]);

</script>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL The font shorthand should be serialized just like any other shorthand. assert_equals: expected "font: 10px / 1 Ahem;" but got "font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: 1; font-family: Ahem; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"
FAIL The font shorthand should be serialized just like any other shorthand. assert_equals: expected "font: 10px / 1 Ahem;" but got "font-style: normal; font-variant-caps: normal; font-weight: normal; font-stretch: normal; font-size: 10px; line-height: 1; font-family: Ahem; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"

Loading

0 comments on commit 19378f7

Please sign in to comment.