Bug 1102679 part 1. Pass around the TextDecoderOptions as needed, not just one boolean from it. r=hsivonen

This commit is contained in:
Boris Zbarsky 2018-08-08 14:30:01 -04:00
Родитель 81731ac92a
Коммит ac9ade8709
2 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -15,7 +15,8 @@ namespace mozilla {
namespace dom {
void
TextDecoder::Init(const nsAString& aLabel, const bool aFatal,
TextDecoder::Init(const nsAString& aLabel,
const TextDecoderOptions& aOptions,
ErrorResult& aRv)
{
// Let encoding be the result of getting an encoding from label.
@ -28,18 +29,18 @@ TextDecoder::Init(const nsAString& aLabel, const bool aFatal,
aRv.ThrowRangeError<MSG_ENCODING_NOT_SUPPORTED>(label);
return;
}
InitWithEncoding(WrapNotNull(encoding), aFatal);
InitWithEncoding(WrapNotNull(encoding), aOptions);
}
void
TextDecoder::InitWithEncoding(NotNull<const Encoding*> aEncoding,
const bool aFatal)
const TextDecoderOptions& aOptions)
{
aEncoding->Name(mEncoding);
// If the constructor is called with an options argument,
// and the fatal property of the dictionary is set,
// set the internal fatal flag of the decoder object.
mFatal = aFatal;
mFatal = aOptions.mFatal;
// Create a decoder object for mEncoding.
mDecoder = aEncoding->NewDecoderWithBOMRemoval();

Просмотреть файл

@ -33,7 +33,7 @@ public:
ErrorResult& aRv)
{
nsAutoPtr<TextDecoder> txtDecoder(new TextDecoder());
txtDecoder->Init(aEncoding, aOptions.mFatal, aRv);
txtDecoder->Init(aEncoding, aOptions, aRv);
if (aRv.Failed()) {
return nullptr;
}
@ -60,22 +60,21 @@ public:
* Validates provided label and throws an exception if invalid label.
*
* @param aLabel The encoding label (case insensitive) provided.
* @param aFatal indicates whether to throw an 'EncodingError'
* exception or not when decoding.
* @param aOptions The TextDecoderOptions to use.
* @return aRv EncodingError exception else null.
*/
void Init(const nsAString& aLabel, const bool aFatal, ErrorResult& aRv);
void Init(const nsAString& aLabel, const TextDecoderOptions& aOptions,
ErrorResult& aRv);
/**
* Performs initialization with a Gecko-canonical encoding name (as opposed
* to a label.)
*
* @param aEncoding An Encoding object
* @param aFatal indicates whether to throw an 'EncodingError'
* exception or not when decoding.
* @param aOptions The TextDecoderOptions to use.
*/
void InitWithEncoding(NotNull<const Encoding*> aEncoding,
const bool aFatal);
const TextDecoderOptions& aOptions);
/**
* Return the encoding name.