Title: [194923] trunk/Source/WebCore
Revision
194923
Author
mmaxfi...@apple.com
Date
2016-01-12 13:36:41 -0800 (Tue, 12 Jan 2016)

Log Message

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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (194922 => 194923)


--- 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)
@@ -1,3 +1,50 @@
+2016-01-12  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        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:
+
 2016-01-12  Ryosuke Niwa  <rn...@webkit.org>
 
         Add a build flag for custom element

Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (194922 => 194923)


--- 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)
@@ -37,16 +37,6 @@
 
 namespace WebCore {
 
-bool CSSFontFace::isLoaded() const
-{
-    size_t size = m_sources.size();
-    for (size_t i = 0; i < size; i++) {
-        if (!m_sources[i]->isLoaded())
-            return false;
-    }
-    return true;
-}
-
 bool CSSFontFace::isValid() const
 {
     size_t size = m_sources.size();

Modified: trunk/Source/WebCore/css/CSSFontFace.h (194922 => 194923)


--- 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)
@@ -75,7 +75,6 @@
     void addedToSegmentedFontFace(CSSSegmentedFontFace*);
     void removedFromSegmentedFontFace(CSSSegmentedFontFace*);
 
-    bool isLoaded() const;
     bool isValid() const;
 
     bool isLocalFallback() const { return m_isLocalFallback; }

Modified: trunk/Source/WebCore/css/CSSFontFaceSource.cpp (194922 => 194923)


--- 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)
@@ -80,13 +80,6 @@
     m_fontTable.clear();
 }
 
-bool CSSFontFaceSource::isLoaded() const
-{
-    if (m_font)
-        return m_font->isLoaded();
-    return true;
-}
-
 bool CSSFontFaceSource::isValid() const
 {
     if (m_font)
@@ -124,7 +117,7 @@
     if (font)
         return font.release();
 
-    if (isLoaded()) {
+    if (!m_font || m_font->isLoaded()) {
         if (m_font) {
             bool hasExternalSVGFont = false;
 #if ENABLE(SVG_FONTS)

Modified: trunk/Source/WebCore/css/CSSFontFaceSource.h (194922 => 194923)


--- 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)
@@ -53,7 +53,6 @@
     CSSFontFaceSource(const String&, CachedFont* = nullptr);
     virtual ~CSSFontFaceSource();
 
-    bool isLoaded() const;
     bool isValid() const;
 
     const AtomicString& string() const { return m_string; }

Modified: trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp (194922 => 194923)


--- 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)
@@ -100,14 +100,15 @@
 
 CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document, bool isSVG, bool isInitiatingElementInUserAgentShadowTree)
 {
-    if (!m_cachedFont) {
-        ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-        options.setContentSecurityPolicyImposition(isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+    if (m_cachedFont)
+        return m_cachedFont.get();
 
-        CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)), options);
-        request.setInitiator(cachedResourceRequestInitiators().css);
-        m_cachedFont = document->cachedResourceLoader().requestFont(request, isSVG);
-    }
+    ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
+    options.setContentSecurityPolicyImposition(isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+
+    CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)), options);
+    request.setInitiator(cachedResourceRequestInitiators().css);
+    m_cachedFont = document->cachedResourceLoader().requestFont(request, isSVG);
     return m_cachedFont.get();
 }
 

Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (194922 => 194923)


--- 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)
@@ -231,24 +231,22 @@
     }
 }
 
