Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/PageSerializer.cpp |
| diff --git a/third_party/WebKit/Source/core/page/PageSerializer.cpp b/third_party/WebKit/Source/core/page/PageSerializer.cpp |
| index a1a484551dd8f0eaf8262e46f15651a8f413d970..2639dd05b4441f9b7dc8bf0f5a98acc7c97980ef 100644 |
| --- a/third_party/WebKit/Source/core/page/PageSerializer.cpp |
| +++ b/third_party/WebKit/Source/core/page/PageSerializer.cpp |
| @@ -82,6 +82,21 @@ static bool shouldIgnoreElement(const Element& element) |
| return isHTMLMetaElement(element) && toHTMLMetaElement(element).computeEncoding().isValid(); |
| } |
| +bool PageSerializer::Delegate::shouldIgnoreAttribute(const Attribute&) |
| +{ |
| + return false; |
| +} |
| + |
| +bool PageSerializer::Delegate::rewriteLink(const Element&, String& rewrittenLink) |
| +{ |
| + return false; |
| +} |
| + |
| +bool PageSerializer::Delegate::shouldSkipResource(const KURL&) |
| +{ |
| + return false; |
| +} |
| + |
| class SerializerMarkupAccumulator : public MarkupAccumulator { |
| STACK_ALLOCATED(); |
| public: |
| @@ -298,7 +313,6 @@ void PageSerializer::serializeFrame(const LocalFrame& frame) |
| if (CSSStyleSheet* sheet = linkElement.sheet()) { |
| KURL url = document.completeURL(linkElement.getAttribute(HTMLNames::hrefAttr)); |
| serializeCSSStyleSheet(*sheet, url); |
| - ASSERT(m_resourceURLs.contains(url)); |
| } |
| } else if (isHTMLStyleElement(element)) { |
| HTMLStyleElement& styleElement = toHTMLStyleElement(element); |
| @@ -328,7 +342,7 @@ void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet, const KUR |
| serializeCSSRule(rule); |
| } |
| - if (url.isValid() && !m_resourceURLs.contains(url)) { |
| + if (shouldAddURL(url)) { |
| WTF::TextEncoding textEncoding(styleSheet.contents()->charset()); |
| ASSERT(textEncoding.isValid()); |
| String textString = cssText.toString(); |
| @@ -388,7 +402,8 @@ void PageSerializer::serializeCSSRule(CSSRule* rule) |
| bool PageSerializer::shouldAddURL(const KURL& url) |
| { |
| - return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData(); |
| + return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData() |
| + && (!delegate() || !delegate()->shouldSkipResource(url)); |
|
dcheng
2015/12/22 01:01:45
Do we ever construct this with a null delegate? Ma
Łukasz Anforowicz
2015/12/22 21:06:46
Good point. Done.
I also made similar change for
|
| } |
| void PageSerializer::addToResources(Resource* resource, PassRefPtr<SharedBuffer> data, const KURL& url) |