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

Unified Diff: third_party/WebKit/Source/modules/encoding/TextEncoder.cpp

Issue 1862453003: [Blink>TextEncoder] Removed UTF-16 support from TextEncoder API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed code, removed meaningless test Created 4 years, 8 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
Index: third_party/WebKit/Source/modules/encoding/TextEncoder.cpp
diff --git a/third_party/WebKit/Source/modules/encoding/TextEncoder.cpp b/third_party/WebKit/Source/modules/encoding/TextEncoder.cpp
index 72bb04deffb1d9bac4bf2f3f8c98e2f19f122f5c..c7cb2772146d8168164bb5bfe4319e9fe61dab41 100644
--- a/third_party/WebKit/Source/modules/encoding/TextEncoder.cpp
+++ b/third_party/WebKit/Source/modules/encoding/TextEncoder.cpp
@@ -29,33 +29,17 @@
*/
#include "modules/encoding/TextEncoder.h"
jsbell 2016/05/02 20:20:06 Keep the blank line below here; we separate the in
lpan 2016/05/03 13:42:01 Done.
-
#include "bindings/core/v8/ExceptionState.h"
#include "core/dom/ExecutionContext.h"
-#include "core/frame/UseCounter.h"
#include "modules/encoding/Encoding.h"
#include "wtf/text/CString.h"
#include "wtf/text/TextEncodingRegistry.h"
namespace blink {
-TextEncoder* TextEncoder::create(ExecutionContext* context, const String& utfLabel, ExceptionState& exceptionState)
+TextEncoder* TextEncoder::create(ExecutionContext* context, ExceptionState& exceptionState)
{
- WTF::TextEncoding encoding(utfLabel.stripWhiteSpace(&Encoding::isASCIIWhiteSpace));
- if (!encoding.isValid()) {
- exceptionState.throwRangeError("The encoding label provided ('" + utfLabel + "') is invalid.");
- return 0;
- }
-
- String name(encoding.name());
- if (name != "UTF-8" && name != "UTF-16LE" && name != "UTF-16BE") {
- exceptionState.throwRangeError("The encoding provided ('" + utfLabel + "') is not one of 'utf-8', 'utf-16', or 'utf-16be'.");
- return 0;
- }
-
- if (name == "UTF-16LE" || name == "UTF-16BE")
- UseCounter::count(context, UseCounter::TextEncoderUTF16);
-
+ WTF::TextEncoding encoding("UTF-8");
return new TextEncoder(encoding);
}
@@ -63,6 +47,8 @@ TextEncoder::TextEncoder(const WTF::TextEncoding& encoding)
: m_encoding(encoding)
, m_codec(newTextCodec(encoding))
{
+ String name(m_encoding.name());
+ ASSERT(name == "UTF-8");
}
TextEncoder::~TextEncoder()
@@ -72,7 +58,7 @@ TextEncoder::~TextEncoder()
String TextEncoder::encoding() const
{
String name = String(m_encoding.name()).lower();
- ASSERT(name == "utf-8" || name == "utf-16le" || name == "utf-16be");
+ ASSERT(name == "utf-8");
return name;
}

Powered by Google App Engine
This is Rietveld 408576698