Title: [136622] trunk/Source/WebCore
- Revision
- 136622
- Author
- [email protected]
- Date
- 2012-12-04 20:22:29 -0800 (Tue, 04 Dec 2012)
Log Message
[V8] Remove v8NonStringValueToWebCoreString() and v8NonStringValueToAtomicWebCoreString()
https://bugs.webkit.org/show_bug.cgi?id=103981
Reviewed by Adam Barth.
v8NonStringValueToWebCoreString() and v8NonStringValueToAtomicWebCoreString()
are equivalent to what StringResource does.
No tests. No change in behavior.
* bindings/v8/V8Binding.cpp:
* bindings/v8/V8Binding.h:
(WebCore::toWebCoreString):
(WebCore):
(WebCore::toWebCoreStringWithNullCheck):
(WebCore::toWebCoreStringWithUndefinedOrNullCheck):
(WebCore::toWebCoreAtomicString):
(WebCore::toWebCoreAtomicStringWithNullCheck):
* bindings/v8/V8StringResource.h:
(WebCore::V8StringResource::V8StringResource):
(V8StringResource):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (136621 => 136622)
--- trunk/Source/WebCore/ChangeLog 2012-12-05 04:21:34 UTC (rev 136621)
+++ trunk/Source/WebCore/ChangeLog 2012-12-05 04:22:29 UTC (rev 136622)
@@ -1,3 +1,27 @@
+2012-12-04 Kentaro Hara <[email protected]>
+
+ [V8] Remove v8NonStringValueToWebCoreString() and v8NonStringValueToAtomicWebCoreString()
+ https://bugs.webkit.org/show_bug.cgi?id=103981
+
+ Reviewed by Adam Barth.
+
+ v8NonStringValueToWebCoreString() and v8NonStringValueToAtomicWebCoreString()
+ are equivalent to what StringResource does.
+
+ No tests. No change in behavior.
+
+ * bindings/v8/V8Binding.cpp:
+ * bindings/v8/V8Binding.h:
+ (WebCore::toWebCoreString):
+ (WebCore):
+ (WebCore::toWebCoreStringWithNullCheck):
+ (WebCore::toWebCoreStringWithUndefinedOrNullCheck):
+ (WebCore::toWebCoreAtomicString):
+ (WebCore::toWebCoreAtomicStringWithNullCheck):
+ * bindings/v8/V8StringResource.h:
+ (WebCore::V8StringResource::V8StringResource):
+ (V8StringResource):
+
2012-12-04 Abhishek Arya <[email protected]>
Crash in WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (136621 => 136622)
--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-12-05 04:21:34 UTC (rev 136621)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp 2012-12-05 04:22:29 UTC (rev 136622)
@@ -97,49 +97,6 @@
return V8ThrowException::throwNotEnoughArgumentsError(isolate);
}
-static String v8NonStringValueToWebCoreString(v8::Handle<v8::Value> object)
-{
- ASSERT(!object->IsString());
- if (object->IsInt32())
- return int32ToWebCoreString(object->Int32Value());
-
- v8::TryCatch block;
- v8::Handle<v8::String> v8String = object->ToString();
- // Handle the case where an exception is thrown as part of invoking toString on the object.
- if (block.HasCaught()) {
- throwError(block.Exception());
- return StringImpl::empty();
- }
- // This path is unexpected. However there is hypothesis that it
- // might be combination of v8 and v8 bindings bugs. For now
- // just bailout as we'll crash if attempt to convert empty handle into a string.
- if (v8String.IsEmpty()) {
- ASSERT_NOT_REACHED();
- return StringImpl::empty();
- }
- return v8StringToWebCoreString<String>(v8String, DoNotExternalize);
-}
-
-static AtomicString v8NonStringValueToAtomicWebCoreString(v8::Handle<v8::Value> object)
-{
- ASSERT(!object->IsString());
- return AtomicString(v8NonStringValueToWebCoreString(object));
-}
-
-String toWebCoreString(v8::Handle<v8::Value> value)
-{
- if (value->IsString())
- return v8StringToWebCoreString<String>(v8::Handle<v8::String>::Cast(value), Externalize);
- return v8NonStringValueToWebCoreString(value);
-}
-
-AtomicString toWebCoreAtomicString(v8::Handle<v8::Value> value)
-{
- if (value->IsString())
- return v8StringToWebCoreString<AtomicString>(v8::Handle<v8::String>::Cast(value), Externalize);
- return v8NonStringValueToAtomicWebCoreString(value);
-}
-
v8::Handle<v8::Value> v8Array(PassRefPtr<DOMStringList> stringList, v8::Isolate* isolate)
{
if (!stringList)
Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (136621 => 136622)
--- trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-12-05 04:21:34 UTC (rev 136621)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h 2012-12-05 04:22:29 UTC (rev 136622)
@@ -93,11 +93,54 @@
// 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.
- String toWebCoreString(v8::Handle<v8::Value>);
+ //
+ // 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().
+ inline String toWebCoreString(v8::Handle<v8::Value> value)
+ {
+ V8StringResource<> stringResource(value);
+ if (!stringResource.prepare())
+ return String();
+ return stringResource;
+ }
- // Convert a V8 value to a WTF::AtomicString.
- AtomicString toWebCoreAtomicString(v8::Handle<v8::Value>);
+ // FIXME: See the above comment.
+ inline String toWebCoreStringWithNullCheck(v8::Handle<v8::Value> value)
+ {
+ V8StringResource<WithNullCheck> stringResource(value);
+ if (!stringResource.prepare())
+ return String();
+ return stringResource;
+ }
+ // FIXME: See the above comment.
+ inline String toWebCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::Value> value)
+ {
+ V8StringResource<WithUndefinedOrNullCheck> stringResource(value);
+ if (!stringResource.prepare())
+ return String();
+ return stringResource;
+ }
+
+ // FIXME: See the above comment.
+ inline AtomicString toWebCoreAtomicString(v8::Handle<v8::Value> value)
+ {
+ V8StringResource<> stringResource(value);
+ if (!stringResource.prepare())
+ return AtomicString();
+ 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;
+ }
+
// Return a V8 external string that shares the underlying buffer with the given
// WebCore string. The reference counting mechanism is used to keep the
// underlying buffer alive while the string is still live in the V8 engine.
@@ -362,21 +405,6 @@
return isolate ? v8Boolean(value, isolate) : v8Boolean(value);
}
- inline String toWebCoreStringWithNullCheck(v8::Handle<v8::Value> value)
- {
- return value->IsNull() ? String() : toWebCoreString(value);
- }
-
- inline String toWebCoreStringWithUndefinedOrNullCheck(v8::Handle<v8::Value> value)
- {
- return (value->IsNull() || value->IsUndefined()) ? String() : toWebCoreString(value);
- }
-
- inline AtomicString toWebCoreAtomicStringWithNullCheck(v8::Handle<v8::Value> value)
- {
- return value->IsNull() ? AtomicString() : toWebCoreAtomicString(value);
- }
-
inline v8::Handle<v8::Value> v8StringOrNull(const String& str, v8::Isolate* isolate = 0)
{
return str.isNull() ? v8::Handle<v8::Value>(v8::Null()) : v8::Handle<v8::Value>(v8String(str, isolate));
Modified: trunk/Source/WebCore/bindings/v8/V8StringResource.h (136621 => 136622)
--- trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-12-05 04:21:34 UTC (rev 136621)
+++ trunk/Source/WebCore/bindings/v8/V8StringResource.h 2012-12-05 04:22:29 UTC (rev 136622)
@@ -155,7 +155,7 @@
template <V8StringResourceMode Mode = DefaultMode>
class V8StringResource {
public:
- V8StringResource(v8::Local<v8::Value> object)
+ V8StringResource(v8::Handle<v8::Value> object)
: m_v8Object(object)
, m_mode(Externalize)
, m_string()
@@ -206,7 +206,7 @@
return StringType(m_string);
}
- v8::Local<v8::Value> m_v8Object;
+ v8::Handle<v8::Value> m_v8Object;
ExternalMode m_mode;
String m_string;
};
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes