Chromium Code Reviews| Index: third_party/WebKit/Source/web/WebPageSerializerImpl.cpp |
| diff --git a/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp b/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp |
| index 694c823537fd26515f275bd1652c7d9b25ae848e..dae6be2b83589f54d21dd41a566007e9bb56d3fb 100644 |
| --- a/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp |
| +++ b/third_party/WebKit/Source/web/WebPageSerializerImpl.cpp |
| @@ -93,6 +93,8 @@ |
| #include "core/page/PageSerializer.h" |
| #include "public/platform/WebVector.h" |
| #include "web/WebLocalFrameImpl.h" |
| +#include "wtf/ArrayBufferBuilder.h" |
| +#include "wtf/text/CString.h" |
| #include "wtf/text/TextEncoding.h" |
| namespace blink { |
| @@ -274,8 +276,26 @@ void WebPageSerializerImpl::encodeAndFlushBuffer( |
| CString encodedContent = param->textEncoding.encode(content, WTF::EntitiesForUnencodables); |
| + CString encodedBOM; |
|
jsbell
2015/12/07 22:53:51
Move this block up above the encodedContent initia
|
| + if (m_noBytesEncodedYet) { |
| + encodedBOM = param->textEncoding.encodeBOMifApplicable(); |
|
jsbell
2015/12/07 22:53:51
I was going to suggest some changes to encodeBOMif
|
| + m_noBytesEncodedYet = false; |
| + } |
| + |
| + WebCString result; |
| + if (encodedBOM.length() == 0) { |
| + result = WebCString(encodedContent); |
| + } else { |
| + ArrayBufferBuilder resultBuilder; |
| + resultBuilder.append(encodedBOM.data(), encodedBOM.length()); |
| + resultBuilder.append(encodedContent.data(), encodedContent.length()); |
| + result = WebCString( |
|
jsbell
2015/12/07 22:53:51
Don't need to wrap in blink.
|
| + static_cast<const char*>(resultBuilder.data()), |
| + resultBuilder.byteLength()); |
| + } |
| + |
| // Send result to the client. |
| - m_client->didSerializeDataForFrame(WebCString(encodedContent), status); |
| + m_client->didSerializeDataForFrame(result, status); |
| } |
| // TODO(yosin): We should utilize |MarkupFormatter| here to share code, |
| @@ -423,6 +443,7 @@ WebPageSerializerImpl::WebPageSerializerImpl(WebLocalFrame* frame, |
| const WebString& localDirectoryName) |
| : m_client(client) |
| , m_localDirectoryName(localDirectoryName) |
| + , m_noBytesEncodedYet(true) |
| , m_htmlEntities(false) |
| , m_xmlEntities(true) |
| { |