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

Unified Diff: Source/core/dom/DecodedDataDocumentParser.cpp

Issue 22909053: Store the Document's encoding on the Document (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Set document encoding in DecodedDataDocumentParser instead of DocumentWriter Created 7 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/Document.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/DecodedDataDocumentParser.cpp
diff --git a/Source/core/dom/DecodedDataDocumentParser.cpp b/Source/core/dom/DecodedDataDocumentParser.cpp
index 7ceaabe6d582fc797f5350d51b1ba5743c7f734d..5450170442c19280cc284535fd7b65d94d262301 100644
--- a/Source/core/dom/DecodedDataDocumentParser.cpp
+++ b/Source/core/dom/DecodedDataDocumentParser.cpp
@@ -40,7 +40,7 @@ class TitleEncodingFixer {
public:
explicit TitleEncodingFixer(Document* document)
: m_document(document)
- , m_firstEncoding(document->decoder()->encoding())
+ , m_firstEncoding(document->encoding())
{
}
@@ -52,7 +52,7 @@ public:
// in the title bar.
inline void fixTitleEncodingIfNeeded()
{
- if (m_firstEncoding == m_document->decoder()->encoding())
+ if (m_firstEncoding == m_document->encoding())
return; // In the common case, the encoding doesn't change and there isn't any work to do.
fixTitleEncoding();
}
@@ -73,7 +73,7 @@ void TitleEncodingFixer::fixTitleEncoding()
|| !titleElement->textContent().containsOnlyLatin1())
return; // Either we don't have a title yet or something bizzare as happened and we give up.
CString originalBytes = titleElement->textContent().latin1();
- OwnPtr<TextCodec> codec = newTextCodec(m_document->decoder()->encoding());
+ OwnPtr<TextCodec> codec = newTextCodec(m_document->encoding());
String correctlyDecodedTitle = codec->decode(originalBytes.data(), originalBytes.length(), true);
titleElement->setTextContent(correctlyDecodedTitle, IGNORE_EXCEPTION);
}
@@ -93,6 +93,7 @@ size_t DecodedDataDocumentParser::appendBytes(const char* data, size_t length)
TitleEncodingFixer encodingFixer(document());
String decoded = document()->decoder()->decode(data, length);
+ document()->setEncoding(document()->decoder()->encoding());
encodingFixer.fixTitleEncodingIfNeeded();
@@ -113,6 +114,7 @@ size_t DecodedDataDocumentParser::flush()
if (!decoder)
return 0;
String remainingData = decoder->flush();
+ document()->setEncoding(document()->decoder()->encoding());
if (remainingData.isEmpty())
return 0;
« no previous file with comments | « no previous file | Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698