Chromium Code Reviews| Index: Source/bindings/v8/V8Binding.h |
| diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h |
| index 4e43b873c64635c57eda58de18756f8db0ab72dd..3c32d161265cf74dc28a964cd9fa067a39c66dd4 100644 |
| --- a/Source/bindings/v8/V8Binding.h |
| +++ b/Source/bindings/v8/V8Binding.h |
| @@ -161,6 +161,13 @@ namespace WebCore { |
| return v8StringToWebCoreString<String>(value, Externalize); |
| } |
| + inline String toCoreString(v8::Handle<v8::Value> value) |
| + { |
| + if (!value->IsString()) |
| + return String(); |
| + return toCoreString(value.As<v8::String>()); |
| + } |
| + |
| inline String toCoreStringWithNullCheck(v8::Handle<v8::String> value) |
| { |
| if (value.IsEmpty() || value->IsNull()) |
| @@ -180,19 +187,15 @@ namespace WebCore { |
| return v8StringToWebCoreString<AtomicString>(value, Externalize); |
| } |
| - // Convert v8 types to a WTF::String. If the V8 string is not already |
| - // an external string then it is transformed into an external string at this |
| - // point to avoid repeated conversions. |
| - // |
| - // FIXME: Replace all the call sites with V8TRYCATCH_FOR_V8STRINGRESOURCE(). |
| - // Using this method will lead to a wrong behavior, because you cannot stop the |
| - // execution when an exception is thrown inside stringResource.prepare(). |
| + // This method will return a null String if the v8::Value does not contain a v8::String. |
| + // It will not call ToString() on the v8::Value. If you want ToString() to be called, |
| + // please use the V8TRYCATCH_FOR_V8STRINGRESOURCE_*() macros instead. |
|
haraken
2013/12/12 15:41:43
You want to add this comment to toCoreString(v8::H
Inactive
2013/12/12 15:44:22
Oh my bad, I did not intend to include toCoreStrin
|
| inline String toCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::Value> value) |
| { |
| - V8StringResource<WithUndefinedOrNullCheck> stringResource(value); |
| - if (!stringResource.prepare()) |
| + if (value.IsEmpty() || value->IsNull() || value->IsUndefined() || !value->IsString()) |
| return String(); |
| - return stringResource; |
| + |
| + return toCoreString(value.As<v8::String>()); |
| } |
| // Convert a string to a V8 string. |