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

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: Addressed CR feedback from Daniel. 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..59120dd291cf171e08b1a34959b273e5785f400c 100644
--- a/third_party/WebKit/Source/web/WebPageSerializer.cpp
+++ b/third_party/WebKit/Source/web/WebPageSerializer.cpp
@@ -87,10 +87,39 @@ bool MHTMLPageSerializerDelegate::shouldIgnoreAttribute(const Attribute& attribu
static PassRefPtr<SharedBuffer> serializePageToMHTML(Page* page, MHTMLArchive::EncodingPolicy encodingPolicy)
{
Vector<SerializedResource> resources;
+ HashSet<KURL> alreadySerializedUrls;
dcheng 2015/11/18 03:27:12 How come we weren't previously deduping?
Łukasz Anforowicz 2015/11/18 18:40:41 You're right - my changes here don't make sense...
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();
dcheng 2015/11/18 03:27:12 I don't think you need this outside the loop, so j
Łukasz Anforowicz 2015/11/18 18:40:41 Done. (for some reason I was previously worried a
+ for (; frame; frame = frame->tree().traverseNext()) {
+ // TODO(lukasza): This causes incomplete MHTML for OOPIFs.
+ // (crbug.com/538766)
+ if (!frame->isLocalFrame())
+ continue;
+
+ resources.clear();
+ LocalFrame* localFrame = toLocalFrame(frame);
+ serializer.serializeFrame(*localFrame);
dcheng 2015/11/18 03:27:12 Ditto: just inline toLocalFrame(*frame)
Łukasz Anforowicz 2015/11/18 18:40:41 Done. (for some reason previously I was worried t
+
+ 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