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

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: 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/V8InjectedScriptHostCustom.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..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.
« no previous file with comments | « Source/bindings/v8/ScriptDebugServer.cpp ('k') | Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698