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

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

Issue 1167413004: Merge page serializers [4/12] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix nits Created 5 years, 6 months 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
« no previous file with comments | « no previous file | Source/web/tests/PageSerializerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/PageSerializer.cpp
diff --git a/Source/core/page/PageSerializer.cpp b/Source/core/page/PageSerializer.cpp
index 2fce87965a1f796e03557b583f3bed9345113874..3fa687418c38a82422d04e4a72e1101714583a02 100644
--- a/Source/core/page/PageSerializer.cpp
+++ b/Source/core/page/PageSerializer.cpp
@@ -56,10 +56,11 @@
#include "core/html/HTMLLinkElement.h"
#include "core/html/HTMLMetaElement.h"
#include "core/html/HTMLStyleElement.h"
+#include "core/html/ImageDocument.h"
#include "core/html/parser/HTMLParserIdioms.h"
+#include "core/page/Page.h"
#include "core/style/StyleFetchedImage.h"
#include "core/style/StyleImage.h"
-#include "core/page/Page.h"
#include "platform/SerializedResource.h"
#include "platform/graphics/Image.h"
#include "wtf/OwnPtr.h"
@@ -226,16 +227,17 @@ void PageSerializer::serializeFrame(LocalFrame* frame)
return;
}
- WTF::TextEncoding textEncoding(document.charset());
- if (!textEncoding.isValid()) {
- // FIXME: iframes used as images trigger this. We should deal with them correctly.
+ // If frame is an image document, add the image and don't continue
+ if (document.isImageDocument()) {
+ ImageDocument& imageDocument = toImageDocument(document);
+ addImageToResources(imageDocument.cachedImage(), imageDocument.imageElement()->layoutObject(), url);
return;
}
WillBeHeapVector<RawPtrWillBeMember<Node>> serializedNodes;
SerializerMarkupAccumulator accumulator(this, document, serializedNodes);
String text = serializeNodes<EditingStrategy>(accumulator, document, IncludeNode);
- CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUnencodables);
+ CString frameHTML = document.encoding().normalizeAndEncode(text, WTF::EntitiesForUnencodables);
m_resources->append(SerializedResource(url, document.suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length())));
m_resourceURLs.add(url);
@@ -343,7 +345,7 @@ void PageSerializer::addImageToResources(ImageResource* image, LayoutObject* ima
if (!shouldAddURL(url))
return;
- if (!image || image->image() == Image::nullImage() || image->errorOccurred())
+ if (!image || !image->hasImage() || image->errorOccurred())
return;
RefPtr<SharedBuffer> data = imageLayoutObject ? image->imageForLayoutObject(imageLayoutObject)->data() : nullptr;
« no previous file with comments | « no previous file | Source/web/tests/PageSerializerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698