namespace blink {
-TextDecoder* TextDecoder::create(const String& label, const Dictionary& options, ExceptionState& exceptionState)
+TextDecoder* TextDecoder::create(const String& label, const TextDecoderOptions& options, ExceptionState& exceptionState)
{
WTF::TextEncoding encoding(label);
// The replacement encoding is not valid, but the Encoding API also
return 0;
}
- bool fatal = false;
- DictionaryHelper::get(options, "fatal", fatal);
-
- bool ignoreBOM = false;
- DictionaryHelper::get(options, "ignoreBOM", ignoreBOM);
-
- return new TextDecoder(encoding, fatal, ignoreBOM);
+ return new TextDecoder(encoding, options.fatal(), options.ignoreBOM());
}
, m_ignoreBOM(ignoreBOM)
, m_bomSeen(false)
{
- ScriptWrappable::init(this);
}
TextDecoder::~TextDecoder()
return name;
}
-String TextDecoder::decode(ArrayBufferView* input, const Dictionary& options, ExceptionState& exceptionState)
+String TextDecoder::decode(ArrayBufferView* input, const TextDecodeOptions& options, ExceptionState& exceptionState)
{
- bool stream = false;
- DictionaryHelper::get(options, "stream", stream);
-
const char* start = input ? static_cast<const char*>(input->baseAddress()) : 0;
size_t length = input ? input->byteLength() : 0;
- WTF::FlushBehavior flush = stream ? WTF::DoNotFlush : WTF::DataEOF;
+ WTF::FlushBehavior flush = options.stream() ? WTF::DoNotFlush : WTF::DataEOF;
bool sawError = false;
String s = m_codec->decode(start, length, flush, m_fatal, sawError);
return s;
}
+String TextDecoder::decode(ExceptionState& exceptionState)
+{
+ TextDecodeOptions* options = TextDecodeOptions::create();
+ return decode(0, *options, exceptionState);
+}
+
} // namespace blink