Title: [282204] trunk
Revision
282204
Author
[email protected]
Date
2021-09-09 02:38:41 -0700 (Thu, 09 Sep 2021)

Log Message

FontFaceSet.has() needs to react to style changes
https://bugs.webkit.org/show_bug.cgi?id=229848

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

This test was landed upstream in https://github.com/web-platform-tests/wpt/pull/30322

* web-platform-tests/css/css-font-loading/fontfaceset-has-expected.txt: Added.
* web-platform-tests/css/css-font-loading/fontfaceset-has.html: Added.

Source/WebCore:

When content says "document.fonts.has(...)", the ".has(...)" part needs to
update style instead of the "document.fonts" part. This is because it's
totally legal for content to say:

var f = document.fonts;
// Modify style here
... f.has(...) ... <=== This needs to reflect the style changes.

Test: imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has.html

* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::has const):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (282203 => 282204)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-09 09:19:28 UTC (rev 282203)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-09 09:38:41 UTC (rev 282204)
@@ -1,3 +1,15 @@
+2021-09-09  Myles C. Maxfield  <[email protected]>
+
+        FontFaceSet.has() needs to react to style changes
+        https://bugs.webkit.org/show_bug.cgi?id=229848
+
+        Reviewed by Antti Koivisto.
+
+        This test was landed upstream in https://github.com/web-platform-tests/wpt/pull/30322
+
+        * web-platform-tests/css/css-font-loading/fontfaceset-has-expected.txt: Added.
+        * web-platform-tests/css/css-font-loading/fontfaceset-has.html: Added.
+
 2021-09-09  Cameron McCormack  <[email protected]>
 
         Update WPT tests under /html/canvas/element

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has-expected.txt (0 => 282204)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has-expected.txt	2021-09-09 09:38:41 UTC (rev 282204)
@@ -0,0 +1,3 @@
+
+PASS fontfaceset-has
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has.html (0 => 282204)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has.html	2021-09-09 09:38:41 UTC (rev 282204)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head id="head">
+<meta charset="utf-8">
+<link rel="author" title="Myles C. Maxfield" href=""
+<link rel="help" href=""
+<meta name="assert" content="Ensure that calling FontFaceSet.has() works properly." />
+<script src=""
+<script src=""
+<style id="style">
+@font-face {
+    font-family: "WebFont";
+    src: url("resources/Rochester.otf") format("opentype");
+}
+</style>
+</head>
+<body>
+<script>
+test(function(t) {
+    let fonts = document.fonts;
+    let font = fonts.keys().next().value;
+    let font2 = new FontFace("WebFont2", "url('resources/GenR102.woff2') format('woff2')");
+    assert_true(fonts.has(font));
+    assert_false(fonts.has(font2));
+    fonts.add(font2);
+    assert_true(fonts.has(font));
+    assert_true(fonts.has(font2));
+    document.getElementById("head").removeChild(document.getElementById("style"));
+    assert_false(fonts.has(font));
+    assert_true(fonts.has(font2));
+    fonts.delete(font2);
+    assert_false(fonts.has(font));
+    assert_false(fonts.has(font2));
+});
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (282203 => 282204)


--- trunk/Source/WebCore/ChangeLog	2021-09-09 09:19:28 UTC (rev 282203)
+++ trunk/Source/WebCore/ChangeLog	2021-09-09 09:38:41 UTC (rev 282204)
@@ -1,3 +1,23 @@
+2021-09-09  Myles C. Maxfield  <[email protected]>
+
+        FontFaceSet.has() needs to react to style changes
+        https://bugs.webkit.org/show_bug.cgi?id=229848
+
+        Reviewed by Antti Koivisto.
+
+        When content says "document.fonts.has(...)", the ".has(...)" part needs to
+        update style instead of the "document.fonts" part. This is because it's
+        totally legal for content to say:
+
+        var f = document.fonts;
+        // Modify style here
+        ... f.has(...) ... <=== This needs to reflect the style changes.
+
+        Test: imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-has.html
+
+        * css/FontFaceSet.cpp:
+        (WebCore::FontFaceSet::has const):
+
 2021-09-09  Antti Koivisto  <[email protected]>
 
         RenderInline offsetTop/Left should not switch to legacy layout

Modified: trunk/Source/WebCore/css/FontFaceSet.cpp (282203 => 282204)


--- trunk/Source/WebCore/css/FontFaceSet.cpp	2021-09-09 09:19:28 UTC (rev 282203)
+++ trunk/Source/WebCore/css/FontFaceSet.cpp	2021-09-09 09:38:41 UTC (rev 282204)
@@ -107,6 +107,8 @@
 
 bool FontFaceSet::has(FontFace& face) const
 {
+    if (face.backing().cssConnection())
+        m_backing->updateStyleIfNeeded();
     return m_backing->hasFace(face.backing());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to