<!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>[194923] trunk/Source/WebCore</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/194923">194923</a></dd>
<dt>Author</dt> <dd>mmaxfield@apple.com</dd>
<dt>Date</dt> <dd>2016-01-12 13:36:41 -0800 (Tue, 12 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cleanup in font loading code
https://bugs.webkit.org/show_bug.cgi?id=153023

Reviewed by Zalan Bujtas.

See detailed notes below.

No new tests because there is no behavior change.

* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::isLoaded): Deleted. Never called.
* css/CSSFontFace.h: Ditto.
* css/CSSFontFaceSource.cpp:
(WebCore::CSSFontFaceSource::font): No need to use a helper
isLoaded() function.
(WebCore::CSSFontFaceSource::isLoaded): Deleted. Unnecessary.
* css/CSSFontFaceSource.h:
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::cachedFont): Un-indent code.
* css/CSSFontSelector.cpp:
(WebCore::registerLocalFontFacesForFamily): constructFamilyFontFaces()
always returns an empty Vector. Therefore, the function of this function
is to perform the ancillary processing related to the case where the Faces
don't already exist. Renames the function and removes the empty vector
return.
(WebCore::CSSFontSelector::addFontFaceRule): Update for
registerLocalFontFacesForFamily().
(WebCore::FontFaceComparator::FontFaceComparator): Instead of using a static,
construct a wrapper class around the comparator.
(WebCore::FontFaceComparator::operator()): Ditto.
(WebCore::CSSFontSelector::getFontFace): Un-indent code and update to use
FontFaceComparator.
(WebCore::CSSFontSelector::fallbackFontAt): Migrate off PassRefPtr.
(WebCore::constructFamilyFontFaces): Deleted.
(WebCore::compareFontFaces): Deleted.
(WebCore::CSSFontSelector::resolvesFamilyFor): Deleted. Never called.
* css/CSSFontSelector.h:
* css/CSSSegmentedFontFace.cpp:
(WebCore::CSSSegmentedFontFace::isValid): Deleted.
(WebCore::CSSSegmentedFontFace::fontRanges): Cache negative validity results.
* css/CSSSegmentedFontFace.h:
* platform/graphics/FontCascade.h:
(WebCore::FontCascade::fontSelector): Use nullptr.
* platform/graphics/FontSelector.h:</pre>

