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

Unified Diff: Source/modules/encoding/TextDecoder.cpp

Issue 564463002: Encoding API: Add TextDecodeOptions and TextDecoderOptions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@dic-webmidi
Patch Set: Rebase Created 6 years, 3 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/modules/encoding/TextDecoder.h ('k') | Source/modules/encoding/TextDecoder.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/encoding/TextDecoder.cpp
diff --git a/Source/modules/encoding/TextDecoder.cpp b/Source/modules/encoding/TextDecoder.cpp
index a33215187ca4b4e228077454fd7f828873b99711..03186dcdef1c36a13680f5536c48d8da7654df00 100644
--- a/Source/modules/encoding/TextDecoder.cpp
+++ b/Source/modules/encoding/TextDecoder.cpp
@@ -39,7 +39,7 @@
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
@@ -49,13 +49,7 @@ TextDecoder* TextDecoder::create(const String& label, const Dictionary& options,
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());
}
@@ -82,15 +76,12 @@ String TextDecoder::encoding() const
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);
@@ -113,4 +104,10 @@ String TextDecoder::decode(ArrayBufferView* input, const Dictionary& options, Ex
return s;
}
+String TextDecoder::decode(ExceptionState& exceptionState)
+{
+ TextDecodeOptions* options = TextDecodeOptions::create();
+ return decode(0, *options, exceptionState);
+}
+
} // namespace blink
« no previous file with comments | « Source/modules/encoding/TextDecoder.h ('k') | Source/modules/encoding/TextDecoder.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698