Remove fonts from CSSFontFaceSet safely
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2018 13:48:52 +0000 (13:48 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2018 13:48:52 +0000 (13:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191676

Reviewed by Zalan Bujtas.

Source/WebCore:

Test: fast/text/font-face-set-remove-safely.html

* css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::remove):

LayoutTests:

* fast/text/font-face-set-remove-safely-expected.txt: Added.
* fast/text/font-face-set-remove-safely.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238222 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/font-face-set-remove-safely-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/font-face-set-remove-safely.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontFaceSet.cpp

index f89dae3..2db2ad6 100644 (file)
@@ -1,3 +1,13 @@
+2018-11-15  Antti Koivisto  <antti@apple.com>
+
+        Remove fonts from CSSFontFaceSet safely
+        https://bugs.webkit.org/show_bug.cgi?id=191676
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/text/font-face-set-remove-safely-expected.txt: Added.
+        * fast/text/font-face-set-remove-safely.html: Added.
+
 2018-11-14  Timothy Hatcher  <timothy@apple.com>
 
         Default the view background color and text color to different values when in dark mode.
diff --git a/LayoutTests/fast/text/font-face-set-remove-safely-expected.txt b/LayoutTests/fast/text/font-face-set-remove-safely-expected.txt
new file mode 100644 (file)
index 0000000..6cc3045
--- /dev/null
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: line 6: Retrieving fonts...
+CONSOLE MESSAGE: line 8: Clearing...
+CONSOLE MESSAGE: line 10: Done.
+
diff --git a/LayoutTests/fast/text/font-face-set-remove-safely.html b/LayoutTests/fast/text/font-face-set-remove-safely.html
new file mode 100644 (file)
index 0000000..b4e79dc
--- /dev/null
@@ -0,0 +1,20 @@
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function test() {
+   console.log("Retrieving fonts...");
+   var fonts = document.fonts;
+   console.log("Clearing...");
+   fonts.clear();
+   console.log("Done.");
+}
+
+</script>
+<body onload=test()>
+
+<svg>
+
+<font>
+
+<font-face font-family="Palatino, Menlo, Verdana, serif, monospace">
index 2305303..29c1e1f 100644 (file)
@@ -1,3 +1,15 @@
+2018-11-15  Antti Koivisto  <antti@apple.com>
+
+        Remove fonts from CSSFontFaceSet safely
+        https://bugs.webkit.org/show_bug.cgi?id=191676
+
+        Reviewed by Zalan Bujtas.
+
+        Test: fast/text/font-face-set-remove-safely.html
+
+        * css/CSSFontFaceSet.cpp:
+        (WebCore::CSSFontFaceSet::remove):
+
 2018-11-15  Manuel Rego Casasnovas  <rego@igalia.com>
 
         [css-grid] Consider scrollbars in populateGridPositionsForDirection()
index e1c831e..5a71458 100644 (file)
@@ -230,6 +230,8 @@ void CSSFontFaceSet::removeFromFacesLookupTable(const CSSFontFace& face, const C
 
 void CSSFontFaceSet::remove(const CSSFontFace& face)
 {
+    auto protect = makeRef(face);
+
     m_cache.clear();
 
     for (auto* client : m_clients)