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

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

Issue 24139004: Add toWebCoreString() / toWebCoreAtomicString() overloads taking a v8::String (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix bad if condition Created 7 years, 3 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
« no previous file with comments | « Source/bindings/v8/ScriptValue.cpp ('k') | Source/bindings/v8/V8Initializer.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 27eed7615d691af6c4a57748a589cea5189696a2..9c7849148921e8289faa9fdd11608cbbcbd93e96 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -163,6 +163,33 @@ namespace WebCore {
V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
}
+ // Convert v8::String 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.
+ inline String toWebCoreString(v8::Handle<v8::String> value)
+ {
+ return v8StringToWebCoreString<String>(value, Externalize);
+ }
+
+ inline String toWebCoreStringWithNullCheck(v8::Handle<v8::String> value)
+ {
+ if (value.IsEmpty() || value->IsNull())
+ return String();
+ return toWebCoreString(value);
+ }
+
+ inline String toWebCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::String> value)
+ {
+ if (value.IsEmpty() || value->IsNull() || value->IsUndefined())
+ return String();
+ return toWebCoreString(value);
+ }
+
+ inline AtomicString toWebCoreAtomicString(v8::Handle<v8::String> value)
+ {
+ 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.
@@ -205,15 +232,6 @@ namespace WebCore {
return stringResource;
}
- // FIXME: See the above comment.
- inline AtomicString toWebCoreAtomicStringWithNullCheck(v8::Handle<v8::Value> value)
- {
- V8StringResource<WithNullCheck> stringResource(value);
- if (!stringResource.prepare())
- return AtomicString();
- return stringResource;
- }
-
// Convert a string to a V8 string.
// Return a V8 external string that shares the underlying buffer with the given
// WebCore string. The reference counting mechanism is used to keep the
« no previous file with comments | « Source/bindings/v8/ScriptValue.cpp ('k') | Source/bindings/v8/V8Initializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698