bindings: Retires ScriptWrappableBase mostly.

Removes functions which take ScriptWrappableBase as an argument
in DOMDataStore, V8Wrapper, and V8Binding.

ScriptWrappableBase is still used as the internal pointer in a
wrapper, and it's used to support NPObject.

BUG=235436

Review URL: https://codereview.chromium.org/721383003

git-svn-id: svn://svn.chromium.org/blink/trunk@185370 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0440e127
...@@ -71,7 +71,6 @@ NamedConstructor=* ...@@ -71,7 +71,6 @@ NamedConstructor=*
NoImplHeader NoImplHeader
NoInterfaceObject NoInterfaceObject
NotEnumerable NotEnumerable
NotScriptWrappable
OnlyExposedToPrivateScript OnlyExposedToPrivateScript
OverrideBuiltins OverrideBuiltins
PartialInterfaceImplementedAs=* PartialInterfaceImplementedAs=*
......
...@@ -61,30 +61,6 @@ public: ...@@ -61,30 +61,6 @@ public:
return DOMWrapperWorld::current(isolate).domDataStore(); return DOMWrapperWorld::current(isolate).domDataStore();
} }
static bool setReturnValueFast(v8::ReturnValue<v8::Value> returnValue, ScriptWrappable* object, v8::Local<v8::Object> holder, const ScriptWrappable* wrappable)
{
// The second fastest way to check if we're in the main world is to check if
// the wrappable's wrapper is the same as the holder.
if (holderContainsWrapper(holder, wrappable))
return object->setReturnValue(returnValue);
return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue, object);
}
static bool setReturnValueFast(v8::ReturnValue<v8::Value> returnValue, Node* node, v8::Local<v8::Object> holder, const ScriptWrappable* wrappable)
{
if (canUseScriptWrappable(node)
// The second fastest way to check if we're in the main world is to
// check if the wrappable's wrapper is the same as the holder.
|| holderContainsWrapper(holder, wrappable))
return ScriptWrappable::fromNode(node)->setReturnValue(returnValue);
return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue, ScriptWrappable::fromNode(node));
}
static bool setReturnValue(v8::ReturnValue<v8::Value> returnValue, ScriptWrappableBase* object)
{
return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue, object);
}
static bool setReturnValue(v8::ReturnValue<v8::Value> returnValue, ScriptWrappable* object) static bool setReturnValue(v8::ReturnValue<v8::Value> returnValue, ScriptWrappable* object)
{ {
return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue, object); return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue, object);
...@@ -102,9 +78,23 @@ public: ...@@ -102,9 +78,23 @@ public:
return object->setReturnValue(returnValue); return object->setReturnValue(returnValue);
} }
static v8::Handle<v8::Object> getWrapper(ScriptWrappableBase* object, v8::Isolate* isolate) static bool setReturnValueFast(v8::ReturnValue<v8::Value> returnValue, ScriptWrappable* object, v8::Local<v8::Object> holder, const ScriptWrappable* wrappable)
{ {
return current(isolate).get(object, isolate); // The second fastest way to check if we're in the main world is to check if
// the wrappable's wrapper is the same as the holder.
if (holderContainsWrapper(holder, wrappable))
return object->setReturnValue(returnValue);
return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue, object);
}
static bool setReturnValueFast(v8::ReturnValue<v8::Value> returnValue, Node* node, v8::Local<v8::Object> holder, const ScriptWrappable* wrappable)
{
if (canUseScriptWrappable(node)
// The second fastest way to check if we're in the main world is to
// check if the wrappable's wrapper is the same as the holder.
|| holderContainsWrapper(holder, wrappable))
return ScriptWrappable::fromNode(node)->setReturnValue(returnValue);
return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue, ScriptWrappable::fromNode(node));
} }
static v8::Handle<v8::Object> getWrapper(ScriptWrappable* object, v8::Isolate* isolate) static v8::Handle<v8::Object> getWrapper(ScriptWrappable* object, v8::Isolate* isolate)
...@@ -123,11 +113,6 @@ public: ...@@ -123,11 +113,6 @@ public:
return current(isolate).get(ScriptWrappable::fromNode(node), isolate); return current(isolate).get(ScriptWrappable::fromNode(node), isolate);
} }
static void setWrapperReference(const v8::Persistent<v8::Object>& parent, ScriptWrappableBase* child, v8::Isolate* isolate)
{
current(isolate).setReference(parent, child, isolate);
}
static void setWrapperReference(const v8::Persistent<v8::Object>& parent, ScriptWrappable* child, v8::Isolate* isolate) static void setWrapperReference(const v8::Persistent<v8::Object>& parent, ScriptWrappable* child, v8::Isolate* isolate)
{ {
current(isolate).setReference(parent, child, isolate); current(isolate).setReference(parent, child, isolate);
...@@ -142,11 +127,6 @@ public: ...@@ -142,11 +127,6 @@ public:
current(isolate).setReference(parent, ScriptWrappable::fromNode(child), isolate); current(isolate).setReference(parent, ScriptWrappable::fromNode(child), isolate);
} }
static void setWrapper(ScriptWrappableBase* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo)
{
return current(isolate).set(object, wrapper, isolate, wrapperTypeInfo);
}
static void setWrapper(ScriptWrappable* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo) static void setWrapper(ScriptWrappable* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo)
{ {
return current(isolate).set(object, wrapper, isolate, wrapperTypeInfo); return current(isolate).set(object, wrapper, isolate, wrapperTypeInfo);
...@@ -161,21 +141,11 @@ public: ...@@ -161,21 +141,11 @@ public:
return current(isolate).set(ScriptWrappable::fromNode(node), wrapper, isolate, wrapperTypeInfo); return current(isolate).set(ScriptWrappable::fromNode(node), wrapper, isolate, wrapperTypeInfo);
} }
static bool containsWrapper(ScriptWrappableBase* object, v8::Isolate* isolate)
{
return current(isolate).containsWrapper(object);
}
static bool containsWrapper(ScriptWrappable* object, v8::Isolate* isolate) static bool containsWrapper(ScriptWrappable* object, v8::Isolate* isolate)
{ {
return current(isolate).containsWrapper(object); return current(isolate).containsWrapper(object);
} }
v8::Handle<v8::Object> get(ScriptWrappableBase* object, v8::Isolate* isolate)
{
return m_wrapperMap.newLocal(object->toScriptWrappableBase(), isolate);
}
v8::Handle<v8::Object> get(ScriptWrappable* object, v8::Isolate* isolate) v8::Handle<v8::Object> get(ScriptWrappable* object, v8::Isolate* isolate)
{ {
if (m_isMainWorld) if (m_isMainWorld)
...@@ -183,11 +153,6 @@ public: ...@@ -183,11 +153,6 @@ public:
return m_wrapperMap.newLocal(object->toScriptWrappableBase(), isolate); return m_wrapperMap.newLocal(object->toScriptWrappableBase(), isolate);
} }
void setReference(const v8::Persistent<v8::Object>& parent, ScriptWrappableBase* child, v8::Isolate* isolate)
{
m_wrapperMap.setReference(parent, child, isolate);
}
void setReference(const v8::Persistent<v8::Object>& parent, ScriptWrappable* child, v8::Isolate* isolate) void setReference(const v8::Persistent<v8::Object>& parent, ScriptWrappable* child, v8::Isolate* isolate)
{ {
if (m_isMainWorld) { if (m_isMainWorld) {
...@@ -197,11 +162,6 @@ public: ...@@ -197,11 +162,6 @@ public:
m_wrapperMap.setReference(parent, child->toScriptWrappableBase(), isolate); m_wrapperMap.setReference(parent, child->toScriptWrappableBase(), isolate);
} }
bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, ScriptWrappableBase* object)
{
return m_wrapperMap.setReturnValueFrom(returnValue, object);
}
bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, ScriptWrappable* object) bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, ScriptWrappable* object)
{ {
if (m_isMainWorld) if (m_isMainWorld)
...@@ -209,11 +169,6 @@ public: ...@@ -209,11 +169,6 @@ public:
return m_wrapperMap.setReturnValueFrom(returnValue, object->toScriptWrappableBase()); return m_wrapperMap.setReturnValueFrom(returnValue, object->toScriptWrappableBase());
} }
bool containsWrapper(ScriptWrappableBase* object)
{
return m_wrapperMap.containsKey(object->toScriptWrappableBase());
}
bool containsWrapper(ScriptWrappable* object) bool containsWrapper(ScriptWrappable* object)
{ {
if (m_isMainWorld) if (m_isMainWorld)
...@@ -222,13 +177,6 @@ public: ...@@ -222,13 +177,6 @@ public:
} }
private: private:
void set(ScriptWrappableBase* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo)
{
ASSERT(object);
ASSERT(!wrapper.IsEmpty());
m_wrapperMap.set(object->toScriptWrappableBase(), wrapper, wrapperTypeInfo);
}
void set(ScriptWrappable* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo) void set(ScriptWrappable* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo)
{ {
ASSERT(object); ASSERT(object);
......
...@@ -46,27 +46,6 @@ private: ...@@ -46,27 +46,6 @@ private:
} // namespace } // namespace
// ScriptWrappableBase
v8::Handle<v8::Object> ScriptWrappableBase::wrap(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo)
{
// It's possible that no one except for the new wrapper owns this object at
// this moment, so we have to prevent GC to collect this object until the
// object gets associated with the wrapper.
ScriptWrappableBaseProtector protect(this, wrapperTypeInfo);
ASSERT(!DOMDataStore::containsWrapper(this, isolate));
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creationContext, wrapperTypeInfo, this);
if (UNLIKELY(wrapper.IsEmpty()))
return wrapper;
wrapperTypeInfo->installConditionallyEnabledProperties(wrapper, isolate);
return V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTypeInfo, wrapper);
}
// ScriptWrappable
v8::Handle<v8::Object> ScriptWrappable::wrap(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) v8::Handle<v8::Object> ScriptWrappable::wrap(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{ {
const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo();
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "bindings/core/v8/WrapperTypeInfo.h" #include "bindings/core/v8/WrapperTypeInfo.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "wtf/Noncopyable.h"
#include <v8.h> #include <v8.h>
namespace blink { namespace blink {
...@@ -68,6 +69,8 @@ namespace blink { ...@@ -68,6 +69,8 @@ namespace blink {
__declspec(align(4)) __declspec(align(4))
#endif #endif
class ScriptWrappableBase { class ScriptWrappableBase {
WTF_MAKE_NONCOPYABLE(ScriptWrappableBase);
friend class ScriptWrappable;
public: public:
template<typename T> template<typename T>
T* toImpl() T* toImpl()
...@@ -89,19 +92,16 @@ public: ...@@ -89,19 +92,16 @@ public:
return this; return this;
} }
// Creates and returns a new wrapper object.
// Do not call this method for a ScriptWrappable or its subclasses. This
// non-virtual version of "wrap" is meant only for non-ScriptWrappable
// objects. This wrap takes an extra third argument of type WrapperTypeInfo
// because ScriptWrappableBase doesn't have wrapperTypeInfo() method unlike
// ScriptWrappable.
v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext, v8::Isolate*, const WrapperTypeInfo*);
void assertWrapperSanity(v8::Local<v8::Object> object) void assertWrapperSanity(v8::Local<v8::Object> object)
{ {
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(object.IsEmpty() RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(object.IsEmpty()
|| object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == toScriptWrappableBase()); || object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == toScriptWrappableBase());
} }
private:
// Do not allow DOM classes to inherit directly from ScriptWrappableBase.
// DOM classes must inherit from ScriptWrappable instead.
ScriptWrappableBase() { }
}; };
/** /**
...@@ -236,17 +236,9 @@ private: ...@@ -236,17 +236,9 @@ private:
// the instance. Also declares a static member of type WrapperTypeInfo, of which // the instance. Also declares a static member of type WrapperTypeInfo, of which
// the definition is given by the IDL code generator. // the definition is given by the IDL code generator.
// //
// Every DOM Class T must meet either of the following conditions:
// - T.idl inherits from [NotScriptWrappable].
// - T inherits from ScriptWrappable and has DEFINE_WRAPPERTYPEINFO().
//
// If a DOM class T does not inherit from ScriptWrappable, you have to write
// [NotScriptWrappable] in the IDL file as an extended attribute in order to let
// IDL code generator know that T does not inherit from ScriptWrappable. Note
// that [NotScriptWrappable] is inheritable.
//
// All the derived classes of ScriptWrappable, regardless of directly or // All the derived classes of ScriptWrappable, regardless of directly or
// indirectly, must write this macro in the class definition. // indirectly, must write this macro in the class definition as long as the
// class has a corresponding .idl file.
#define DEFINE_WRAPPERTYPEINFO() \ #define DEFINE_WRAPPERTYPEINFO() \
public: \ public: \
virtual const WrapperTypeInfo* wrapperTypeInfo() const override \ virtual const WrapperTypeInfo* wrapperTypeInfo() const override \
......
...@@ -127,7 +127,7 @@ PassRefPtrWillBeRawPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value> callback, ...@@ -127,7 +127,7 @@ PassRefPtrWillBeRawPtr<NodeFilter> toNodeFilter(v8::Handle<v8::Value> callback,
return nullptr; return nullptr;
RefPtrWillBeRawPtr<NodeFilter> filter = NodeFilter::create(); RefPtrWillBeRawPtr<NodeFilter> filter = NodeFilter::create();
v8::Handle<v8::Object> filterWrapper = toV8(filter, creationContext, scriptState->isolate()).As<v8::Object>(); v8::Handle<v8::Object> filterWrapper = toV8(filter.get(), creationContext, scriptState->isolate()).As<v8::Object>();
RefPtrWillBeRawPtr<NodeFilterCondition> condition = V8NodeFilterCondition::create(callback, filterWrapper, scriptState); RefPtrWillBeRawPtr<NodeFilterCondition> condition = V8NodeFilterCondition::create(callback, filterWrapper, scriptState);
filter->setCondition(condition.release()); filter->setCondition(condition.release());
......
...@@ -176,19 +176,6 @@ inline void v8SetReturnValueStringOrUndefined(const CallbackInfo& info, const St ...@@ -176,19 +176,6 @@ inline void v8SetReturnValueStringOrUndefined(const CallbackInfo& info, const St
V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl()); V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(info.GetReturnValue(), string.impl());
} }
template<typename CallbackInfo>
inline void v8SetReturnValue(const CallbackInfo& callbackInfo, ScriptWrappableBase* impl, const WrapperTypeInfo* wrapperTypeInfo)
{
if (UNLIKELY(!impl)) {
v8SetReturnValueNull(callbackInfo);
return;
}
if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
return;
v8::Handle<v8::Object> wrapper = impl->wrap(callbackInfo.Holder(), callbackInfo.GetIsolate(), wrapperTypeInfo);
v8SetReturnValue(callbackInfo, wrapper);
}
template<typename CallbackInfo> template<typename CallbackInfo>
inline void v8SetReturnValue(const CallbackInfo& callbackInfo, ScriptWrappable* impl) inline void v8SetReturnValue(const CallbackInfo& callbackInfo, ScriptWrappable* impl)
{ {
...@@ -302,13 +289,6 @@ inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, Node* impl, c ...@@ -302,13 +289,6 @@ inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, Node* impl, c
v8SetReturnValue(callbackInfo, wrapper); v8SetReturnValue(callbackInfo, wrapper);
} }
template<typename CallbackInfo>
inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, ScriptWrappable* impl, const ScriptWrappableBase*)
{
// If the third arg is not ScriptWrappable, there is no fast path.
v8SetReturnValue(callbackInfo, impl);
}
template<typename CallbackInfo, typename T, typename Wrappable> template<typename CallbackInfo, typename T, typename Wrappable>
inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<T> impl, const Wrappable* wrappable) inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<T> impl, const Wrappable* wrappable)
{ {
...@@ -386,17 +366,6 @@ inline v8::Handle<v8::Value> v8Undefined() ...@@ -386,17 +366,6 @@ inline v8::Handle<v8::Value> v8Undefined()
return v8::Handle<v8::Value>(); return v8::Handle<v8::Value>();
} }
inline v8::Handle<v8::Value> toV8(ScriptWrappableBase* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo)
{
if (UNLIKELY(!impl))
return v8::Null(isolate);
v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
if (!wrapper.IsEmpty())
return wrapper;
return impl->wrap(creationContext, isolate, wrapperTypeInfo);
}
inline v8::Handle<v8::Value> toV8(ScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) inline v8::Handle<v8::Value> toV8(ScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{ {
if (UNLIKELY(!impl)) if (UNLIKELY(!impl))
...@@ -419,12 +388,6 @@ inline v8::Handle<v8::Value> toV8(Node* impl, v8::Handle<v8::Object> creationCon ...@@ -419,12 +388,6 @@ inline v8::Handle<v8::Value> toV8(Node* impl, v8::Handle<v8::Object> creationCon
return ScriptWrappable::fromNode(impl)->wrap(creationContext, isolate); return ScriptWrappable::fromNode(impl)->wrap(creationContext, isolate);
} }
template<typename T>
inline v8::Handle<v8::Value> toV8(RefPtr<T>& impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return toV8(impl.get(), creationContext, isolate);
}
template<typename T> template<typename T>
inline v8::Handle<v8::Value> toV8(PassRefPtr<T> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) inline v8::Handle<v8::Value> toV8(PassRefPtr<T> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{ {
......
...@@ -47,7 +47,6 @@ class V8DOMWrapper { ...@@ -47,7 +47,6 @@ class V8DOMWrapper {
public: public:
static v8::Local<v8::Object> createWrapper(v8::Isolate*, v8::Handle<v8::Object> creationContext, const WrapperTypeInfo*, ScriptWrappableBase*); static v8::Local<v8::Object> createWrapper(v8::Isolate*, v8::Handle<v8::Object> creationContext, const WrapperTypeInfo*, ScriptWrappableBase*);
static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, ScriptWrappableBase*, const WrapperTypeInfo*, v8::Handle<v8::Object> wrapper);
static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, ScriptWrappable*, const WrapperTypeInfo*, v8::Handle<v8::Object>); static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, ScriptWrappable*, const WrapperTypeInfo*, v8::Handle<v8::Object>);
static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, Node*, const WrapperTypeInfo*, v8::Handle<v8::Object>); static v8::Handle<v8::Object> associateObjectWithWrapper(v8::Isolate*, Node*, const WrapperTypeInfo*, v8::Handle<v8::Object>);
static void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, ScriptWrappableBase*); static void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, ScriptWrappableBase*);
...@@ -75,15 +74,6 @@ inline void V8DOMWrapper::clearNativeInfo(v8::Handle<v8::Object> wrapper, const ...@@ -75,15 +74,6 @@ inline void V8DOMWrapper::clearNativeInfo(v8::Handle<v8::Object> wrapper, const
wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, 0); wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, 0);
} }
inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isolate* isolate, ScriptWrappableBase* impl, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper)
{
wrapperTypeInfo->refObject(impl);
setNativeInfo(wrapper, wrapperTypeInfo, impl);
ASSERT(isDOMWrapper(wrapper));
DOMDataStore::setWrapper(impl, wrapper, isolate, wrapperTypeInfo);
return wrapper;
}
inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isolate* isolate, ScriptWrappable* impl, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper) inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(v8::Isolate* isolate, ScriptWrappable* impl, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper)
{ {
wrapperTypeInfo->refObject(impl->toScriptWrappableBase()); wrapperTypeInfo->refObject(impl->toScriptWrappableBase());
......
...@@ -63,7 +63,7 @@ v8::Handle<v8::Value> V8ThrowException::createDOMException(v8::Isolate* isolate, ...@@ -63,7 +63,7 @@ v8::Handle<v8::Value> V8ThrowException::createDOMException(v8::Isolate* isolate,
return V8ThrowException::createReferenceError(isolate, sanitizedMessage); return V8ThrowException::createReferenceError(isolate, sanitizedMessage);
RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, sanitizedMessage, unsanitizedMessage); RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, sanitizedMessage, unsanitizedMessage);
v8::Handle<v8::Value> exception = toV8(domException, creationContext, isolate); v8::Handle<v8::Value> exception = toV8(domException.get(), creationContext, isolate);
if (exception.IsEmpty()) if (exception.IsEmpty())
return v8Undefined(); return v8Undefined();
......
...@@ -92,7 +92,6 @@ INHERITED_EXTENDED_ATTRIBUTES = set([ ...@@ -92,7 +92,6 @@ INHERITED_EXTENDED_ATTRIBUTES = set([
'ActiveDOMObject', 'ActiveDOMObject',
'DependentLifetime', 'DependentLifetime',
'GarbageCollected', 'GarbageCollected',
'NotScriptWrappable',
'WillBeGarbageCollected', 'WillBeGarbageCollected',
]) ])
......
...@@ -163,9 +163,6 @@ def interface_context(interface): ...@@ -163,9 +163,6 @@ def interface_context(interface):
for set_wrapper_reference_to in set_wrapper_reference_to_list: for set_wrapper_reference_to in set_wrapper_reference_to_list:
set_wrapper_reference_to['idl_type'].add_includes_for_type() set_wrapper_reference_to['idl_type'].add_includes_for_type()
# [NotScriptWrappable]
is_script_wrappable = 'NotScriptWrappable' not in extended_attributes
# [SetWrapperReferenceFrom] # [SetWrapperReferenceFrom]
has_visit_dom_wrapper = ( has_visit_dom_wrapper = (
has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper') or
...@@ -204,7 +201,6 @@ def interface_context(interface): ...@@ -204,7 +201,6 @@ def interface_context(interface):
'is_exception': interface.is_exception, 'is_exception': interface.is_exception,
'is_node': inherits_interface(interface.name, 'Node'), 'is_node': inherits_interface(interface.name, 'Node'),
'is_partial': interface.is_partial, 'is_partial': interface.is_partial,
'is_script_wrappable': is_script_wrappable,
'is_typed_array_type': is_typed_array_type, 'is_typed_array_type': is_typed_array_type,
'iterator_method': iterator_method, 'iterator_method': iterator_method,
'lifetime': 'Dependent' 'lifetime': 'Dependent'
......
...@@ -202,37 +202,6 @@ inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}} ...@@ -202,37 +202,6 @@ inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}
v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate())); v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
} }
{% elif not is_script_wrappable %}
inline v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
return toV8(scriptWrappableBase, creationContext, isolate, &{{v8_class}}::wrapperTypeInfo);
}
template<typename CallbackInfo>
inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
{
ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
return v8SetReturnValue(callbackInfo, scriptWrappableBase, &{{v8_class}}::wrapperTypeInfo);
}
template<typename CallbackInfo>
inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, {{cpp_class}}* impl)
{
ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
// Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
// main world or not.
return v8SetReturnValue(callbackInfo, impl);
}
template<typename CallbackInfo, typename Wrappable>
inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, {{cpp_class}}* impl, Wrappable*)
{
// Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
// main world or not.
return v8SetReturnValue(callbackInfo, impl);
}
{% endif %}{# has_custom_to_v8 #} {% endif %}{# has_custom_to_v8 #}
{% if has_event_constructor %} {% if has_event_constructor %}
bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info); bool initialize{{cpp_class}}({{cpp_class}}Init&, const Dictionary&, ExceptionState&, const v8::FunctionCallbackInfo<v8::Value>& info);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "{{filename}}" #include "{{filename}}"
{% endfor %} {% endfor %}
{% block initialize_script_wrappable %}{% endblock %}
namespace blink { namespace blink {
{% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
if is_active_dom_object else '0' %} if is_active_dom_object else '0' %}
...@@ -30,7 +29,6 @@ namespace blink { ...@@ -30,7 +29,6 @@ namespace blink {
{% if not is_partial %} {% if not is_partial %}
{{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{dom_template}}, {{v8_class}}::refObject, {{v8_class}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, {{to_event_target}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditionallyEnabledProperties, {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} }; {{wrapper_type_info_const}}WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { gin::kEmbedderBlink, {{dom_template}}, {{v8_class}}::refObject, {{v8_class}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, {{to_event_target}}, {{visit_dom_wrapper}}, {{v8_class}}::installConditionallyEnabledMethods, {{v8_class}}::installConditionallyEnabledProperties, {{parent_wrapper_type_info}}, WrapperTypeInfo::{{wrapper_type_prototype}}, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} };
{% if is_script_wrappable %}
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class}}.h. // This static member must be declared by DEFINE_WRAPPERTYPEINFO in {{cpp_class}}.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// bindings/core/v8/ScriptWrappable.h. // bindings/core/v8/ScriptWrappable.h.
...@@ -39,7 +37,6 @@ template<> ...@@ -39,7 +37,6 @@ template<>
{% endif %} {% endif %}
const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperTypeInfo; const WrapperTypeInfo& {{cpp_class}}::s_wrapperTypeInfo = {{v8_class}}::wrapperTypeInfo;
{% endif %}
{% endif %} {% endif %}
{% if not is_array_buffer_or_view %} {% if not is_array_buffer_or_view %}
namespace {{cpp_class_or_partial}}V8Internal { namespace {{cpp_class_or_partial}}V8Internal {
......
...@@ -573,11 +573,7 @@ static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) ...@@ -573,11 +573,7 @@ static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info)
if constructor.is_named_constructor else if constructor.is_named_constructor else
'') %} '') %}
v8::Handle<v8::Object> wrapper = info.Holder(); v8::Handle<v8::Object> wrapper = info.Holder();
{% if is_script_wrappable %}
impl->associateWithWrapper(&{{constructor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate()); impl->associateWithWrapper(&{{constructor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate());
{% else %}
V8DOMWrapper::associateObjectWithWrapper(info.GetIsolate(), impl.get(), &{{constructor_class}}::wrapperTypeInfo, wrapper);
{% endif %}
v8SetReturnValue(info, wrapper); v8SetReturnValue(info, wrapper);
{% endmacro %} {% endmacro %}
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
NotScriptWrappable,
] interface TestInterfaceNotScriptWrappable {
attribute TestInterfaceNotScriptWrappable attr1;
void func(TestInterfaceNotScriptWrappable arg);
};
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
#include "config.h"
#include "V8TestInterfaceNotScriptWrappable.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "bindings/core/v8/V8TestInterfaceNotScriptWrappable.h"
#include "core/dom/ContextFeatures.h"
#include "core/dom/Document.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h"
#include "wtf/GetPtr.h"
#include "wtf/RefPtr.h"
namespace blink {
const WrapperTypeInfo V8TestInterfaceNotScriptWrappable::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceNotScriptWrappable::domTemplate, V8TestInterfaceNotScriptWrappable::refObject, V8TestInterfaceNotScriptWrappable::derefObject, V8TestInterfaceNotScriptWrappable::trace, 0, 0, 0, V8TestInterfaceNotScriptWrappable::installConditionallyEnabledMethods, V8TestInterfaceNotScriptWrappable::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject };
namespace TestInterfaceNotScriptWrappableV8Internal {
static void attr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
TestInterfaceNotScriptWrappable* impl = V8TestInterfaceNotScriptWrappable::toImpl(holder);
v8SetReturnValueFast(info, WTF::getPtr(impl->attr1()), impl);
}
static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TestInterfaceNotScriptWrappableV8Internal::attr1AttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void attr1AttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
TestInterfaceNotScriptWrappable* impl = V8TestInterfaceNotScriptWrappable::toImpl(holder);
TestInterfaceNotScriptWrappable* cppValue = V8TestInterfaceNotScriptWrappable::toImplWithTypeCheck(info.GetIsolate(), v8Value);
impl->setAttr1(WTF::getPtr(cppValue));
}
static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
TestInterfaceNotScriptWrappableV8Internal::attr1AttributeSetter(v8Value, info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
if (UNLIKELY(info.Length() < 1)) {
V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "func", "TestInterfaceNotScriptWrappable", 1, info.Length()), info.GetIsolate());
return;
}
TestInterfaceNotScriptWrappable* impl = V8TestInterfaceNotScriptWrappable::toImpl(info.Holder());
TestInterfaceNotScriptWrappable* arg;
{
arg = V8TestInterfaceNotScriptWrappable::toImplWithTypeCheck(info.GetIsolate(), info[0]);
}
impl->func(arg);
}
static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
TestInterfaceNotScriptWrappableV8Internal::funcMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
} // namespace TestInterfaceNotScriptWrappableV8Internal
static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNotScriptWrappableAttributes[] = {
{"attr1", TestInterfaceNotScriptWrappableV8Internal::attr1AttributeGetterCallback, TestInterfaceNotScriptWrappableV8Internal::attr1AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
};
static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceNotScriptWrappableMethods[] = {
{"func", TestInterfaceNotScriptWrappableV8Internal::funcMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
};
static void installV8TestInterfaceNotScriptWrappableTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
functionTemplate->ReadOnlyPrototype();
v8::Local<v8::Signature> defaultSignature;
defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceNotScriptWrappable", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceNotScriptWrappable::internalFieldCount,
V8TestInterfaceNotScriptWrappableAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceNotScriptWrappableAttributes),
0, 0,
V8TestInterfaceNotScriptWrappableMethods, WTF_ARRAY_LENGTH(V8TestInterfaceNotScriptWrappableMethods),
isolate);
v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
ALLOW_UNUSED_LOCAL(instanceTemplate);
v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
ALLOW_UNUSED_LOCAL(prototypeTemplate);
// Custom toString template
functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
}
v8::Handle<v8::FunctionTemplate> V8TestInterfaceNotScriptWrappable::domTemplate(v8::Isolate* isolate)
{
return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceNotScriptWrappableTemplate);
}
bool V8TestInterfaceNotScriptWrappable::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
}
v8::Handle<v8::Object> V8TestInterfaceNotScriptWrappable::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
}
TestInterfaceNotScriptWrappable* V8TestInterfaceNotScriptWrappable::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
{
return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceNotScriptWrappable>() : 0;
}
void V8TestInterfaceNotScriptWrappable::refObject(ScriptWrappableBase* scriptWrappableBase)
{
scriptWrappableBase->toImpl<TestInterfaceNotScriptWrappable>()->ref();
}
void V8TestInterfaceNotScriptWrappable::derefObject(ScriptWrappableBase* scriptWrappableBase)
{
scriptWrappableBase->toImpl<TestInterfaceNotScriptWrappable>()->deref();
}
template<>
v8::Handle<v8::Value> toV8NoInline(TestInterfaceNotScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
return toV8(impl, creationContext, isolate);
}
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
#ifndef V8TestInterfaceNotScriptWrappable_h
#define V8TestInterfaceNotScriptWrappable_h
#include "bindings/core/v8/ScriptWrappable.h"
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8DOMWrapper.h"
#include "bindings/core/v8/WrapperTypeInfo.h"
#include "bindings/tests/idls/core/TestInterfaceNotScriptWrappable.h"
#include "platform/heap/Handle.h"
namespace blink {
class V8TestInterfaceNotScriptWrappable {
public:
static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Value>, v8::Isolate*);
static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
static TestInterfaceNotScriptWrappable* toImpl(v8::Handle<v8::Object> object)
{
return blink::toScriptWrappableBase(object)->toImpl<TestInterfaceNotScriptWrappable>();
}
static TestInterfaceNotScriptWrappable* toImplWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
static const WrapperTypeInfo wrapperTypeInfo;
static void refObject(ScriptWrappableBase*);
static void derefObject(ScriptWrappableBase*);
static void trace(Visitor* visitor, ScriptWrappableBase* scriptWrappableBase)
{
}
static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0;
static inline ScriptWrappableBase* toScriptWrappableBase(TestInterfaceNotScriptWrappable* impl)
{
return impl->toScriptWrappableBase();
}
static void installConditionallyEnabledProperties(v8::Handle<v8::Object>, v8::Isolate*) { }
static void installConditionallyEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*) { }
};
inline v8::Handle<v8::Value> toV8(TestInterfaceNotScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
return toV8(scriptWrappableBase, creationContext, isolate, &V8TestInterfaceNotScriptWrappable::wrapperTypeInfo);
}
template<typename CallbackInfo>
inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceNotScriptWrappable* impl)
{
ScriptWrappableBase* scriptWrappableBase = impl ? impl->toScriptWrappableBase() : 0;
return v8SetReturnValue(callbackInfo, scriptWrappableBase, &V8TestInterfaceNotScriptWrappable::wrapperTypeInfo);
}
template<typename CallbackInfo>
inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestInterfaceNotScriptWrappable* impl)
{
ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
// Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
// main world or not.
return v8SetReturnValue(callbackInfo, impl);
}
template<typename CallbackInfo, typename Wrappable>
inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, TestInterfaceNotScriptWrappable* impl, Wrappable*)
{
// Since |impl| is not ScriptWrappable, it doesn't matter much if it's the
// main world or not.
return v8SetReturnValue(callbackInfo, impl);
}
} // namespace blink
#endif // V8TestInterfaceNotScriptWrappable_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment