Bug 1373984 - Turn nsIDocument::mCharacterSet into mozilla::NotNull<const mozilla::Encoding*>. r=hsivonen

MozReview-Commit-ID: GF0YXDwfA14
This commit is contained in:
Masatoshi Kimura
2017-06-18 20:37:50 +09:00
parent 8ddaccacfb
commit cff1fdcb48
81 changed files with 584 additions and 450 deletions

View File

@@ -126,6 +126,7 @@ public:
* default constructor
*/
nsParser::nsParser()
: mCharset(WINDOWS_1252_ENCODING)
{
Initialize(true);
}
@@ -150,7 +151,7 @@ nsParser::Initialize(bool aConstructor)
mContinueEvent = nullptr;
mCharsetSource = kCharsetUninitialized;
mCharset.AssignLiteral("windows-1252");
mCharset = WINDOWS_1252_ENCODING;
mInternalState = NS_OK;
mStreamStatus = NS_OK;
mCommand = eViewNormal;
@@ -283,8 +284,9 @@ nsParser::SetCommand(eParserCommands aParserCommand)
* @param aCharset- the charset of a document
* @param aCharsetSource- the source of the charset
*/
NS_IMETHODIMP_(void)
nsParser::SetDocumentCharset(const nsACString& aCharset, int32_t aCharsetSource)
void
nsParser::SetDocumentCharset(NotNull<const Encoding*> aCharset,
int32_t aCharsetSource)
{
mCharset = aCharset;
mCharsetSource = aCharsetSource;
@@ -294,7 +296,7 @@ nsParser::SetDocumentCharset(const nsACString& aCharset, int32_t aCharsetSource)
}
void
nsParser::SetSinkCharset(nsACString& aCharset)
nsParser::SetSinkCharset(NotNull<const Encoding*> aCharset)
{
if (mSink) {
mSink->SetDocumentCharset(aCharset);
@@ -1331,8 +1333,7 @@ ParserWriteFunc(nsIInputStream* in,
if (pws->mNeedCharsetCheck) {
pws->mNeedCharsetCheck = false;
int32_t source;
nsAutoCString preferred;
pws->mParser->GetDocumentCharset(preferred, source);
auto preferred = pws->mParser->GetDocumentCharset(source);
// This code was bogus when I found it. It expects the BOM or the XML
// declaration to be entirely in the first network buffer. -- hsivonen
@@ -1344,7 +1345,7 @@ ParserWriteFunc(nsIInputStream* in,
// The decoder will swallow the BOM. The UTF-16 will re-sniff for
// endianness. The value of preferred is now "UTF-8", "UTF-16LE"
// or "UTF-16BE".
encoding->Name(preferred);
preferred = WrapNotNull(encoding);
source = kCharsetFromByteOrderMark;
} else if (source < kCharsetFromChannel) {
nsAutoCString declCharset;
@@ -1352,7 +1353,7 @@ ParserWriteFunc(nsIInputStream* in,
if (ExtractCharsetFromXmlDeclaration(buf, count, declCharset)) {
encoding = Encoding::ForLabel(declCharset);
if (encoding) {
encoding->Name(preferred);
preferred = WrapNotNull(encoding);
source = kCharsetFromMetaTag;
}
}