Title: [283756] trunk
Revision
283756
Author
[email protected]
Date
2021-10-07 16:37:01 -0700 (Thu, 07 Oct 2021)

Log Message

Shadowing of @font-palette-values rules doesn't work
https://bugs.webkit.org/show_bug.cgi?id=231218
<rdar://problem/83872258>

Reviewed by Wenson Hsieh.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-fonts/font-palette-32-expected.html: Added.
* web-platform-tests/css/css-fonts/font-palette-32.html: Added.

Source/WebCore:

https://drafts.csswg.org/css-fonts-4/#font-palette-values says:
> When a given descriptor occurs multiple times in a given @font-palette-values rule,
> only the last descriptor declaration is used.

Test: imported/w3c/web-platform-tests/css/css-fonts/font-palette-32.html

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::buildStarted):
(WebCore::CSSFontSelector::addFontPaletteValuesRule):
(WebCore::CSSFontSelector::lookupFontPaletteValues):
* css/CSSFontSelector.h:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (283755 => 283756)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-07 23:30:56 UTC (rev 283755)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-10-07 23:37:01 UTC (rev 283756)
@@ -1,5 +1,16 @@
 2021-10-07  Myles C. Maxfield  <[email protected]>
 
+        Shadowing of @font-palette-values rules doesn't work
+        https://bugs.webkit.org/show_bug.cgi?id=231218
+        <rdar://problem/83872258>
+
+        Reviewed by Wenson Hsieh.
+
+        * web-platform-tests/css/css-fonts/font-palette-32-expected.html: Added.
+        * web-platform-tests/css/css-fonts/font-palette-32.html: Added.
+
+2021-10-07  Myles C. Maxfield  <[email protected]>
+
         Stop parsing font palette things that we can't implement
         https://bugs.webkit.org/show_bug.cgi?id=230799
         <rdar://problem/83537772>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-32-expected.html (0 => 283756)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-32-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-32-expected.html	2021-10-07 23:37:01 UTC (rev 283756)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Tests for font-palette and @font-palette-values</title>
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<style>
+@font-face {
+    font-family: "COLR-test-font";
+    src: url("resources/COLR-palettes-test-font.ttf") format("truetype");
+}
+
+@font-palette-values --MyPalette {
+    font-family: "COLR-test-font";
+    base-palette: 2;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'COLR-test-font'; font-palette: --MyPalette">A</div>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-32.html (0 => 283756)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-32.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/font-palette-32.html	2021-10-07 23:37:01 UTC (rev 283756)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Tests for font-palette and @font-palette-values</title>
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<link rel="match" href=""
+<style>
+@font-face {
+    font-family: "COLR-test-font";
+    src: url("resources/COLR-palettes-test-font.ttf") format("truetype");
+}
+
+@font-palette-values --MyPalette {
+    font-family: "COLR-test-font";
+    base-palette: 1;
+}
+
+@font-palette-values --MyPalette {
+    font-family: "COLR-test-font";
+    base-palette: 2;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'COLR-test-font'; font-palette: --MyPalette;">A</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (283755 => 283756)


--- trunk/Source/WebCore/ChangeLog	2021-10-07 23:30:56 UTC (rev 283755)
+++ trunk/Source/WebCore/ChangeLog	2021-10-07 23:37:01 UTC (rev 283756)
@@ -1,3 +1,23 @@
+2021-10-07  Myles C. Maxfield  <[email protected]>
+
+        Shadowing of @font-palette-values rules doesn't work
+        https://bugs.webkit.org/show_bug.cgi?id=231218
+        <rdar://problem/83872258>
+
+        Reviewed by Wenson Hsieh.
+
+        https://drafts.csswg.org/css-fonts-4/#font-palette-values says:
+        > When a given descriptor occurs multiple times in a given @font-palette-values rule,
+        > only the last descriptor declaration is used.
+
+        Test: imported/w3c/web-platform-tests/css/css-fonts/font-palette-32.html
+
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::buildStarted):
+        (WebCore::CSSFontSelector::addFontPaletteValuesRule):
+        (WebCore::CSSFontSelector::lookupFontPaletteValues):
+        * css/CSSFontSelector.h:
+
 2021-10-07  Alan Bujtas  <[email protected]>
 
         Do not check for firstLineStyle while constructing RenderText

Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (283755 => 283756)


--- trunk/Source/WebCore/css/CSSFontSelector.cpp	2021-10-07 23:30:56 UTC (rev 283755)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp	2021-10-07 23:37:01 UTC (rev 283756)
@@ -136,7 +136,7 @@
             m_cssConnectionsPossiblyToRemove.add(&face);
     }
 
-    m_paletteFamilyMap.clear();
+    m_paletteMap.clear();
 }
 
 void CSSFontSelector::buildCompleted()
@@ -235,9 +235,7 @@
 {
     AtomString fontFamily = fontPaletteValuesRule.fontFamily().isNull() ? emptyAtom() : fontPaletteValuesRule.fontFamily();
     AtomString name = fontPaletteValuesRule.name().isNull() ? emptyAtom() : fontPaletteValuesRule.name();
-    m_paletteFamilyMap.ensure(std::make_pair(fontFamily, name), [&] () {
-        return fontPaletteValuesRule.fontPaletteValues();
-    });
+    m_paletteMap.set(std::make_pair(fontFamily, name), fontPaletteValuesRule.fontPaletteValues());
 
     ++m_version;
 }
@@ -325,8 +323,8 @@
 
     const AtomString paletteName = fontDescription.fontPalette().identifier;
 
-    auto iterator = m_paletteFamilyMap.find(std::make_pair(familyName, paletteName));
-    if (iterator == m_paletteFamilyMap.end())
+    auto iterator = m_paletteMap.find(std::make_pair(familyName, paletteName));
+    if (iterator == m_paletteMap.end())
         return emptyFontPaletteValues.get();
     return iterator->value;
 }

Modified: trunk/Source/WebCore/css/CSSFontSelector.h (283755 => 283756)


--- trunk/Source/WebCore/css/CSSFontSelector.h	2021-10-07 23:30:56 UTC (rev 283755)
+++ trunk/Source/WebCore/css/CSSFontSelector.h	2021-10-07 23:37:01 UTC (rev 283756)
@@ -128,7 +128,7 @@
     Ref<CSSFontFaceSet> m_cssFontFaceSet;
     HashSet<FontSelectorClient*> m_clients;
 
-    HashMap<std::pair<AtomString, AtomString>, FontPaletteValues> m_paletteFamilyMap;
+    HashMap<std::pair<AtomString, AtomString>, FontPaletteValues> m_paletteMap;
 
     HashSet<RefPtr<CSSFontFace>> m_cssConnectionsPossiblyToRemove;
     HashSet<RefPtr<StyleRuleFontFace>> m_cssConnectionsEncounteredDuringBuild;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to