<h3>Modified Paths</h3>
<ul>
<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="#trunkSourceWebCorecssCSSFontFaceSourcecpp">trunk/Source/WebCore/css/CSSFontFaceSource.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontFaceSourceh">trunk/Source/WebCore/css/CSSFontFaceSource.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontFaceSrcValuecpp">trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontSelectorcpp">trunk/Source/WebCore/css/CSSFontSelector.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSFontSelectorh">trunk/Source/WebCore/css/CSSFontSelector.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSSegmentedFontFacecpp">trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSSegmentedFontFaceh">trunk/Source/WebCore/css/CSSSegmentedFontFace.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCascadeh">trunk/Source/WebCore/platform/graphics/FontCascade.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontSelectorh">trunk/Source/WebCore/platform/graphics/FontSelector.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/ChangeLog        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2016-01-12  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
+
+        Cleanup in font loading code
+        https://bugs.webkit.org/show_bug.cgi?id=153023
+
+        Reviewed by Zalan Bujtas.
+
+        See detailed notes below.
+
+        No new tests because there is no behavior change.
+
+        * css/CSSFontFace.cpp:
+        (WebCore::CSSFontFace::isLoaded): Deleted. Never called.
+        * css/CSSFontFace.h: Ditto.
+        * css/CSSFontFaceSource.cpp:
+        (WebCore::CSSFontFaceSource::font): No need to use a helper
+        isLoaded() function.
+        (WebCore::CSSFontFaceSource::isLoaded): Deleted. Unnecessary.
+        * css/CSSFontFaceSource.h:
+        * css/CSSFontFaceSrcValue.cpp:
+        (WebCore::CSSFontFaceSrcValue::cachedFont): Un-indent code.
+        * css/CSSFontSelector.cpp:
+        (WebCore::registerLocalFontFacesForFamily): constructFamilyFontFaces()
+        always returns an empty Vector. Therefore, the function of this function
+        is to perform the ancillary processing related to the case where the Faces
+        don't already exist. Renames the function and removes the empty vector
+        return.
+        (WebCore::CSSFontSelector::addFontFaceRule): Update for
+        registerLocalFontFacesForFamily().
+        (WebCore::FontFaceComparator::FontFaceComparator): Instead of using a static,
+        construct a wrapper class around the comparator.
+        (WebCore::FontFaceComparator::operator()): Ditto.
+        (WebCore::CSSFontSelector::getFontFace): Un-indent code and update to use
+        FontFaceComparator.
+        (WebCore::CSSFontSelector::fallbackFontAt): Migrate off PassRefPtr.
+        (WebCore::constructFamilyFontFaces): Deleted.
+        (WebCore::compareFontFaces): Deleted.
+        (WebCore::CSSFontSelector::resolvesFamilyFor): Deleted. Never called.
+        * css/CSSFontSelector.h:
+        * css/CSSSegmentedFontFace.cpp:
+        (WebCore::CSSSegmentedFontFace::isValid): Deleted.
+        (WebCore::CSSSegmentedFontFace::fontRanges): Cache negative validity results.
+        * css/CSSSegmentedFontFace.h:
+        * platform/graphics/FontCascade.h:
+        (WebCore::FontCascade::fontSelector): Use nullptr.
+        * platform/graphics/FontSelector.h:
+
</ins><span class="cx"> 2016-01-12  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Add a build flag for custom element
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFace.cpp        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -37,16 +37,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-bool CSSFontFace::isLoaded() const
-{
-    size_t size = m_sources.size();
-    for (size_t i = 0; i &lt; size; i++) {
-        if (!m_sources[i]-&gt;isLoaded())
-            return false;
-    }
-    return true;
-}
-
</del><span class="cx"> bool CSSFontFace::isValid() const
</span><span class="cx"> {
</span><span class="cx">     size_t size = m_sources.size();
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFace.h (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFace.h        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSFontFace.h        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -75,7 +75,6 @@
</span><span class="cx">     void addedToSegmentedFontFace(CSSSegmentedFontFace*);
</span><span class="cx">     void removedFromSegmentedFontFace(CSSSegmentedFontFace*);
</span><span class="cx"> 
</span><del>-    bool isLoaded() const;
</del><span class="cx">     bool isValid() const;
</span><span class="cx"> 
</span><span class="cx">     bool isLocalFallback() const { return m_isLocalFallback; }
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceSourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFaceSource.cpp (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFaceSource.cpp        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.cpp        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -80,13 +80,6 @@
</span><span class="cx">     m_fontTable.clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CSSFontFaceSource::isLoaded() const
-{
-    if (m_font)
-        return m_font-&gt;isLoaded();
-    return true;
-}
-
</del><span class="cx"> bool CSSFontFaceSource::isValid() const
</span><span class="cx"> {
</span><span class="cx">     if (m_font)
</span><span class="lines">@@ -124,7 +117,7 @@
</span><span class="cx">     if (font)
</span><span class="cx">         return font.release();
</span><span class="cx"> 
</span><del>-    if (isLoaded()) {
</del><ins>+    if (!m_font || m_font-&gt;isLoaded()) {
</ins><span class="cx">         if (m_font) {
</span><span class="cx">             bool hasExternalSVGFont = false;
</span><span class="cx"> #if ENABLE(SVG_FONTS)
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceSourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFaceSource.h (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFaceSource.h        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.h        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -53,7 +53,6 @@
</span><span class="cx">     CSSFontFaceSource(const String&amp;, CachedFont* = nullptr);
</span><span class="cx">     virtual ~CSSFontFaceSource();
</span><span class="cx"> 
</span><del>-    bool isLoaded() const;
</del><span class="cx">     bool isValid() const;
</span><span class="cx"> 
</span><span class="cx">     const AtomicString&amp; string() const { return m_string; }
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontFaceSrcValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -100,14 +100,15 @@
</span><span class="cx"> 
</span><span class="cx"> CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document, bool isSVG, bool isInitiatingElementInUserAgentShadowTree)
</span><span class="cx"> {
</span><del>-    if (!m_cachedFont) {
-        ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-        options.setContentSecurityPolicyImposition(isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
</del><ins>+    if (m_cachedFont)
+        return m_cachedFont.get();
</ins><span class="cx"> 
</span><del>-        CachedResourceRequest request(ResourceRequest(document-&gt;completeURL(m_resource)), options);
-        request.setInitiator(cachedResourceRequestInitiators().css);
-        m_cachedFont = document-&gt;cachedResourceLoader().requestFont(request, isSVG);
-    }
</del><ins>+    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
+    options.setContentSecurityPolicyImposition(isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+
+    CachedResourceRequest request(ResourceRequest(document-&gt;completeURL(m_resource)), options);
+    request.setInitiator(cachedResourceRequestInitiators().css);
+    m_cachedFont = document-&gt;cachedResourceLoader().requestFont(request, isSVG);
</ins><span class="cx">     return m_cachedFont.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontSelector.cpp        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -231,24 +231,22 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static Vector&lt;Ref&lt;CSSFontFace&gt;&gt; constructFamilyFontFaces(const String&amp; familyName, HashMap&lt;String, Vector&lt;Ref&lt;CSSFontFace&gt;&gt;, CaseFoldingHash&gt;&amp; locallyInstalledFontFaces)
</del><ins>+static void registerLocalFontFacesForFamily(const String&amp; familyName, HashMap&lt;String, Vector&lt;Ref&lt;CSSFontFace&gt;&gt;, CaseFoldingHash&gt;&amp; locallyInstalledFontFaces)
</ins><span class="cx"> {
</span><del>-    auto result = Vector&lt;Ref&lt;CSSFontFace&gt;&gt;();
-
</del><span class="cx">     ASSERT(!locallyInstalledFontFaces.contains(familyName));
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;FontTraitsMask&gt; traitsMasks = FontCache::singleton().getTraitsInFamily(familyName);
</span><del>-    if (!traitsMasks.isEmpty()) {
-        Vector&lt;Ref&lt;CSSFontFace&gt;&gt; faces = { };
-        for (auto mask : traitsMasks) {
-            Ref&lt;CSSFontFace&gt; face = CSSFontFace::create(mask, nullptr, true);
-            face-&gt;addSource(std::make_unique&lt;CSSFontFaceSource&gt;(familyName));
-            ASSERT(face-&gt;isValid());
-            faces.append(WTFMove(face));
-        }
-        locallyInstalledFontFaces.add(familyName, WTFMove(faces));
</del><ins>+    if (traitsMasks.isEmpty())
+        return;
+
+    Vector&lt;Ref&lt;CSSFontFace&gt;&gt; faces = { };
+    for (auto mask : traitsMasks) {
+        Ref&lt;CSSFontFace&gt; face = CSSFontFace::create(mask, nullptr, true);
+        face-&gt;addSource(std::make_unique&lt;CSSFontFaceSource&gt;(familyName));
+        ASSERT(face-&gt;isValid());
+        faces.append(WTFMove(face));
</ins><span class="cx">     }
</span><del>-    return result;
</del><ins>+    locallyInstalledFontFaces.add(familyName, WTFMove(faces));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace&amp; fontFaceRule, bool isInitiatingElementInUserAgentShadowTree)
</span><span class="lines">@@ -326,8 +324,10 @@
</span><span class="cx"> 
</span><span class="cx">         auto addResult = m_fontFaces.add(familyName, Vector&lt;Ref&lt;CSSFontFace&gt;&gt;());
</span><span class="cx">         auto&amp; familyFontFaces = addResult.iterator-&gt;value;
</span><del>-        if (addResult.isNewEntry)
-            familyFontFaces = constructFamilyFontFaces(familyName, m_locallyInstalledFontFaces);
</del><ins>+        if (addResult.isNewEntry) {
+            registerLocalFontFacesForFamily(familyName, m_locallyInstalledFontFaces);
+            familyFontFaces = { };
+        }
</ins><span class="cx"> 
</span><span class="cx">         familyFontFaces.append(fontFace.copyRef());
</span><span class="cx">         
</span><span class="lines">@@ -391,71 +391,80 @@
</span><span class="cx">     return familyName;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static FontTraitsMask desiredTraitsMaskForComparison;
</del><ins>+class FontFaceComparator {
+public:
+    FontFaceComparator(FontTraitsMask desiredTraitsMaskForComparison)
+        : m_desiredTraitsMaskForComparison(desiredTraitsMaskForComparison)
+    {
+    }
</ins><span class="cx"> 
</span><del>-static inline bool compareFontFaces(const CSSFontFace&amp; first, const CSSFontFace&amp; second)
-{
-    FontTraitsMask firstTraitsMask = first.traitsMask();
-    FontTraitsMask secondTraitsMask = second.traitsMask();
</del><ins>+    bool operator()(const CSSFontFace&amp; first, const CSSFontFace&amp; second)
+    {
+        FontTraitsMask firstTraitsMask = first.traitsMask();
+        FontTraitsMask secondTraitsMask = second.traitsMask();
</ins><span class="cx"> 
</span><del>-    bool firstHasDesiredStyle = firstTraitsMask &amp; desiredTraitsMaskForComparison &amp; FontStyleMask;
-    bool secondHasDesiredStyle = secondTraitsMask &amp; desiredTraitsMaskForComparison &amp; FontStyleMask;
</del><ins>+        bool firstHasDesiredStyle = firstTraitsMask &amp; m_desiredTraitsMaskForComparison &amp; FontStyleMask;
+        bool secondHasDesiredStyle = secondTraitsMask &amp; m_desiredTraitsMaskForComparison &amp; FontStyleMask;
</ins><span class="cx"> 
</span><del>-    if (firstHasDesiredStyle != secondHasDesiredStyle)
-        return firstHasDesiredStyle;
</del><ins>+        if (firstHasDesiredStyle != secondHasDesiredStyle)
+            return firstHasDesiredStyle;
</ins><span class="cx"> 
</span><del>-    if ((desiredTraitsMaskForComparison &amp; FontStyleItalicMask) &amp;&amp; !first.isLocalFallback() &amp;&amp; !second.isLocalFallback()) {
-        // Prefer a font that has indicated that it can only support italics to a font that claims to support
-        // all styles.  The specialized font is more likely to be the one the author wants used.
-        bool firstRequiresItalics = (firstTraitsMask &amp; FontStyleItalicMask) &amp;&amp; !(firstTraitsMask &amp; FontStyleNormalMask);
-        bool secondRequiresItalics = (secondTraitsMask &amp; FontStyleItalicMask) &amp;&amp; !(secondTraitsMask &amp; FontStyleNormalMask);
-        if (firstRequiresItalics != secondRequiresItalics)
-            return firstRequiresItalics;
-    }
</del><ins>+        if ((m_desiredTraitsMaskForComparison &amp; FontStyleItalicMask) &amp;&amp; !first.isLocalFallback() &amp;&amp; !second.isLocalFallback()) {
+            // Prefer a font that has indicated that it can only support italics to a font that claims to support
+            // all styles. The specialized font is more likely to be the one the author wants used.
+            bool firstRequiresItalics = (firstTraitsMask &amp; FontStyleItalicMask) &amp;&amp; !(firstTraitsMask &amp; FontStyleNormalMask);
+            bool secondRequiresItalics = (secondTraitsMask &amp; FontStyleItalicMask) &amp;&amp; !(secondTraitsMask &amp; FontStyleNormalMask);
+            if (firstRequiresItalics != secondRequiresItalics)
+                return firstRequiresItalics;
+        }
</ins><span class="cx"> 
</span><del>-    if (secondTraitsMask &amp; desiredTraitsMaskForComparison &amp; FontWeightMask)
-        return false;
-    if (firstTraitsMask &amp; desiredTraitsMaskForComparison &amp; FontWeightMask)
-        return true;
</del><ins>+        if (secondTraitsMask &amp; m_desiredTraitsMaskForComparison &amp; FontWeightMask)
+            return false;
+        if (firstTraitsMask &amp; m_desiredTraitsMaskForComparison &amp; FontWeightMask)
+            return true;
</ins><span class="cx"> 
</span><del>-    // http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-matching-algorithm says :
-    //   - If the desired weight is less than 400, weights below the desired weight are checked in descending order followed by weights above the desired weight in ascending order until a match is found.
-    //   - If the desired weight is greater than 500, weights above the desired weight are checked in ascending order followed by weights below the desired weight in descending order until a match is found.
-    //   - If the desired weight is 400, 500 is checked first and then the rule for desired weights less than 400 is used.
-    //   - If the desired weight is 500, 400 is checked first and then the rule for desired weights less than 400 is used.
</del><ins>+        // http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-matching-algorithm says :
+        //   - If the desired weight is less than 400, weights below the desired weight are checked in descending order followed by weights above the desired weight in ascending order until a match is found.
+        //   - If the desired weight is greater than 500, weights above the desired weight are checked in ascending order followed by weights below the desired weight in descending order until a match is found.
+        //   - If the desired weight is 400, 500 is checked first and then the rule for desired weights less than 400 is used.
+        //   - If the desired weight is 500, 400 is checked first and then the rule for desired weights less than 400 is used.
</ins><span class="cx"> 
</span><del>-    static const unsigned fallbackRuleSets = 9;
-    static const unsigned rulesPerSet = 8;
-    static const FontTraitsMask weightFallbackRuleSets[fallbackRuleSets][rulesPerSet] = {
-        { FontWeight200Mask, FontWeight300Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
-        { FontWeight100Mask, FontWeight300Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
-        { FontWeight200Mask, FontWeight100Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
-        { FontWeight500Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
-        { FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
-        { FontWeight700Mask, FontWeight800Mask, FontWeight900Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask },
-        { FontWeight800Mask, FontWeight900Mask, FontWeight600Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask },
-        { FontWeight900Mask, FontWeight700Mask, FontWeight600Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask },
-        { FontWeight800Mask, FontWeight700Mask, FontWeight600Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask }
-    };
</del><ins>+        static const unsigned fallbackRuleSets = 9;
+        static const unsigned rulesPerSet = 8;
+        static const FontTraitsMask weightFallbackRuleSets[fallbackRuleSets][rulesPerSet] = {
+            { FontWeight200Mask, FontWeight300Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
+            { FontWeight100Mask, FontWeight300Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
+            { FontWeight200Mask, FontWeight100Mask, FontWeight400Mask, FontWeight500Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
+            { FontWeight500Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
+            { FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask, FontWeight600Mask, FontWeight700Mask, FontWeight800Mask, FontWeight900Mask },
+            { FontWeight700Mask, FontWeight800Mask, FontWeight900Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask },
+            { FontWeight800Mask, FontWeight900Mask, FontWeight600Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask },
+            { FontWeight900Mask, FontWeight700Mask, FontWeight600Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask },
+            { FontWeight800Mask, FontWeight700Mask, FontWeight600Mask, FontWeight500Mask, FontWeight400Mask, FontWeight300Mask, FontWeight200Mask, FontWeight100Mask }
+        };
</ins><span class="cx"> 
</span><del>-    unsigned ruleSetIndex = 0;
-    unsigned w = FontWeight100Bit;
-    while (!(desiredTraitsMaskForComparison &amp; (1 &lt;&lt; w))) {
-        w++;
-        ruleSetIndex++;
-    }
</del><ins>+        unsigned ruleSetIndex = 0;
+        unsigned w = FontWeight100Bit;
+        while (!(m_desiredTraitsMaskForComparison &amp; (1 &lt;&lt; w))) {
+            w++;
+            ruleSetIndex++;
+        }
</ins><span class="cx"> 
</span><del>-    ASSERT_WITH_SECURITY_IMPLICATION(ruleSetIndex &lt; fallbackRuleSets);
-    const FontTraitsMask* weightFallbackRule = weightFallbackRuleSets[ruleSetIndex];
-    for (unsigned i = 0; i &lt; rulesPerSet; ++i) {
-        if (secondTraitsMask &amp; weightFallbackRule[i])
-            return false;
-        if (firstTraitsMask &amp; weightFallbackRule[i])
-            return true;
</del><ins>+        ASSERT_WITH_SECURITY_IMPLICATION(ruleSetIndex &lt; fallbackRuleSets);
+        const FontTraitsMask* weightFallbackRule = weightFallbackRuleSets[ruleSetIndex];
+        for (unsigned i = 0; i &lt; rulesPerSet; ++i) {
+            if (secondTraitsMask &amp; weightFallbackRule[i])
+                return false;
+            if (firstTraitsMask &amp; weightFallbackRule[i])
+                return true;
+        }
+
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return false;
-}
</del><ins>+private:
+    FontTraitsMask m_desiredTraitsMaskForComparison;
+};
</ins><span class="cx"> 
</span><span class="cx"> FontRanges CSSFontSelector::fontRangesForFamily(const FontDescription&amp; fontDescription, const AtomicString&amp; familyName)
</span><span class="cx"> {
</span><span class="lines">@@ -485,33 +494,34 @@
</span><span class="cx">     FontTraitsMask traitsMask = fontDescription.traitsMask();
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;CSSSegmentedFontFace&gt;&amp; face = segmentedFontFaceCache.add(traitsMask, nullptr).iterator-&gt;value;
</span><del>-    if (!face) {
-        face = CSSSegmentedFontFace::create(this);
</del><ins>+    if (face)
+        return face.get();
</ins><span class="cx"> 
</span><del>-        Vector&lt;std::reference_wrapper&lt;CSSFontFace&gt;, 32&gt; candidateFontFaces;
-        for (int i = familyFontFaces.size() - 1; i &gt;= 0; --i) {
-            CSSFontFace&amp; candidate = familyFontFaces[i];
-            unsigned candidateTraitsMask = candidate.traitsMask();
</del><ins>+    face = CSSSegmentedFontFace::create(this);
+
+    Vector&lt;std::reference_wrapper&lt;CSSFontFace&gt;, 32&gt; candidateFontFaces;
+    for (int i = familyFontFaces.size() - 1; i &gt;= 0; --i) {
+        CSSFontFace&amp; candidate = familyFontFaces[i];
+        unsigned candidateTraitsMask = candidate.traitsMask();
+        if ((traitsMask &amp; FontStyleNormalMask) &amp;&amp; !(candidateTraitsMask &amp; FontStyleNormalMask))
+            continue;
+        candidateFontFaces.append(candidate);
+    }
+
+    auto localIterator = m_locallyInstalledFontFaces.find(family);
+    if (localIterator != m_locallyInstalledFontFaces.end()) {
+        for (auto&amp; candidate : localIterator-&gt;value) {
+            unsigned candidateTraitsMask = candidate-&gt;traitsMask();
</ins><span class="cx">             if ((traitsMask &amp; FontStyleNormalMask) &amp;&amp; !(candidateTraitsMask &amp; FontStyleNormalMask))
</span><span class="cx">                 continue;
</span><span class="cx">             candidateFontFaces.append(candidate);
</span><span class="cx">         }
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-        auto iterator = m_locallyInstalledFontFaces.find(family);
-        if (iterator != m_locallyInstalledFontFaces.end()) {
-            for (auto&amp; candidate : iterator-&gt;value) {
-                unsigned candidateTraitsMask = candidate-&gt;traitsMask();
-                if ((traitsMask &amp; FontStyleNormalMask) &amp;&amp; !(candidateTraitsMask &amp; FontStyleNormalMask))
-                    continue;
-                candidateFontFaces.append(candidate);
-            }
-        }
</del><ins>+    std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), FontFaceComparator(traitsMask));
+    for (auto&amp; candidate : candidateFontFaces)
+        face-&gt;appendFontFace(candidate.get());
</ins><span class="cx"> 
</span><del>-        desiredTraitsMaskForComparison = traitsMask;
-        std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compareFontFaces);
-        for (auto&amp; candidate : candidateFontFaces)
-            face-&gt;appendFontFace(candidate.get());
-    }
</del><span class="cx">     return face.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -570,21 +580,6 @@
</span><span class="cx">         m_document-&gt;frame()-&gt;loader().checkLoadComplete();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CSSFontSelector::resolvesFamilyFor(const FontCascadeDescription&amp; description) const
-{
-    for (unsigned i = 0; i &lt; description.familyCount(); ++i) {
-        const AtomicString&amp; familyName = description.familyAt(i);
-        if (familyName.isEmpty())
-            continue;
-        if (m_fontFaces.contains(familyName))
-            return true;
-        static NeverDestroyed&lt;String&gt; webkitPrefix(&quot;-webkit-&quot;);
-        if (familyName.startsWith(webkitPrefix.get()))
-            return true;
-    }
-    return false;
-}
-
</del><span class="cx"> size_t CSSFontSelector::fallbackFontCount()
</span><span class="cx"> {
</span><span class="cx">     if (!m_document)
</span><span class="lines">@@ -596,7 +591,7 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;Font&gt; CSSFontSelector::fallbackFontAt(const FontDescription&amp; fontDescription, size_t index)
</del><ins>+RefPtr&lt;Font&gt; CSSFontSelector::fallbackFontAt(const FontDescription&amp; fontDescription, size_t index)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(index, !index);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSFontSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSFontSelector.h (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSFontSelector.h        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSFontSelector.h        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -59,11 +59,9 @@
</span><span class="cx"> 
</span><span class="cx">     virtual FontRanges fontRangesForFamily(const FontDescription&amp;, const AtomicString&amp;) override;
</span><span class="cx">     virtual size_t fallbackFontCount() override;
</span><del>-    virtual PassRefPtr&lt;Font&gt; fallbackFontAt(const FontDescription&amp;, size_t) override;
</del><ins>+    virtual RefPtr&lt;Font&gt; fallbackFontAt(const FontDescription&amp;, size_t) override;
</ins><span class="cx">     CSSSegmentedFontFace* getFontFace(const FontDescription&amp;, const AtomicString&amp; family);
</span><span class="cx"> 
</span><del>-    virtual bool resolvesFamilyFor(const FontCascadeDescription&amp;) const override;
-
</del><span class="cx">     void clearDocument();
</span><span class="cx"> 
</span><span class="cx">     void addFontFaceRule(const StyleRuleFontFace&amp;, bool isInitiatingElementInUserAgentShadowTree);
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSegmentedFontFacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -54,16 +54,6 @@
</span><span class="cx">     m_descriptionToRangesMap.clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CSSSegmentedFontFace::isValid() const
-{
-    // Valid if at least one font face is valid.
-    for (auto&amp; face : m_fontFaces) {
-        if (face-&gt;isValid())
-            return true;
-    }
-    return false;
-}
-
</del><span class="cx"> void CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
</span><span class="cx"> {
</span><span class="cx">     pruneTable();
</span><span class="lines">@@ -108,9 +98,6 @@
</span><span class="cx"> 
</span><span class="cx"> FontRanges CSSSegmentedFontFace::fontRanges(const FontDescription&amp; fontDescription)
</span><span class="cx"> {
</span><del>-    if (!isValid())
-        return FontRanges();
-
</del><span class="cx">     FontTraitsMask desiredTraitsMask = fontDescription.traitsMask();
</span><span class="cx"> 
</span><span class="cx">     auto addResult = m_descriptionToRangesMap.add(FontDescriptionKey(fontDescription), FontRanges());
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSegmentedFontFaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.h (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSegmentedFontFace.h        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/css/CSSSegmentedFontFace.h        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -68,7 +68,6 @@
</span><span class="cx">     CSSSegmentedFontFace(CSSFontSelector*);
</span><span class="cx"> 
</span><span class="cx">     void pruneTable();
</span><del>-    bool isValid() const;
</del><span class="cx"> #if ENABLE(FONT_LOAD_EVENTS)
</span><span class="cx">     bool isLoading() const;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCascadeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCascade.h        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -367,7 +367,7 @@
</span><span class="cx"> 
</span><span class="cx"> inline FontSelector* FontCascade::fontSelector() const
</span><span class="cx"> {
</span><del>-    return m_fonts ? m_fonts-&gt;fontSelector() : 0;
</del><ins>+    return m_fonts ? m_fonts-&gt;fontSelector() : nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline float FontCascade::tabWidth(const Font&amp; font, unsigned tabSize, float position) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontSelector.h (194922 => 194923)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontSelector.h        2016-01-12 21:34:29 UTC (rev 194922)
+++ trunk/Source/WebCore/platform/graphics/FontSelector.h        2016-01-12 21:36:41 UTC (rev 194923)
</span><span class="lines">@@ -42,10 +42,9 @@
</span><span class="cx">     virtual ~FontSelector() { }
</span><span class="cx"> 
</span><span class="cx">     virtual FontRanges fontRangesForFamily(const FontDescription&amp;, const AtomicString&amp;) = 0;
</span><del>-    virtual PassRefPtr&lt;Font&gt; fallbackFontAt(const FontDescription&amp;, size_t) = 0;
</del><ins>+    virtual RefPtr&lt;Font&gt; fallbackFontAt(const FontDescription&amp;, size_t) = 0;
</ins><span class="cx"> 
</span><span class="cx">     virtual size_t fallbackFontCount() = 0;
</span><del>-    virtual bool resolvesFamilyFor(const FontCascadeDescription&amp;) const = 0;
</del><span class="cx"> 
</span><span class="cx">     virtual void fontCacheInvalidated() { }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>