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

Unified Diff: Source/core/dom/Document.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 | « Source/core/dom/Document.h ('k') | Source/core/html/HTMLBaseElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 3a9216003d3c4c679c0e648ce5703314be7db56b..c3e1c948ef2c195d21358091521a24d27b57a8d9 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -536,7 +536,7 @@ Document::~Document()
if (this == topDocument())
clearAXObjectCache();
- m_decoder = 0;
+ setDecoder(PassRefPtr<TextResourceDecoder>());
if (m_styleSheetList)
m_styleSheetList->detachFromDocument();
@@ -1109,14 +1109,12 @@ void Document::setReadyState(ReadyState readyState)
dispatchEvent(Event::create(eventNames().readystatechangeEvent, false, false));
}
-String Document::encoding() const
+String Document::encodingName() const
{
// TextEncoding::domName() returns a char*, no need to allocate a new
// String for it each time.
// FIXME: We should fix TextEncoding to speak AtomicString anyway.
- if (TextResourceDecoder* d = decoder())
- return AtomicString(d->encoding().domName());
- return String();
+ return AtomicString(m_encoding.domName());
}
String Document::defaultCharset() const
@@ -1131,6 +1129,7 @@ void Document::setCharset(const String& charset)
if (!decoder())
return;
decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding);
+ setEncoding(m_decoder->encoding());
}
void Document::setContentLanguage(const String& language)
@@ -3941,6 +3940,12 @@ bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S
void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
{
m_decoder = decoder;
+ setEncoding(m_decoder ? m_decoder->encoding() : WTF::TextEncoding());
+}
+
+void Document::setEncoding(const WTF::TextEncoding& encoding)
+{
+ m_encoding = encoding;
}
KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/html/HTMLBaseElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698