Modified: trunk/Source/WebCore/bindings/v8/NPObjectWrapper.cpp (97428 => 97429)
--- trunk/Source/WebCore/bindings/v8/NPObjectWrapper.cpp 2011-10-14 00:35:11 UTC (rev 97428)
+++ trunk/Source/WebCore/bindings/v8/NPObjectWrapper.cpp 2011-10-14 00:37:56 UTC (rev 97429)
@@ -1,43 +1,43 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NPObjectWrapper.h"
-
-namespace WebCore {
-
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NPObjectWrapper.h"
+
+namespace WebCore {
+
struct NPProxyObject {
NPObject object;
NPObjectWrapper* wrapper;
};
-
+
NPClass NPObjectWrapper::m_npClassWrapper = {
NP_CLASS_STRUCT_VERSION,
NPObjectWrapper::NPAllocate,
@@ -53,82 +53,97 @@
NPObjectWrapper::NPNEnumerate,
NPObjectWrapper::NPNConstruct
};
-
-NPObjectWrapper::NPObjectWrapper(NPObject* obj)
- : m_wrappedNPObject(obj) {
-}
-
-NPObject* NPObjectWrapper::create(NPObject* object) {
- ASSERT(object);
- NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(_NPN_CreateObject(0, &m_npClassWrapper));
- proxyObject->wrapper = new NPObjectWrapper(object);
- return reinterpret_cast<NPObject*>(proxyObject);
-}
-
-void NPObjectWrapper::clear() {
- m_wrappedNPObject = 0;
-}
-
-NPObjectWrapper* NPObjectWrapper::getWrapper(NPObject* obj) {
- if (&m_npClassWrapper == obj->_class) {
- NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj);
- return proxyObject->wrapper;
- }
- return 0;
-}
-
-NPObject* NPObjectWrapper::getUnderlyingNPObject(NPObject* obj) {
- NPObjectWrapper* wrapper = getWrapper(obj);
- return wrapper ? wrapper->m_wrappedNPObject : 0;
-}
-
-NPObject* NPObjectWrapper::getObjectForCall(NPObject* obj) {
- NPObject* actualObject = getUnderlyingNPObject(obj);
- return actualObject ? actualObject : obj;
-}
-
-NPObject* NPObjectWrapper::NPAllocate(NPP, NPClass*) {
- return reinterpret_cast<NPObject*>(new NPObjectWrapper(0));
+
+NPObjectWrapper::NPObjectWrapper(NPObject* obj)
+ : m_wrappedNPObject(obj)
+{
}
-void NPObjectWrapper::NPDeallocate(NPObject* obj) {
- NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj);
+NPObject* NPObjectWrapper::create(NPObject* object)
+{
+ ASSERT(object);
+ NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(_NPN_CreateObject(0, &m_npClassWrapper));
+ proxyObject->wrapper = new NPObjectWrapper(object);
+ return reinterpret_cast<NPObject*>(proxyObject);
+}
+
+void NPObjectWrapper::clear()
+{
+ m_wrappedNPObject = 0;
+}
+
+NPObjectWrapper* NPObjectWrapper::getWrapper(NPObject* obj)
+{
+ if (&m_npClassWrapper == obj->_class) {
+ NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj);
+ return proxyObject->wrapper;
+ }
+ return 0;
+}
+
+NPObject* NPObjectWrapper::getUnderlyingNPObject(NPObject* obj)
+{
+ NPObjectWrapper* wrapper = getWrapper(obj);
+ return wrapper ? wrapper->m_wrappedNPObject : 0;
+}
+
+NPObject* NPObjectWrapper::getObjectForCall(NPObject* obj)
+{
+ NPObject* actualObject = getUnderlyingNPObject(obj);
+ return actualObject ? actualObject : 0;
+}
+
+NPObject* NPObjectWrapper::NPAllocate(NPP, NPClass*)
+{
+ return reinterpret_cast<NPObject*>(new NPProxyObject);
+}
+
+void NPObjectWrapper::NPDeallocate(NPObject* obj)
+{
+ NPProxyObject* proxyObject = reinterpret_cast<NPProxyObject*>(obj);
delete proxyObject->wrapper;
delete proxyObject;
}
-
-void NPObjectWrapper::NPPInvalidate(NPObject* obj) {
+
+void NPObjectWrapper::NPPInvalidate(NPObject* obj)
+{
NPObject* actualObject = getObjectForCall(obj);
if (actualObject && actualObject->_class->invalidate)
actualObject->_class->invalidate(actualObject);
}
-
-bool NPObjectWrapper::NPHasMethod(NPObject* obj, NPIdentifier name) {
+
+bool NPObjectWrapper::NPHasMethod(NPObject* obj, NPIdentifier name)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_HasMethod(0, actualObject, name) : false;
}
-bool NPObjectWrapper::NPInvoke(NPObject* obj, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result) {
+bool NPObjectWrapper::NPInvoke(NPObject* obj, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_Invoke(0, actualObject, name, args, argCount, result) : false;
}
-bool NPObjectWrapper::NPInvokeDefault(NPObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result) {
+bool NPObjectWrapper::NPInvokeDefault(NPObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_InvokeDefault(0, actualObject, args, argCount, result) : false;
}
-bool NPObjectWrapper::NPHasProperty(NPObject* obj, NPIdentifier name) {
+bool NPObjectWrapper::NPHasProperty(NPObject* obj, NPIdentifier name)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_HasProperty(0, actualObject, name) : false;
}
-bool NPObjectWrapper::NPGetProperty(NPObject* obj, NPIdentifier name, NPVariant* result) {
+bool NPObjectWrapper::NPGetProperty(NPObject* obj, NPIdentifier name, NPVariant* result)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_GetProperty(0, actualObject, name, result) : false;
}
-bool NPObjectWrapper::NPSetProperty(NPObject* obj, NPIdentifier name, const NPVariant* value) {
+bool NPObjectWrapper::NPSetProperty(NPObject* obj, NPIdentifier name, const NPVariant* value)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_SetProperty(0, actualObject, name, value) : false;
}
@@ -138,17 +153,20 @@
return actualObject ? _NPN_RemoveProperty(0, actualObject, name) : false;
}
-bool NPObjectWrapper::NPNEnumerate(NPObject* obj, NPIdentifier** value, uint32_t* count) {
+bool NPObjectWrapper::NPNEnumerate(NPObject* obj, NPIdentifier** value, uint32_t* count)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_Enumerate(0, actualObject, value, count) : false;
}
-bool NPObjectWrapper::NPNConstruct(NPObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result) {
+bool NPObjectWrapper::NPNConstruct(NPObject* obj, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
NPObject* actualObject = getObjectForCall(obj);
return actualObject ? _NPN_Construct(0, actualObject, args, argCount, result) : false;
}
-bool NPObjectWrapper::NPInvokePrivate(NPP npp, NPObject* obj, bool isDefault, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result) {
+bool NPObjectWrapper::NPInvokePrivate(NPP npp, NPObject* obj, bool isDefault, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result)
+{
NPObject* actualObject = getObjectForCall(obj);
if (!actualObject)
return false;
@@ -159,5 +177,5 @@
return _NPN_Invoke(0, actualObject, name, args, argCount, result);
}
}
-
-} // namespace WebCore
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/NPObjectWrapper.h (97428 => 97429)
--- trunk/Source/WebCore/bindings/v8/NPObjectWrapper.h 2011-10-14 00:35:11 UTC (rev 97428)
+++ trunk/Source/WebCore/bindings/v8/NPObjectWrapper.h 2011-10-14 00:37:56 UTC (rev 97429)
@@ -1,61 +1,61 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NPObjectWrapper_h
-#define NPObjectWrapper_h
-
-#include "npruntime_impl.h"
-
-namespace WebCore {
-
-// This class wraps a NPObject and provides functionality for the wrapped
-// object to be cleared out when this object is destroyed. This is to ensure
-// that callers trying to access the underlying object don't crash while
-// invoking methods on the NPObject.
-class NPObjectWrapper : public NPObject {
-public:
- // Creates an instance of the NPObjectWrapper class and wraps the object
- // passed in.
- static NPObject* create(NPObject* object);
-
- // This method should be called to invalidate the underlying NPObject pointer.
- void clear();
-
- // Returns a pointer to NPObjectWrapper if the object passed in was wrapped by us.
- static NPObjectWrapper* getWrapper(NPObject* obj);
-
- // Returns a pointer to the underlying raw NPObject pointer or 0 if the object
- // passed in was not wrapped.
- static NPObject* getUnderlyingNPObject(NPObject* obj);
-
- // NPObject functions implemented by the wrapper.
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NPObjectWrapper_h
+#define NPObjectWrapper_h
+
+#include "npruntime_impl.h"
+
+namespace WebCore {
+
+// This class wraps a NPObject and provides functionality for the wrapped
+// object to be cleared out when this object is destroyed. This is to ensure
+// that callers trying to access the underlying object don't crash while
+// invoking methods on the NPObject.
+class NPObjectWrapper {
+public:
+ // Creates an instance of the NPObjectWrapper class and wraps the object
+ // passed in.
+ static NPObject* create(NPObject* object);
+
+ // This method should be called to invalidate the underlying NPObject pointer.
+ void clear();
+
+ // Returns a pointer to NPObjectWrapper if the object passed in was wrapped by us.
+ static NPObjectWrapper* getWrapper(NPObject* obj);
+
+ // Returns a pointer to the underlying raw NPObject pointer or 0 if the object
+ // passed in was not wrapped.
+ static NPObject* getUnderlyingNPObject(NPObject* obj);
+
+ // NPObject functions implemented by the wrapper.
static NPObject* NPAllocate(NPP, NPClass*);
static void NPDeallocate(NPObject* obj);
static void NPPInvalidate(NPObject *obj);
@@ -71,18 +71,18 @@
static bool NPInvokePrivate(NPP npp, NPObject* obj,bool isDefault, NPIdentifier name, const NPVariant* args, uint32_t argCount, NPVariant* result);
private:
- NPObjectWrapper(NPObject* obj);
-
- // Returns the underlying NPObject if the object passed in was wrapped. Otherwise
- // just returns the object passed in.
- static NPObject* getObjectForCall(NPObject* obj);
-
+ NPObjectWrapper(NPObject* obj);
+
+ // Returns the underlying NPObject if the object passed in was wrapped. Otherwise
+ // just returns the object passed in.
+ static NPObject* getObjectForCall(NPObject* obj);
+
static NPClass m_npClassWrapper;
// Weak NPObject poointer.
NPObject* m_wrappedNPObject;
-};
-
-} // namespace WebCore
-
-#endif // NPObjectWrapper_h
-
+};
+
+} // namespace WebCore
+
+#endif // NPObjectWrapper_h
+