Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: third_party/WebKit/Source/core/page/PageSerializer.cpp

Issue 1417323006: OOPIFs: Deduplicating MHTML parts across frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-serialization-per-frame
Patch Set: Introduced MHTMLPartsGenerationDelegate interface. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698