Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "core/editing/MarkupAccumulator.h" | 49 #include "core/editing/MarkupAccumulator.h" |
| 50 #include "core/fetch/FontResource.h" | 50 #include "core/fetch/FontResource.h" |
| 51 #include "core/fetch/ImageResource.h" | 51 #include "core/fetch/ImageResource.h" |
| 52 #include "core/frame/LocalFrame.h" | 52 #include "core/frame/LocalFrame.h" |
| 53 #include "core/html/HTMLFrameOwnerElement.h" | 53 #include "core/html/HTMLFrameOwnerElement.h" |
| 54 #include "core/html/HTMLImageElement.h" | 54 #include "core/html/HTMLImageElement.h" |
| 55 #include "core/html/HTMLInputElement.h" | 55 #include "core/html/HTMLInputElement.h" |
| 56 #include "core/html/HTMLLinkElement.h" | 56 #include "core/html/HTMLLinkElement.h" |
| 57 #include "core/html/HTMLMetaElement.h" | 57 #include "core/html/HTMLMetaElement.h" |
| 58 #include "core/html/HTMLStyleElement.h" | 58 #include "core/html/HTMLStyleElement.h" |
| 59 #include "core/html/ImageDocument.h" | |
| 59 #include "core/html/parser/HTMLParserIdioms.h" | 60 #include "core/html/parser/HTMLParserIdioms.h" |
| 61 #include "core/page/Page.h" | |
| 60 #include "core/style/StyleFetchedImage.h" | 62 #include "core/style/StyleFetchedImage.h" |
| 61 #include "core/style/StyleImage.h" | 63 #include "core/style/StyleImage.h" |
| 62 #include "core/page/Page.h" | |
| 63 #include "platform/SerializedResource.h" | 64 #include "platform/SerializedResource.h" |
| 64 #include "platform/graphics/Image.h" | 65 #include "platform/graphics/Image.h" |
| 65 #include "wtf/OwnPtr.h" | 66 #include "wtf/OwnPtr.h" |
| 66 #include "wtf/text/CString.h" | 67 #include "wtf/text/CString.h" |
| 67 #include "wtf/text/StringBuilder.h" | 68 #include "wtf/text/StringBuilder.h" |
| 68 #include "wtf/text/TextEncoding.h" | 69 #include "wtf/text/TextEncoding.h" |
| 69 #include "wtf/text/WTFString.h" | 70 #include "wtf/text/WTFString.h" |
| 70 | 71 |
| 71 namespace blink { | 72 namespace blink { |
| 72 | 73 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 url = urlForBlankFrame(frame); | 220 url = urlForBlankFrame(frame); |
| 220 } | 221 } |
| 221 | 222 |
| 222 if (m_resourceURLs.contains(url)) { | 223 if (m_resourceURLs.contains(url)) { |
| 223 // FIXME: We could have 2 frame with the same URL but which were dynamic ally changed and have now | 224 // FIXME: We could have 2 frame with the same URL but which were dynamic ally changed and have now |
| 224 // different content. So we should serialize both and somehow rename the frame src in the containing | 225 // different content. So we should serialize both and somehow rename the frame src in the containing |
| 225 // frame. Arg! | 226 // frame. Arg! |
| 226 return; | 227 return; |
| 227 } | 228 } |
| 228 | 229 |
| 229 WTF::TextEncoding textEncoding(document.charset()); | 230 // If frame is an image document, add the image and don't continue |
| 230 if (!textEncoding.isValid()) { | 231 if (document.isImageDocument()) { |
| 231 // FIXME: iframes used as images trigger this. We should deal with them correctly. | 232 ImageDocument& imageDocument = toImageDocument(document); |
| 233 addImageToResources(imageDocument.cachedImage(), imageDocument.imageElem ent()->layoutObject(), url); | |
| 232 return; | 234 return; |
| 233 } | 235 } |
| 234 | 236 |
| 235 WillBeHeapVector<RawPtrWillBeMember<Node>> serializedNodes; | 237 WillBeHeapVector<RawPtrWillBeMember<Node>> serializedNodes; |
| 236 SerializerMarkupAccumulator accumulator(this, document, serializedNodes); | 238 SerializerMarkupAccumulator accumulator(this, document, serializedNodes); |
| 237 String text = serializeNodes<EditingStrategy>(accumulator, document, Include Node); | 239 String text = serializeNodes<EditingStrategy>(accumulator, document, Include Node); |
| 240 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
| |
| 238 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn encodables); | 241 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn encodables); |
| 239 m_resources->append(SerializedResource(url, document.suggestedMIMEType(), Sh aredBuffer::create(frameHTML.data(), frameHTML.length()))); | 242 m_resources->append(SerializedResource(url, document.suggestedMIMEType(), Sh aredBuffer::create(frameHTML.data(), frameHTML.length()))); |
| 240 m_resourceURLs.add(url); | 243 m_resourceURLs.add(url); |
| 241 | 244 |
| 242 for (Node* node: serializedNodes) { | 245 for (Node* node: serializedNodes) { |
| 243 ASSERT(node); | 246 ASSERT(node); |
| 244 if (!node->isElementNode()) | 247 if (!node->isElementNode()) |
| 245 continue; | 248 continue; |
| 246 | 249 |
| 247 Element& element = toElement(*node); | 250 Element& element = toElement(*node); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 String mimeType = resource->response().mimeType(); | 339 String mimeType = resource->response().mimeType(); |
| 337 m_resources->append(SerializedResource(url, mimeType, data)); | 340 m_resources->append(SerializedResource(url, mimeType, data)); |
| 338 m_resourceURLs.add(url); | 341 m_resourceURLs.add(url); |
| 339 } | 342 } |
| 340 | 343 |
| 341 void PageSerializer::addImageToResources(ImageResource* image, LayoutObject* ima geLayoutObject, const KURL& url) | 344 void PageSerializer::addImageToResources(ImageResource* image, LayoutObject* ima geLayoutObject, const KURL& url) |
| 342 { | 345 { |
| 343 if (!shouldAddURL(url)) | 346 if (!shouldAddURL(url)) |
| 344 return; | 347 return; |
| 345 | 348 |
| 346 if (!image || image->image() == Image::nullImage() || image->errorOccurred() ) | 349 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.
| |
| 347 return; | 350 return; |
| 348 | 351 |
| 349 RefPtr<SharedBuffer> data = imageLayoutObject ? image->imageForLayoutObject( imageLayoutObject)->data() : nullptr; | 352 RefPtr<SharedBuffer> data = imageLayoutObject ? image->imageForLayoutObject( imageLayoutObject)->data() : nullptr; |
| 350 if (!data) | 353 if (!data) |
| 351 data = image->image()->data(); | 354 data = image->image()->data(); |
| 352 | 355 |
| 353 addToResources(image, data, url); | 356 addToResources(image, data, url); |
| 354 } | 357 } |
| 355 | 358 |
| 356 void PageSerializer::addFontToResources(FontResource* font) | 359 void PageSerializer::addFontToResources(FontResource* font) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 | 416 |
| 414 return fakeURL; | 417 return fakeURL; |
| 415 } | 418 } |
| 416 | 419 |
| 417 PageSerializer::Delegate* PageSerializer::delegate() | 420 PageSerializer::Delegate* PageSerializer::delegate() |
| 418 { | 421 { |
| 419 return m_delegate.get(); | 422 return m_delegate.get(); |
| 420 } | 423 } |
| 421 | 424 |
| 422 } // namespace blink | 425 } // namespace blink |
| OLD | NEW |