Changeset 224763 in webkit


Ignore:
Timestamp:
Nov 13, 2017 11:33:19 AM (6 years ago)
Author:
achristensen@apple.com
Message:

Source/WebCore:
Added mime type check to the picture source preloader to avoid downloading incompatible resources.
https://bugs.webkit.org/show_bug.cgi?id=179231

Patch by Colin Bendell <colin> on 2017-11-13
Reviewed by Alex Christensen.

Test: http/tests/loading/preload-picture-type.html

  • html/parser/HTMLPreloadScanner.cpp:

(WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): include type match state when selecting candidate imgs
(WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): added type attribute evaluation and matching

LayoutTests:
Add tests to ensure that <source> tags are only preloaded when the type
attribute matches.
https://bugs.webkit.org/show_bug.cgi?id=179231

Patch by Colin Bendell <colin> on 2017-11-13
Reviewed by Alex Christensen.

  • http/tests/preload/picture-type-expected.txt: Added.
  • http/tests/preload/picture-type.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224760 r224763  
     12017-11-13  Colin Bendell  <colin@bendell.ca>
     2
     3        Add tests to ensure that <source> tags are only preloaded when the `type`
     4        attribute matches.
     5        https://bugs.webkit.org/show_bug.cgi?id=179231
     6
     7        Reviewed by Alex Christensen.
     8
     9        * http/tests/preload/picture-type-expected.txt: Added.
     10        * http/tests/preload/picture-type.html: Added.
     11
    1122017-11-13  Antoine Quint  <graouts@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r224760 r224763  
     12017-11-13  Colin Bendell  <colin@bendell.ca>
     2
     3        Added mime type check to the picture source preloader to avoid downloading incompatible resources.
     4        https://bugs.webkit.org/show_bug.cgi?id=179231
     5
     6        Reviewed by Alex Christensen.
     7
     8        Test: http/tests/loading/preload-picture-type.html
     9
     10        * html/parser/HTMLPreloadScanner.cpp:
     11        (WebCore::TokenPreloadScanner::StartTagScanner::processAttributes): include type match state when selecting candidate imgs
     12        (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): added type attribute evaluation and matching
     13
    1142017-11-13  Antoine Quint  <graouts@apple.com>
    215
  • trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp

    r224703 r224763  
    3737#include "LinkRelAttribute.h"
    3838#include "Logging.h"
     39#include "MIMETypeRegistry.h"
    3940#include "MediaList.h"
    4041#include "MediaQueryEvaluator.h"
     
    122123        }
    123124       
    124         if (m_tagId == TagId::Source && !pictureState.isEmpty() && !pictureState.last() && m_mediaMatched && !m_srcSetAttribute.isEmpty()) {
     125        if (m_tagId == TagId::Source && !pictureState.isEmpty() && !pictureState.last() && m_mediaMatched && m_typeMatched && !m_srcSetAttribute.isEmpty()) {
    125126           
    126127            auto sourceSize = SizesAttributeParser(m_sizesAttribute, document).length();
     
    219220                LOG(MediaQueries, "HTMLPreloadScanner %p processAttribute evaluating media queries", this);
    220221                m_mediaMatched = MediaQueryEvaluator { document.printing() ? "print" : "screen", document, documentElement ? documentElement->computedStyle() : nullptr }.evaluate(mediaSet.get());
     222            }
     223            if (match(attributeName, typeAttr) && m_typeAttribute.isNull()) {
     224                // when multiple type attributes present: first value wins, ignore subsequent (to match ImageElement parser and Blink behaviours)
     225                m_typeAttribute = attributeValue;
     226                m_typeMatched &= MIMETypeRegistry::isSupportedImageOrSVGMIMEType(m_typeAttribute);
    221227            }
    222228            break;
     
    342348    String m_sizesAttribute;
    343349    bool m_mediaMatched { true };
     350    bool m_typeMatched { true };
    344351    String m_charset;
    345352    String m_crossOriginMode;
Note: See TracChangeset for help on using the changeset viewer.