| Index: Source/core/html/parser/HTMLPreloadScanner.cpp | 
| diff --git a/Source/core/html/parser/HTMLPreloadScanner.cpp b/Source/core/html/parser/HTMLPreloadScanner.cpp | 
| index 79fb5611b843bf476ac278893b53deb26426128c..b0b463421340106ed9600079963e2ec3a8609df5 100644 | 
| --- a/Source/core/html/parser/HTMLPreloadScanner.cpp | 
| +++ b/Source/core/html/parser/HTMLPreloadScanner.cpp | 
| @@ -85,20 +85,37 @@ static String initiatorFor(const StringImpl* tagImpl) | 
| return linkTag.localName(); | 
| if (match(tagImpl, scriptTag)) | 
| return scriptTag.localName(); | 
| +#if ENABLE(PICTURE) | 
| +    if (match(tagImpl, sourceTag)) | 
| +        return sourceTag.localName(); | 
| +    if (match(tagImpl, pictureTag)) | 
| +        return pictureTag.localName(); | 
| +#endif | 
| ASSERT_NOT_REACHED(); | 
| return "unknown"; | 
| } | 
|  | 
| class TokenPreloadScanner::StartTagScanner { | 
| public: | 
| -    explicit StartTagScanner(const StringImpl* tagImpl) | 
| +    explicit StartTagScanner(const StringImpl* tagImpl | 
| +#if ENABLE(PICTURE) | 
| +        , bool inPicture | 
| +#endif | 
| +        ) | 
| : m_tagImpl(tagImpl) | 
| , m_linkIsStyleSheet(false) | 
| , m_inputIsImage(false) | 
| +#if ENABLE(PICTURE) | 
| +        , m_tagInPicture(inPicture) | 
| +#endif | 
| { | 
| if (!match(m_tagImpl, imgTag) | 
| && !match(m_tagImpl, inputTag) | 
| && !match(m_tagImpl, linkTag) | 
| +#if ENABLE(PICTURE) | 
| +            && !match(m_tagImpl, pictureTag) | 
| +            && !match(m_tagImpl, sourceTag) | 
| +#endif | 
| && !match(m_tagImpl, scriptTag)) | 
| m_tagImpl = 0; | 
| } | 
| @@ -134,6 +151,9 @@ public: | 
| return request.release(); | 
| } | 
|  | 
| +#if ENABLE(PICTURE) | 
| +    bool inPicture() { return m_tagInPicture; } | 
| +#endif | 
| private: | 
| template<typename NameType> | 
| void processAttribute(const NameType& attributeName, const String& attributeValue) | 
| @@ -141,11 +161,27 @@ private: | 
| if (match(attributeName, charsetAttr)) | 
| m_charset = attributeValue; | 
|  | 
| -        if (match(m_tagImpl, scriptTag) || match(m_tagImpl, imgTag)) { | 
| -            if (match(attributeName, srcAttr)) | 
| +        if (match(m_tagImpl, scriptTag) | 
| +            || match(m_tagImpl, imgTag) | 
| +#if ENABLE(PICTURE) | 
| +            || match(m_tagImpl, pictureTag) | 
| +#endif | 
| +            ) { | 
| +            if (match(attributeName, srcAttr)) { | 
| setUrlToLoad(attributeValue); | 
| +#if ENABLE(PICTURE) | 
| +                m_tagInPicture = false; | 
| +#endif | 
| +            } | 
| else if (match(attributeName, crossoriginAttr) && !attributeValue.isNull()) | 
| m_crossOriginMode = stripLeadingAndTrailingHTMLSpaces(attributeValue); | 
| +#if ENABLE(PICTURE) | 
| +        } else if (match(m_tagImpl, sourceTag) && m_tagInPicture) { | 
| +            if (match(attributeName, srcAttr)) | 
| +                setUrlToLoad(attributeValue); | 
| +            else if (match(attributeName, mediaAttr)) | 
| +                m_mediaAttribute = attributeValue; | 
| +#endif | 
| } else if (match(m_tagImpl, linkTag)) { | 
| if (match(attributeName, hrefAttr)) | 
| setUrlToLoad(attributeValue); | 
| @@ -188,7 +224,13 @@ private: | 
| { | 
| if (match(m_tagImpl, scriptTag)) | 
| return CachedResource::Script; | 
| -        if (match(m_tagImpl, imgTag) || (match(m_tagImpl, inputTag) && m_inputIsImage)) | 
| +        if (match(m_tagImpl, imgTag) | 
| +            || (match(m_tagImpl, inputTag) && m_inputIsImage) | 
| +#if ENABLE(PICTURE) | 
| +            || (match(m_tagImpl, pictureTag)) | 
| +            || (match(m_tagImpl, sourceTag)) | 
| +#endif | 
| +            ) | 
| return CachedResource::ImageResource; | 
| if (match(m_tagImpl, linkTag) && m_linkIsStyleSheet) | 
| return CachedResource::CSSStyleSheet; | 
| @@ -219,8 +261,18 @@ private: | 
| bool m_linkIsStyleSheet; | 
| String m_mediaAttribute; | 
| bool m_inputIsImage; | 
| +#if ENABLE(PICTURE) | 
| +    bool m_tagInPicture; | 
| +#endif | 
| }; | 
|  | 
| +static void appendBundleRequest(PreloadRequestStream& requests, bool start, bool end) | 
| +{ | 
| +    OwnPtr<PreloadRequest> request = PreloadRequest::create(start, end); | 
| +    if (request) | 
| +        requests.append(request.release()); | 
| +} | 
| + | 
| TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL) | 
| : m_documentURL(documentURL) | 
| , m_inStyle(false) | 
| @@ -250,18 +302,18 @@ void TokenPreloadScanner::rewindTo(TokenPreloadScannerCheckpoint checkpointIndex | 
| m_checkpoints.clear(); | 
| } | 
|  | 
| -void TokenPreloadScanner::scan(const HTMLToken& token, Vector<OwnPtr<PreloadRequest> >& requests) | 
| +void TokenPreloadScanner::scan(const HTMLToken& token, PreloadRequestStream& requests) | 
| { | 
| scanCommon(token, requests); | 
| } | 
|  | 
| -void TokenPreloadScanner::scan(const CompactHTMLToken& token, Vector<OwnPtr<PreloadRequest> >& requests) | 
| +void TokenPreloadScanner::scan(const CompactHTMLToken& token, PreloadRequestStream& requests) | 
| { | 
| scanCommon(token, requests); | 
| } | 
|  | 
| template<typename Token> | 
| -void TokenPreloadScanner::scanCommon(const Token& token, Vector<OwnPtr<PreloadRequest> >& requests) | 
| +void TokenPreloadScanner::scanCommon(const Token& token, PreloadRequestStream& requests) | 
| { | 
| switch (token.type()) { | 
| case HTMLToken::Character: { | 
| @@ -282,6 +334,12 @@ void TokenPreloadScanner::scanCommon(const Token& token, Vector<OwnPtr<PreloadRe | 
| m_cssScanner.reset(); | 
| m_inStyle = false; | 
| } | 
| +#if ENABLE(PICTURE) | 
| +        else if (match(tagImpl, pictureTag)) { | 
| +            m_inPicture = false; | 
| +            appendBundleRequest(requests, false, true); | 
| +        } | 
| +#endif | 
| return; | 
| } | 
| case HTMLToken::StartTag: { | 
| @@ -296,6 +354,12 @@ void TokenPreloadScanner::scanCommon(const Token& token, Vector<OwnPtr<PreloadRe | 
| m_inStyle = true; | 
| return; | 
| } | 
| +#if ENABLE(PICTURE) | 
| +        if (match(tagImpl, pictureTag)) { | 
| +            m_inPicture = true; | 
| +            appendBundleRequest(requests, true, false); | 
| +        } | 
| +#endif | 
| if (match(tagImpl, baseTag)) { | 
| // The first <base> element is the one that wins. | 
| if (!m_predictedBaseElementURL.isEmpty()) | 
| @@ -304,8 +368,15 @@ void TokenPreloadScanner::scanCommon(const Token& token, Vector<OwnPtr<PreloadRe | 
| return; | 
| } | 
|  | 
| -        StartTagScanner scanner(tagImpl); | 
| +        StartTagScanner scanner(tagImpl | 
| +#if ENABLE(PICTURE) | 
| +                                , m_inPicture | 
| +#endif | 
| +                                ); | 
| scanner.processAttributes(token.attributes()); | 
| +#if ENABLE(PICTURE) | 
| +        m_inPicture = scanner.inPicture(); | 
| +#endif | 
| OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predictedBaseElementURL); | 
| if (request) | 
| requests.append(request.release()); | 
|  |