Changeset 199881 in webkit


Ignore:
Timestamp:
Apr 22, 2016 10:37:09 AM (8 years ago)
Author:
Antti Koivisto
Message:

REGRESSION (r194898): Multi download of external SVG defs file by <use> xlinks:href (caching)
https://bugs.webkit.org/show_bug.cgi?id=156368
<rdar://problem/25611746>

Reviewed by Simon Fraser.

Source/WebCore:

We would load svg resources with fragment identifier again because the encoding never matched.

Test: http/tests/svg/svg-use-external.html

  • loader/TextResourceDecoder.cpp:

(WebCore::TextResourceDecoder::setEncoding):
(WebCore::TextResourceDecoder::hasEqualEncodingForCharset):

Encoding can depend on mime type. Add a comparison function that takes this into account.

(WebCore::findXMLEncoding):

  • loader/TextResourceDecoder.h:

(WebCore::TextResourceDecoder::encoding):

  • loader/cache/CachedCSSStyleSheet.h:
  • loader/cache/CachedResource.h:

(WebCore::CachedResource::textResourceDecoder):

Add a way to get the TextResourceDecoder from a cached resource.

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::determineRevalidationPolicy):

Use the new comparison function.

  • loader/cache/CachedSVGDocument.h:
  • loader/cache/CachedScript.h:
  • loader/cache/CachedXSLStyleSheet.h:

LayoutTests:

  • http/tests/svg/resources/symbol-defs.svg: Added.
  • http/tests/svg/svg-use-external-expected.txt: Added.
  • http/tests/svg/svg-use-external.html: Added.
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r199878 r199881  
     12016-04-22  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (r194898): Multi download of external SVG defs file by <use> xlinks:href (caching)
     4        https://bugs.webkit.org/show_bug.cgi?id=156368
     5        <rdar://problem/25611746>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * http/tests/svg/resources/symbol-defs.svg: Added.
     10        * http/tests/svg/svg-use-external-expected.txt: Added.
     11        * http/tests/svg/svg-use-external.html: Added.
     12
    1132016-04-22  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r199879 r199881  
     12016-04-22  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (r194898): Multi download of external SVG defs file by <use> xlinks:href (caching)
     4        https://bugs.webkit.org/show_bug.cgi?id=156368
     5        <rdar://problem/25611746>
     6
     7        Reviewed by Simon Fraser.
     8
     9        We would load svg resources with fragment identifier again because the encoding never matched.
     10
     11        Test: http/tests/svg/svg-use-external.html
     12
     13        * loader/TextResourceDecoder.cpp:
     14        (WebCore::TextResourceDecoder::setEncoding):
     15        (WebCore::TextResourceDecoder::hasEqualEncodingForCharset):
     16
     17            Encoding can depend on mime type. Add a comparison function that takes this into account.
     18
     19        (WebCore::findXMLEncoding):
     20        * loader/TextResourceDecoder.h:
     21        (WebCore::TextResourceDecoder::encoding):
     22        * loader/cache/CachedCSSStyleSheet.h:
     23        * loader/cache/CachedResource.h:
     24        (WebCore::CachedResource::textResourceDecoder):
     25
     26            Add a way to get the TextResourceDecoder from a cached resource.
     27
     28        * loader/cache/CachedResourceLoader.cpp:
     29        (WebCore::CachedResourceLoader::determineRevalidationPolicy):
     30
     31            Use the new comparison function.
     32
     33        * loader/cache/CachedSVGDocument.h:
     34        * loader/cache/CachedScript.h:
     35        * loader/cache/CachedXSLStyleSheet.h:
     36
    1372016-04-22  Youenn Fablet  <youenn.fablet@crf.canon.fr>
    238
  • trunk/Source/WebCore/loader/TextResourceDecoder.cpp

    r195452 r199881  
    360360}
    361361
     362bool TextResourceDecoder::hasEqualEncodingForCharset(const String& charset) const
     363{
     364    return defaultEncoding(m_contentType, charset) == m_encoding;
     365}
     366
    362367// Returns the position of the encoding string.
    363368static int findXMLEncoding(const char* str, int len, int& encodingLength)
  • trunk/Source/WebCore/loader/TextResourceDecoder.h

    r177733 r199881  
    5353    const TextEncoding& encoding() const { return m_encoding; }
    5454
     55    bool hasEqualEncodingForCharset(const String&) const;
     56
    5557    WEBCORE_EXPORT String decode(const char* data, size_t length);
    5658    WEBCORE_EXPORT String flush();
  • trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.h

    r197563 r199881  
    5656        void setEncoding(const String&) override;
    5757        String encoding() const override;
     58        const TextResourceDecoder* textResourceDecoder() const override { return m_decoder.get(); }
    5859        void finishLoading(SharedBuffer*) override;
    5960        void destroyDecodedData() override;
  • trunk/Source/WebCore/loader/cache/CachedResource.h

    r199650 r199881  
    5151class SharedBuffer;
    5252class SubresourceLoader;
     53class TextResourceDecoder;
    5354
    5455// A resource that is held in the cache. Classes who want to use this object should derive
     
    101102    virtual void setEncoding(const String&) { }
    102103    virtual String encoding() const { return String(); }
     104    virtual const TextResourceDecoder* textResourceDecoder() const { return nullptr; }
    103105    virtual void addDataBuffer(SharedBuffer&);
    104106    virtual void addData(const char* data, unsigned length);
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r199650 r199881  
    759759    }
    760760
    761     if (existingResource->encoding() != TextEncoding(cachedResourceRequest.charset()))
     761    auto* textDecoder = existingResource->textResourceDecoder();
     762    if (textDecoder && !textDecoder->hasEqualEncodingForCharset(cachedResourceRequest.charset()))
    762763        return Reload;
    763764
  • trunk/Source/WebCore/loader/cache/CachedSVGDocument.h

    r197563 r199881  
    4242    void setEncoding(const String&) override;
    4343    String encoding() const override;
     44    const TextResourceDecoder* textResourceDecoder() const override { return m_decoder.get(); }
    4445    void finishLoading(SharedBuffer*) override;
    4546
  • trunk/Source/WebCore/loader/cache/CachedScript.h

    r197563 r199881  
    5454    void setEncoding(const String&) override;
    5555    String encoding() const override;
     56    const TextResourceDecoder* textResourceDecoder() const override { return m_decoder.get(); }
    5657    void finishLoading(SharedBuffer*) override;
    5758
  • trunk/Source/WebCore/loader/cache/CachedXSLStyleSheet.h

    r197563 r199881  
    4848    void setEncoding(const String&) override;
    4949    String encoding() const override;
     50    const TextResourceDecoder* textResourceDecoder() const override { return m_decoder.get(); }
    5051    void finishLoading(SharedBuffer*) override;
    5152
Note: See TracChangeset for help on using the changeset viewer.