diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 20:17:08 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 20:17:08 +0000 |
commit | 2eb312b025971ee1529b3a6c67d715055cb77906 (patch) | |
tree | 8d0eb7b8445c14840c255ed988f0e9b9b518cb08 /webkit | |
parent | 0ed164e1bbe8bde1b5be616c10ef46388ea78079 (diff) | |
download | chromium_src-2eb312b025971ee1529b3a6c67d715055cb77906.zip chromium_src-2eb312b025971ee1529b3a6c67d715055cb77906.tar.gz chromium_src-2eb312b025971ee1529b3a6c67d715055cb77906.tar.bz2 |
Address some of the review comments on comment 2 of
https://bugs.webkit.org/show_bug.cgi?id=24299
This is everything up to "not supposed to be using STL container classes."
Review URL: http://codereview.chromium.org/40122
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11025 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
16 files changed, 334 insertions, 321 deletions
diff --git a/webkit/build/V8Bindings/SConscript b/webkit/build/V8Bindings/SConscript index a1763aa..64fa2b5 100644 --- a/webkit/build/V8Bindings/SConscript +++ b/webkit/build/V8Bindings/SConscript @@ -327,7 +327,7 @@ inputs = [ '$PORT_DIR/bindings/v8/JSDOMBinding.cpp', '$PORT_DIR/bindings/v8/JSXPathNSResolver.cpp', - '$PORT_DIR/bindings/v8/np_v8object.cpp', + '$PORT_DIR/bindings/v8/NPV8Object.cpp', '$PORT_DIR/bindings/v8/npruntime.cpp', '$PORT_DIR/bindings/v8/RGBColor.cpp', '$WEBCORE_DIR/bindings/v8/ScheduledAction.cpp', @@ -340,8 +340,8 @@ inputs = [ '$PORT_DIR/bindings/v8/v8_helpers.cpp', '$PORT_DIR/bindings/v8/v8_index.cpp', '$PORT_DIR/bindings/v8/v8_nodefilter.cpp', - '$PORT_DIR/bindings/v8/v8_np_utils.cpp', - '$PORT_DIR/bindings/v8/v8_npobject.cpp', + '$PORT_DIR/bindings/v8/V8NPUtils.cpp', + '$PORT_DIR/bindings/v8/V8NPObject.cpp', '$PORT_DIR/bindings/v8/v8_proxy.cpp', '$PORT_DIR/bindings/v8/V8CanvasPixelArrayCustom.cpp', '$PORT_DIR/bindings/v8/V8MessagePortCustom.cpp', diff --git a/webkit/build/V8Bindings/V8Bindings.vcproj b/webkit/build/V8Bindings/V8Bindings.vcproj index 6246f35..c104f9e 100644 --- a/webkit/build/V8Bindings/V8Bindings.vcproj +++ b/webkit/build/V8Bindings/V8Bindings.vcproj @@ -127,162 +127,162 @@ <Filter Name="custom" > - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CanvasRenderingContext2DCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8ClipboardCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CSSStyleDeclarationCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CustomBinding.h" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CustomEventListener.h" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DocumentCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DOMParserConstructor.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DOMStringListCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DOMWindowCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8EventCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLCanvasElementCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLCollectionCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLDocumentCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLFormElementCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLFrameSetElementCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLInputElementCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLOptionsCollectionCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLPlugInElementCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLSelectElementCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLSelectElementCustom.h" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8LocationCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8MessageChannelConstructor.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NamedNodesCollection.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NamedNodesCollection.h" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NamedNodeMapCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NavigatorCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeFilterCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeIteratorCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeListCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8StyleSheetListCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8SVGElementInstanceCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8SVGLengthCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8SVGMatrixCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8TreeWalkerCustom.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8WebKitCSSMatrixConstructor.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8XMLSerializerConstructor.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8XPathEvaluatorConstructor.cpp" - > - </File> - <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8XSLTProcessorCustom.cpp" - > - </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CanvasRenderingContext2DCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8ClipboardCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CSSStyleDeclarationCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CustomBinding.h" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8CustomEventListener.h" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DocumentCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DOMParserConstructor.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DOMStringListCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8DOMWindowCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8EventCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLCanvasElementCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLCollectionCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLDocumentCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLFormElementCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLFrameSetElementCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLInputElementCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLOptionsCollectionCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLPlugInElementCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLSelectElementCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8HTMLSelectElementCustom.h" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8LocationCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8MessageChannelConstructor.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NamedNodeMapCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NamedNodesCollection.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NamedNodesCollection.h" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NavigatorCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeFilterCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeIteratorCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8NodeListCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8StyleSheetListCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8SVGElementInstanceCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8SVGLengthCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8SVGMatrixCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8TreeWalkerCustom.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8WebKitCSSMatrixConstructor.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8XMLSerializerConstructor.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8XPathEvaluatorConstructor.cpp" + > + </File> + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\custom\V8XSLTProcessorCustom.cpp" + > + </File> </Filter> <Filter Name="DerivedSources" @@ -2616,15 +2616,15 @@ Name="c_binding" > <File - RelativePath="..\..\port\bindings\v8\np_v8object.cpp" + RelativePath="..\..\port\bindings\v8\npruntime.cpp" > </File> <File - RelativePath="..\..\port\bindings\v8\np_v8object.h" + RelativePath="..\..\port\bindings\v8\npruntime_impl.h" > </File> <File - RelativePath="..\..\port\bindings\v8\npruntime.cpp" + RelativePath="..\..\port\bindings\v8\npruntime_internal.h" > </File> <File @@ -2632,6 +2632,14 @@ > </File> <File + RelativePath="..\..\port\bindings\v8\NPV8Object.cpp" + > + </File> + <File + RelativePath="..\..\port\bindings\v8\NPV8Object.h" + > + </File> + <File RelativePath="..\..\port\bindings\v8\v8_helpers.cpp" > </File> @@ -2640,19 +2648,19 @@ > </File> <File - RelativePath="..\..\port\bindings\v8\v8_np_utils.cpp" + RelativePath="..\..\port\bindings\v8\V8NPObject.cpp" > </File> <File - RelativePath="..\..\port\bindings\v8\v8_np_utils.h" + RelativePath="..\..\port\bindings\v8\V8NPObject.h" > </File> <File - RelativePath="..\..\port\bindings\v8\v8_npobject.cpp" + RelativePath="..\..\port\bindings\v8\V8NPUtils.cpp" > </File> <File - RelativePath="..\..\port\bindings\v8\v8_npobject.h" + RelativePath="..\..\port\bindings\v8\V8NPUtils.h" > </File> </Filter> @@ -2745,11 +2753,11 @@ > </File> <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\ScheduledAction.h" + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\ScheduledAction.cpp" > </File> <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\ScheduledAction.cpp" + RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\v8\ScheduledAction.h" > </File> <File diff --git a/webkit/glue/npruntime_util.cc b/webkit/glue/npruntime_util.cc index ced8f04..e21d52d 100644 --- a/webkit/glue/npruntime_util.cc +++ b/webkit/glue/npruntime_util.cc @@ -8,7 +8,7 @@ // Import the definition of PrivateIdentifier #if USE(V8_BINDING) -#include "webkit/port/bindings/v8/np_v8object.h" +#include "NPV8Object.h" #elif USE(JAVASCRIPTCORE_BINDINGS) #include "bridge/c/c_utility.h" #undef LOG diff --git a/webkit/port/bindings/v8/np_v8object.cpp b/webkit/port/bindings/v8/NPV8Object.cpp index 731bd9d..829fd074 100644 --- a/webkit/port/bindings/v8/np_v8object.cpp +++ b/webkit/port/bindings/v8/NPV8Object.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2007 Google, Inc. All rights reserved. + * Copyright (C) 2007-2009 Google, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,7 +31,7 @@ #define max max #define min min #include <v8.h> -#include "np_v8object.h" +#include "NPV8Object.h" #include "ChromiumBridge.h" #include "Frame.h" #include "bindings/npruntime.h" @@ -40,7 +40,7 @@ #include "ScriptController.h" #include "v8_custom.h" #include "v8_helpers.h" -#include "v8_np_utils.h" +#include "V8NPUtils.h" #include "v8_proxy.h" #include "DOMWindow.h" @@ -48,7 +48,7 @@ using WebCore::V8ClassIndex; using WebCore::V8Custom; using WebCore::V8Proxy; -// TODO(mbelshe): comments on why use malloc and free. +// FIXME(mbelshe): comments on why use malloc and free. static NPObject* AllocV8NPObject(NPP, NPClass*) { return static_cast<NPObject*>(malloc(sizeof(V8NPObject))); @@ -71,7 +71,7 @@ static v8::Handle<v8::Value>* listFromVariantArgs(const NPVariant* args, v8::Handle<v8::Value>* argv = new v8::Handle<v8::Value>[argCount]; for (uint32_t index = 0; index < argCount; index++) { const NPVariant *arg = &args[index]; - argv[index] = ConvertNPVariantToV8Object(arg, owner); + argv[index] = convertNPVariantToV8Object(arg, owner); } return argv; } @@ -94,9 +94,9 @@ static NPClass V8NPObjectClass = { NP_CLASS_STRUCT_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // NPAPI's npruntime functions -NPClass* NPScriptObjectClass = &V8NPObjectClass; +NPClass* npScriptObjectClass = &V8NPObjectClass; -NPObject* NPN_CreateScriptObject(NPP npp, v8::Handle<v8::Object> object, WebCore::DOMWindow* root) +NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, WebCore::DOMWindow* root) { // Check to see if this object is already wrapped. if (object->InternalFieldCount() == V8Custom::kNPObjectInternalFieldCount && @@ -123,7 +123,7 @@ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, if (!npobj) return false; - if (npobj->_class == NPScriptObjectClass) { + if (npobj->_class == npScriptObjectClass) { V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); PrivateIdentifier *identifier = static_cast<PrivateIdentifier*>(methodName); @@ -131,8 +131,8 @@ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, return false; v8::HandleScope handleScope; - // TODO: should use the plugin's owner frame as the security context - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + // FIXME: should use the plugin's owner frame as the security context + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -160,7 +160,7 @@ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, WebCore::V8Proxy* proxy = GetV8Proxy(npobj); ASSERT(proxy); // must not be null - // TODO: fix variable naming + // FIXME: fix variable naming // Call the function object v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(funcObj); // Create list of args to pass to v8 @@ -175,7 +175,7 @@ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, return false; // Convert the result back to an NPVariant - ConvertV8ObjectToNPVariant(resultObj, npobj, result); + convertV8ObjectToNPVariant(resultObj, npobj, result); return true; } @@ -186,21 +186,20 @@ bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, return true; } - -// TODO: Fix it same as NPN_Invoke (HandleScope and such) +// FIXME: Fix it same as NPN_Invoke (HandleScope and such) bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { if (!npobj) return false; - if (npobj->_class == NPScriptObjectClass) { + if (npobj->_class == npScriptObjectClass) { V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); VOID_TO_NPVARIANT(*result); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -231,7 +230,7 @@ bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, return false; // Convert the result back to an NPVariant. - ConvertV8ObjectToNPVariant(resultObj, npobj, result); + convertV8ObjectToNPVariant(resultObj, npobj, result); return true; } @@ -254,11 +253,11 @@ bool NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npobj, NPString* if (!npobj) return false; - if (npobj->_class != NPScriptObjectClass) + if (npobj->_class != npScriptObjectClass) return false; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -279,7 +278,7 @@ bool NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npobj, NPString* if (v8result.IsEmpty()) return false; - ConvertV8ObjectToNPVariant(v8result, npobj, result); + convertV8ObjectToNPVariant(v8result, npobj, result); return true; } @@ -288,11 +287,11 @@ bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVari if (!npobj) return false; - if (npobj->_class == NPScriptObjectClass) { + if (npobj->_class == npScriptObjectClass) { V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -301,7 +300,7 @@ bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVari v8::Handle<v8::Object> obj(object->v8Object); v8::Local<v8::Value> v8result = obj->Get(NPIdentifierToV8Identifier(propertyName)); - ConvertV8ObjectToNPVariant(v8result, npobj, result); + convertV8ObjectToNPVariant(v8result, npobj, result); return true; } @@ -319,11 +318,11 @@ bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const if (!npobj) return false; - if (npobj->_class == NPScriptObjectClass) { + if (npobj->_class == npScriptObjectClass) { V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; @@ -331,7 +330,7 @@ bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const v8::Handle<v8::Object> obj(object->v8Object); obj->Set(NPIdentifierToV8Identifier(propertyName), - ConvertNPVariantToV8Object(value, object->rootObject->frame()->script()->windowScriptNPObject())); + convertNPVariantToV8Object(value, object->rootObject->frame()->script()->windowScriptNPObject())); return true; } @@ -345,19 +344,19 @@ bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName) { if (!npobj) return false; - if (npobj->_class != NPScriptObjectClass) + if (npobj->_class != npScriptObjectClass) return false; V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); v8::Handle<v8::Object> obj(object->v8Object); - // TODO(mbelshe) - verify that setting to undefined is right. + // FIXME(mbelshe) - verify that setting to undefined is right. obj->Set(NPIdentifierToV8Identifier(propertyName), v8::Undefined()); return true; } @@ -367,11 +366,11 @@ bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName) if (!npobj) return false; - if (npobj->_class == NPScriptObjectClass) { + if (npobj->_class == npScriptObjectClass) { V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); @@ -390,11 +389,11 @@ bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName) if (!npobj) return false; - if (npobj->_class == NPScriptObjectClass) { + if (npobj->_class == npScriptObjectClass) { V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); @@ -411,10 +410,10 @@ bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName) void NPN_SetException(NPObject *npobj, const NPUTF8 *message) { - if (npobj->_class != NPScriptObjectClass) + if (npobj->_class != npScriptObjectClass) return; v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(0, npobj); + v8::Handle<v8::Context> context = getV8Context(0, npobj); if (context.IsEmpty()) return; @@ -427,24 +426,24 @@ bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t if (!npobj) return false; - if (npobj->_class == NPScriptObjectClass) { + if (npobj->_class == npScriptObjectClass) { V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj); v8::HandleScope handleScope; - v8::Handle<v8::Context> context = GetV8Context(npp, npobj); + v8::Handle<v8::Context> context = getV8Context(npp, npobj); if (context.IsEmpty()) return false; v8::Context::Scope scope(context); v8::Handle<v8::Object> obj(object->v8Object); - // TODO(fqian): http://b/issue?id=1210340: Use a v8::Object::Keys() method + // FIXME(fqian): http://b/issue?id=1210340: Use a v8::Object::Keys() method // when it exists, instead of evaluating javascript. - // TODO(mpcomplete): figure out how to cache this helper function. + // FIXME(mpcomplete): figure out how to cache this helper function. // Run a helper function that collects the properties on the object into // an array. - const char kEnumeratorCode[] = + const char enumeratorCode[] = "(function (obj) {" " var props = [];" " for (var prop in obj) {" @@ -452,7 +451,7 @@ bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t " }" " return props;" "});"; - v8::Handle<v8::String> source = v8::String::New(kEnumeratorCode); + v8::Handle<v8::String> source = v8::String::New(enumeratorCode); v8::Handle<v8::Script> script = v8::Script::Compile(source, 0); v8::Handle<v8::Value> enumeratorObj = script->Run(); v8::Handle<v8::Function> enumerator = v8::Handle<v8::Function>::Cast(enumeratorObj); @@ -467,7 +466,7 @@ bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *identifier = static_cast<NPIdentifier*>(malloc(sizeof(NPIdentifier*) * *count)); for (uint32_t i = 0; i < *count; ++i) { v8::Local<v8::Value> name = props->Get(v8::Integer::New(i)); - (*identifier)[i] = GetStringIdentifier(v8::Local<v8::String>::Cast(name)); + (*identifier)[i] = getStringIdentifier(v8::Local<v8::String>::Cast(name)); } return true; } @@ -483,8 +482,8 @@ bool NPN_Construct(NPP npp, NPObject* npobj, const NPVariant* args, uint32_t arg if (!npobj) return false; - // TODO(estade): implement this case. - if (npobj->_class == NPScriptObjectClass) { + // FIXME(estade): implement this case. + if (npobj->_class == npScriptObjectClass) { VOID_TO_NPVARIANT(*result); return false; } diff --git a/webkit/port/bindings/v8/np_v8object.h b/webkit/port/bindings/v8/NPV8Object.h index cd89b5a..a3cade9 100644 --- a/webkit/port/bindings/v8/np_v8object.h +++ b/webkit/port/bindings/v8/NPV8Object.h @@ -1,18 +1,18 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 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 np_v8object_h #define np_v8object_h -#include "third_party/npapi/bindings/npruntime.h" +#include "bindings/npruntime.h" #include <v8.h> namespace WebCore { class DOMWindow; } -extern NPClass* NPScriptObjectClass; +extern NPClass* npScriptObjectClass; // A V8NPObject is a NPObject which carries additional V8-specific // information. It is allocated and deallocated by AllocV8NPObject() @@ -31,8 +31,7 @@ struct PrivateIdentifier { bool isString; }; -NPObject* NPN_CreateScriptObject(NPP npp, v8::Handle<v8::Object>, WebCore::DOMWindow*); -NPObject* NPN_CreateNoScriptObject(); +NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object>, WebCore::DOMWindow*); #endif // np_v8object_h diff --git a/webkit/port/bindings/v8/ScriptController.cpp b/webkit/port/bindings/v8/ScriptController.cpp index 9f2a5be..4da169b 100644 --- a/webkit/port/bindings/v8/ScriptController.cpp +++ b/webkit/port/bindings/v8/ScriptController.cpp @@ -41,13 +41,13 @@ #include "Node.h" #include "NotImplemented.h" #include "npruntime_priv.h" -#include "np_v8object.h" +#include "NPV8Object.h" #include "ScriptSourceCode.h" #include "Widget.h" #include "v8_proxy.h" #include "v8_binding.h" -#include "v8_npobject.h" +#include "V8NPObject.h" NPRuntimeFunctions npruntime_functions = { NPN_GetStringIdentifier, @@ -382,7 +382,7 @@ static NPObject* createScriptObject(Frame* frame) DOMWindow* window = frame->domWindow(); v8::Handle<v8::Value> global = V8Proxy::ToV8Object(V8ClassIndex::DOMWINDOW, window); ASSERT(global->IsObject()); - return NPN_CreateScriptObject(0, v8::Handle<v8::Object>::Cast(global), window); + return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), window); } NPObject* ScriptController::windowScriptNPObject() @@ -421,7 +421,7 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement if (!v8plugin->IsObject()) return createNoScriptObject(); - return NPN_CreateScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), window); + return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), window); } diff --git a/webkit/port/bindings/v8/v8_npobject.cpp b/webkit/port/bindings/v8/V8NPObject.cpp index cdb9bee..60e66a9 100644 --- a/webkit/port/bindings/v8/v8_npobject.cpp +++ b/webkit/port/bindings/v8/V8NPObject.cpp @@ -1,10 +1,10 @@ // 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 @@ -14,7 +14,7 @@ // * 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 @@ -31,9 +31,9 @@ #include "v8_custom.h" #include "v8_helpers.h" -#include "v8_npobject.h" -#include "v8_np_utils.h" -#include "np_v8object.h" +#include "V8NPObject.h" +#include "V8NPUtils.h" +#include "NPV8Object.h" #include "npruntime_priv.h" #include "v8_proxy.h" #include "dom_wrapper_map.h" @@ -88,7 +88,7 @@ static v8::Handle<v8::Value> NPObjectInvokeImpl(const v8::Arguments& args, Invok NPVariant* npArgs = new NPVariant[argc]; for (int i = 0; i < argc; i++) - ConvertV8ObjectToNPVariant(args[i], npobject, &npArgs[i]); + convertV8ObjectToNPVariant(args[i], npobject, &npArgs[i]); NPVariant result; VOID_TO_NPVARIANT(result); @@ -97,7 +97,7 @@ static v8::Handle<v8::Value> NPObjectInvokeImpl(const v8::Arguments& args, Invok case INVOKE_METHOD: if (npobject->_class->invoke) { v8::Handle<v8::String> function_name(v8::String::Cast(*args.Data())); - NPIdentifier ident = GetStringIdentifier(function_name); + NPIdentifier ident = getStringIdentifier(function_name); npobject->_class->invoke(npobject, ident, npArgs, argc, &result); } break; @@ -114,7 +114,7 @@ static v8::Handle<v8::Value> NPObjectInvokeImpl(const v8::Arguments& args, Invok delete[] npArgs; // unwrap return values - v8::Handle<v8::Value> rv = ConvertNPVariantToV8Object(&result, npobject); + v8::Handle<v8::Value> rv = convertNPVariantToV8Object(&result, npobject); NPN_ReleaseVariantValue(&result); return rv; @@ -171,7 +171,7 @@ static v8::Handle<v8::Value> NPObjectGetProperty(v8::Local<v8::Object> self, if (!npobject->_class->getProperty(npobject, ident, &result)) return v8::Handle<v8::Value>(); - v8::Handle<v8::Value> rv = ConvertNPVariantToV8Object(&result, npobject); + v8::Handle<v8::Value> rv = convertNPVariantToV8Object(&result, npobject); NPN_ReleaseVariantValue(&result); return rv; } else if (key->IsString() && npobject->_class->hasMethod && npobject->_class->hasMethod(npobject, ident)) { @@ -198,7 +198,7 @@ static v8::Handle<v8::Value> NPObjectGetProperty(v8::Local<v8::Object> self, v8::Handle<v8::Value> NPObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { - NPIdentifier ident = GetStringIdentifier(name); + NPIdentifier ident = getStringIdentifier(name); return NPObjectGetProperty(info.Holder(), ident, name); } @@ -212,7 +212,7 @@ v8::Handle<v8::Value> NPObjectIndexedPropertyGetter(uint32_t index, v8::Handle<v8::Value> NPObjectGetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name) { - NPIdentifier ident = GetStringIdentifier(name); + NPIdentifier ident = getStringIdentifier(name); return NPObjectGetProperty(self, ident, name); } @@ -242,7 +242,7 @@ static v8::Handle<v8::Value> NPObjectSetProperty(v8::Local<v8::Object> self, NPVariant npvalue; VOID_TO_NPVARIANT(npvalue); - ConvertV8ObjectToNPVariant(value, npobject, &npvalue); + convertV8ObjectToNPVariant(value, npobject, &npvalue); bool succ = npobject->_class->setProperty(npobject, ident, &npvalue); NPN_ReleaseVariantValue(&npvalue); if (succ) @@ -256,7 +256,7 @@ v8::Handle<v8::Value> NPObjectNamedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - NPIdentifier ident = GetStringIdentifier(name); + NPIdentifier ident = getStringIdentifier(name); return NPObjectSetProperty(info.Holder(), ident, value); } @@ -273,7 +273,7 @@ v8::Handle<v8::Value> NPObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value> value) { - NPIdentifier ident = GetStringIdentifier(name); + NPIdentifier ident = getStringIdentifier(name); return NPObjectSetProperty(self, ident, value); } @@ -313,7 +313,7 @@ v8::Local<v8::Object> CreateV8ObjectForNPObject(NPObject* object, NPObject* root ASSERT(v8::Context::InContext()); // If this is a v8 object, just return it. - if (object->_class == NPScriptObjectClass) { + if (object->_class == npScriptObjectClass) { V8NPObject* v8npobject = reinterpret_cast<V8NPObject*>(object); return v8::Local<v8::Object>::New(v8npobject->v8Object); } @@ -337,10 +337,10 @@ v8::Local<v8::Object> CreateV8ObjectForNPObject(NPObject* object, NPObject* root v8::Handle<v8::Function> func = npObjectDesc->GetFunction(); v8::Local<v8::Object> value = SafeAllocation::NewInstance(func); - - // 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); diff --git a/webkit/port/bindings/v8/V8NPObject.h b/webkit/port/bindings/v8/V8NPObject.h new file mode 100644 index 0000000..c236c60 --- /dev/null +++ b/webkit/port/bindings/v8/V8NPObject.h @@ -0,0 +1,53 @@ +// 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_npobject_h +#define v8_npobject_h + +#include <v8.h> +#include "third_party/npapi/bindings/npruntime.h" + +// These functions can be replaced by normal JS operation. +// Getters +v8::Handle<v8::Value> NPObjectNamedPropertyGetter(v8::Local<v8::String> name, + const v8::AccessorInfo& info); +v8::Handle<v8::Value> NPObjectIndexedPropertyGetter(uint32_t index, + const v8::AccessorInfo& info); +v8::Handle<v8::Value> NPObjectGetNamedProperty(v8::Local<v8::Object> self, + v8::Local<v8::String> name); +v8::Handle<v8::Value> NPObjectGetIndexedProperty(v8::Local<v8::Object> self, + uint32_t index); + +// Setters +v8::Handle<v8::Value> NPObjectNamedPropertySetter(v8::Local<v8::String> name, + v8::Local<v8::Value> value, + const v8::AccessorInfo& info); +v8::Handle<v8::Value> NPObjectIndexedPropertySetter(uint32_t index, + const v8::AccessorInfo& info); +v8::Handle<v8::Value> NPObjectSetNamedProperty(v8::Local<v8::Object> self, + v8::Local<v8::String> name, + v8::Local<v8::Value> value); +v8::Handle<v8::Value> NPObjectSetIndexedProperty(v8::Local<v8::Object> self, + uint32_t index, + v8::Local<v8::Value> value); + +v8::Handle<v8::Value> NPObjectInvokeDefaultHandler(const v8::Arguments& args); + +// Get a wrapper for a NPObject. +// If the object is already wrapped, the pre-existing wrapper +// will be returned. +// If the object is not wrapped, wrap it, and give V8 a weak +// reference to the wrapper which will cleanup when there are +// no more JS references to the object. +v8::Local<v8::Object> CreateV8ObjectForNPObject(NPObject* object, NPObject *root); + +// Tell V8 to forcibly remove an object. +// This is used at plugin teardown so that the caller can +// aggressively unload the plugin library. After calling this +// function, the persistent handle to the wrapper will be +// gone, and the wrapped NPObject will be removed so that +// it cannot be referred to. +void ForgetV8ObjectForNPObject(NPObject*object); + +#endif // v8_npobject_h diff --git a/webkit/port/bindings/v8/v8_np_utils.cpp b/webkit/port/bindings/v8/V8NPUtils.cpp index f7bb20a..04e6ede 100644 --- a/webkit/port/bindings/v8/v8_np_utils.cpp +++ b/webkit/port/bindings/v8/V8NPUtils.cpp @@ -1,10 +1,10 @@ // 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 @@ -14,7 +14,7 @@ // * 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 @@ -29,7 +29,7 @@ #include "config.h" -#include "v8_np_utils.h" +#include "V8NPUtils.h" #include "DOMWindow.h" #include "Frame.h" @@ -37,11 +37,11 @@ #undef LOG #include "npruntime_priv.h" -#include "np_v8object.h" -#include "v8_npobject.h" +#include "NPV8Object.h" +#include "V8NPObject.h" #include "v8_proxy.h" -void ConvertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NPVariant* result) +void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NPVariant* result) { VOID_TO_NPVARIANT(*result); @@ -54,7 +54,7 @@ void ConvertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NP return; if (object->IsInt32()) - INT32_TO_NPVARIANT(object->NumberValue(), *result); + INT32_TO_NPVARIANT(object->NumberValue(), *result); else if (object->IsNumber()) DOUBLE_TO_NPVARIANT(object->NumberValue(), *result); else if (object->IsBoolean()) @@ -69,7 +69,7 @@ void ConvertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NP STRINGN_TO_NPVARIANT(utf8_chars, utf8.length(), *result); } else if (object->IsObject()) { WebCore::DOMWindow* window = WebCore::V8Proxy::retrieveWindow(); - NPObject* npobject = NPN_CreateScriptObject(0, v8::Handle<v8::Object>::Cast(object), window); + NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(object), window); if (npobject) _NPN_RegisterObject(npobject, owner); OBJECT_TO_NPVARIANT(npobject, *result); @@ -77,7 +77,7 @@ void ConvertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NP } -v8::Handle<v8::Value> ConvertNPVariantToV8Object(const NPVariant* variant, NPObject* npobject) +v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObject* npobject) { NPVariantType type = variant->type; @@ -97,7 +97,7 @@ v8::Handle<v8::Value> ConvertNPVariantToV8Object(const NPVariant* variant, NPObj } if (type == NPVariantType_Object) { NPObject* obj = NPVARIANT_TO_OBJECT(*variant); - if (obj->_class == NPScriptObjectClass) + if (obj->_class == npScriptObjectClass) return reinterpret_cast<V8NPObject*>(obj)->v8Object; return CreateV8ObjectForNPObject(obj, npobject); } @@ -105,7 +105,7 @@ v8::Handle<v8::Value> ConvertNPVariantToV8Object(const NPVariant* variant, NPObj } // Helper function to create an NPN String Identifier from a v8 string. -NPIdentifier GetStringIdentifier(v8::Handle<v8::String> str) +NPIdentifier getStringIdentifier(v8::Handle<v8::String> str) { const int kStackBufSize = 100; diff --git a/webkit/port/bindings/v8/v8_np_utils.h b/webkit/port/bindings/v8/V8NPUtils.h index 6e8290b..4b6fc2b 100644 --- a/webkit/port/bindings/v8/v8_np_utils.h +++ b/webkit/port/bindings/v8/V8NPUtils.h @@ -13,16 +13,16 @@ namespace WebCore { } // Convert a V8 Value of any type (string, bool, object, etc) to a NPVariant. -void ConvertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NPVariant* result); +void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NPVariant* result); // Convert a NPVariant (string, bool, object, etc) back to a V8 Value. // The owner object is the NPObject which relates to the object, if the object // is an Object. The created NPObject will be tied to the lifetime of the // owner. -v8::Handle<v8::Value> ConvertNPVariantToV8Object(const NPVariant* value, NPObject* owner); +v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* value, NPObject* owner); // Helper function to create an NPN String Identifier from a v8 string. -NPIdentifier GetStringIdentifier(v8::Handle<v8::String> str); +NPIdentifier getStringIdentifier(v8::Handle<v8::String> str); #endif // v8_np_utils_h diff --git a/webkit/port/bindings/v8/npruntime.cpp b/webkit/port/bindings/v8/npruntime.cpp index 9b21c36..f95d621 100644 --- a/webkit/port/bindings/v8/npruntime.cpp +++ b/webkit/port/bindings/v8/npruntime.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. - * Copyright (C) 2007 Google, Inc. All rights reserved. + * Copyright (C) 2007-2009 Google, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,16 +33,16 @@ #include "bindings/npruntime.h" #include "ChromiumBridge.h" -#include "np_v8object.h" +#include "NPV8Object.h" #include "npruntime_priv.h" -#include "v8_npobject.h" +#include "V8NPObject.h" #include <wtf/Assertions.h> using namespace v8; -// TODO: Consider removing locks if we're singlethreaded already. +// FIXME: Consider removing locks if we're singlethreaded already. // The static initializer here should work okay, but we want to avoid // static initialization in general. // @@ -81,7 +81,7 @@ static StringIdentifierMap* getStringIdentifierMap() { return stringIdentifierMap; } -// TODO: Consider removing locks if we're singlethreaded already. +// FIXME: Consider removing locks if we're singlethreaded already. // static Lock IntIdentifierMapLock; typedef std::map<int, PrivateIdentifier*> IntIdentifierMap; diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp index 32a5f14..f5e3e5a 100644 --- a/webkit/port/bindings/v8/v8_custom.cpp +++ b/webkit/port/bindings/v8/v8_custom.cpp @@ -29,7 +29,7 @@ #include "v8_proxy.h" #include "v8_events.h" #include "v8_binding.h" -#include "v8_npobject.h" +#include "V8NPObject.h" #include "v8_custom.h" #include "V8Attr.h" diff --git a/webkit/port/bindings/v8/v8_helpers.cpp b/webkit/port/bindings/v8/v8_helpers.cpp index f09c2e0..7a72ab5e 100644 --- a/webkit/port/bindings/v8/v8_helpers.cpp +++ b/webkit/port/bindings/v8/v8_helpers.cpp @@ -34,7 +34,7 @@ #include "v8_helpers.h" #include "v8_proxy.h" #include "v8_index.h" -#include "np_v8object.h" +#include "NPV8Object.h" #include "DOMWindow.h" @@ -45,7 +45,7 @@ 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) +v8::Local<v8::Context> getV8Context(NPP npp, NPObject* npobj) { V8NPObject* object = reinterpret_cast<V8NPObject*>(npobj); return WebCore::V8Proxy::GetContext(object->rootObject->frame()); diff --git a/webkit/port/bindings/v8/v8_helpers.h b/webkit/port/bindings/v8/v8_helpers.h index 28d7bf1..4c49a4a 100644 --- a/webkit/port/bindings/v8/v8_helpers.h +++ b/webkit/port/bindings/v8/v8_helpers.h @@ -16,7 +16,7 @@ namespace WebCore { 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); +v8::Local<v8::Context> getV8Context(NPP npp, NPObject* npobj); // Get V8Proxy object from an NPObject. WebCore::V8Proxy* GetV8Proxy(NPObject* npobj); diff --git a/webkit/port/bindings/v8/v8_npobject.h b/webkit/port/bindings/v8/v8_npobject.h index c236c60..c2d8550 100644 --- a/webkit/port/bindings/v8/v8_npobject.h +++ b/webkit/port/bindings/v8/v8_npobject.h @@ -2,52 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef v8_npobject_h -#define v8_npobject_h - -#include <v8.h> -#include "third_party/npapi/bindings/npruntime.h" - -// These functions can be replaced by normal JS operation. -// Getters -v8::Handle<v8::Value> NPObjectNamedPropertyGetter(v8::Local<v8::String> name, - const v8::AccessorInfo& info); -v8::Handle<v8::Value> NPObjectIndexedPropertyGetter(uint32_t index, - const v8::AccessorInfo& info); -v8::Handle<v8::Value> NPObjectGetNamedProperty(v8::Local<v8::Object> self, - v8::Local<v8::String> name); -v8::Handle<v8::Value> NPObjectGetIndexedProperty(v8::Local<v8::Object> self, - uint32_t index); - -// Setters -v8::Handle<v8::Value> NPObjectNamedPropertySetter(v8::Local<v8::String> name, - v8::Local<v8::Value> value, - const v8::AccessorInfo& info); -v8::Handle<v8::Value> NPObjectIndexedPropertySetter(uint32_t index, - const v8::AccessorInfo& info); -v8::Handle<v8::Value> NPObjectSetNamedProperty(v8::Local<v8::Object> self, - v8::Local<v8::String> name, - v8::Local<v8::Value> value); -v8::Handle<v8::Value> NPObjectSetIndexedProperty(v8::Local<v8::Object> self, - uint32_t index, - v8::Local<v8::Value> value); - -v8::Handle<v8::Value> NPObjectInvokeDefaultHandler(const v8::Arguments& args); - -// Get a wrapper for a NPObject. -// If the object is already wrapped, the pre-existing wrapper -// will be returned. -// If the object is not wrapped, wrap it, and give V8 a weak -// reference to the wrapper which will cleanup when there are -// no more JS references to the object. -v8::Local<v8::Object> CreateV8ObjectForNPObject(NPObject* object, NPObject *root); - -// Tell V8 to forcibly remove an object. -// This is used at plugin teardown so that the caller can -// aggressively unload the plugin library. After calling this -// function, the persistent handle to the wrapper will be -// gone, and the wrapped NPObject will be removed so that -// it cannot be referred to. -void ForgetV8ObjectForNPObject(NPObject*object); - -#endif // v8_npobject_h +// This is a temporary file until V8HTMLPlugInElementCustom.cpp in WebKit +// includes the new name of this file. +#include "V8NPObject.h" diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index bbeac60..591a3a1 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -1048,8 +1048,8 @@ 'port/bindings/v8/WorkerScriptController.cpp', 'port/bindings/v8/WorkerScriptController.h', 'port/bindings/v8/dom_wrapper_map.h', - 'port/bindings/v8/np_v8object.cpp', - 'port/bindings/v8/np_v8object.h', + 'port/bindings/v8/NPV8Object.cpp', + 'port/bindings/v8/NPV8Object.h', 'port/bindings/v8/npruntime.cpp', 'port/bindings/v8/npruntime_impl.h', 'port/bindings/v8/npruntime_internal.h', @@ -1066,10 +1066,10 @@ 'port/bindings/v8/v8_index.h', 'port/bindings/v8/v8_nodefilter.cpp', 'port/bindings/v8/v8_nodefilter.h', - 'port/bindings/v8/v8_np_utils.cpp', - 'port/bindings/v8/v8_np_utils.h', - 'port/bindings/v8/v8_npobject.cpp', - 'port/bindings/v8/v8_npobject.h', + 'port/bindings/v8/V8NPUtils.cpp', + 'port/bindings/v8/V8NPUtils.h', + 'port/bindings/v8/V8NPobject.cpp', + 'port/bindings/v8/V8NPobject.h', 'port/bindings/v8/v8_proxy.cpp', 'port/bindings/v8/v8_proxy.h', 'port/bindings/v8/v8_utility.h', |