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

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: Rebased after landing the test files in a separate CL. 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 { 436 {
437 bool didSerialization = false; 437 bool didSerialization = false;
438 438
439 Document* document = m_specifiedWebLocalFrameImpl->frame()->document(); 439 Document* document = m_specifiedWebLocalFrameImpl->frame()->document();
440 const KURL& url = document->url(); 440 const KURL& url = document->url();
441 441
442 if (url.isValid()) { 442 if (url.isValid()) {
443 didSerialization = true; 443 didSerialization = true;
444 444
445 const WTF::TextEncoding& textEncoding = document->encoding().isValid() ? document->encoding() : UTF8Encoding(); 445 const WTF::TextEncoding& textEncoding = document->encoding().isValid() ? document->encoding() : UTF8Encoding();
446 if (textEncoding.isNonByteBasedEncoding()) {
447 const UChar byteOrderMark = 0xFEFF;
448 m_dataBuffer.append(byteOrderMark);
449 }
446 450
447 SerializeDomParam param(url, textEncoding, document); 451 SerializeDomParam param(url, textEncoding, document);
448 452
449 Element* documentElement = document->documentElement(); 453 Element* documentElement = document->documentElement();
450 if (documentElement) 454 if (documentElement)
451 buildContentForNode(documentElement, &param); 455 buildContentForNode(documentElement, &param);
452 456
453 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p aram, ForceFlush); 457 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p aram, ForceFlush);
454 } else { 458 } else {
455 // Report empty contents for invalid URLs. 459 // Report empty contents for invalid URLs.
456 m_client->didSerializeDataForFrame( 460 m_client->didSerializeDataForFrame(
457 WebCString(), WebPageSerializerClient::CurrentFrameIsFinished); 461 WebCString(), WebPageSerializerClient::CurrentFrameIsFinished);
458 } 462 }
459 463
460 ASSERT(m_dataBuffer.isEmpty()); 464 ASSERT(m_dataBuffer.isEmpty());
461 return didSerialization; 465 return didSerialization;
462 } 466 }
463 467
464 } // namespace blink 468 } // namespace blink
OLDNEW
« no previous file with comments | « chrome/test/data/save_page/frames-encodings.htm ('k') | third_party/WebKit/Source/wtf/text/TextEncoding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698