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

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

Issue 313993002: Bindings: Add ScalarValueString support (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Incorporate review feedback Created 6 years, 6 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 bef984e7af5aff1ac0aafda305d59436dbe6173d..3a30b2c108f71599bc4b6bed18695324104b87d5 100644
--- a/Source/bindings/v8/V8Binding.cpp
+++ b/Source/bindings/v8/V8Binding.cpp
@@ -499,6 +499,8 @@ String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
return String();
// From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString
+ if (value.IsEmpty())
+ return String();
// 1. Let x be ToString(v)
TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value->ToString(), exceptionState, String());
@@ -517,6 +519,21 @@ String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
return x;
}
+String toScalarValueString(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
+{
+ // From the Encoding standard (with a TODO to move to Web IDL):
+ // http://encoding.spec.whatwg.org/#type-scalarvaluestring
+ if (value.IsEmpty())
+ return String();
+ TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value->ToString(), exceptionState, String());
+
+ // ScalarValueString is identical to DOMString except that "convert a
+ // DOMString to a sequence of Unicode characters" is used subsequently
+ // when converting to an IDL value
+ String x = toCoreString(stringObject);
+ return x.toScalarValueString();
+}
+
PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::Isolate* isolate)
{
RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr;

Powered by Google App Engine
This is Rietveld 408576698