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

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

Issue 100963003: Use V8TRYCATCH_FOR_V8STRINGRESOURCE() macro instead of toCoreStringWithUndefinedOrNullCheck() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Take Yury's feedback into consideration Created 7 years 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
« no previous file with comments | « Source/bindings/v8/ScriptDebugServer.cpp ('k') | Source/bindings/v8/custom/V8WindowCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8Binding.h
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index 4e43b873c64635c57eda58de18756f8db0ab72dd..48200a2fdd00b7ced8581c2ba83e053e005e444a 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -180,19 +180,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.
inline String toCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::Value> value)
{
- V8StringResource<WithUndefinedOrNullCheck> stringResource(value);
- if (!stringResource.prepare())
+ if (value.IsEmpty() || !value->IsString())
return String();
- return stringResource;
+
+ return toCoreString(value.As<v8::String>());
}
// Convert a string to a V8 string.
« no previous file with comments | « Source/bindings/v8/ScriptDebugServer.cpp ('k') | Source/bindings/v8/custom/V8WindowCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698