<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[197804] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/197804">197804</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-03-08 14:22:40 -0800 (Tue, 08 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Font Loading] Crash when a single load request causes multiple fonts to fail loading
https://bugs.webkit.org/show_bug.cgi?id=155009
Reviewed by Simon Fraser.
Source/WebCore:
In JavaScript, the first promise fulfillment/failure wins. However, in C++, any
subsequent fulfillments/failures cause a crash.
Test: fast/text/font-face-set-document-multiple-failure.html
* css/CSSFontFace.cpp:
(WebCore::iterateClients): Notifying a client may cause some other client
to be destroyed, thereby modifying the clients set. This function allows
for notifying clients in a resilient manner.
(WebCore::CSSFontFace::setStyle): Update to use iterateClients().
(WebCore::CSSFontFace::setWeight): Ditto.
(WebCore::CSSFontFace::setUnicodeRange): Ditto.
(WebCore::CSSFontFace::setVariantLigatures): Ditto.
(WebCore::CSSFontFace::setVariantPosition): Ditto.
(WebCore::CSSFontFace::setVariantCaps): Ditto.
(WebCore::CSSFontFace::setVariantNumeric): Ditto.
(WebCore::CSSFontFace::setVariantAlternates): Ditto.
(WebCore::CSSFontFace::setVariantEastAsian): Ditto.
(WebCore::CSSFontFace::setFeatureSettings): Ditto.
(WebCore::CSSFontFace::setStatus): Ditto.
(WebCore::CSSFontFace::notifyClientsOfFontPropertyChange): Deleted.
* css/CSSFontFace.h: Adding a way for clients to make sure they don't register
or deregister another client.
* css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::guardAgainstClientRegistrationChanges): Simple
ref()/deref() pair.
(WebCore::CSSFontFaceSet::stopGuardingAgainstClientRegistrationChanges):
* css/CSSFontFaceSet.h:
* css/FontFace.cpp: Ditto.
(WebCore::FontFace::guardAgainstClientRegistrationChanges):
(WebCore::FontFace::stopGuardingAgainstClientRegistrationChanges):
* css/FontFace.h:
* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::faceFinished): Make sure that we only fulfil or reject
a promise once.
* css/FontFaceSet.h:
* dom/Document.cpp:
(WebCore::Document::fonts): The CSSFontFaces inside the CSSFontSelector get
created during style recalc. We may be in a state where there is a style
recalc pending. In order to make sure the Javascript API sees the current
state of the world, force a style recalc here (but only if one is pending).
LayoutTests:
* fast/text/font-face-set-document-multiple-failure-expected.txt: Added.
* fast/text/font-face-set-document-multiple-failure.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontFacecpp">trunk/Source/WebCore/css/CSSFontFace.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontFaceh">trunk/Source/WebCore/css/CSSFontFace.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontFaceSetcpp">trunk/Source/WebCore/css/CSSFontFaceSet.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontFaceSeth">trunk/Source/WebCore/css/CSSFontFaceSet.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSSegmentedFontFaceh">trunk/Source/WebCore/css/CSSSegmentedFontFace.h</a></li>
<li><a href="#trunkSourceWebCorecssFontFaceh">trunk/Source/WebCore/css/FontFace.h</a></li>
<li><a href="#trunkSourceWebCorecssFontFaceSetcpp">trunk/Source/WebCore/css/FontFaceSet.cpp</a></li>
<li><a href="#trunkSourceWebCorecssFontFaceSeth">trunk/Source/WebCore/css/FontFaceSet.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextfontfacesetdocumentmultiplefailureexpectedtxt">trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttextfontfacesetdocumentmultiplefailurehtml">trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/LayoutTests/ChangeLog        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-03-08 Myles C. Maxfield <mmaxfield@apple.com>
+
+ [Font Loading] Crash when a single load request causes multiple fonts to fail loading
+ https://bugs.webkit.org/show_bug.cgi?id=155009
+
+ Reviewed by Simon Fraser.
+
+ * fast/text/font-face-set-document-multiple-failure-expected.txt: Added.
+ * fast/text/font-face-set-document-multiple-failure.html: Added.
+
</ins><span class="cx"> 2016-03-08 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Skip fast/events/prevent-default-prevents-interaction-with-scrollbars.html on ios-simulator
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextfontfacesetdocumentmultiplefailureexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure-expected.txt (0 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure-expected.txt        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+PASS globalX.code is globalX.NETWORK_ERR
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextfontfacesetdocumentmultiplefailurehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure.html (0 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure.html         (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-set-document-multiple-failure.html        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<style>
+@font-face {
+        font-family: "WebFont";
+        src: url("garbage");
+}
+@font-face {
+        font-family: "WebFont";
+        src: url("garbage");
+        font-variant: small-caps;
+}
+</style>
+</head>
+<body>
+<script>
+self.jsTestIsAsync = true;
+var globalX;
+document.fonts.load("16px WebFont").then(function() {
+ testFailed("Bogus URLs should not load");
+ finishJSTest();
+}, function(x) {
+        globalX = x;
+ shouldBe("globalX.code", "globalX.NETWORK_ERR");
+ finishJSTest();
+})
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/ChangeLog        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2016-03-08 Myles C. Maxfield <mmaxfield@apple.com>
+
+ [Font Loading] Crash when a single load request causes multiple fonts to fail loading
+ https://bugs.webkit.org/show_bug.cgi?id=155009
+
+ Reviewed by Simon Fraser.
+
+ In JavaScript, the first promise fulfillment/failure wins. However, in C++, any
+ subsequent fulfillments/failures cause a crash.
+
+ Test: fast/text/font-face-set-document-multiple-failure.html
+
+ * css/CSSFontFace.cpp:
+ (WebCore::iterateClients): Notifying a client may cause some other client
+ to be destroyed, thereby modifying the clients set. This function allows
+ for notifying clients in a resilient manner.
+ (WebCore::CSSFontFace::setStyle): Update to use iterateClients().
+ (WebCore::CSSFontFace::setWeight): Ditto.
+ (WebCore::CSSFontFace::setUnicodeRange): Ditto.
+ (WebCore::CSSFontFace::setVariantLigatures): Ditto.
+ (WebCore::CSSFontFace::setVariantPosition): Ditto.
+ (WebCore::CSSFontFace::setVariantCaps): Ditto.
+ (WebCore::CSSFontFace::setVariantNumeric): Ditto.
+ (WebCore::CSSFontFace::setVariantAlternates): Ditto.
+ (WebCore::CSSFontFace::setVariantEastAsian): Ditto.
+ (WebCore::CSSFontFace::setFeatureSettings): Ditto.
+ (WebCore::CSSFontFace::setStatus): Ditto.
+ (WebCore::CSSFontFace::notifyClientsOfFontPropertyChange): Deleted.
+ * css/CSSFontFace.h: Adding a way for clients to make sure they don't register
+ or deregister another client.
+ * css/CSSFontFaceSet.cpp:
+ (WebCore::CSSFontFaceSet::guardAgainstClientRegistrationChanges): Simple
+ ref()/deref() pair.
+ (WebCore::CSSFontFaceSet::stopGuardingAgainstClientRegistrationChanges):
+ * css/CSSFontFaceSet.h:
+ * css/FontFace.cpp: Ditto.
+ (WebCore::FontFace::guardAgainstClientRegistrationChanges):
+ (WebCore::FontFace::stopGuardingAgainstClientRegistrationChanges):
+ * css/FontFace.h:
+ * css/FontFaceSet.cpp:
+ (WebCore::FontFaceSet::faceFinished): Make sure that we only fulfil or reject
+ a promise once.
+ * css/FontFaceSet.h:
+ * dom/Document.cpp:
+ (WebCore::Document::fonts): The CSSFontFaces inside the CSSFontSelector get
+ created during style recalc. We may be in a state where there is a style
+ recalc pending. In order to make sure the Javascript API sees the current
+ state of the world, force a style recalc here (but only if one is pending).
+
</ins><span class="cx"> 2016-03-08 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r197793 and r197799.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFace.cpp        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -48,6 +48,17 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+template<typename T> void iterateClients(HashSet<CSSFontFace::Client*>& clients, T callback)
+{
+ Vector<Ref<CSSFontFace::Client>> clientsCopy;
+ clientsCopy.reserveInitialCapacity(clients.size());
+ for (auto* client : clients)
+ clientsCopy.uncheckedAppend(*client);
+
+ for (auto* client : clients)
+ callback(*client);
+}
+
</ins><span class="cx"> void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Document* document, bool isInitiatingElementInUserAgentShadowTree)
</span><span class="cx"> {
</span><span class="cx"> for (auto& src : srcList) {
</span><span class="lines">@@ -89,15 +100,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CSSFontFace::notifyClientsOfFontPropertyChange()
-{
- auto clientsCopy = m_clients;
- for (auto* client : clientsCopy) {
- if (m_clients.contains(client))
- client->fontPropertyChanged(*this);
- }
-}
-
</del><span class="cx"> bool CSSFontFace::setFamilies(CSSValue& family)
</span><span class="cx"> {
</span><span class="cx"> if (!is<CSSValueList>(family))
</span><span class="lines">@@ -110,11 +112,9 @@
</span><span class="cx"> RefPtr<CSSValueList> oldFamilies = m_families;
</span><span class="cx"> m_families = &familyList;
</span><span class="cx">
</span><del>- auto clientsCopy = m_clients;
- for (auto* client : clientsCopy) {
- if (m_clients.contains(client))
- client->fontPropertyChanged(*this, oldFamilies.get());
- }
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this, oldFamilies.get());
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -142,7 +142,9 @@
</span><span class="cx"> if (auto mask = calculateStyleMask(style)) {
</span><span class="cx"> m_traitsMask = static_cast<FontTraitsMask>((static_cast<unsigned>(m_traitsMask) & (~FontStyleMask)) | mask.value());
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -189,7 +191,9 @@
</span><span class="cx"> if (auto mask = calculateWeightMask(weight)) {
</span><span class="cx"> m_traitsMask = static_cast<FontTraitsMask>((static_cast<unsigned>(m_traitsMask) & (~FontWeightMask)) | mask.value());
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -209,7 +213,9 @@
</span><span class="cx"> m_ranges.append(UnicodeRange(range.from(), range.to()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -222,7 +228,9 @@
</span><span class="cx"> m_variantSettings.historicalLigatures = ligatures.historicalLigatures;
</span><span class="cx"> m_variantSettings.contextualAlternates = ligatures.contextualAlternates;
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -233,7 +241,9 @@
</span><span class="cx"> return false;
</span><span class="cx"> m_variantSettings.position = downcast<CSSPrimitiveValue>(variantPosition);
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -244,7 +254,9 @@
</span><span class="cx"> return false;
</span><span class="cx"> m_variantSettings.caps = downcast<CSSPrimitiveValue>(variantCaps);
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -258,7 +270,9 @@
</span><span class="cx"> m_variantSettings.numericOrdinal = numeric.ordinal;
</span><span class="cx"> m_variantSettings.numericSlashedZero = numeric.slashedZero;
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -269,7 +283,9 @@
</span><span class="cx"> return false;
</span><span class="cx"> m_variantSettings.alternates = downcast<CSSPrimitiveValue>(variantAlternates);
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -281,7 +297,9 @@
</span><span class="cx"> m_variantSettings.eastAsianWidth = eastAsian.width;
</span><span class="cx"> m_variantSettings.eastAsianRuby = eastAsian.ruby;
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -298,7 +316,9 @@
</span><span class="cx"> m_featureSettings.insert(FontFeature(feature.tag(), feature.value()));
</span><span class="cx"> }
</span><span class="cx">
</span><del>- notifyClientsOfFontPropertyChange();
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontPropertyChanged(*this);
+ });
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -380,8 +400,9 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- for (auto* client : m_clients)
- client->fontStateChanged(*this, m_status, newStatus);
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontStateChanged(*this, m_status, newStatus);
+ });
</ins><span class="cx">
</span><span class="cx"> m_status = newStatus;
</span><span class="cx"> }
</span><span class="lines">@@ -397,8 +418,9 @@
</span><span class="cx"> ASSERT(m_fontSelector);
</span><span class="cx"> m_fontSelector->fontLoaded();
</span><span class="cx">
</span><del>- for (auto* client : m_clients)
- client->fontLoaded(*this);
</del><ins>+ iterateClients(m_clients, [&](Client& client) {
+ client.fontLoaded(*this);
+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> size_t CSSFontFace::pump()
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFace.h (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFace.h        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/CSSFontFace.h        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -108,9 +108,11 @@
</span><span class="cx"> class Client {
</span><span class="cx"> public:
</span><span class="cx"> virtual ~Client() { }
</span><del>- virtual void fontLoaded(CSSFontFace&) { };
- virtual void fontStateChanged(CSSFontFace&, Status oldState, Status newState) { UNUSED_PARAM(oldState); UNUSED_PARAM(newState); };
- virtual void fontPropertyChanged(CSSFontFace&, CSSValueList* oldFamilies = nullptr) { UNUSED_PARAM(oldFamilies); };
</del><ins>+ virtual void fontLoaded(CSSFontFace&) { }
+ virtual void fontStateChanged(CSSFontFace&, Status oldState, Status newState) { UNUSED_PARAM(oldState); UNUSED_PARAM(newState); }
+ virtual void fontPropertyChanged(CSSFontFace&, CSSValueList* oldFamilies = nullptr) { UNUSED_PARAM(oldFamilies); }
+ virtual void ref() = 0;
+ virtual void deref() = 0;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> // Pending => Loading => TimedOut
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceSetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFaceSet.cpp (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFaceSet.cpp        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.cpp        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -398,13 +398,13 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> auto& familyFontFaces = iterator->value;
</span><span class="cx">
</span><del>- auto& segmentedFontFaceCache = m_cache.add(family, HashMap<unsigned, std::unique_ptr<CSSSegmentedFontFace>>()).iterator->value;
</del><ins>+ auto& segmentedFontFaceCache = m_cache.add(family, HashMap<unsigned, RefPtr<CSSSegmentedFontFace>>()).iterator->value;
</ins><span class="cx">
</span><span class="cx"> auto& face = segmentedFontFaceCache.add(traitsMask, nullptr).iterator->value;
</span><span class="cx"> if (face)
</span><span class="cx"> return face.get();
</span><span class="cx">
</span><del>- face = std::make_unique<CSSSegmentedFontFace>();
</del><ins>+ face = CSSSegmentedFontFace::create();
</ins><span class="cx">
</span><span class="cx"> Vector<std::reference_wrapper<CSSFontFace>, 32> candidateFontFaces;
</span><span class="cx"> for (int i = familyFontFaces.size() - 1; i >= 0; --i) {
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceSeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFaceSet.h (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFaceSet.h        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.h        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -75,6 +75,10 @@
</span><span class="cx">
</span><span class="cx"> Vector<std::reference_wrapper<CSSFontFace>> matchingFaces(const String& font, const String& text, ExceptionCode&);
</span><span class="cx">
</span><ins>+ // CSSFontFace::Client needs to be able to be held in a RefPtr.
+ void ref() override { RefCounted<CSSFontFaceSet>::ref(); }
+ void deref() override { RefCounted<CSSFontFaceSet>::deref(); }
+
</ins><span class="cx"> private:
</span><span class="cx"> CSSFontFaceSet();
</span><span class="cx">
</span><span class="lines">@@ -95,7 +99,7 @@
</span><span class="cx"> Vector<Ref<CSSFontFace>> m_faces; // We should investigate moving m_faces to FontFaceSet and making it reference FontFaces. This may clean up the font loading design.
</span><span class="cx"> HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_facesLookupTable;
</span><span class="cx"> HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_locallyInstalledFacesLookupTable;
</span><del>- HashMap<String, HashMap<unsigned, std::unique_ptr<CSSSegmentedFontFace>>, ASCIICaseInsensitiveHash> m_cache;
</del><ins>+ HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace>>, ASCIICaseInsensitiveHash> m_cache;
</ins><span class="cx"> size_t m_facesPartitionIndex { 0 }; // All entries in m_faces before this index are CSS-connected.
</span><span class="cx"> Status m_status { Status::Loaded };
</span><span class="cx"> HashSet<CSSFontFaceSetClient*> m_clients;
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSegmentedFontFaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.h (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSegmentedFontFace.h        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/CSSSegmentedFontFace.h        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -39,10 +39,13 @@
</span><span class="cx"> class CSSFontSelector;
</span><span class="cx"> class FontDescription;
</span><span class="cx">
</span><del>-class CSSSegmentedFontFace final : public CSSFontFace::Client {
</del><ins>+class CSSSegmentedFontFace final : public RefCounted<CSSSegmentedFontFace>, public CSSFontFace::Client {
</ins><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>- CSSSegmentedFontFace();
</del><ins>+ static Ref<CSSSegmentedFontFace> create()
+ {
+ return adoptRef(*new CSSSegmentedFontFace());
+ }
</ins><span class="cx"> ~CSSSegmentedFontFace();
</span><span class="cx">
</span><span class="cx"> void appendFontFace(Ref<CSSFontFace>&&);
</span><span class="lines">@@ -51,7 +54,12 @@
</span><span class="cx">
</span><span class="cx"> Vector<Ref<CSSFontFace>, 1>& constituentFaces() { return m_fontFaces; }
</span><span class="cx">
</span><ins>+ // CSSFontFace::Client needs to be able to be held in a RefPtr.
+ void ref() override { RefCounted<CSSSegmentedFontFace>::ref(); }
+ void deref() override { RefCounted<CSSSegmentedFontFace>::deref(); }
+
</ins><span class="cx"> private:
</span><ins>+ CSSSegmentedFontFace();
</ins><span class="cx"> void fontLoaded(CSSFontFace&) override;
</span><span class="cx">
</span><span class="cx"> HashMap<FontDescriptionKey, FontRanges, FontDescriptionKeyHash, WTF::SimpleClassHashTraits<FontDescriptionKey>> m_cache;
</span></span></pre></div>
<a id="trunkSourceWebCorecssFontFaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/FontFace.h (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/FontFace.h        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/FontFace.h        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -82,6 +82,10 @@
</span><span class="cx">
</span><span class="cx"> WeakPtr<FontFace> createWeakPtr() const;
</span><span class="cx">
</span><ins>+ // CSSFontFace::Client needs to be able to be held in a RefPtr.
+ void ref() override { RefCounted<FontFace>::ref(); }
+ void deref() override { RefCounted<FontFace>::deref(); }
+
</ins><span class="cx"> private:
</span><span class="cx"> FontFace(JSC::ExecState&, CSSFontSelector&);
</span><span class="cx"> FontFace(JSC::ExecState&, CSSFontFace&);
</span></span></pre></div>
<a id="trunkSourceWebCorecssFontFaceSetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/FontFaceSet.cpp (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/FontFaceSet.cpp        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/FontFaceSet.cpp        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -236,12 +236,16 @@
</span><span class="cx">
</span><span class="cx"> for (auto& pendingPromise : iterator->value) {
</span><span class="cx"> if (newStatus == CSSFontFace::Status::Success) {
</span><del>- if (pendingPromise->hasOneRef())
</del><ins>+ if (pendingPromise->hasOneRef() && !pendingPromise->hasReachedTerminalState) {
</ins><span class="cx"> pendingPromise->promise.resolve(pendingPromise->faces);
</span><ins>+ pendingPromise->hasReachedTerminalState = true;
+ }
</ins><span class="cx"> } else {
</span><span class="cx"> ASSERT(newStatus == CSSFontFace::Status::Failure);
</span><del>- // The first resolution wins, so we can just reject early now.
- pendingPromise->promise.reject(DOMCoreException::create(ExceptionCodeDescription(NETWORK_ERR)));
</del><ins>+ if (!pendingPromise->hasReachedTerminalState) {
+ pendingPromise->promise.reject(DOMCoreException::create(ExceptionCodeDescription(NETWORK_ERR)));
+ pendingPromise->hasReachedTerminalState = true;
+ }
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssFontFaceSeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/FontFaceSet.h (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/FontFaceSet.h        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/css/FontFaceSet.h        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -101,6 +101,7 @@
</span><span class="cx"> public:
</span><span class="cx"> Vector<RefPtr<FontFace>> faces;
</span><span class="cx"> Promise promise;
</span><ins>+ bool hasReachedTerminalState { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> FontFaceSet(Document&, const Vector<RefPtr<FontFace>>&);
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (197803 => 197804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2016-03-08 21:58:30 UTC (rev 197803)
+++ trunk/Source/WebCore/dom/Document.cpp        2016-03-08 22:22:40 UTC (rev 197804)
</span><span class="lines">@@ -6706,6 +6706,7 @@
</span><span class="cx">
</span><span class="cx"> Ref<FontFaceSet> Document::fonts()
</span><span class="cx"> {
</span><ins>+ updateStyleIfNeeded();
</ins><span class="cx"> return fontSelector().fontFaceSet();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>