Changeset 283398 in webkit
- Timestamp:
- Oct 1, 2021 2:00:49 PM (10 months ago)
- Location:
- trunk
- Files:
-
- 60 added
- 12 edited
- 1 copied
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-10-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-10.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-11-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-11.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-12-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-12.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-13-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-13.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-14-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-14.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-15-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-15.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-16-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-16.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-17-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-17.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-18-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-18.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-19-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-19.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-2-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-2.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-20-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-20.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-21-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-21.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-22-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-22.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-23-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-23.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-24-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-24.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-25-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-25.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-26-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-26.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-27-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-27.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-28-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-28.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-29-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-29.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-3-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-3.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-30-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-30.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-31-expected.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-31.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-4-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-4.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-5-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-5.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-6-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-6.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-7-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-7.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-8-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-8.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-9-expected-mismatch.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-9.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-expected.html (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette.html (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/resources/Ahem-COLR-palettes-no-light-dark.ttf (copied) (copied from trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/resources/Ahem-COLR-palettes.ttf)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/resources/Ahem-COLR-palettes.ttf (modified) (previous)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSFontPaletteValuesRule.cpp (modified) (2 diffs)
-
Source/WebCore/css/StyleRule.cpp (modified) (1 diff)
-
Source/WebCore/css/StyleRule.h (modified) (3 diffs)
-
Source/WebCore/css/parser/CSSParserImpl.cpp (modified) (1 diff)
-
Source/WebCore/css/parser/CSSPropertyParser.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/FontPaletteValues.h (modified) (5 diffs)
-
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r283397 r283398 1 2021-10-01 Myles C. Maxfield <mmaxfield@apple.com> 2 3 base-palette can accept "light" or "dark" 4 https://bugs.webkit.org/show_bug.cgi?id=230792 5 <rdar://problem/83530228> 6 7 Reviewed by Simon Fraser. 8 9 These are being upstreamed at https://github.com/web-platform-tests/wpt/pull/31044. 10 11 * web-platform-tests/css/css-fonts/font-palette-10-expected.html: Added. 12 * web-platform-tests/css/css-fonts/font-palette-10.html: Added. 13 * web-platform-tests/css/css-fonts/font-palette-11-expected.html: Added. 14 * web-platform-tests/css/css-fonts/font-palette-11.html: Added. 15 * web-platform-tests/css/css-fonts/font-palette-12-expected.html: Added. 16 * web-platform-tests/css/css-fonts/font-palette-12.html: Added. 17 * web-platform-tests/css/css-fonts/font-palette-13-expected-mismatch.html: Added. 18 * web-platform-tests/css/css-fonts/font-palette-13.html: Added. 19 * web-platform-tests/css/css-fonts/font-palette-14-expected.html: Added. 20 * web-platform-tests/css/css-fonts/font-palette-14.html: Added. 21 * web-platform-tests/css/css-fonts/font-palette-15-expected.html: Added. 22 * web-platform-tests/css/css-fonts/font-palette-15.html: Added. 23 * web-platform-tests/css/css-fonts/font-palette-16-expected-mismatch.html: Added. 24 * web-platform-tests/css/css-fonts/font-palette-16.html: Added. 25 * web-platform-tests/css/css-fonts/font-palette-17-expected-mismatch.html: Added. 26 * web-platform-tests/css/css-fonts/font-palette-17.html: Added. 27 * web-platform-tests/css/css-fonts/font-palette-18-expected-mismatch.html: Added. 28 * web-platform-tests/css/css-fonts/font-palette-18.html: Added. 29 * web-platform-tests/css/css-fonts/font-palette-19-expected-mismatch.html: Added. 30 * web-platform-tests/css/css-fonts/font-palette-19.html: Added. 31 * web-platform-tests/css/css-fonts/font-palette-2-expected.html: Added. 32 * web-platform-tests/css/css-fonts/font-palette-2.html: Added. 33 * web-platform-tests/css/css-fonts/font-palette-20-expected.html: Added. 34 * web-platform-tests/css/css-fonts/font-palette-20.html: Added. 35 * web-platform-tests/css/css-fonts/font-palette-21-expected.html: Added. 36 * web-platform-tests/css/css-fonts/font-palette-21.html: Added. 37 * web-platform-tests/css/css-fonts/font-palette-22-expected-mismatch.html: Added. 38 * web-platform-tests/css/css-fonts/font-palette-22.html: Added. 39 * web-platform-tests/css/css-fonts/font-palette-23-expected.html: Added. 40 * web-platform-tests/css/css-fonts/font-palette-23.html: Added. 41 * web-platform-tests/css/css-fonts/font-palette-24-expected.html: Added. 42 * web-platform-tests/css/css-fonts/font-palette-24.html: Added. 43 * web-platform-tests/css/css-fonts/font-palette-25-expected.html: Added. 44 * web-platform-tests/css/css-fonts/font-palette-25.html: Added. 45 * web-platform-tests/css/css-fonts/font-palette-26-expected.html: Added. 46 * web-platform-tests/css/css-fonts/font-palette-26.html: Added. 47 * web-platform-tests/css/css-fonts/font-palette-27-expected.html: Added. 48 * web-platform-tests/css/css-fonts/font-palette-27.html: Added. 49 * web-platform-tests/css/css-fonts/font-palette-28-expected.html: Added. 50 * web-platform-tests/css/css-fonts/font-palette-28.html: Added. 51 * web-platform-tests/css/css-fonts/font-palette-29-expected.html: Added. 52 * web-platform-tests/css/css-fonts/font-palette-29.html: Added. 53 * web-platform-tests/css/css-fonts/font-palette-3-expected-mismatch.html: Added. 54 * web-platform-tests/css/css-fonts/font-palette-3.html: Added. 55 * web-platform-tests/css/css-fonts/font-palette-30-expected.html: Added. 56 * web-platform-tests/css/css-fonts/font-palette-30.html: Added. 57 * web-platform-tests/css/css-fonts/font-palette-31-expected.html: Added. 58 * web-platform-tests/css/css-fonts/font-palette-31.html: Added. 59 * web-platform-tests/css/css-fonts/font-palette-4-expected-mismatch.html: Added. 60 * web-platform-tests/css/css-fonts/font-palette-4.html: Added. 61 * web-platform-tests/css/css-fonts/font-palette-5-expected-mismatch.html: Added. 62 * web-platform-tests/css/css-fonts/font-palette-5.html: Added. 63 * web-platform-tests/css/css-fonts/font-palette-6-expected-mismatch.html: Added. 64 * web-platform-tests/css/css-fonts/font-palette-6.html: Added. 65 * web-platform-tests/css/css-fonts/font-palette-7-expected-mismatch.html: Added. 66 * web-platform-tests/css/css-fonts/font-palette-7.html: Added. 67 * web-platform-tests/css/css-fonts/font-palette-8-expected-mismatch.html: Added. 68 * web-platform-tests/css/css-fonts/font-palette-8.html: Added. 69 * web-platform-tests/css/css-fonts/font-palette-9-expected-mismatch.html: Added. 70 * web-platform-tests/css/css-fonts/font-palette-9.html: Added. 71 * web-platform-tests/css/css-fonts/font-palette-expected.html: 72 * web-platform-tests/css/css-fonts/font-palette.html: 73 * web-platform-tests/css/css-fonts/resources/Ahem-COLR-palettes-no-light-dark.ttf: Copied from LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/resources/Ahem-COLR-palettes.ttf. 74 * web-platform-tests/css/css-fonts/resources/Ahem-COLR-palettes.ttf: 75 1 76 2021-10-01 Chris Dumez <cdumez@apple.com> 2 77 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-expected.html
r282922 r283398 1 1 <!DOCTYPE html> 2 <html lang="en">2 <html> 3 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 5 <title>CSS Test: font-palette drawing</title> 6 <link rel="author" title="Myles C. Maxfield" href="mmaxfield@apple.com"> 7 <link rel="match" href="font-palette-ref.html"> 8 <link rel="help" href="https://drafts.csswg.org/css-fonts-4/#font-palette-prop"> 9 <meta name="assert" content="Font palettes are applied as necessary"> 4 <meta charset="utf-8"> 5 <title>Tests for font-palette and @font-palette-values</title> 6 <link rel="help" href="https://drafts.csswg.org/css-fonts/#font-palette-prop"> 7 <link rel="help" href="https://drafts.csswg.org/css-fonts-4/#font-palette-values"> 8 <link rel="author" title="Myles C. Maxfield" href="mailto:mmaxfield@apple.com"> 9 <style> 10 @font-face { 11 font-family: "Ahem-COLR"; 12 src: url("resources/Ahem-COLR-palettes.ttf") format("truetype"); 13 } 14 15 @font-palette-values --MyPalette { 16 font-family: "Ahem-COLR"; 17 base-palette: 2; 18 } 19 </style> 10 20 </head> 11 21 <body> 12 <p>Test passes if you see particular rectangles of particular colors.</p> 13 <div style="position: relative;"> 14 <div style="position: absolute; left: 0px; top: 0px; width: 100px; height: 100px; background: #FF00FF;"> 15 <div style="position: absolute; left: 20px; top: 0px; width: 20px; height: 100px; background: #00FFFF;"></div> 16 </div> 17 <div style="position: absolute; left: 100px; top: 0px; width: 100px; height: 100px; background: #0000FF;"> 18 <div style="position: absolute; left: 20px; top: 0px; width: 20px; height: 100px; background: #00FF00;"></div> 19 </div> 20 <div style="position: absolute; left: 200px; top: 0px; width: 100px; height: 100px; background: #0000FF;"> 21 <div style="position: absolute; left: 20px; top: 0px; width: 20px; height: 100px; background: #FFFF00;"></div> 22 </div> 23 <div style="position: absolute; left: 300px; top: 0px; width: 100px; height: 100px; background: #00FF00;"> 24 <div style="position: absolute; left: 20px; top: 0px; width: 20px; height: 100px; background: #000000;"></div> 25 </div> 26 <div style="position: absolute; left: 400px; top: 0px; width: 100px; height: 100px; background: #00FF00;"> 27 <div style="position: absolute; left: 20px; top: 0px; width: 20px; height: 100px; background: #000000;"></div> 28 </div> 29 </div> 22 <div id="target" style="font: 48px 'Ahem-COLR'; font-palette: --MyPalette;">A</div> 30 23 </body> 31 24 </html> -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette.html
r283221 r283398 1 1 <!DOCTYPE html> 2 <html lang="en">2 <html> 3 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 5 <title>CSS Test: font-palette drawing</title> 6 <link rel="author" title="Myles C. Maxfield" href="mmaxfield@apple.com"> 4 <meta charset="utf-8"> 5 <title>Tests for font-palette and @font-palette-values</title> 6 <link rel="help" href="https://drafts.csswg.org/css-fonts/#font-palette-prop"> 7 <link rel="help" href="https://drafts.csswg.org/css-fonts-4/#font-palette-values"> 8 <link rel="author" title="Myles C. Maxfield" href="mailto:mmaxfield@apple.com"> 7 9 <link rel="match" href="font-palette-ref.html"> 8 <link rel="help" href="https://drafts.csswg.org/css-fonts-4/#font-palette-prop">9 <meta name="assert" content="Font palettes are applied as necessary">10 10 <style> 11 11 @font-face { 12 font-family: " WebFont";12 font-family: "Ahem-COLR"; 13 13 src: url("resources/Ahem-COLR-palettes.ttf") format("truetype"); 14 }15 16 @font-palette-values --Palette1 {17 font-family: "WebFont";18 base-palette: 0;19 }20 21 @font-palette-values --Palette2 {22 font-family: "WebFont";23 base-palette: 1;24 }25 26 @font-palette-values --Palette3 {27 font-family: "WebFont";28 base-palette: 1;29 override-colors: 1 #FFFF00;30 }31 32 @font-palette-values --Palette4 {33 font-family: "WebFont";34 base-palette: 1;35 override-colors: 0 #00FF00, 1 #000000;36 }37 38 @font-palette-values --Palette5 {39 font-family: "WebFont";40 base-palette: 1;41 override-colors: 1 #000000, 0 #00FF00;42 14 } 43 15 </style> 44 16 </head> 45 17 <body> 46 <p>Test passes if you see particular rectangles of particular colors.</p> 47 <div style="display: inline-block; font: 100px 'WebFont'; font-palette: --Palette1;">A</div><div style="display: inline-block; font: 100px 'WebFont'; font-palette: --Palette2;">A</div><div style="display: inline-block; font: 100px 'WebFont'; font-palette: --Palette3;">A</div><div style="display: inline-block; font: 100px 'WebFont'; font-palette: --Palette4;">A</div><div style="display: inline-block; font: 100px 'WebFont'; font-palette: --Palette5;">A</div> 18 <div id="target" style="font: 48px 'Ahem-COLR'; font-palette: light;">A</div> 48 19 </body> 49 20 </html> -
trunk/Source/WebCore/ChangeLog
r283397 r283398 1 2021-10-01 Myles C. Maxfield <mmaxfield@apple.com> 2 3 base-palette can accept "light" or "dark" 4 https://bugs.webkit.org/show_bug.cgi?id=230792 5 <rdar://problem/83530228> 6 7 Reviewed by Simon Fraser. 8 9 The spec was changed in 10 https://github.com/w3c/csswg-drafts/commit/1c74611151b452930609627a0de2412c0cb86175 11 to add this functionality. Luckily, the additional functionality doesn't 12 require any Core Text change. 13 14 The old grammar was "<<integer [0, ∞]>> | <<string>>". The new grammar is 15 "light | dark | <<integer [0, ∞]>> | <<string>>". Before "light" and 16 "dark" existed, we were representing this by Variant<int64_t, AtomString>. Now that 17 "light" and "dark" exist, this is being expanded so the form 18 19 struct FontPaletteIndex { 20 enum class Type { 21 Light, 22 Dark, 23 Integer, 24 String 25 } type; 26 unsigned integer; 27 AtomString string; 28 }; 29 30 This seems to be in accordance with WebKit style, instead of doing something like 31 class FontPaletteLight { }; class FontPaletteDark { }; 32 using FontPaletteIndex = Variant<FontPaletteLight, FontPaletteDark, unsigned, AtomString>; 33 34 Tests: imported/w3c/web-platform-tests/css/css-fonts/font-palette-10.html 35 imported/w3c/web-platform-tests/css/css-fonts/font-palette-11.html 36 imported/w3c/web-platform-tests/css/css-fonts/font-palette-12.html 37 imported/w3c/web-platform-tests/css/css-fonts/font-palette-13.html 38 imported/w3c/web-platform-tests/css/css-fonts/font-palette-14.html 39 imported/w3c/web-platform-tests/css/css-fonts/font-palette-15.html 40 imported/w3c/web-platform-tests/css/css-fonts/font-palette-16.html 41 imported/w3c/web-platform-tests/css/css-fonts/font-palette-17.html 42 imported/w3c/web-platform-tests/css/css-fonts/font-palette-18.html 43 imported/w3c/web-platform-tests/css/css-fonts/font-palette-19.html 44 imported/w3c/web-platform-tests/css/css-fonts/font-palette-2.html 45 imported/w3c/web-platform-tests/css/css-fonts/font-palette-20.html 46 imported/w3c/web-platform-tests/css/css-fonts/font-palette-21.html 47 imported/w3c/web-platform-tests/css/css-fonts/font-palette-22.html 48 imported/w3c/web-platform-tests/css/css-fonts/font-palette-23.html 49 imported/w3c/web-platform-tests/css/css-fonts/font-palette-24.html 50 imported/w3c/web-platform-tests/css/css-fonts/font-palette-25.html 51 imported/w3c/web-platform-tests/css/css-fonts/font-palette-26.html 52 imported/w3c/web-platform-tests/css/css-fonts/font-palette-27.html 53 imported/w3c/web-platform-tests/css/css-fonts/font-palette-28.html 54 imported/w3c/web-platform-tests/css/css-fonts/font-palette-29.html 55 imported/w3c/web-platform-tests/css/css-fonts/font-palette-3.html 56 imported/w3c/web-platform-tests/css/css-fonts/font-palette-30.html 57 imported/w3c/web-platform-tests/css/css-fonts/font-palette-31.html 58 imported/w3c/web-platform-tests/css/css-fonts/font-palette-4.html 59 imported/w3c/web-platform-tests/css/css-fonts/font-palette-5.html 60 imported/w3c/web-platform-tests/css/css-fonts/font-palette-6.html 61 imported/w3c/web-platform-tests/css/css-fonts/font-palette-7.html 62 imported/w3c/web-platform-tests/css/css-fonts/font-palette-8.html 63 imported/w3c/web-platform-tests/css/css-fonts/font-palette-9.html 64 65 * css/CSSFontPaletteValuesRule.cpp: 66 (WebCore::CSSFontPaletteValuesRule::basePalette const): 67 (WebCore::CSSFontPaletteValuesRule::cssText const): 68 * css/StyleRule.cpp: 69 (WebCore::StyleRuleFontPaletteValues::StyleRuleFontPaletteValues): 70 * css/StyleRule.h: 71 * css/parser/CSSParserImpl.cpp: 72 (WebCore::CSSParserImpl::consumeFontPaletteValuesRule): 73 * css/parser/CSSPropertyParser.cpp: 74 (WebCore::consumeBasePaletteDescriptor): 75 * platform/graphics/FontPaletteValues.h: 76 (WebCore::FontPaletteIndex::FontPaletteIndex): 77 (WebCore::FontPaletteIndex::operator bool const): 78 (WebCore::FontPaletteIndex::operator== const): 79 (WebCore::FontPaletteIndex::operator!= const): 80 (WebCore::add): 81 (WebCore::FontPaletteValues::FontPaletteValues): 82 (WebCore::FontPaletteValues::basePalette const): 83 (WebCore::FontPaletteValues::operator bool const): 84 * platform/graphics/cocoa/FontCacheCoreText.cpp: 85 (WebCore::addLightPalette): 86 (WebCore::addDarkPalette): 87 (WebCore::addAttributesForCustomFontPalettes): 88 (WebCore::addAttributesForFontPalettes): 89 1 90 2021-10-01 Chris Dumez <cdumez@apple.com> 2 91 -
trunk/Source/WebCore/css/CSSFontPaletteValuesRule.cpp
r283219 r283398 59 59 String CSSFontPaletteValuesRule::basePalette() const 60 60 { 61 return WTF::switchOn(m_fontPaletteValuesRule->basePalette(), [&] (unsigned index) { 62 return makeString(index); 63 }, [&] (const AtomString& basePalette) -> String { 64 if (!basePalette.isNull()) 65 return basePalette.string(); 61 switch (m_fontPaletteValuesRule->basePalette().type) { 62 case FontPaletteIndex::Type::Light: 63 return "light"_s; 64 case FontPaletteIndex::Type::Dark: 65 return "dark"_s; 66 case FontPaletteIndex::Type::Integer: 67 return makeString(m_fontPaletteValuesRule->basePalette().integer); 68 case FontPaletteIndex::Type::String: 69 if (!m_fontPaletteValuesRule->basePalette().string.isNull()) 70 return m_fontPaletteValuesRule->basePalette().string; 66 71 return StringImpl::empty(); 67 } );72 } 68 73 } 69 74 … … 91 96 if (!m_fontPaletteValuesRule->fontFamily().isNull()) 92 97 builder.append("font-family: ", m_fontPaletteValuesRule->fontFamily(), "; "); 93 WTF::switchOn(m_fontPaletteValuesRule->basePalette(), [&] (unsigned index) { 94 builder.append("base-palette: ", index, "; "); 95 }, [&] (const AtomString& basePalette) { 96 if (!basePalette.isNull()) 97 builder.append("base-palette: ", serializeString(basePalette.string()), "; "); 98 }); 98 99 switch (m_fontPaletteValuesRule->basePalette().type) { 100 case FontPaletteIndex::Type::Light: 101 builder.append("base-palette: light; "); 102 break; 103 case FontPaletteIndex::Type::Dark: 104 builder.append("base-palette: dark; "); 105 break; 106 case FontPaletteIndex::Type::Integer: 107 builder.append("base-palette: ", m_fontPaletteValuesRule->basePalette().integer, "; "); 108 break; 109 case FontPaletteIndex::Type::String: 110 if (!m_fontPaletteValuesRule->basePalette().string.isNull()) 111 builder.append("base-palette: ", serializeString(m_fontPaletteValuesRule->basePalette().string), "; "); 112 break; 113 } 114 99 115 if (!m_fontPaletteValuesRule->overrideColors().isEmpty()) { 100 116 builder.append("override-colors:"); -
trunk/Source/WebCore/css/StyleRule.cpp
r283170 r283398 331 331 } 332 332 333 StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPalette Values::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColors)333 StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColors) 334 334 : StyleRuleBase(StyleRuleType::FontPaletteValues) 335 335 , m_name(name) -
trunk/Source/WebCore/css/StyleRule.h
r283159 r283398 160 160 class StyleRuleFontPaletteValues final : public StyleRuleBase { 161 161 public: 162 static Ref<StyleRuleFontPaletteValues> create(const AtomString& name, const AtomString& fontFamily, const FontPaletteValues::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColors) { return adoptRef(*new StyleRuleFontPaletteValues(name, fontFamily, basePalette, WTFMove(overrideColors))); } 162 static Ref<StyleRuleFontPaletteValues> create(const AtomString& name, const AtomString& fontFamily, const FontPaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColors) 163 { 164 return adoptRef(*new StyleRuleFontPaletteValues(name, fontFamily, basePalette, WTFMove(overrideColors))); 165 } 163 166 164 167 ~StyleRuleFontPaletteValues(); … … 179 182 } 180 183 181 const FontPalette Values::PaletteIndex& basePalette() const184 const FontPaletteIndex& basePalette() const 182 185 { 183 186 return m_fontPaletteValues.basePalette(); … … 192 195 193 196 private: 194 StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPalette Values::PaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColors);197 StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, const FontPaletteIndex& basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColors); 195 198 StyleRuleFontPaletteValues(const StyleRuleFontPaletteValues&); 196 199 -
trunk/Source/WebCore/css/parser/CSSParserImpl.cpp
r283221 r283398 681 681 fontFamily = downcast<CSSPrimitiveValue>(*fontFamilyValue).fontFamily().familyName; 682 682 683 FontPalette Values::PaletteIndex basePalette(nullAtom());683 FontPaletteIndex basePalette; 684 684 if (auto basePaletteValue = properties->getPropertyCSSValue(CSSPropertyBasePalette)) { 685 685 const auto& primitiveValue = downcast<CSSPrimitiveValue>(*basePaletteValue); 686 686 if (primitiveValue.isString()) 687 basePalette = primitiveValue.stringValue();687 basePalette = FontPaletteIndex(primitiveValue.stringValue()); 688 688 else if (primitiveValue.isNumber()) 689 basePalette = primitiveValue.value<unsigned>(); 689 basePalette = FontPaletteIndex(primitiveValue.value<int64_t>()); 690 else if (primitiveValue.valueID() == CSSValueLight) 691 basePalette = FontPaletteIndex(FontPaletteIndex::Type::Light); 692 else if (primitiveValue.valueID() == CSSValueDark) 693 basePalette = FontPaletteIndex(FontPaletteIndex::Type::Dark); 690 694 } 691 695 -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r283237 r283398 4849 4849 static RefPtr<CSSPrimitiveValue> consumeBasePaletteDescriptor(CSSParserTokenRange& range) 4850 4850 { 4851 if (range.peek().type() == StringToken) 4852 return consumeString(range); 4851 if (auto result = consumeIdent<CSSValueLight, CSSValueDark>(range)) 4852 return result; 4853 if (auto result = consumeString(range)) 4854 return result; 4853 4855 return consumeInteger(range, 0); 4854 4856 } -
trunk/Source/WebCore/platform/graphics/FontPaletteValues.h
r283210 r283398 35 35 namespace WebCore { 36 36 37 struct FontPaletteIndex { 38 enum class Type : uint8_t; 39 40 FontPaletteIndex() = default; 41 42 FontPaletteIndex(Type type) 43 : type(type) 44 { 45 ASSERT(type == Type::Light || type == Type::Dark); 46 } 47 48 FontPaletteIndex(unsigned integer) 49 : type(Type::Integer) 50 , integer(integer) 51 { 52 } 53 54 FontPaletteIndex(const AtomString& string) 55 : type(Type::String) 56 , string(string) 57 { 58 } 59 60 operator bool() const 61 { 62 return type != Type::String || !string.isNull(); 63 } 64 65 bool operator==(const FontPaletteIndex& other) const 66 { 67 if (type != other.type) 68 return false; 69 if (type == Type::Integer) 70 return integer == other.integer; 71 if (type == Type::String) 72 return string == other.string; 73 return true; 74 } 75 76 bool operator!=(const FontPaletteIndex& other) const 77 { 78 return !(*this == other); 79 } 80 81 enum class Type : uint8_t { 82 Light, 83 Dark, 84 Integer, 85 String 86 } type { Type::String }; 87 88 unsigned integer { 0 }; 89 AtomString string; 90 }; 91 92 inline void add(Hasher& hasher, const FontPaletteIndex& paletteIndex) 93 { 94 add(hasher, paletteIndex.type); 95 if (paletteIndex.type == FontPaletteIndex::Type::Integer) 96 add(hasher, paletteIndex.integer); 97 else if (paletteIndex.type == FontPaletteIndex::Type::String) 98 add(hasher, paletteIndex.string); 99 } 100 37 101 class FontPaletteValues { 38 102 public: 39 using PaletteIndex = Variant<unsigned, AtomString>;40 103 using PaletteColorIndex = Variant<AtomString, unsigned>; 41 104 using OverriddenColor = std::pair<PaletteColorIndex, Color>; … … 43 106 FontPaletteValues() = default; 44 107 45 FontPaletteValues(const PaletteIndex& basePalette, Vector<OverriddenColor>&& overrideColors)108 FontPaletteValues(const FontPaletteIndex& basePalette, Vector<OverriddenColor>&& overrideColors) 46 109 : m_basePalette(basePalette) 47 110 , m_overrideColors(WTFMove(overrideColors)) … … 49 112 } 50 113 51 const PaletteIndex& basePalette() const114 const FontPaletteIndex& basePalette() const 52 115 { 53 116 return m_basePalette; … … 61 124 operator bool() const 62 125 { 63 return WTF::switchOn(m_basePalette, [] (int64_t) { 64 return true; 65 }, [] (const AtomString& string) { 66 return !string.isNull(); 67 }) || !m_overrideColors.isEmpty(); 126 return m_basePalette || !m_overrideColors.isEmpty(); 68 127 } 69 128 … … 79 138 80 139 private: 81 PaletteIndex m_basePalette;140 FontPaletteIndex m_basePalette; 82 141 Vector<OverriddenColor> m_overrideColors; 83 142 }; -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r283210 r283398 444 444 }; 445 445 446 static void addLightPalette(CFMutableDictionaryRef attributes) 447 { 448 CFIndex light = kCTFontPaletteLight; 449 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &light)); 450 CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get()); 451 } 452 453 static void addDarkPalette(CFMutableDictionaryRef attributes) 454 { 455 CFIndex dark = kCTFontPaletteDark; 456 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &dark)); 457 CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get()); 458 } 459 460 static void addAttributesForCustomFontPalettes(CFMutableDictionaryRef attributes, const FontPaletteIndex& basePalette, const Vector<FontPaletteValues::OverriddenColor>& overrideColors) 461 { 462 switch (basePalette.type) { 463 case FontPaletteIndex::Type::Light: 464 addLightPalette(attributes); 465 break; 466 case FontPaletteIndex::Type::Dark: 467 addDarkPalette(attributes); 468 break; 469 case FontPaletteIndex::Type::Integer: { 470 int64_t rawIndex = basePalette.integer; // There is no kCFNumberUIntType. 471 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &rawIndex)); 472 CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get()); 473 break; 474 } 475 case FontPaletteIndex::Type::String: 476 // This is unimplementable in Core Text. 477 break; 478 } 479 480 if (!overrideColors.isEmpty()) { 481 auto overrideDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 482 for (const auto& pair : overrideColors) { 483 const auto& paletteColorIndex = pair.first; 484 const auto& color = pair.second; 485 WTF::switchOn(paletteColorIndex, [] (const AtomString&) { 486 // This is unimplementable in Core Text. 487 }, [&] (unsigned index) { 488 int64_t rawIndex = index; // There is no kCFNumberUIntType. 489 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &rawIndex)); 490 auto colorObject = cachedCGColor(color); 491 CFDictionaryAddValue(overrideDictionary.get(), number.get(), colorObject); 492 }); 493 } 494 if (CFDictionaryGetCount(overrideDictionary.get())) 495 CFDictionaryAddValue(attributes, kCTFontPaletteColorsAttribute, overrideDictionary.get()); 496 } 497 } 498 446 499 static void addAttributesForFontPalettes(CFMutableDictionaryRef attributes, const FontPalette& fontPalette, const FontPaletteValues* fontPaletteValues) 447 500 { … … 452 505 case FontPalette::Type::Normal: 453 506 break; 454 case FontPalette::Type::Light: { 455 CFIndex light = kCTFontPaletteLight; 456 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &light)); 457 CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get()); 458 break; 459 } 460 case FontPalette::Type::Dark: { 461 CFIndex dark = kCTFontPaletteDark; 462 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCFIndexType, &dark)); 463 CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get()); 464 break; 465 } 507 case FontPalette::Type::Light: 508 addLightPalette(attributes); 509 break; 510 case FontPalette::Type::Dark: 511 addDarkPalette(attributes); 512 break; 466 513 case FontPalette::Type::Custom: { 467 if (!fontPaletteValues) 468 break; 469 WTF::switchOn(fontPaletteValues->basePalette(), [&](int64_t index) { 470 int64_t rawIndex = index; // There is no kCFNumberUIntType. 471 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &rawIndex)); 472 CFDictionaryAddValue(attributes, kCTFontPaletteAttribute, number.get()); 473 }, [](const AtomString&) { 474 // This is unimplementable in Core Text. 475 }); 476 477 if (!fontPaletteValues->overrideColors().isEmpty()) { 478 auto overrideDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 479 for (const auto& pair : fontPaletteValues->overrideColors()) { 480 const auto& paletteColorIndex = pair.first; 481 const auto& color = pair.second; 482 WTF::switchOn(paletteColorIndex, [](const AtomString&) { 483 // This is unimplementable in Core Text. 484 }, [&](unsigned index) { 485 int64_t rawIndex = index; // There is no kCFNumberUIntType. 486 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &rawIndex)); 487 auto colorObject = cachedCGColor(color); 488 CFDictionaryAddValue(overrideDictionary.get(), number.get(), colorObject); 489 }); 490 } 491 if (CFDictionaryGetCount(overrideDictionary.get())) 492 CFDictionaryAddValue(attributes, kCTFontPaletteColorsAttribute, overrideDictionary.get()); 493 } 514 if (fontPaletteValues) 515 addAttributesForCustomFontPalettes(attributes, fontPaletteValues->basePalette(), fontPaletteValues->overrideColors()); 516 break; 494 517 } 495 518 }
Note: See TracChangeset
for help on using the changeset viewer.