-static Vector<Ref<CSSFontFace>> constructFamilyFontFaces(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash>& locallyInstalledFontFaces)
+static void registerLocalFontFacesForFamily(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash>& locallyInstalledFontFaces)
 {
-    auto result = Vector<Ref<CSSFontFace>>();
-
     ASSERT(!locallyInstalledFontFaces.contains(familyName));
 
     Vector<FontTraitsMask> traitsMasks = FontCache::singleton().getTraitsInFamily(familyName);
-    if (!traitsMasks.isEmpty()) {
-        Vector<Ref<CSSFontFace>> faces = { };
-        for (auto mask : traitsMasks) {
-            Ref<CSSFontFace> face = CSSFontFace::create(mask, nullptr, true);
-            face->addSource(std::make_unique<CSSFontFaceSource>(familyName));
-            ASSERT(face->isValid());
-            faces.append(WTFMove(face));
-        }
-        locallyInstalledFontFaces.add(familyName, WTFMove(faces));
+    if (traitsMasks.isEmpty())
+        return;
+
+    Vector<Ref<CSSFontFace>> faces = { };
+    for (auto mask : traitsMasks) {
+        Ref<CSSFontFace> face = CSSFontFace::create(mask, nullptr, true);
+        face->addSource(std::make_unique<CSSFontFaceSource>(familyName));
+        ASSERT(face->isValid());
+        faces.append(WTFMove(face));
     }
-    return result;
+    locallyInstalledFontFaces.add(familyName, WTFMove(faces));
 }
 
 void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace& fontFaceRule, bool isInitiatingElementInUserAgentShadowTree)
@@ -326,8 +324,10 @@
 
         auto addResult = m_fontFaces.add(familyName, Vector<Ref<CSSFontFace>>());
         auto& familyFontFaces = addResult.iterator->value;
-        if (addResult.isNewEntry)
-            familyFontFaces = constructFamilyFontFaces(familyName, m_locallyInstalledFontFaces);
+        if (addResult.isNewEntry) {
+            registerLocalFontFacesForFamily(familyName, m_locallyInstalledFontFaces);
+            familyFontFaces = { };
+        }
 
         familyFontFaces.append(fontFace.copyRef());
         
@@ -391,71 +391,80 @@
     return familyName;
 }
 
-static FontTraitsMask desiredTraitsMaskForComparison;
+class FontFaceComparator {
+public:
+    FontFaceComparator(FontTraitsMask desiredTraitsMaskForComparison)
+        : m_desiredTraitsMaskForComparison(desiredTraitsMaskForComparison)
+    {
+    }
 
-static inline bool compareFontFaces(const CSSFontFace& first, const CSSFontFace& second)
-{
-    FontTraitsMask firstTraitsMask = first.traitsMask();
-    FontTraitsMask secondTraitsMask = second.traitsMask();
+    bool operator()(const CSSFontFace& first, const CSSFontFace& second)
+    {
+        FontTraitsMask firstTraitsMask = first.traitsMask();
+        FontTraitsMask secondTraitsMask = second.traitsMask();
 
-    bool firstHasDesiredStyle = firstTraitsMask & desiredTraitsMaskForComparison & FontStyleMask;
-    bool secondHasDesiredStyle = secondTraitsMask & desiredTraitsMaskForComparison & FontStyleMask;
+        bool firstHasDesiredStyle = firstTraitsMask & m_desiredTraitsMaskForComparison & FontStyleMask;
+        bool secondHasDesiredStyle = secondTraitsMask & m_desiredTraitsMaskForComparison & FontStyleMask;
 
-    if (firstHasDesiredStyle != secondHasDesiredStyle)
-        return firstHasDesiredStyle;
+        if (firstHasDesiredStyle != secondHasDesiredStyle)
+            return firstHasDesiredStyle;
 
-    if ((desiredTraitsMaskForComparison & FontStyleItalicMask) && !first.isLocalFallback() && !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 & FontStyleItalicMask) && !(firstTraitsMask & FontStyleNormalMask);
-        bool secondRequiresItalics = (secondTraitsMask & FontStyleItalicMask) && !(secondTraitsMask & FontStyleNormalMask);
-        if (firstRequiresItalics != secondRequiresItalics)
-            return firstRequiresItalics;
-    }
+        if ((m_desiredTraitsMaskForComparison & FontStyleItalicMask) && !first.isLocalFallback() && !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 & FontStyleItalicMask) && !(firstTraitsMask & FontStyleNormalMask);
+            bool secondRequiresItalics = (secondTraitsMask & FontStyleItalicMask) && !(secondTraitsMask & FontStyleNormalMask);
+            if (firstRequiresItalics != secondRequiresItalics)
+                return firstRequiresItalics;
+        }
 
-    if (secondTraitsMask & desiredTraitsMaskForComparison & FontWeightMask)
-        return false;
-    if (firstTraitsMask & desiredTraitsMaskForComparison & FontWeightMask)
-        return true;
+        if (secondTraitsMask & m_desiredTraitsMaskForComparison & FontWeightMask)
+            return false;
+        if (firstTraitsMask & m_desiredTraitsMaskForComparison & FontWeightMask)
+            return true;
 
-    // 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.
+        // 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.
 
-    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 }
-    };
+        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 }
+        };
 
