diff options
-rw-r--r-- | webkit/glue/npruntime_util.cc | 2 | ||||
-rw-r--r-- | webkit/port/bindings/v8/NPV8Object.cpp | 34 | ||||
-rw-r--r-- | webkit/port/bindings/v8/V8NPObject.cpp | 12 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_helpers.cpp | 59 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_helpers.h | 24 | ||||
-rw-r--r-- | webkit/webkit.gyp | 4 |
6 files changed, 27 insertions, 108 deletions
diff --git a/webkit/glue/npruntime_util.cc b/webkit/glue/npruntime_util.cc index 152a9e3..f1c23eb 100644 --- a/webkit/glue/npruntime_util.cc +++ b/webkit/glue/npruntime_util.cc @@ -12,7 +12,7 @@ #include "EventNames.h" #include "MouseEvent.h" #include "NPV8Object.h" // for PrivateIdentifier -#include "v8_helpers.h" +#include "V8Helpers.h" #include "v8_proxy.h" #elif USE(JAVASCRIPTCORE_BINDINGS) #include "bridge/c/c_utility.h" diff --git a/webkit/port/bindings/v8/NPV8Object.cpp b/webkit/port/bindings/v8/NPV8Object.cpp index 479704c..24381c8 100644 --- a/webkit/port/bindings/v8/NPV8Object.cpp +++ b/webkit/port/bindings/v8/NPV8Object.cpp @@ -39,11 +39,13 @@ #include "PlatformString.h" #include "ScriptController.h" #include "V8CustomBinding.h" -#include "v8_helpers.h" +#include "V8Helpers.h" #include "V8NPUtils.h" #include "v8_proxy.h" #include "DOMWindow.h" +using WebCore::toV8Context; +using WebCore::toV8Proxy; using WebCore::V8ClassIndex; using WebCore::V8Custom; using WebCore::V8Proxy; @@ -132,7 +134,7 @@ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, v8::HandleScope handleScope; // FIXME: should use the plugin's owner frame as the security context - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -157,7 +159,7 @@ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, return false; } - WebCore::V8Proxy* proxy = GetV8Proxy(npobj); + V8Proxy* proxy = toV8Proxy(npobj); ASSERT(proxy); // must not be null // FIXME: fix variable naming @@ -199,7 +201,7 @@ bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, VOID_TO_NPVARIANT(*result); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -214,7 +216,7 @@ bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, v8::Local<v8::Value> resultObj; v8::Handle<v8::Function> func(v8::Function::Cast(*funcObj)); if (!func->IsNull()) { - WebCore::V8Proxy* proxy = GetV8Proxy(npobj); + V8Proxy* proxy = toV8Proxy(npobj); ASSERT(proxy); // Create list of args to pass to v8 @@ -257,11 +259,11 @@ bool NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npobj, NPString* return false; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; - WebCore::V8Proxy* proxy = GetV8Proxy(npobj); + V8Proxy* proxy = toV8Proxy(npobj); ASSERT(proxy); v8::Context::Scope scope(context); @@ -291,7 +293,7 @@ bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVari V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -322,7 +324,7 @@ bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -350,7 +352,7 @@ bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName) V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); @@ -370,7 +372,7 @@ bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName) V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); @@ -393,7 +395,7 @@ bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName) V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); @@ -413,7 +415,7 @@ void NPN_SetException(NPObject *npobj, const NPUTF8 *message) if (npobj->_class != npScriptObjectClass) return; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(0, npobj); + v8::Handle<v8::Context> context = toV8Context(0, npobj); if (context.IsEmpty()) return; @@ -430,7 +432,7 @@ bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); @@ -486,7 +488,7 @@ bool NPN_Construct(NPP npp, NPObject* npobj, const NPVariant* args, uint32_t arg V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = getV8Context(npp, npobj); + v8::Handle<v8::Context> context = toV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); @@ -500,7 +502,7 @@ bool NPN_Construct(NPP npp, NPObject* npobj, const NPVariant* args, uint32_t arg v8::Local<v8::Value> resultObj; v8::Handle<v8::Function> ctor(v8::Function::Cast(*ctorObj)); if (!ctor->IsNull()) { - WebCore::V8Proxy* proxy = GetV8Proxy(npobj); + V8Proxy* proxy = toV8Proxy(npobj); ASSERT(proxy); // Create list of args to pass to v8. diff --git a/webkit/port/bindings/v8/V8NPObject.cpp b/webkit/port/bindings/v8/V8NPObject.cpp index 8d3a518..35be7e0 100644 --- a/webkit/port/bindings/v8/V8NPObject.cpp +++ b/webkit/port/bindings/v8/V8NPObject.cpp @@ -37,12 +37,12 @@ #include "NPV8Object.h" #include "V8CustomBinding.h" #include "V8DOMMap.h" +#include "V8Helpers.h" #include "V8HTMLAppletElement.h" #include "V8HTMLEmbedElement.h" #include "V8HTMLObjectElement.h" #include "V8NPUtils.h" #include "V8Proxy.h" -#include "v8_helpers.h" #include "wtf/OwnArrayPtr.h" using namespace WebCore; @@ -340,13 +340,13 @@ v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root v8::Handle<v8::Function> v8Function = npObjectDesc->GetFunction(); v8::Local<v8::Object> value = SafeAllocation::NewInstance(v8Function); - - // If we were unable to allocate the instance, we avoid wrapping - // and registering the NP object. - if (value.IsEmpty()) + + // If we were unable to allocate the instance, we avoid wrapping + // and registering the NP object. + if (value.IsEmpty()) return value; - WrapNPObject(value, object); + wrapNPObject(value, object); // KJS retains the object as part of its wrapper (see Bindings::CInstance). NPN_RetainObject(object); diff --git a/webkit/port/bindings/v8/v8_helpers.cpp b/webkit/port/bindings/v8/v8_helpers.cpp deleted file mode 100644 index 7a72ab5e..0000000 --- a/webkit/port/bindings/v8/v8_helpers.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2008, 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" - -#define max max -#define min min -#include "v8_helpers.h" -#include "v8_proxy.h" -#include "v8_index.h" -#include "NPV8Object.h" - -#include "DOMWindow.h" - -using WebCore::V8Custom; - -void WrapNPObject(v8::Handle<v8::Object> obj, NPObject* npobj) -{ - WebCore::V8Proxy::SetDOMWrapper(obj, WebCore::V8ClassIndex::NPOBJECT, npobj); -} - -v8::Local<v8::Context> getV8Context(NPP npp, NPObject* npobj) -{ - V8NPObject* object = reinterpret_cast<V8NPObject*>(npobj); - return WebCore::V8Proxy::GetContext(object->rootObject->frame()); -} - -WebCore::V8Proxy* GetV8Proxy(NPObject* npobj) -{ - V8NPObject* object = reinterpret_cast<V8NPObject*>(npobj); - WebCore::Frame* frame = object->rootObject->frame(); - return WebCore::V8Proxy::retrieve(frame); -} diff --git a/webkit/port/bindings/v8/v8_helpers.h b/webkit/port/bindings/v8/v8_helpers.h deleted file mode 100644 index eebdd1e..0000000 --- a/webkit/port/bindings/v8/v8_helpers.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#ifndef V8_HELPERS_H__ -#define V8_HELPERS_H__ - -#include "third_party/npapi/bindings/npruntime.h" -#include <v8.h> - -namespace WebCore { - class V8Proxy; -} - -// Associates an NPObject with a V8 object. -void WrapNPObject(v8::Handle<v8::Object> obj, NPObject *npobj); - -// Retrieves the V8 Context from the NP context pr obj (at most 1 may be NULL). -v8::Local<v8::Context> getV8Context(NPP npp, NPObject* npobj); - -// Get V8Proxy object from an NPObject. -WebCore::V8Proxy* GetV8Proxy(NPObject* npobj); - -#endif // V8_HELPERS_H__ diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 7ae81b3..effc4bd 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -1102,6 +1102,8 @@ '../third_party/WebKit/WebCore/bindings/v8/V8DOMMap.h', '../third_party/WebKit/WebCore/bindings/v8/V8EventListenerList.cpp', '../third_party/WebKit/WebCore/bindings/v8/V8EventListenerList.h', + '../third_party/WebKit/WebCore/bindings/v8/V8Helpers.cpp', + '../third_party/WebKit/WebCore/bindings/v8/V8Helpers.h', '../third_party/WebKit/WebCore/bindings/v8/V8LazyEventListener.cpp', '../third_party/WebKit/WebCore/bindings/v8/V8LazyEventListener.h', '../third_party/WebKit/WebCore/bindings/v8/V8NodeFilterCondition.cpp', @@ -1145,8 +1147,6 @@ 'port/bindings/v8/npruntime_priv.h', 'port/bindings/v8/v8_binding.h', 'port/bindings/v8/v8_binding.cpp', - 'port/bindings/v8/v8_helpers.cpp', - 'port/bindings/v8/v8_helpers.h', 'port/bindings/v8/v8_index.cpp', 'port/bindings/v8/v8_index.h', 'port/bindings/v8/V8NPUtils.cpp', |