Chromium Code Reviews| 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) |