| Index: Source/core/dom/Document.cpp
|
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
|
| index 15500c05e3f1044605f35c5b8c068109bd7d8ba3..7fa9541144831a0bf27f764d7a0e3f0706f09bb3 100644
|
| --- a/Source/core/dom/Document.cpp
|
| +++ b/Source/core/dom/Document.cpp
|
| @@ -518,8 +518,6 @@ Document::~Document()
|
| if (this == topDocument())
|
| clearAXObjectCache();
|
|
|
| - setDecoder(PassRefPtr<TextResourceDecoder>());
|
| -
|
| if (m_styleSheetList)
|
| m_styleSheetList->detachFromDocument();
|
|
|
| @@ -1100,7 +1098,7 @@ String Document::encodingName() const
|
| // TextEncoding::name() returns a char*, no need to allocate a new
|
| // String for it each time.
|
| // FIXME: We should fix TextEncoding to speak AtomicString anyway.
|
| - return AtomicString(m_encoding.name());
|
| + return AtomicString(m_encoding.domName());
|
| }
|
|
|
| String Document::defaultCharset() const
|
| @@ -1112,10 +1110,15 @@ String Document::defaultCharset() const
|
|
|
| void Document::setCharset(const String& charset)
|
| {
|
| - if (!decoder())
|
| + if (DocumentLoader* documentLoader = loader())
|
| + documentLoader->setUserChosenEncoding(charset);
|
| + WTF::TextEncoding encoding(charset);
|
| + // In case the encoding didn't exist, we keep the old one (helps some sites specifying invalid encodings).
|
| + if (!encoding.isValid())
|
| return;
|
| - decoder()->setEncoding(charset, TextResourceDecoder::UserChosenEncoding);
|
| - setEncoding(m_decoder->encoding());
|
| + DocumentEncodingData data;
|
| + data.encoding = encoding;
|
| + setEncoding(data);
|
| }
|
|
|
| void Document::setContentLanguage(const String& language)
|
| @@ -3953,13 +3956,9 @@ bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S
|
| return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16(), length, prefix, localName, es);
|
| }
|
|
|
| -void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
|
| -{
|
| - m_decoder = decoder;
|
| - setEncoding(m_decoder ? m_decoder->encoding() : WTF::TextEncoding());
|
| -}
|
| -
|
| -void Document::setEncoding(const WTF::TextEncoding& encoding)
|
| +Document::DocumentEncodingData::DocumentEncodingData()
|
| + : wasDetectedHeuristically(false)
|
| + , sawDecodingError(false)
|
| {
|
| if (m_encoding == encoding)
|
| return;
|
| @@ -3982,6 +3981,13 @@ void Document::setEncoding(const WTF::TextEncoding& encoding)
|
| }
|
|
|
| m_encoding = encoding;
|
| + m_encodingWasDetectedHeuristically = wasDetectedHeuristically;
|
| + m_sawDecodingError = sawDecodingError;
|
| +}
|
| +
|
| +void Document::setEncoding(DocumentEncodingData data)
|
| +{
|
| + m_encodingData = data;
|
| }
|
|
|
| KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const
|
| @@ -3992,9 +3998,9 @@ KURL Document::completeURL(const String& url, const KURL& baseURLOverride) const
|
| if (url.isNull())
|
| return KURL();
|
| const KURL& baseURL = ((baseURLOverride.isEmpty() || baseURLOverride == blankURL()) && parentDocument()) ? parentDocument()->baseURL() : baseURLOverride;
|
| - if (!m_decoder)
|
| + if (!encoding().isValid())
|
| return KURL(baseURL, url);
|
| - return KURL(baseURL, url, m_decoder->encoding());
|
| + return KURL(baseURL, url, encoding());
|
| }
|
|
|
| KURL Document::completeURL(const String& url) const
|
|
|