Changeset 195523 in webkit


Ignore:
Timestamp:
Jan 24, 2016 9:23:49 PM (8 years ago)
Author:
mmaxfield@apple.com
Message:

[Font Loading] General cleanup
https://bugs.webkit.org/show_bug.cgi?id=153403

Reviewed by Darin Adler.

It turns out that CSSFontFaceSource::m_hasExternalSVGFont exactly equals
whether or not CSSFontFaceSource::m_font is a CachedSVGFont. Therefore,
the variable is redundant.

In addition, it was being passed to functions on CSSFontFaceSource::m_font,
which means it was always true inside the CachedSVGFont subclass and
always false for the CachedFont. Therefore, there is no reason pass this
variable to these functions because its value can be determined at
authorship time.

No new tests because there is no behavior change.

  • css/CSSFontFaceSource.cpp:

(WebCore::CSSFontFaceSource::font):
(WebCore::CSSFontFaceSource::CSSFontFaceSource): Deleted.

  • css/CSSFontFaceSource.h:
  • css/CSSFontSelector.cpp:

(WebCore::createFontFace):

  • loader/cache/CachedFont.cpp:

(WebCore::CachedFont::ensureCustomFontData):
(WebCore::CachedFont::createFont):

  • loader/cache/CachedFont.h:
  • loader/cache/CachedSVGFont.cpp:

(WebCore::CachedSVGFont::createFont):
(WebCore::CachedSVGFont::ensureCustomFontData):

  • loader/cache/CachedSVGFont.h:
  • platform/network/HTTPParsers.cpp:

