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

Unified Diff: Source/bindings/v8/V8Binding.cpp

Issue 309553002: Add ByteString support to IDL bindings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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: Source/bindings/v8/V8Binding.cpp
diff --git a/Source/bindings/v8/V8Binding.cpp b/Source/bindings/v8/V8Binding.cpp
index a03187eabab6280a96c799868359f8952fe9a002..61acaf5cd2c074300f0d579b442faf3125d9caf2 100644
--- a/Source/bindings/v8/V8Binding.cpp
+++ b/Source/bindings/v8/V8Binding.cpp
@@ -492,6 +492,16 @@ float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
return numberObject->NumberValue();
}
+String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ String string = toCoreString(value.As<v8::String>());
jsbell 2014/05/30 21:53:28 Yeah, this As<v8::String> is bogus if it's not a s
Nils Barth (inactive) 2014/06/02 03:20:16 Should it be ToString() instead then? (JS values a
jsbell 2014/06/03 23:22:36 Yeah; handling should be identical to js->DOMStrin
+ if (!string.containsOnlyLatin1()) {
+ exceptionState.throwTypeError("Value is not a valid ByteString.");
+ return String();
+ }
+ return string;
+}
+
PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr;

Powered by Google App Engine
This is Rietveld 408576698