Chromium Code Reviews| Index: Source/core/page/PageSerializer.cpp |
| diff --git a/Source/core/page/PageSerializer.cpp b/Source/core/page/PageSerializer.cpp |
| index 2fce87965a1f796e03557b583f3bed9345113874..8e863ddf5bb8a455b83ccb28edf2563538d96404 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,15 +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); |
| + WTF::TextEncoding textEncoding(document.charset()); |
|
philipj_slow
2015/06/10 09:09:30
Try document.encoding(), it's what backs document.
Tiger (Sony Mobile)
2015/06/10 09:38:08
Will fix
|
| CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUnencodables); |
| m_resources->append(SerializedResource(url, document.suggestedMIMEType(), SharedBuffer::create(frameHTML.data(), frameHTML.length()))); |
| m_resourceURLs.add(url); |
| @@ -343,7 +346,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->image() == Image::nullImage() || image->errorOccurred()) |
|
philipj_slow
2015/06/10 09:09:30
Would removing the |image->image() == Image::nullI
Tiger (Sony Mobile)
2015/06/10 09:38:08
Yes, removing that part should be ok.
|
| return; |
| RefPtr<SharedBuffer> data = imageLayoutObject ? image->imageForLayoutObject(imageLayoutObject)->data() : nullptr; |