-    unsigned ruleSetIndex = 0;
-    unsigned w = FontWeight100Bit;
-    while (!(desiredTraitsMaskForComparison & (1 << w))) {
-        w++;
-        ruleSetIndex++;
-    }
+        unsigned ruleSetIndex = 0;
+        unsigned w = FontWeight100Bit;
+        while (!(m_desiredTraitsMaskForComparison & (1 << w))) {
+            w++;
+            ruleSetIndex++;
+        }
 
-    ASSERT_WITH_SECURITY_IMPLICATION(ruleSetIndex < fallbackRuleSets);
-    const FontTraitsMask* weightFallbackRule = weightFallbackRuleSets[ruleSetIndex];
-    for (unsigned i = 0; i < rulesPerSet; ++i) {
-        if (secondTraitsMask & weightFallbackRule[i])
-            return false;
-        if (firstTraitsMask & weightFallbackRule[i])
-            return true;
+        ASSERT_WITH_SECURITY_IMPLICATION(ruleSetIndex < fallbackRuleSets);
+        const FontTraitsMask* weightFallbackRule = weightFallbackRuleSets[ruleSetIndex];
+        for (unsigned i = 0; i < rulesPerSet; ++i) {
+            if (secondTraitsMask & weightFallbackRule[i])
+                return false;
+            if (firstTraitsMask & weightFallbackRule[i])
+                return true;
+        }
+
+        return false;
     }
 
-    return false;
-}
+private:
+    FontTraitsMask m_desiredTraitsMaskForComparison;
+};
 
 FontRanges CSSFontSelector::fontRangesForFamily(const FontDescription& fontDescription, const AtomicString& familyName)
 {
@@ -485,33 +494,34 @@
     FontTraitsMask traitsMask = fontDescription.traitsMask();
 
     RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache.add(traitsMask, nullptr).iterator->value;
-    if (!face) {
-        face = CSSSegmentedFontFace::create(this);
+    if (face)
+        return face.get();
 
-        Vector<std::reference_wrapper<CSSFontFace>, 32> candidateFontFaces;
-        for (int i = familyFontFaces.size() - 1; i >= 0; --i) {
-            CSSFontFace& candidate = familyFontFaces[i];
-            unsigned candidateTraitsMask = candidate.traitsMask();
+    face = CSSSegmentedFontFace::create(this);
+
+    Vector<std::reference_wrapper<CSSFontFace>, 32> candidateFontFaces;
+    for (int i = familyFontFaces.size() - 1; i >= 0; --i) {
+        CSSFontFace& candidate = familyFontFaces[i];
+        unsigned candidateTraitsMask = candidate.traitsMask();
+        if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
+            continue;
+        candidateFontFaces.append(candidate);
+    }
+
+    auto localIterator = m_locallyInstalledFontFaces.find(family);
+    if (localIterator != m_locallyInstalledFontFaces.end()) {
+        for (auto& candidate : localIterator->value) {
+            unsigned candidateTraitsMask = candidate->traitsMask();
             if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
                 continue;
             candidateFontFaces.append(candidate);
         }
+    }
 
-        auto iterator = m_locallyInstalledFontFaces.find(family);
-        if (iterator != m_locallyInstalledFontFaces.end()) {
-            for (auto& candidate : iterator->value) {
-                unsigned candidateTraitsMask = candidate->traitsMask();
-                if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
-                    continue;
-                candidateFontFaces.append(candidate);
-            }
-        }
+    std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), FontFaceComparator(traitsMask));
+    for (auto& candidate : candidateFontFaces)
+        face->appendFontFace(candidate.get());
 
-        desiredTraitsMaskForComparison = traitsMask;
-        std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compareFontFaces);
-        for (auto& candidate : candidateFontFaces)
-            face->appendFontFace(candidate.get());
-    }
     return face.get();
 }
 
