Title: [140302] trunk/Source/WebCore
- Revision
- 140302
- Author
- [email protected]
- Date
- 2013-01-20 23:18:48 -0800 (Sun, 20 Jan 2013)
Log Message
[V8] We should set a class id for a NPObject wrapper
https://bugs.webkit.org/show_bug.cgi?id=107249
Reviewed by Adam Barth.
This is one of steps to avoid hitting an ASSERT()
that will be added in https://bugs.webkit.org/show_bug.cgi?id=107137 .
No tests. No change in behavior.
* bindings/v8/V8DOMWrapper.h:
(V8DOMWrapper):
(WebCore::V8DOMWrapper::setWrapperClass):
(WebCore):
* bindings/v8/V8NPObject.cpp:
(WebCore::createV8ObjectForNPObject):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (140301 => 140302)
--- trunk/Source/WebCore/ChangeLog 2013-01-21 07:10:43 UTC (rev 140301)
+++ trunk/Source/WebCore/ChangeLog 2013-01-21 07:18:48 UTC (rev 140302)
@@ -1,3 +1,22 @@
+2013-01-20 Kentaro Hara <[email protected]>
+
+ [V8] We should set a class id for a NPObject wrapper
+ https://bugs.webkit.org/show_bug.cgi?id=107249
+
+ Reviewed by Adam Barth.
+
+ This is one of steps to avoid hitting an ASSERT()
+ that will be added in https://bugs.webkit.org/show_bug.cgi?id=107137 .
+
+ No tests. No change in behavior.
+
+ * bindings/v8/V8DOMWrapper.h:
+ (V8DOMWrapper):
+ (WebCore::V8DOMWrapper::setWrapperClass):
+ (WebCore):
+ * bindings/v8/V8NPObject.cpp:
+ (WebCore::createV8ObjectForNPObject):
+
2013-01-20 Mike Lawther <[email protected]>
CSS3 calc: unprefix implementation
Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h (140301 => 140302)
--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h 2013-01-21 07:10:43 UTC (rev 140301)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h 2013-01-21 07:18:48 UTC (rev 140302)
@@ -64,6 +64,8 @@
static inline v8::Persistent<v8::Object> associateObjectWithWrapper(PassRefPtr<T>, WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*);
static inline void setNativeInfo(v8::Handle<v8::Object>, WrapperTypeInfo*, void*);
static inline void clearNativeInfo(v8::Handle<v8::Object>, WrapperTypeInfo*);
+ static inline void setWrapperClass(void*, v8::Persistent<v8::Object>);
+ static inline void setWrapperClass(Node*, v8::Persistent<v8::Object>);
// FIXME: This function should probably move to V8EventListenerList.h
static PassRefPtr<EventListener> getEventListener(v8::Local<v8::Value>, bool isAttribute, ListenerLookupType);
@@ -72,12 +74,18 @@
// FIXME: Why is this function in V8DOMWrapper?
static void setNamedHiddenReference(v8::Handle<v8::Object> parent, const char* name, v8::Handle<v8::Value> child);
-
- private:
- static void setWrapperClass(void*, v8::Persistent<v8::Object> wrapper) { wrapper.SetWrapperClassId(v8DOMObjectClassId); }
- static void setWrapperClass(Node*, v8::Persistent<v8::Object> wrapper) { wrapper.SetWrapperClassId(v8DOMNodeClassId); }
};
+ inline void V8DOMWrapper::setWrapperClass(void*, v8::Persistent<v8::Object> wrapper)
+ {
+ wrapper.SetWrapperClassId(v8DOMObjectClassId);
+ }
+
+ inline void V8DOMWrapper::setWrapperClass(Node*, v8::Persistent<v8::Object> wrapper)
+ {
+ wrapper.SetWrapperClassId(v8DOMNodeClassId);
+ }
+
inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, WrapperTypeInfo* type, void* object)
{
ASSERT(wrapper->InternalFieldCount() >= 2);
Modified: trunk/Source/WebCore/bindings/v8/V8NPObject.cpp (140301 => 140302)
--- trunk/Source/WebCore/bindings/v8/V8NPObject.cpp 2013-01-21 07:10:43 UTC (rev 140301)
+++ trunk/Source/WebCore/bindings/v8/V8NPObject.cpp 2013-01-21 07:18:48 UTC (rev 140302)
@@ -431,24 +431,25 @@
npObjectDesc->InstanceTemplate()->SetCallAsFunctionHandler(npObjectInvokeDefaultHandler);
}
+ // FIXME: Move staticNPObjectMap() to DOMDataStore.
+ // Use V8DOMWrapper::createWrapper() and
+ // V8DOMWrapper::associateObjectWithWrapper()
+ // to create a wrapper object.
v8::Handle<v8::Function> v8Function = npObjectDesc->GetFunction();
v8::Local<v8::Object> value = V8ObjectConstructor::newInstance(v8Function);
-
- // If we were unable to allocate the instance, we avoid wrapping and registering the NP object.
if (value.IsEmpty())
return value;
V8DOMWrapper::setNativeInfo(value, npObjectTypeInfo(), object);
+ v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(value);
+ V8DOMWrapper::setWrapperClass(object, wrapperHandle);
// KJS retains the object as part of its wrapper (see Bindings::CInstance).
_NPN_RetainObject(object);
-
_NPN_RegisterObject(object, root);
- // Maintain a weak pointer for v8 so we can cleanup the object.
- v8::Persistent<v8::Object> weakRef = v8::Persistent<v8::Object>::New(value);
- staticNPObjectMap().set(object, weakRef);
-
+ staticNPObjectMap().set(object, wrapperHandle);
+ ASSERT(maybeDOMWrapper(wrapperHandle));
return value;
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes