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

Side by Side Diff: third_party/WebKit/Source/web/WebPageSerializerImpl.cpp

Issue 1407663004: Tweaking WebPageSerializerImpl to emit a BOM for UTF16/32. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using TextEncoding::isNonByteBasedEncoding instead. Created 5 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 { 446 {
447 bool didSerialization = false; 447 bool didSerialization = false;
448 448
449 Document* document = m_specifiedWebLocalFrameImpl->frame()->document(); 449 Document* document = m_specifiedWebLocalFrameImpl->frame()->document();
450 const KURL& url = document->url(); 450 const KURL& url = document->url();
451 451
452 if (url.isValid()) { 452 if (url.isValid()) {
453 didSerialization = true; 453 didSerialization = true;
454 454
455 const WTF::TextEncoding& textEncoding = document->encoding().isValid() ? document->encoding() : UTF8Encoding(); 455 const WTF::TextEncoding& textEncoding = document->encoding().isValid() ? document->encoding() : UTF8Encoding();
456 if (textEncoding.isNonByteBasedEncoding()) {
457 const UChar bomCharacter = 0xFEFF;
jsbell 2015/12/08 01:19:07 nit: maybe call this `byteOrderMark` as it's not t
Łukasz Anforowicz 2015/12/09 00:50:59 Done.
458 m_dataBuffer.append(bomCharacter);
459 }
456 460
457 SerializeDomParam param(url, textEncoding, document, m_localDirectoryNam e); 461 SerializeDomParam param(url, textEncoding, document, m_localDirectoryNam e);
458 462
459 Element* documentElement = document->documentElement(); 463 Element* documentElement = document->documentElement();
460 if (documentElement) 464 if (documentElement)
461 buildContentForNode(documentElement, &param); 465 buildContentForNode(documentElement, &param);
462 466
463 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p aram, ForceFlush); 467 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p aram, ForceFlush);
464 } else { 468 } else {
465 // Report empty contents for invalid URLs. 469 // Report empty contents for invalid URLs.
466 m_client->didSerializeDataForFrame( 470 m_client->didSerializeDataForFrame(
467 WebCString(), WebPageSerializerClient::CurrentFrameIsFinished); 471 WebCString(), WebPageSerializerClient::CurrentFrameIsFinished);
468 } 472 }
469 473
470 ASSERT(m_dataBuffer.isEmpty()); 474 ASSERT(m_dataBuffer.isEmpty());
471 return didSerialization; 475 return didSerialization;
472 } 476 }
473 477
474 } // namespace blink 478 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698