Chromium Code Reviews| Index: Source/bindings/v8/V8Binding.cpp |
| diff --git a/Source/bindings/v8/V8Binding.cpp b/Source/bindings/v8/V8Binding.cpp |
| index b928d011e2ce29dc0817582dc9b977fbe3fcd7a2..bef984e7af5aff1ac0aafda305d59436dbe6173d 100644 |
| --- a/Source/bindings/v8/V8Binding.cpp |
| +++ b/Source/bindings/v8/V8Binding.cpp |
| @@ -492,6 +492,31 @@ float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| return numberObject->NumberValue(); |
| } |
| +String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| +{ |
| + // Handle [Default=NullString] |
| + if (value.IsEmpty()) |
| + return String(); |
| + |
| + // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString |
| + |
| + // 1. Let x be ToString(v) |
| + TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value->ToString(), exceptionState, String()); |
| + String x = toCoreString(stringObject); |
|
haraken
2014/06/11 03:54:52
I'm not quite sure, but probably this should be:
Nils Barth (inactive)
2014/06/11 03:59:47
Oh, that's a good point, I think.
We're only throw
jsbell
2014/06/11 16:55:06
Just to make sure I'm understanding things - TOSTR
jsbell
2014/06/11 16:57:43
And to be clear, the TONATIVE_DEFAULT_EXCEPTIONSTA
haraken
2014/06/11 23:55:16
You're right. Your programming pattern matches wha
|
| + |
| + // 2. If the value of any element of x is greater than 255, then throw a TypeError. |
| + if (!x.containsOnlyLatin1()) { |
| + exceptionState.throwTypeError("Value is not a valid ByteString."); |
| + return String(); |
| + } |
| + |
| + // 3. Return an IDL ByteString value whose length is the length of x, and where the |
| + // value of each element is the value of the corresponding element of x. |
| + // Blink: A ByteString is simply a String with a range constrained per the above, so |
| + // this is the identity operation. |
| + return x; |
| +} |
| + |
| PassRefPtrWillBeRawPtr<XPathNSResolver> toXPathNSResolver(v8::Handle<v8::Value> value, v8::Isolate* isolate) |
| { |
| RefPtrWillBeRawPtr<XPathNSResolver> resolver = nullptr; |