(WebCore::isValidHTTPToken):

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::uppercaseKnownHTTPMethod):

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195520 r195523  
     12016-01-24  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [Font Loading] General cleanup
     4        https://bugs.webkit.org/show_bug.cgi?id=153403
     5
     6        Reviewed by Darin Adler.
     7
     8        It turns out that CSSFontFaceSource::m_hasExternalSVGFont exactly equals
     9        whether or not CSSFontFaceSource::m_font is a CachedSVGFont. Therefore,
     10        the variable is redundant.
     11
     12        In addition, it was being passed to functions on CSSFontFaceSource::m_font,
     13        which means it was always true inside the CachedSVGFont subclass and
     14        always false for the CachedFont. Therefore, there is no reason pass this
     15        variable to these functions because its value can be determined at
     16        authorship time.
     17
     18        No new tests because there is no behavior change.
     19
     20        * css/CSSFontFaceSource.cpp:
     21        (WebCore::CSSFontFaceSource::font):
     22        (WebCore::CSSFontFaceSource::CSSFontFaceSource): Deleted.
     23        * css/CSSFontFaceSource.h:
     24        * css/CSSFontSelector.cpp:
     25        (WebCore::createFontFace):
     26        * loader/cache/CachedFont.cpp:
     27        (WebCore::CachedFont::ensureCustomFontData):
     28        (WebCore::CachedFont::createFont):
     29        * loader/cache/CachedFont.h:
     30        * loader/cache/CachedSVGFont.cpp:
     31        (WebCore::CachedSVGFont::createFont):
     32        (WebCore::CachedSVGFont::ensureCustomFontData):
     33        * loader/cache/CachedSVGFont.h:
     34        * platform/network/HTTPParsers.cpp:
     35        (WebCore::isValidHTTPToken):
     36        * xml/XMLHttpRequest.cpp:
     37        (WebCore::XMLHttpRequest::uppercaseKnownHTTPMethod):
     38
    1392016-01-24  Chris Dumez  <cdumez@apple.com>
    240
  • trunk/Source/WebCore/css/CSSFontFaceSource.cpp

    r194923 r195523  
    5858    , m_font(font)
    5959    , m_face(0)
    60 #if ENABLE(SVG_FONTS)
    61     , m_hasExternalSVGFont(false)
    62 #endif
    6360{
    6461    if (m_font)
     
    120117    if (!m_font || m_font->isLoaded()) {
    121118        if (m_font) {
    122             bool hasExternalSVGFont = false;
    123 #if ENABLE(SVG_FONTS)
    124             hasExternalSVGFont = m_hasExternalSVGFont;
    125 #endif
    126             if (!m_font->ensureCustomFontData(hasExternalSVGFont, m_string))
     119            if (!m_font->ensureCustomFontData(m_string))
    127120                return nullptr;
    128121
    129             font = m_font->createFont(fontDescription, m_string, syntheticBold, syntheticItalic, hasExternalSVGFont, fontFaceFeatures, fontFaceVariantSettings);
     122            font = m_font->createFont(fontDescription, m_string, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings);
    130123        } else {
    131124#if ENABLE(SVG_FONTS)
     
    165158}
    166159
     160#if ENABLE(SVG_FONTS)
     161bool CSSFontFaceSource::isSVGFontFaceSource() const
     162{
     163    return m_svgFontFaceElement || is<CachedSVGFont>(m_font.get());
     164}
     165#endif
     166
    167167#if ENABLE(FONT_LOAD_EVENTS)
    168168bool CSSFontFaceSource::isDecodeError() const
  • trunk/Source/WebCore/css/CSSFontFaceSource.h

    r194923 r195523  
    4040namespace WebCore {
    4141
    42 class CachedFont;
    4342class CSSFontFace;
    4443class CSSFontSelector;
     
    6968    SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement.get(); }
    7069    void setSVGFontFaceElement(PassRefPtr<SVGFontFaceElement> element) { m_svgFontFaceElement = element; }
    71     bool isSVGFontFaceSource() const { return m_svgFontFaceElement || m_hasExternalSVGFont; }
    72     void setHasExternalSVGFont() { m_hasExternalSVGFont = true; }
     70    bool isSVGFontFaceSource() const;
    7371#endif
    7472
     
    9290#if ENABLE(SVG_FONTS) || ENABLE(SVG_OTF_CONVERTER)
    9391    RefPtr<SVGFontFaceElement> m_svgFontFaceElement;
    94     bool m_hasExternalSVGFont;
    9592#endif
    9693};
  • trunk/Source/WebCore/css/CSSFontSelector.cpp

    r195164 r195523  
    181181            bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
    182182            if (allowDownloading && item.isSupportedFormat() && document) {
    183                 CachedFont* cachedFont = item.cachedFont(document, foundSVGFont, isInitiatingElementInUserAgentShadowTree);
    184                 if (cachedFont) {
     183                if (CachedFont* cachedFont = item.cachedFont(document, foundSVGFont, isInitiatingElementInUserAgentShadowTree))
    185184                    source = std::make_unique<CSSFontFaceSource>(item.resource(), cachedFont);
    186 #if ENABLE(SVG_FONTS)
    187                     if (foundSVGFont)
    188                         source->setHasExternalSVGFont();
    189 #endif
    190                 }
    191185            }
    192         } else {
     186        } else
    193187            source = std::make_unique<CSSFontFaceSource>(item.resource());
    194         }
    195188
    196189        if (source) {
  • trunk/Source/WebCore/loader/cache/CachedFont.cpp

    r194318 r195523  
    9393}
    9494
    95 bool CachedFont::ensureCustomFontData(bool, const AtomicString&)
     95bool CachedFont::ensureCustomFontData(const AtomicString&)
    9696{
    9797    return ensureCustomFontData(m_data.get());
     
    122122}
    123123
    124 RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, bool, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
     124RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
    125125{
    126126    return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings), true, false);
  • trunk/Source/WebCore/loader/cache/CachedFont.h

    r191968 r195523  
    5050    virtual bool stillNeedsLoad() const override { return !m_loadInitiated; }
    5151
    52     virtual bool ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI);
     52    virtual bool ensureCustomFontData(const AtomicString& remoteURI);
    5353
    54     virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG, const FontFeatureSettings&, const FontVariantSettings&);
     54    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, const FontVariantSettings&);
    5555
    5656protected:
  • trunk/Source/WebCore/loader/cache/CachedSVGFont.cpp

    r194839 r195523  
    5252}
    5353
    54 RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
     54RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings)
    5555{
    5656#if ENABLE(SVG_OTF_CONVERTER)
    57     if (!externalSVG || firstFontFace(remoteURI))
    58         return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, externalSVG, fontFaceFeatures, fontFaceVariantSettings);
     57    if (firstFontFace(remoteURI))
     58        return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings);
    5959#else
    60     if (!externalSVG)
    61         return CachedFont::createFont(fontDescription, remoteURI, syntheticBold, syntheticItalic, externalSVG, fontFaceFeatures, fontFaceVariantSettings);
    62 
     60    UNUSED_PARAM(fontFaceFeatures);
     61    UNUSED_PARAM(fontFaceVariantSettings);
    6362    if (SVGFontFaceElement* firstFontFace = this->firstFontFace(remoteURI))
    6463        return Font::create(std::make_unique<SVGFontData>(firstFontFace), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
     
    7473}
    7574
    76 bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI)
     75bool CachedSVGFont::ensureCustomFontData(const AtomicString& remoteURI)
    7776{
    78     if (!externalSVG)
    79         return CachedFont::ensureCustomFontData(externalSVG, remoteURI);
    80 
    8177    if (!m_externalSVGDocument && !errorOccurred() && !isLoading() && m_data) {
    8278        m_externalSVGDocument = SVGDocument::create(nullptr, URL());
    8379        RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("application/xml");
    8480        m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
    85 #if !ENABLE(SVG_OTF_CONVERTER)
    8681        if (decoder->sawError())
    8782            m_externalSVGDocument = nullptr;
    88 #else
    89         if (decoder->sawError())
    90             m_externalSVGDocument = nullptr;
    91         else
     83#if ENABLE(SVG_OTF_CONVERTER)
     84        if (m_externalSVGDocument)
    9285            maybeInitializeExternalSVGFontElement(remoteURI);
    9386        if (!m_externalSVGFontElement)
     
    9992            return false;
    10093        }
     94#else
     95        UNUSED_PARAM(remoteURI);
    10196#endif
    10297    }
  • trunk/Source/WebCore/loader/cache/CachedSVGFont.h

    r191968 r195523  
    3939    CachedSVGFont(const ResourceRequest&, SessionID);
    4040
    41     virtual bool ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI) override;
     41    virtual bool ensureCustomFontData(const AtomicString& remoteURI) override;
    4242   
    43     virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG, const FontFeatureSettings&, const FontVariantSettings&) override;
     43    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings&, const FontVariantSettings&) override;
    4444
    4545private:
  • trunk/Source/WebCore/platform/network/HTTPParsers.cpp

    r195452 r195523  
    126126    if (value.isEmpty())
    127127        return false;
    128     for (unsigned i = 0; i < value.length(); ++i) {
    129         UChar c = value[i];
     128    auto valueStringView = StringView(value);
     129    for (UChar c : valueStringView.codeUnits()) {
    130130        if (c <= 0x20 || c >= 0x7F
    131131            || c == '(' || c == ')' || c == '<' || c == '>' || c == '@'
Note: See TracChangeset for help on using the changeset viewer.