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

Unified Diff: third_party/WebKit/Source/web/WebPageSerializer.cpp

Issue 1436683002: Making PageSerializer operate on single frames only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-removing-unused-code
Patch Set: Created 5 years, 1 month 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/web/WebPageSerializer.cpp
diff --git a/third_party/WebKit/Source/web/WebPageSerializer.cpp b/third_party/WebKit/Source/web/WebPageSerializer.cpp
index 193da0a60ca134135d630398d24c567b403cd21d..336926b057a528da0b119caf7364686516f201fb 100644
--- a/third_party/WebKit/Source/web/WebPageSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebPageSerializer.cpp
@@ -87,10 +87,38 @@ bool MHTMLPageSerializerDelegate::shouldIgnoreAttribute(const Attribute& attribu
static PassRefPtr<SharedBuffer> serializePageToMHTML(Page* page, MHTMLArchive::EncodingPolicy encodingPolicy)
dcheng 2015/11/12 23:47:32 Is this covered by any tests right now?
Łukasz Anforowicz 2015/11/13 00:22:10 If "this" = "serializePageToMHTML function", then
{
Vector<SerializedResource> resources;
+ HashSet<KURL> alreadySerializedUrls;
PageSerializer serializer(&resources, adoptPtr(new MHTMLPageSerializerDelegate));
- serializer.serialize(page);
+
+ RefPtr<SharedBuffer> output = SharedBuffer::create();
+ String boundary = MHTMLArchive::generateMHTMLBoundary();
+
Document* document = page->deprecatedLocalMainFrame()->document();
- return MHTMLArchive::generateMHTMLData(resources, encodingPolicy, document->title(), document->suggestedMIMEType());
+ MHTMLArchive::generateMHTMLHeader(
+ boundary, document->title(), document->suggestedMIMEType(), *output);
+
+ Frame* frame = page->deprecatedLocalMainFrame();
+ for (; frame; frame = frame->tree().traverseNext()) {
+ // TODO(lukasza): This causes incomplete MHTML for OOPIFs.
+ // (crbug.com/538766)
+ if (!frame->isLocalFrame())
+ continue;
+
+ resources.clear();
+ serializer.serializeFrame(toLocalFrame(frame));
+
+ for (const auto& resource : resources) {
+ if (alreadySerializedUrls.contains(resource.url))
+ continue;
+ alreadySerializedUrls.add(resource.url);
+
+ MHTMLArchive::generateMHTMLPart(
+ boundary, encodingPolicy, resource, *output);
+ }
+ }
+
+ MHTMLArchive::generateMHTMLFooter(boundary, *output);
+ return output.release();
}
WebCString WebPageSerializer::serializeToMHTML(WebView* view)

Powered by Google App Engine
This is Rietveld 408576698