@@ -570,21 +580,6 @@
         m_document->frame()->loader().checkLoadComplete();
 }
 
-bool CSSFontSelector::resolvesFamilyFor(const FontCascadeDescription& description) const
-{
-    for (unsigned i = 0; i < description.familyCount(); ++i) {
-        const AtomicString& familyName = description.familyAt(i);
-        if (familyName.isEmpty())
-            continue;
-        if (m_fontFaces.contains(familyName))
-            return true;
-        static NeverDestroyed<String> webkitPrefix("-webkit-");
-        if (familyName.startsWith(webkitPrefix.get()))
-            return true;
-    }
-    return false;
-}
-
 size_t CSSFontSelector::fallbackFontCount()
 {
     if (!m_document)
@@ -596,7 +591,7 @@
     return 0;
 }
 
-PassRefPtr<Font> CSSFontSelector::fallbackFontAt(const FontDescription& fontDescription, size_t index)
+RefPtr<Font> CSSFontSelector::fallbackFontAt(const FontDescription& fontDescription, size_t index)
 {
     ASSERT_UNUSED(index, !index);
 

Modified: trunk/Source/WebCore/css/CSSFontSelector.h (194922 => 194923)


--- 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)
@@ -59,11 +59,9 @@
 
     virtual FontRanges fontRangesForFamily(const FontDescription&, const AtomicString&) override;
     virtual size_t fallbackFontCount() override;
-    virtual PassRefPtr<Font> fallbackFontAt(const FontDescription&, size_t) override;
+    virtual RefPtr<Font> fallbackFontAt(const FontDescription&, size_t) override;
     CSSSegmentedFontFace* getFontFace(const FontDescription&, const AtomicString& family);
 
-    virtual bool resolvesFamilyFor(const FontCascadeDescription&) const override;
-
     void clearDocument();
 
     void addFontFaceRule(const StyleRuleFontFace&, bool isInitiatingElementInUserAgentShadowTree);

Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp (194922 => 194923)


--- 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)
@@ -54,16 +54,6 @@
     m_descriptionToRangesMap.clear();
 }
 
-bool CSSSegmentedFontFace::isValid() const
-{
-    // Valid if at least one font face is valid.
-    for (auto& face : m_fontFaces) {
-        if (face->isValid())
-            return true;
-    }
-    return false;
-}
-
 void CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
 {
     pruneTable();
@@ -108,9 +98,6 @@
 
 FontRanges CSSSegmentedFontFace::fontRanges(const FontDescription& fontDescription)
 {
-    if (!isValid())
-        return FontRanges();
-
     FontTraitsMask desiredTraitsMask = fontDescription.traitsMask();
 
     auto addResult = m_descriptionToRangesMap.add(FontDescriptionKey(fontDescription), FontRanges());

Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.h (194922 => 194923)


--- 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)
@@ -68,7 +68,6 @@
     CSSSegmentedFontFace(CSSFontSelector*);
 
     void pruneTable();
-    bool isValid() const;
 #if ENABLE(FONT_LOAD_EVENTS)
     bool isLoading() const;
 #endif

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (194922 => 194923)


--- 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)
@@ -367,7 +367,7 @@
 
 inline FontSelector* FontCascade::fontSelector() const
 {
-    return m_fonts ? m_fonts->fontSelector() : 0;
+    return m_fonts ? m_fonts->fontSelector() : nullptr;
 }
 
 inline float FontCascade::tabWidth(const Font& font, unsigned tabSize, float position) const

Modified: trunk/Source/WebCore/platform/graphics/FontSelector.h (194922 => 194923)


--- 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)
@@ -42,10 +42,9 @@
     virtual ~FontSelector() { }
 
     virtual FontRanges fontRangesForFamily(const FontDescription&, const AtomicString&) = 0;
-    virtual PassRefPtr<Font> fallbackFontAt(const FontDescription&, size_t) = 0;
+    virtual RefPtr<Font> fallbackFontAt(const FontDescription&, size_t) = 0;
 
     virtual size_t fallbackFontCount() = 0;
-    virtual bool resolvesFamilyFor(const FontCascadeDescription&) const = 0;
 
     virtual void fontCacheInvalidated() { }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to