summaryrefslogtreecommitdiffstats
path: root/V8Binding
diff options
context:
space:
mode:
authorAndrei Popescu <andreip@google.com>2009-08-12 16:03:19 +0100
committerAndrei Popescu <andreip@google.com>2009-08-12 17:25:03 +0100
commit9930f9c387a546011de24dc3117d7f3fbb60fe96 (patch)
tree56578f7fc18e548186df0e5b1a5a3e26015cdba1 /V8Binding
parentf387cad0dc92f856383b5200c20fb02099df4ea5 (diff)
downloadexternal_webkit-9930f9c387a546011de24dc3117d7f3fbb60fe96.zip
external_webkit-9930f9c387a546011de24dc3117d7f3fbb60fe96.tar.gz
external_webkit-9930f9c387a546011de24dc3117d7f3fbb60fe96.tar.bz2
Merge half of V8Binding/binding
Diffstat (limited to 'V8Binding')
-rw-r--r--V8Binding/binding/DOMObjectsInclude.h198
-rw-r--r--V8Binding/binding/NPV8Object.cpp559
-rw-r--r--V8Binding/binding/NPV8Object.h42
-rw-r--r--V8Binding/binding/RGBColor.cpp50
-rw-r--r--V8Binding/binding/RGBColor.h28
-rw-r--r--V8Binding/binding/UndetectableHTMLCollection.idl14
-rw-r--r--V8Binding/binding/V8InitializeThreading.cpp44
-rw-r--r--V8Binding/binding/V8InitializeThreading.h39
-rw-r--r--V8Binding/binding/V8MessagePortCustom.cpp0
-rw-r--r--V8Binding/binding/V8NPObject.cpp373
-rw-r--r--V8Binding/binding/V8NPObject.h83
-rw-r--r--V8Binding/binding/V8NPUtils.cpp124
-rw-r--r--V8Binding/binding/V8NPUtils.h32
-rw-r--r--V8Binding/binding/V8SVGPODTypeWrapper.h387
-rw-r--r--V8Binding/binding/npruntime.cpp437
-rw-r--r--V8Binding/binding/npruntime_impl.h69
-rw-r--r--V8Binding/binding/npruntime_internal.h41
-rw-r--r--V8Binding/binding/npruntime_priv.h97
-rw-r--r--V8Binding/binding/v8_binding.cpp130
-rw-r--r--V8Binding/binding/v8_binding.h135
-rw-r--r--V8Binding/binding/v8_helpers.cpp59
-rw-r--r--V8Binding/binding/v8_helpers.h30
-rw-r--r--V8Binding/binding/v8_npobject.h7
-rw-r--r--V8Binding/binding/v8_utility.h68
24 files changed, 0 insertions, 3046 deletions
diff --git a/V8Binding/binding/DOMObjectsInclude.h b/V8Binding/binding/DOMObjectsInclude.h
deleted file mode 100644
index 9db9b6d..0000000
--- a/V8Binding/binding/DOMObjectsInclude.h
+++ /dev/null
@@ -1,198 +0,0 @@
-// Copyright (c) 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 DOMObjectsInclude_h
-#define DOMObjectsInclude_h
-
-#include "BarInfo.h"
-#include "CanvasGradient.h"
-#include "CanvasPattern.h"
-#include "CanvasPixelArray.h"
-#include "CanvasRenderingContext2D.h"
-#include "CanvasStyle.h"
-#include "CharacterData.h"
-#include "ClientRect.h"
-#include "ClientRectList.h"
-#include "Clipboard.h"
-#include "Console.h"
-#include "Counter.h"
-#include "CSSCharsetRule.h"
-#include "CSSFontFaceRule.h"
-#include "CSSImportRule.h"
-#include "CSSMediaRule.h"
-#include "CSSPageRule.h"
-#include "CSSRule.h"
-#include "CSSRuleList.h"
-#include "CSSStyleDeclaration.h"
-#include "CSSStyleRule.h"
-#include "CSSStyleSheet.h"
-#include "CSSValueList.h"
-#include "CSSVariablesDeclaration.h"
-#include "CSSVariablesRule.h"
-#include "Database.h"
-#include "DocumentType.h"
-#include "DocumentFragment.h"
-#include "DOMApplicationCache.h"
-#include "DOMCoreException.h"
-#include "DOMImplementation.h"
-#include "DOMParser.h"
-#include "DOMSelection.h"
-#include "DOMStringList.h"
-#include "DOMWindow.h"
-#include "Entity.h"
-#include "EventListener.h"
-#include "EventTarget.h"
-#include "Event.h"
-#include "EventException.h"
-#include "ExceptionCode.h"
-#include "File.h"
-#include "FileList.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameTree.h"
-#include "History.h"
-#include "HTMLNames.h"
-#include "HTMLDocument.h"
-#include "HTMLElement.h"
-#include "HTMLImageElement.h"
-#include "HTMLInputElement.h"
-#include "HTMLSelectElement.h"
-#include "HTMLOptionsCollection.h"
-#include "ImageData.h"
-#include "InspectorController.h"
-#include "KeyboardEvent.h"
-#include "Location.h"
-#include "MediaError.h"
-#include "MediaList.h"
-#include "MediaPlayer.h"
-#include "MessageChannel.h"
-#include "MessageEvent.h"
-#include "MessagePort.h"
-#include "MimeTypeArray.h"
-#include "MouseEvent.h"
-#include "MutationEvent.h"
-#include "Navigator.h" // for MimeTypeArray
-#include "NodeFilter.h"
-#include "Notation.h"
-#include "NodeList.h"
-#include "NodeIterator.h"
-#include "OverflowEvent.h"
-#include "Page.h"
-#include "Plugin.h"
-#include "PluginArray.h"
-#include "ProcessingInstruction.h"
-#include "ProgressEvent.h"
-#include "Range.h"
-#include "RangeException.h"
-#include "Rect.h"
-#include "RGBColor.h"
-#include "Screen.h"
-#include "ScriptExecutionContext.h"
-#include "SecurityOrigin.h"
-#include "Settings.h"
-#include "SQLTransaction.h"
-#include "SQLResultSet.h"
-#include "SQLResultSetRowList.h"
-#include "StyleSheet.h"
-#include "StyleSheetList.h"
-#include "TextEvent.h"
-#include "TextMetrics.h"
-#include "TimeRanges.h"
-#include "TreeWalker.h"
-#include "XSLTProcessor.h"
-#include "V8AbstractEventListener.h"
-#include "V8CustomEventListener.h"
-#include "V8DOMWindow.h"
-#include "V8HTMLElement.h"
-#include "V8LazyEventListener.h"
-#include "V8NodeFilterCondition.h"
-#include "V8ObjectEventListener.h"
-#include "WebKitAnimationEvent.h"
-#include "WebKitCSSKeyframeRule.h"
-#include "WebKitCSSKeyframesRule.h"
-#include "WebKitCSSMatrix.h"
-#include "WebKitCSSTransformValue.h"
-#include "WebKitPoint.h"
-#include "WebKitTransitionEvent.h"
-#include "WheelEvent.h"
-#include "XMLHttpRequest.h"
-#include "XMLHttpRequestException.h"
-#include "XMLHttpRequestProgressEvent.h"
-#include "XMLHttpRequestUpload.h"
-#include "XMLSerializer.h"
-#include "XPathEvaluator.h"
-#include "XPathException.h"
-#include "XPathExpression.h"
-#include "XPathNSResolver.h"
-#include "XPathResult.h"
-
-#if ENABLE(DOM_STORAGE)
-#include "Storage.h"
-#include "StorageEvent.h"
-#endif
-
-#if ENABLE(SVG)
-#include "SVGAngle.h"
-#include "SVGAnimatedPoints.h"
-#include "SVGColor.h"
-#include "SVGElement.h"
-#include "SVGElementInstance.h"
-#include "SVGElementInstanceList.h"
-#include "SVGException.h"
-#include "SVGLength.h"
-#include "SVGLengthList.h"
-#include "SVGNumberList.h"
-#include "SVGPaint.h"
-#include "SVGPathSeg.h"
-#include "SVGPathSegArc.h"
-#include "SVGPathSegClosePath.h"
-#include "SVGPathSegCurvetoCubic.h"
-#include "SVGPathSegCurvetoCubicSmooth.h"
-#include "SVGPathSegCurvetoQuadratic.h"
-#include "SVGPathSegCurvetoQuadraticSmooth.h"
-#include "SVGPathSegLineto.h"
-#include "SVGPathSegLinetoHorizontal.h"
-#include "SVGPathSegLinetoVertical.h"
-#include "SVGPathSegList.h"
-#include "SVGPathSegMoveto.h"
-#include "SVGPointList.h"
-#include "SVGPreserveAspectRatio.h"
-#include "SVGRenderingIntent.h"
-#include "SVGStringList.h"
-#include "SVGTransform.h"
-#include "SVGTransformList.h"
-#include "SVGUnitTypes.h"
-#include "SVGURIReference.h"
-#include "SVGZoomEvent.h"
-#include "V8SVGPODTypeWrapper.h"
-#endif // SVG
-
-#if ENABLE(WORKERS)
-#include "Worker.h"
-#include "WorkerContext.h"
-#include "WorkerLocation.h"
-#include "WorkerNavigator.h"
-#endif // WORKERS
-
-#if PLATFORM(ANDROID)
-#include "Coordinates.h"
-#include "Geolocation.h"
-#include "Geoposition.h"
-#include "PositionError.h"
-#include "PositionErrorCallback.h"
-#include "Touch.h"
-#include "TouchList.h"
-#include "TouchEvent.h"
-#include "VoidCallback.h"
-#endif
-
-namespace WebCore {
-
-// A helper class for undetectable document.all
-class UndetectableHTMLCollection : public HTMLCollection {
-};
-
-} // namespace WebCore
-
-#endif // DOMObjectsInclude_h
diff --git a/V8Binding/binding/NPV8Object.cpp b/V8Binding/binding/NPV8Object.cpp
deleted file mode 100644
index d856a43..0000000
--- a/V8Binding/binding/NPV8Object.cpp
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 <stdio.h>
-
-#define max max
-#define min min
-#include <v8.h>
-#include "NPV8Object.h"
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): upstream
-#include "ChromiumBridge.h"
-#endif
-#include "Frame.h"
-#include "npruntime_priv.h"
-#include "PlatformString.h"
-#include "ScriptController.h"
-#include "V8CustomBinding.h"
-#include "v8_helpers.h"
-#include "V8NPUtils.h"
-#include "v8_proxy.h"
-#include "DOMWindow.h"
-
-using WebCore::V8ClassIndex;
-using WebCore::V8Custom;
-using WebCore::V8Proxy;
-
-// FIXME(mbelshe): comments on why use malloc and free.
-static NPObject* AllocV8NPObject(NPP, NPClass*)
-{
- return static_cast<NPObject*>(malloc(sizeof(V8NPObject)));
-}
-
-static void FreeV8NPObject(NPObject* npobj)
-{
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-#ifndef NDEBUG
- V8Proxy::UnregisterGlobalHandle(object, object->v8Object);
-#endif
- object->v8Object.Dispose();
- free(object);
-}
-
-static v8::Handle<v8::Value>* listFromVariantArgs(const NPVariant* args,
- uint32_t argCount,
- NPObject *owner)
-{
- 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);
- }
- return argv;
-}
-
-// Create an identifier (null terminated utf8 char*) from the NPIdentifier.
-static v8::Local<v8::String> NPIdentifierToV8Identifier(NPIdentifier name)
-{
- PrivateIdentifier* identifier = static_cast<PrivateIdentifier*>(name);
- if (identifier->isString)
- return v8::String::New(static_cast<const char *>(identifier->value.string));
-
- char buf[32];
- sprintf(buf, "%d", identifier->value.number);
- return v8::String::New(buf);
-}
-
-static NPClass V8NPObjectClass = { NP_CLASS_STRUCT_VERSION,
- AllocV8NPObject,
- FreeV8NPObject,
- 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-// NPAPI's npruntime functions
-NPClass* npScriptObjectClass = &V8NPObjectClass;
-
-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 &&
- object->GetInternalField(V8Custom::kDOMWrapperTypeIndex)->IsNumber() &&
- object->GetInternalField(V8Custom::kDOMWrapperTypeIndex)->Uint32Value() == V8ClassIndex::NPOBJECT) {
-
- NPObject* rv = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, object);
- NPN_RetainObject(rv);
- return rv;
- }
-
- V8NPObject* obj = reinterpret_cast<V8NPObject*>(NPN_CreateObject(npp, &V8NPObjectClass));
- obj->v8Object = v8::Persistent<v8::Object>::New(object);
-#ifndef NDEBUG
- V8Proxy::RegisterGlobalHandle(WebCore::NPOBJECT, obj, obj->v8Object);
-#endif
- obj->rootObject = root;
- return reinterpret_cast<NPObject*>(obj);
-}
-
-bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName,
- const NPVariant *args, uint32_t argCount, NPVariant *result)
-{
- if (!npobj)
- return false;
-
- LOCK_V8;
-
- if (npobj->_class == npScriptObjectClass) {
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- PrivateIdentifier *identifier = static_cast<PrivateIdentifier*>(methodName);
- if (!identifier->isString)
- return false;
-
- v8::HandleScope handleScope;
- // 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;
-
- v8::Context::Scope scope(context);
-
- // Special case the "eval" method.
- if (methodName == NPN_GetStringIdentifier("eval")) {
- if (argCount != 1)
- return false;
- if (args[0].type != NPVariantType_String)
- return false;
- return NPN_Evaluate(npp, npobj, const_cast<NPString*>(&args[0].value.stringValue), result);
- }
-
- v8::Handle<v8::Value> funcObj = object->v8Object->Get(v8::String::New(identifier->value.string));
- if (funcObj.IsEmpty() || funcObj->IsNull()) {
- NULL_TO_NPVARIANT(*result);
- return false;
- }
- if (funcObj->IsUndefined()) {
- VOID_TO_NPVARIANT(*result);
- return false;
- }
-
- WebCore::V8Proxy* proxy = GetV8Proxy(npobj);
- ASSERT(proxy); // must not be null
-
- // 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
- v8::Handle<v8::Value>* argv = listFromVariantArgs(args, argCount, npobj);
- v8::Local<v8::Value> resultObj = proxy->CallFunction(func, object->v8Object, argCount, argv);
- delete[] argv;
-
- // If we had an error, return false. The spec is a little unclear here, but
- // says "Returns true if the method was successfully invoked". If we get an
- // error return value, was that successfully invoked?
- if (resultObj.IsEmpty())
- return false;
-
- // Convert the result back to an NPVariant
- convertV8ObjectToNPVariant(resultObj, npobj, result);
- return true;
- }
-
- if (npobj->_class->invoke)
- return npobj->_class->invoke(npobj, methodName, args, argCount, result);
-
- VOID_TO_NPVARIANT(*result);
- return true;
-}
-
-// 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;
-
- LOCK_V8;
-
- 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);
- if (context.IsEmpty())
- return false;
-
- v8::Context::Scope scope(context);
-
- // Lookup the function object
- v8::Handle<v8::Object> funcObj(object->v8Object);
- if (!funcObj->IsFunction())
- return false;
-
- // Call the function object
- v8::Local<v8::Value> resultObj;
- v8::Handle<v8::Function> func(v8::Function::Cast(*funcObj));
- if (!func->IsNull()) {
- WebCore::V8Proxy* proxy = GetV8Proxy(npobj);
- ASSERT(proxy);
-
- // Create list of args to pass to v8
- v8::Handle<v8::Value>* argv = listFromVariantArgs(args, argCount, npobj);
- resultObj = proxy->CallFunction(func, funcObj, argCount, argv);
- delete[] argv;
- }
-
- // If we had an error, return false. The spec is a little unclear here, but
- // says "Returns true if the method was successfully invoked". If we get an
- // error return value, was that successfully invoked?
- if (resultObj.IsEmpty())
- return false;
-
- // Convert the result back to an NPVariant.
- convertV8ObjectToNPVariant(resultObj, npobj, result);
- return true;
- }
-
- if (npobj->_class->invokeDefault)
- return npobj->_class->invokeDefault(npobj, args, argCount, result);
-
- VOID_TO_NPVARIANT(*result);
- return true;
-}
-
-#if PLATFORM(ANDROID)
-static
-#endif
-bool NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npobj, NPString* npscript, NPVariant *result)
-{
- VOID_TO_NPVARIANT(*result);
- if (!npobj)
- return false;
-
- if (npobj->_class != npScriptObjectClass)
- return false;
-
- LOCK_V8;
-
- v8::HandleScope handleScope;
- v8::Handle<v8::Context> context = getV8Context(npp, npobj);
- if (context.IsEmpty())
- return false;
-
- WebCore::V8Proxy* proxy = GetV8Proxy(npobj);
- ASSERT(proxy);
-
- v8::Context::Scope scope(context);
-
- WebCore::String filename;
- if (!popupsAllowed)
- filename = "npscript";
-
- // Convert UTF-8 stream to WebCore::String.
- WebCore::String script = WebCore::String::fromUTF8(npscript->UTF8Characters, npscript->UTF8Length);
- v8::Local<v8::Value> v8result = proxy->evaluate(WebCore::ScriptSourceCode(script, WebCore::KURL(filename)), 0);
-
- // If we had an error, return false.
- if (v8result.IsEmpty())
- return false;
-
- convertV8ObjectToNPVariant(v8result, npobj, result);
- return true;
-}
-
-bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *npscript, NPVariant *result)
-{
-#if PLATFORM(CHROMIUM)
- bool popupsAllowed = WebCore::ChromiumBridge::popupsAllowed(npp);
-#else
- // TODO(andreip): Some of the binding code is specific to Chromium
- // and we don't want it to Android. What is the preferred way to handle this?
- bool popupsAllowed = false;
-#endif
- return NPN_EvaluateHelper(npp, popupsAllowed, npobj, npscript, result);
-}
-
-bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result)
-{
- if (!npobj)
- return false;
-
- LOCK_V8;
-
- if (npobj->_class == npScriptObjectClass) {
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- v8::HandleScope handleScope;
- 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);
- v8::Local<v8::Value> v8result = obj->Get(NPIdentifierToV8Identifier(propertyName));
-
- convertV8ObjectToNPVariant(v8result, npobj, result);
- return true;
- }
-
- if (npobj->_class->hasProperty && npobj->_class->getProperty) {
- if (npobj->_class->hasProperty(npobj, propertyName))
- return npobj->_class->getProperty(npobj, propertyName, result);
- }
-
- VOID_TO_NPVARIANT(*result);
- return false;
-}
-
-bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value)
-{
- if (!npobj)
- return false;
-
- LOCK_V8;
-
- if (npobj->_class == npScriptObjectClass) {
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- v8::HandleScope handleScope;
- 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);
- obj->Set(NPIdentifierToV8Identifier(propertyName),
- convertNPVariantToV8Object(value, object->rootObject->frame()->script()->windowScriptNPObject()));
- return true;
- }
-
- if (npobj->_class->setProperty)
- return npobj->_class->setProperty(npobj, propertyName, value);
-
- return false;
-}
-
-bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName)
-{
- if (!npobj)
- return false;
- if (npobj->_class != npScriptObjectClass)
- return false;
-
- LOCK_V8;
-
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- v8::HandleScope handleScope;
- 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);
- // FIXME(mbelshe) - verify that setting to undefined is right.
- obj->Set(NPIdentifierToV8Identifier(propertyName), v8::Undefined());
- return true;
-}
-
-bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName)
-{
- if (!npobj)
- return false;
-
- LOCK_V8;
-
- if (npobj->_class == npScriptObjectClass) {
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- v8::HandleScope handleScope;
- 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);
- return obj->Has(NPIdentifierToV8Identifier(propertyName));
- }
-
- if (npobj->_class->hasProperty)
- return npobj->_class->hasProperty(npobj, propertyName);
- return false;
-}
-
-bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName)
-{
- if (!npobj)
- return false;
-
- LOCK_V8;
-
- if (npobj->_class == npScriptObjectClass) {
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- v8::HandleScope handleScope;
- 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);
- v8::Handle<v8::Value> prop = obj->Get(NPIdentifierToV8Identifier(methodName));
- return prop->IsFunction();
- }
-
- if (npobj->_class->hasMethod)
- return npobj->_class->hasMethod(npobj, methodName);
- return false;
-}
-
-void NPN_SetException(NPObject *npobj, const NPUTF8 *message)
-{
- if (npobj->_class != npScriptObjectClass)
- return;
-
- LOCK_V8;
-
- v8::HandleScope handleScope;
- v8::Handle<v8::Context> context = getV8Context(0, npobj);
- if (context.IsEmpty())
- return;
-
- v8::Context::Scope scope(context);
- V8Proxy::ThrowError(V8Proxy::GENERAL_ERROR, message);
-}
-
-bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count)
-{
- if (!npobj)
- return false;
-
- LOCK_V8;
-
- if (npobj->_class == npScriptObjectClass) {
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- v8::HandleScope handleScope;
- 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);
-
- // FIXME(fqian): http://b/issue?id=1210340: Use a v8::Object::Keys() method
- // when it exists, instead of evaluating javascript.
-
- // 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 enumeratorCode[] =
- "(function (obj) {"
- " var props = [];"
- " for (var prop in obj) {"
- " props[props.length] = prop;"
- " }"
- " return props;"
- "});";
- 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);
- v8::Handle<v8::Value> argv[] = { obj };
- v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), 1, argv);
- if (propsObj.IsEmpty())
- return false;
-
- // Convert the results into an array of NPIdentifiers.
- v8::Handle<v8::Array> props = v8::Handle<v8::Array>::Cast(propsObj);
- *count = props->Length();
- *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));
- }
- return true;
- }
-
- if (NP_CLASS_STRUCT_VERSION_HAS_ENUM(npobj->_class) && npobj->_class->enumerate)
- return npobj->_class->enumerate(npobj, identifier, count);
-
- return false;
-}
-
-bool NPN_Construct(NPP npp, NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
-{
- if (!npobj)
- return false;
-
- LOCK_V8;
-
- if (npobj->_class == npScriptObjectClass) {
- V8NPObject *object = reinterpret_cast<V8NPObject*>(npobj);
-
- v8::HandleScope handleScope;
- v8::Handle<v8::Context> context = getV8Context(npp, npobj);
- if (context.IsEmpty())
- return false;
- v8::Context::Scope scope(context);
-
- // Lookup the constructor function.
- v8::Handle<v8::Object> ctorObj(object->v8Object);
- if (!ctorObj->IsFunction())
- return false;
-
- // Call the constructor.
- v8::Local<v8::Value> resultObj;
- v8::Handle<v8::Function> ctor(v8::Function::Cast(*ctorObj));
- if (!ctor->IsNull()) {
- WebCore::V8Proxy* proxy = GetV8Proxy(npobj);
- ASSERT(proxy);
-
- // Create list of args to pass to v8.
- v8::Handle<v8::Value>* argv = listFromVariantArgs(args, argCount, npobj);
- resultObj = proxy->NewInstance(ctor, argCount, argv);
- delete[] argv;
- }
-
- // If we had an error return false.
- if (resultObj.IsEmpty())
- return false;
-
- // Convert the result back to an NPVariant.
- convertV8ObjectToNPVariant(resultObj, npobj, result);
- return true;
- }
-
- if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npobj->_class) && npobj->_class->construct)
- return npobj->_class->construct(npobj, args, argCount, result);
-
- return false;
-}
diff --git a/V8Binding/binding/NPV8Object.h b/V8Binding/binding/NPV8Object.h
deleted file mode 100644
index ad4b973..0000000
--- a/V8Binding/binding/NPV8Object.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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
-
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): diff and consolidate
-#include "bindings/npruntime.h"
-#else
-#include "bridge/npruntime.h" // use WebCore version
-#endif
-
-#include <v8.h>
-
-namespace WebCore {
- class DOMWindow;
-}
-
-extern NPClass* npScriptObjectClass;
-
-// A V8NPObject is a NPObject which carries additional V8-specific
-// information. It is allocated and deallocated by AllocV8NPObject()
-// and FreeV8NPObject() methods.
-struct V8NPObject {
- NPObject object;
- v8::Persistent<v8::Object> v8Object;
- WebCore::DOMWindow* rootObject;
-};
-
-struct PrivateIdentifier {
- union {
- const NPUTF8* string;
- int32_t number;
- } value;
- bool isString;
-};
-
-NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object>, WebCore::DOMWindow*);
-
-#endif // np_v8object_h
diff --git a/V8Binding/binding/RGBColor.cpp b/V8Binding/binding/RGBColor.cpp
deleted file mode 100644
index 4a37ea6..0000000
--- a/V8Binding/binding/RGBColor.cpp
+++ /dev/null
@@ -1,50 +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 "RGBColor.h"
-
-namespace WebCore {
-
-PassRefPtr<CSSPrimitiveValue> RGBColor::red() {
- unsigned int value = (m_rgbcolor >> 16) & 0xFF;
- return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
-}
-
-PassRefPtr<CSSPrimitiveValue> RGBColor::green() {
- unsigned int value = (m_rgbcolor >> 8) & 0xFF;
- return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
-}
-
-PassRefPtr<CSSPrimitiveValue> RGBColor::blue() {
- unsigned int value = m_rgbcolor & 0xFF;
- return CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER);
-}
-
-} // namespace WebCore
-
diff --git a/V8Binding/binding/RGBColor.h b/V8Binding/binding/RGBColor.h
deleted file mode 100644
index afc0500..0000000
--- a/V8Binding/binding/RGBColor.h
+++ /dev/null
@@ -1,28 +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 RGBColor_h
-#define RGBColor_h
-
-#include "config.h"
-#include "CSSPrimitiveValue.h"
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class RGBColor : public RefCounted<RGBColor> {
- public:
- RGBColor(unsigned rgbcolor) : m_rgbcolor(rgbcolor) { }
-
- PassRefPtr<CSSPrimitiveValue> red();
- PassRefPtr<CSSPrimitiveValue> green();
- PassRefPtr<CSSPrimitiveValue> blue();
-
- private:
- unsigned m_rgbcolor;
-};
-
-} // namespace WebCore
-
-#endif // RGBColor_h
diff --git a/V8Binding/binding/UndetectableHTMLCollection.idl b/V8Binding/binding/UndetectableHTMLCollection.idl
deleted file mode 100644
index bcb2aee..0000000
--- a/V8Binding/binding/UndetectableHTMLCollection.idl
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) 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.
-
-module html {
-
- // This interface is used for undetectable HTMLCollections.
- // An undetectable HTMLCollection behaves like an HTMLCollection
- // when used, but the 'typeof' operator returns undefined and
- // ToBoolean returns false.
- interface UndetectableHTMLCollection : HTMLCollection {
- };
-
-}
diff --git a/V8Binding/binding/V8InitializeThreading.cpp b/V8Binding/binding/V8InitializeThreading.cpp
deleted file mode 100644
index 869e374..0000000
--- a/V8Binding/binding/V8InitializeThreading.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 Apple 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "V8InitializeThreading.h"
-#include <wtf/Threading.h>
-
-namespace V8 {
-
-void initializeThreading() {
- static bool initializedThreading = false;
- if (!initializedThreading) {
- WTF::initializeThreading();
- initializedThreading = true;
- }
-}
-
-} // namespace JSC
-
diff --git a/V8Binding/binding/V8InitializeThreading.h b/V8Binding/binding/V8InitializeThreading.h
deleted file mode 100644
index e548441..0000000
--- a/V8Binding/binding/V8InitializeThreading.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 Apple 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:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 InitializeThreading_h
-#define InitializeThreading_h
-
-namespace V8 {
-
- // This function must be called from the main thread. It is safe to call it repeatedly.
- // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly.
- void initializeThreading();
-}
-
-#endif // InitializeThreading_h
diff --git a/V8Binding/binding/V8MessagePortCustom.cpp b/V8Binding/binding/V8MessagePortCustom.cpp
deleted file mode 100644
index e69de29..0000000
--- a/V8Binding/binding/V8MessagePortCustom.cpp
+++ /dev/null
diff --git a/V8Binding/binding/V8NPObject.cpp b/V8Binding/binding/V8NPObject.cpp
deleted file mode 100644
index dd9af69..0000000
--- a/V8Binding/binding/V8NPObject.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
-* Copyright (C) 2006, 2007, 2008, 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 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 "V8NPObject.h"
-
-#include "HTMLPlugInElement.h"
-#include "npruntime_priv.h"
-#include "NPV8Object.h"
-#include "V8CustomBinding.h"
-#include "V8DOMMap.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;
-
-enum InvokeFunctionType {
- INVOKE_METHOD = 1,
- INVOKE_CONSTRUCT = 2,
- INVOKE_DEFAULT = 3
-};
-
-// FIXME: need comments.
-// Params: holder could be HTMLEmbedElement or NPObject
-static v8::Handle<v8::Value> npObjectInvokeImpl(const v8::Arguments& args, InvokeFunctionType functionId)
-{
- NPObject* npObject;
-
- // These three types are subtypes of HTMLPlugInElement.
- if (V8HTMLAppletElement::HasInstance(args.Holder()) || V8HTMLEmbedElement::HasInstance(args.Holder())
- || V8HTMLObjectElement::HasInstance(args.Holder())) {
- // The holder object is a subtype of HTMLPlugInElement.
- HTMLPlugInElement* element = V8Proxy::DOMWrapperToNode<HTMLPlugInElement>(args.Holder());
- ScriptInstance scriptInstance = element->getInstance();
- if (scriptInstance)
- npObject = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, scriptInstance->instance());
- else
- npObject = 0;
- } else {
- // The holder object is not a subtype of HTMLPlugInElement, it
- // must be an NPObject which has three internal fields.
- if (args.Holder()->InternalFieldCount() != V8Custom::kNPObjectInternalFieldCount)
- return throwError("NPMethod called on non-NPObject", V8Proxy::REFERENCE_ERROR);
-
- npObject = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, args.Holder());
- }
-
- // Verify that our wrapper wasn't using a NPObject which
- // has already been deleted.
- if (!npObject || !_NPN_IsAlive(npObject))
- return throwError("NPObject deleted", V8Proxy::REFERENCE_ERROR);
-
- // Wrap up parameters.
- int numArgs = args.Length();
- OwnArrayPtr<NPVariant> npArgs(new NPVariant[numArgs]);
-
- for (int i = 0; i < numArgs; i++)
- convertV8ObjectToNPVariant(args[i], npObject, &npArgs[i]);
-
- NPVariant result;
- VOID_TO_NPVARIANT(result);
-
- switch (functionId) {
- case INVOKE_METHOD:
- if (npObject->_class->invoke) {
- v8::Handle<v8::String> functionName(v8::String::Cast(*args.Data()));
- NPIdentifier identifier = getStringIdentifier(functionName);
- npObject->_class->invoke(npObject, identifier, npArgs.get(), numArgs, &result);
- }
- break;
- case INVOKE_CONSTRUCT:
- if (npObject->_class->construct)
- npObject->_class->construct(npObject, npArgs.get(), numArgs, &result);
- break;
- case INVOKE_DEFAULT:
- if (npObject->_class->invokeDefault)
- npObject->_class->invokeDefault(npObject, npArgs.get(), numArgs, &result);
- break;
- default:
- break;
- }
-
- for (int i=0; i < numArgs; i++)
- NPN_ReleaseVariantValue(&npArgs[i]);
-
- // Unwrap return values.
- v8::Handle<v8::Value> returnValue = convertNPVariantToV8Object(&result, npObject);
- NPN_ReleaseVariantValue(&result);
-
- return returnValue;
-}
-
-
-v8::Handle<v8::Value> npObjectMethodHandler(const v8::Arguments& args)
-{
- return npObjectInvokeImpl(args, INVOKE_METHOD);
-}
-
-
-v8::Handle<v8::Value> npObjectInvokeDefaultHandler(const v8::Arguments& args)
-{
- if (args.IsConstructCall())
- return npObjectInvokeImpl(args, INVOKE_CONSTRUCT);
- else
- return npObjectInvokeImpl(args, INVOKE_DEFAULT);
-}
-
-
-static void weakTemplateCallback(v8::Persistent<v8::Value>, void* parameter);
-
-// NPIdentifier is PrivateIdentifier*.
-static WeakReferenceMap<PrivateIdentifier, v8::FunctionTemplate> staticTemplateMap(&weakTemplateCallback);
-
-static void weakTemplateCallback(v8::Persistent<v8::Value> object, void* parameter)
-{
- PrivateIdentifier* identifier = static_cast<PrivateIdentifier*>(parameter);
- ASSERT(identifier);
- ASSERT(staticTemplateMap.contains(identifier));
-
- staticTemplateMap.forget(identifier);
-}
-
-
-static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self,
- NPIdentifier identifier,
- v8::Local<v8::Value> key)
-{
- NPObject* npObject = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, self);
-
- // Verify that our wrapper wasn't using a NPObject which
- // has already been deleted.
- if (!npObject || !_NPN_IsAlive(npObject))
- return throwError("NPObject deleted", V8Proxy::REFERENCE_ERROR);
-
-
- if (npObject->_class->hasProperty && npObject->_class->hasProperty(npObject, identifier)
- && npObject->_class->getProperty) {
-
- NPVariant result;
- VOID_TO_NPVARIANT(result);
- if (!npObject->_class->getProperty(npObject, identifier, &result))
- return v8::Handle<v8::Value>();
-
- v8::Handle<v8::Value> returnValue = convertNPVariantToV8Object(&result, npObject);
- NPN_ReleaseVariantValue(&result);
- return returnValue;
-
- } else if (key->IsString() && npObject->_class->hasMethod && npObject->_class->hasMethod(npObject, identifier)) {
- PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier);
- v8::Persistent<v8::FunctionTemplate> functionTemplate = staticTemplateMap.get(id);
- // Cache templates using identifier as the key.
- if (functionTemplate.IsEmpty()) {
- // Create a new template.
- v8::Local<v8::FunctionTemplate> temp = v8::FunctionTemplate::New();
- temp->SetCallHandler(npObjectMethodHandler, key);
- functionTemplate = v8::Persistent<v8::FunctionTemplate>::New(temp);
- staticTemplateMap.set(id, functionTemplate);
- }
-
- // FunctionTemplate caches function for each context.
- v8::Local<v8::Function> v8Function = functionTemplate->GetFunction();
- v8Function->SetName(v8::Handle<v8::String>::Cast(key));
- return v8Function;
- }
-
- return v8::Handle<v8::Value>();
-}
-
-v8::Handle<v8::Value> npObjectNamedPropertyGetter(v8::Local<v8::String> name,
- const v8::AccessorInfo& info)
-{
- NPIdentifier identifier = getStringIdentifier(name);
- return npObjectGetProperty(info.Holder(), identifier, name);
-}
-
-v8::Handle<v8::Value> npObjectIndexedPropertyGetter(uint32_t index,
- const v8::AccessorInfo& info)
-{
- NPIdentifier identifier = NPN_GetIntIdentifier(index);
- return npObjectGetProperty(info.Holder(), identifier, v8::Number::New(index));
-}
-
-v8::Handle<v8::Value> npObjectGetNamedProperty(v8::Local<v8::Object> self,
- v8::Local<v8::String> name)
-{
- NPIdentifier identifier = getStringIdentifier(name);
- return npObjectGetProperty(self, identifier, name);
-}
-
-v8::Handle<v8::Value> npObjectGetIndexedProperty(v8::Local<v8::Object> self,
- uint32_t index)
-{
- NPIdentifier identifier = NPN_GetIntIdentifier(index);
- return npObjectGetProperty(self, identifier, v8::Number::New(index));
-}
-
-static v8::Handle<v8::Value> npObjectSetProperty(v8::Local<v8::Object> self,
- NPIdentifier identifier,
- v8::Local<v8::Value> value)
-{
- NPObject* npObject = V8Proxy::ToNativeObject<NPObject>(V8ClassIndex::NPOBJECT, self);
-
- // Verify that our wrapper wasn't using a NPObject which
- // has already been deleted.
- if (!npObject || !_NPN_IsAlive(npObject)) {
- throwError("NPObject deleted", V8Proxy::REFERENCE_ERROR);
- return value; // Intercepted, but an exception was thrown.
- }
-
- if (npObject->_class->hasProperty && npObject->_class->hasProperty(npObject, identifier)
- && npObject->_class->setProperty) {
-
- NPVariant npValue;
- VOID_TO_NPVARIANT(npValue);
- convertV8ObjectToNPVariant(value, npObject, &npValue);
- bool success = npObject->_class->setProperty(npObject, identifier, &npValue);
- NPN_ReleaseVariantValue(&npValue);
- if (success)
- return value; // Intercept the call.
- }
- return v8::Local<v8::Value>(); // Do not intercept the call.
-}
-
-
-v8::Handle<v8::Value> npObjectNamedPropertySetter(v8::Local<v8::String> name,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo& info)
-{
- NPIdentifier identifier = getStringIdentifier(name);
- return npObjectSetProperty(info.Holder(), identifier, value);
-}
-
-
-v8::Handle<v8::Value> npObjectIndexedPropertySetter(uint32_t index,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo& info)
-{
- NPIdentifier identifier = NPN_GetIntIdentifier(index);
- return npObjectSetProperty(info.Holder(), identifier, value);
-}
-
-v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self,
- v8::Local<v8::String> name,
- v8::Local<v8::Value> value)
-{
- NPIdentifier identifier = getStringIdentifier(name);
- return npObjectSetProperty(self, identifier, value);
-}
-
-v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self,
- uint32_t index,
- v8::Local<v8::Value> value)
-{
- NPIdentifier identifier = NPN_GetIntIdentifier(index);
- return npObjectSetProperty(self, identifier, value);
-}
-
-
-static void weakNPObjectCallback(v8::Persistent<v8::Value>, void* parameter);
-
-static DOMWrapperMap<NPObject> staticNPObjectMap(&weakNPObjectCallback);
-
-static void weakNPObjectCallback(v8::Persistent<v8::Value> object, void* parameter)
-{
- NPObject* npObject = static_cast<NPObject*>(parameter);
- ASSERT(staticNPObjectMap.contains(npObject));
- ASSERT(npObject);
-
- // Must remove from our map before calling NPN_ReleaseObject().
- // NPN_ReleaseObject can call ForgetV8ObjectForNPObject, which
- // uses the table as well.
- staticNPObjectMap.forget(npObject);
-
- if (_NPN_IsAlive(npObject))
- NPN_ReleaseObject(npObject);
-}
-
-
-v8::Local<v8::Object> createV8ObjectForNPObject(NPObject* object, NPObject* root)
-{
- static v8::Persistent<v8::FunctionTemplate> npObjectDesc;
-
- ASSERT(v8::Context::InContext());
-
- // If this is a v8 object, just return it.
- if (object->_class == npScriptObjectClass) {
- V8NPObject* v8NPObject = reinterpret_cast<V8NPObject*>(object);
- return v8::Local<v8::Object>::New(v8NPObject->v8Object);
- }
-
- // If we've already wrapped this object, just return it.
- if (staticNPObjectMap.contains(object))
- return v8::Local<v8::Object>::New(staticNPObjectMap.get(object));
-
- // FIXME: we should create a Wrapper type as a subclass of JSObject.
- // It has two internal fields, field 0 is the wrapped pointer,
- // and field 1 is the type. There should be an api function that
- // returns unused type id.
- // The same Wrapper type can be used by DOM bindings.
- if (npObjectDesc.IsEmpty()) {
- npObjectDesc = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New());
- npObjectDesc->InstanceTemplate()->SetInternalFieldCount(V8Custom::kNPObjectInternalFieldCount);
- npObjectDesc->InstanceTemplate()->SetNamedPropertyHandler(npObjectNamedPropertyGetter, npObjectNamedPropertySetter);
- npObjectDesc->InstanceTemplate()->SetIndexedPropertyHandler(npObjectIndexedPropertyGetter, npObjectIndexedPropertySetter);
- npObjectDesc->InstanceTemplate()->SetCallAsFunctionHandler(npObjectInvokeDefaultHandler);
- }
-
- 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())
- return value;
-
- WrapNPObject(value, object);
-
- // 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);
-
- return value;
-}
-
-void forgetV8ObjectForNPObject(NPObject* object)
-{
- if (staticNPObjectMap.contains(object)) {
- LOCK_V8;
- v8::HandleScope scope;
- v8::Persistent<v8::Object> handle(staticNPObjectMap.get(object));
- WebCore::V8Proxy::SetDOMWrapper(handle, WebCore::V8ClassIndex::NPOBJECT, 0);
- staticNPObjectMap.forget(object);
- NPN_ReleaseObject(object);
- }
-}
diff --git a/V8Binding/binding/V8NPObject.h b/V8Binding/binding/V8NPObject.h
deleted file mode 100644
index ad39f5e..0000000
--- a/V8Binding/binding/V8NPObject.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 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 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 V8NPObject_h
-#define V8NPObject_h
-
-#include <v8.h>
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): diff and consolidate.
-#include "third_party/npapi/bindings/npruntime.h"
-#else
-#include "bridge/npruntime.h" // use WebCore version
-#endif
-
-// FIXME: Remove these #defines when upstreamed. They are needed to compile
-// some currently upstreamed files which will need to be modified when this
-// file is upstreamed.
-#define NPObjectGetNamedProperty npObjectGetNamedProperty
-#define NPObjectSetNamedProperty npObjectSetNamedProperty
-#define NPObjectInvokeDefaultHandler npObjectInvokeDefaultHandler
-#define NPObjectGetIndexedProperty npObjectGetIndexedProperty
-#define NPObjectSetIndexedProperty npObjectSetIndexedProperty
-#define CreateV8ObjectForNPObject createV8ObjectForNPObject
-
-// These functions can be replaced by normal JS operation.
-// Getters
-v8::Handle<v8::Value> npObjectNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo&);
-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>, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectIndexedPropertySetter(uint32_t index, const v8::AccessorInfo&);
-v8::Handle<v8::Value> npObjectSetNamedProperty(v8::Local<v8::Object> self, v8::Local<v8::String> name, v8::Local<v8::Value>);
-v8::Handle<v8::Value> npObjectSetIndexedProperty(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8::Value>);
-
-v8::Handle<v8::Value> npObjectInvokeDefaultHandler(const v8::Arguments&);
-
-// 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*, 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*);
-
-#endif // V8NPObject_h
diff --git a/V8Binding/binding/V8NPUtils.cpp b/V8Binding/binding/V8NPUtils.cpp
deleted file mode 100644
index 3a68288..0000000
--- a/V8Binding/binding/V8NPUtils.cpp
+++ /dev/null
@@ -1,124 +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"
-
-#include "V8NPUtils.h"
-
-#include "DOMWindow.h"
-#include "Frame.h"
-#include "PlatformString.h"
-#undef LOG
-
-#include "npruntime_priv.h"
-#include "NPV8Object.h"
-#include "V8NPObject.h"
-#include "v8_proxy.h"
-
-void convertV8ObjectToNPVariant(v8::Local<v8::Value> object, NPObject *owner, NPVariant* result)
-{
- VOID_TO_NPVARIANT(*result);
-
- // It is really the caller's responsibility to deal with the empty handle
- // case because there could be different actions to take in different
- // contexts.
- ASSERT(!object.IsEmpty());
-
- if (object.IsEmpty())
- return;
-
- if (object->IsInt32())
- INT32_TO_NPVARIANT(object->NumberValue(), *result);
- else if (object->IsNumber())
- DOUBLE_TO_NPVARIANT(object->NumberValue(), *result);
- else if (object->IsBoolean())
- BOOLEAN_TO_NPVARIANT(object->BooleanValue(), *result);
- else if (object->IsNull())
- NULL_TO_NPVARIANT(*result);
- else if (object->IsUndefined())
- VOID_TO_NPVARIANT(*result);
- else if (object->IsString()) {
- v8::String::Utf8Value utf8(object);
- char* utf8_chars = strdup(*utf8);
- STRINGN_TO_NPVARIANT(utf8_chars, utf8.length(), *result);
- } else if (object->IsObject()) {
- WebCore::DOMWindow* window = WebCore::V8Proxy::retrieveWindow();
- NPObject* npobject = npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(object), window);
- if (npobject)
- _NPN_RegisterObject(npobject, owner);
- OBJECT_TO_NPVARIANT(npobject, *result);
- }
-}
-
-
-v8::Handle<v8::Value> convertNPVariantToV8Object(const NPVariant* variant, NPObject* npobject)
-{
- NPVariantType type = variant->type;
-
- if (type == NPVariantType_Int32)
- return v8::Integer::New(NPVARIANT_TO_INT32(*variant));
- if (type == NPVariantType_Double)
- return v8::Number::New(NPVARIANT_TO_DOUBLE(*variant));
- if (type == NPVariantType_Bool)
- return NPVARIANT_TO_BOOLEAN(*variant) ? v8::True() : v8::False();
- if (type == NPVariantType_Null)
- return v8::Null();
- if (type == NPVariantType_Void)
- return v8::Undefined();
- if (type == NPVariantType_String) {
- NPString src = NPVARIANT_TO_STRING(*variant);
- return v8::String::New(src.UTF8Characters, src.UTF8Length);
- }
- if (type == NPVariantType_Object) {
- NPObject* obj = NPVARIANT_TO_OBJECT(*variant);
- if (obj->_class == npScriptObjectClass)
- return reinterpret_cast<V8NPObject*>(obj)->v8Object;
- return createV8ObjectForNPObject(obj, npobject);
- }
- return v8::Undefined();
-}
-
-// Helper function to create an NPN String Identifier from a v8 string.
-NPIdentifier getStringIdentifier(v8::Handle<v8::String> str)
-{
- const int kStackBufSize = 100;
-
- int bufLen = str->Length() + 1;
- if (bufLen <= kStackBufSize) {
- // Use local stack buffer to avoid heap allocations for small strings.
- // Here we should only use the stack space for stack_buf when it's used,
- // not when we use the heap.
- char stackBuf[kStackBufSize];
- str->WriteAscii(stackBuf);
- return NPN_GetStringIdentifier(stackBuf);
- }
-
- v8::String::AsciiValue ascii(str);
- return NPN_GetStringIdentifier(*ascii);
-}
diff --git a/V8Binding/binding/V8NPUtils.h b/V8Binding/binding/V8NPUtils.h
deleted file mode 100644
index 1fd8fd6..0000000
--- a/V8Binding/binding/V8NPUtils.h
+++ /dev/null
@@ -1,32 +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_np_utils_h
-#define v8_np_utils_h
-
-#include <v8.h>
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): diff and consolidate.
-#include "third_party/npapi/bindings/npruntime.h"
-#else
-#include "bridge/npruntime.h" // use WebCore version
-#endif
-
-namespace WebCore {
- class Frame;
-}
-
-// 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);
-
-// 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);
-
-// Helper function to create an NPN String Identifier from a v8 string.
-NPIdentifier getStringIdentifier(v8::Handle<v8::String> str);
-
-#endif // v8_np_utils_h
diff --git a/V8Binding/binding/V8SVGPODTypeWrapper.h b/V8Binding/binding/V8SVGPODTypeWrapper.h
deleted file mode 100644
index 0fb1fb8..0000000
--- a/V8Binding/binding/V8SVGPODTypeWrapper.h
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 The Chromium Authors. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 V8SVGPODTypeWrapper_h
-#define V8SVGPODTypeWrapper_h
-
-#if ENABLE(SVG)
-
-#include "config.h"
-#include "SVGElement.h"
-#include "SVGList.h"
-#include <wtf/Assertions.h>
-#include <wtf/RefCounted.h>
-#include <wtf/HashMap.h>
-#include "v8_proxy.h"
-
-namespace WebCore {
-
-template<typename PODType>
-class V8SVGPODTypeWrapper : public RefCounted<V8SVGPODTypeWrapper<PODType> > {
-public:
- V8SVGPODTypeWrapper() { }
- virtual ~V8SVGPODTypeWrapper() { }
- virtual operator PODType() = 0;
- virtual void commitChange(PODType, SVGElement*) = 0;
-};
-
-template<typename PODType>
-class V8SVGPODTypeWrapperCreatorForList : public V8SVGPODTypeWrapper<PODType>
-{
-public:
- typedef PODType (SVGPODListItem<PODType>::*GetterMethod)() const;
- typedef void (SVGPODListItem<PODType>::*SetterMethod)(PODType);
-
- V8SVGPODTypeWrapperCreatorForList(SVGPODListItem<PODType>* creator, const QualifiedName& attributeName)
- : m_creator(creator)
- , m_getter(&SVGPODListItem<PODType>::value)
- , m_setter(&SVGPODListItem<PODType>::setValue)
- , m_associatedAttributeName(attributeName)
- {
- ASSERT(m_creator);
- ASSERT(m_getter);
- ASSERT(m_setter);
- }
-
- virtual ~V8SVGPODTypeWrapperCreatorForList() { }
-
- // Getter wrapper
- virtual operator PODType() { return (m_creator.get()->*m_getter)(); }
-
- // Setter wrapper
- virtual void commitChange(PODType type, SVGElement* context)
- {
- if (!m_setter)
- return;
-
- (m_creator.get()->*m_setter)(type);
-
- if (context)
- context->svgAttributeChanged(m_associatedAttributeName);
- }
-
-private:
- // Update callbacks
- RefPtr<SVGPODListItem<PODType> > m_creator;
- GetterMethod m_getter;
- SetterMethod m_setter;
- const QualifiedName& m_associatedAttributeName;
-};
-
-template<typename PODType>
-class V8SVGStaticPODTypeWrapper : public V8SVGPODTypeWrapper<PODType>
-{
-public:
- V8SVGStaticPODTypeWrapper(PODType type)
- : m_podType(type)
- { }
-
- virtual ~V8SVGStaticPODTypeWrapper() { }
-
- // Getter wrapper
- virtual operator PODType() { return m_podType; }
-
- // Setter wrapper
- virtual void commitChange(PODType type, SVGElement*)
- {
- m_podType = type;
- }
-
-private:
- PODType m_podType;
-};
-
-template<typename PODType, typename ParentTypeArg>
-class V8SVGStaticPODTypeWrapperWithPODTypeParent : public V8SVGStaticPODTypeWrapper<PODType> {
-public:
- typedef V8SVGPODTypeWrapper<ParentTypeArg> ParentType;
-
- V8SVGStaticPODTypeWrapperWithPODTypeParent(PODType type, ParentType* parent)
- : V8SVGStaticPODTypeWrapper<PODType>(type)
- , m_parentType(parent)
- {
- }
-
- virtual void commitChange(PODType type, SVGElement* context)
- {
- V8SVGStaticPODTypeWrapper<PODType>::commitChange(type, context);
- m_parentType->commitChange(ParentTypeArg(type), context);
- }
-
-private:
- RefPtr<ParentType> m_parentType;
-};
-
-template<typename PODType, typename ParentType>
-class V8SVGStaticPODTypeWrapperWithParent : public V8SVGPODTypeWrapper<PODType> {
-public:
- typedef PODType (ParentType::*GetterMethod)() const;
- typedef void (ParentType::*SetterMethod)(const PODType&);
-
- V8SVGStaticPODTypeWrapperWithParent(ParentType* parent, GetterMethod getter, SetterMethod setter)
- : m_parent(parent)
- , m_getter(getter)
- , m_setter(setter)
- {
- ASSERT(m_parent);
- ASSERT(m_getter);
- ASSERT(m_setter);
- }
-
- virtual operator PODType()
- {
- return (m_parent.get()->*m_getter)();
- }
-
- virtual void commitChange(PODType type, SVGElement* context)
- {
- (m_parent.get()->*m_setter)(type);
- }
-
-private:
- // Update callbacks
- RefPtr<ParentType> m_parent;
- GetterMethod m_getter;
- SetterMethod m_setter;
-};
-
-template<typename PODType, typename PODTypeCreator>
-class V8SVGDynamicPODTypeWrapper : public V8SVGPODTypeWrapper<PODType>
-{
-public:
- typedef PODType (PODTypeCreator::*GetterMethod)() const;
- typedef void (PODTypeCreator::*SetterMethod)(PODType);
- typedef void (*CacheRemovalCallback)(V8SVGPODTypeWrapper<PODType>*);
-
- V8SVGDynamicPODTypeWrapper(PODTypeCreator* creator, GetterMethod getter, SetterMethod setter, CacheRemovalCallback cacheRemovalCallback)
- : m_creator(creator)
- , m_getter(getter)
- , m_setter(setter)
- , m_cacheRemovalCallback(cacheRemovalCallback)
- {
- ASSERT(creator);
- ASSERT(getter);
- ASSERT(setter);
- ASSERT(cacheRemovalCallback);
- }
-
- virtual ~V8SVGDynamicPODTypeWrapper() {
- ASSERT(m_cacheRemovalCallback);
-
- (*m_cacheRemovalCallback)(this);
- }
-
- // Getter wrapper
- virtual operator PODType() { return (m_creator.get()->*m_getter)(); }
-
- // Setter wrapper
- virtual void commitChange(PODType type, SVGElement* context)
- {
- (m_creator.get()->*m_setter)(type);
-
- if (context)
- context->svgAttributeChanged(m_creator->associatedAttributeName());
- }
-
-private:
- // Update callbacks
- RefPtr<PODTypeCreator> m_creator;
- GetterMethod m_getter;
- SetterMethod m_setter;
- CacheRemovalCallback m_cacheRemovalCallback;
-};
-
-// Caching facilities
-template<typename PODType, typename PODTypeCreator>
-struct PODTypeWrapperCacheInfo {
- typedef PODType (PODTypeCreator::*GetterMethod)() const;
- typedef void (PODTypeCreator::*SetterMethod)(PODType);
-
- // Empty value
- PODTypeWrapperCacheInfo()
- : creator(0)
- , getter(0)
- , setter(0)
- { }
-
- // Deleted value
- explicit PODTypeWrapperCacheInfo(WTF::HashTableDeletedValueType)
- : creator(reinterpret_cast<PODTypeCreator*>(-1))
- , getter(0)
- , setter(0)
- {
- }
- bool isHashTableDeletedValue() const
- {
- return creator == reinterpret_cast<PODTypeCreator*>(-1);
- }
-
- PODTypeWrapperCacheInfo(PODTypeCreator* _creator, GetterMethod _getter, SetterMethod _setter)
- : creator(_creator)
- , getter(_getter)
- , setter(_setter)
- {
- ASSERT(creator);
- ASSERT(getter);
- }
-
- bool operator==(const PODTypeWrapperCacheInfo& other) const
- {
- return creator == other.creator && getter == other.getter && setter == other.setter;
- }
-
- PODTypeCreator* creator;
- GetterMethod getter;
- SetterMethod setter;
-};
-
-template<typename PODType, typename PODTypeCreator>
-struct PODTypeWrapperCacheInfoHash {
- static unsigned hash(const PODTypeWrapperCacheInfo<PODType, PODTypeCreator>& info)
- {
- unsigned creator = reinterpret_cast<unsigned>(info.creator);
- unsigned getter = reinterpret_cast<unsigned>(*(void**)&info.getter);
- unsigned setter = reinterpret_cast<unsigned>(*(void**)&info.setter);
- return (creator * 13) + getter ^ (setter >> 2);
- }
-
- static bool equal(const PODTypeWrapperCacheInfo<PODType, PODTypeCreator>& a, const PODTypeWrapperCacheInfo<PODType, PODTypeCreator>& b)
- {
- return a == b;
- }
-
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-template<typename PODType, typename PODTypeCreator>
-struct PODTypeWrapperCacheInfoTraits : WTF::GenericHashTraits<PODTypeWrapperCacheInfo<PODType, PODTypeCreator> > {
- typedef PODTypeWrapperCacheInfo<PODType, PODTypeCreator> CacheInfo;
-
- static const bool emptyValueIsZero = true;
- static const bool needsDestruction = false;
-
- static const CacheInfo& emptyValue()
- {
- static CacheInfo key;
- return key;
- }
-
- static void constructDeletedValue(CacheInfo& slot)
- {
- new (&slot) CacheInfo(WTF::HashTableDeletedValue);
- }
-
- static bool isDeletedValue(const CacheInfo& value)
- {
- return value.isHashTableDeletedValue();
- }
-};
-
-template<typename PODType, typename PODTypeCreator>
-class V8SVGDynamicPODTypeWrapperCache
-{
-public:
- typedef PODType (PODTypeCreator::*GetterMethod)() const;
- typedef void (PODTypeCreator::*SetterMethod)(PODType);
-
- typedef PODTypeWrapperCacheInfo<PODType, PODTypeCreator> CacheInfo;
- typedef PODTypeWrapperCacheInfoHash<PODType, PODTypeCreator> CacheInfoHash;
- typedef PODTypeWrapperCacheInfoTraits<PODType, PODTypeCreator> CacheInfoTraits;
-
- typedef V8SVGPODTypeWrapper<PODType> WrapperBase;
- typedef V8SVGDynamicPODTypeWrapper<PODType, PODTypeCreator> DynamicWrapper;
-
- typedef HashMap<CacheInfo, DynamicWrapper*, CacheInfoHash, CacheInfoTraits> DynamicWrapperHashMap;
- typedef typename DynamicWrapperHashMap::const_iterator DynamicWrapperHashMapIterator;
-
- static DynamicWrapperHashMap& dynamicWrapperHashMap()
- {
- static DynamicWrapperHashMap _dynamicWrapperHashMap;
- return _dynamicWrapperHashMap;
- }
-
- // Used for readwrite attributes only
- static WrapperBase* lookupOrCreateWrapper(PODTypeCreator* creator, GetterMethod getter, SetterMethod setter)
- {
- DynamicWrapperHashMap& map(dynamicWrapperHashMap());
- CacheInfo info(creator, getter, setter);
-
- if (map.contains(info))
- return map.get(info);
-
- DynamicWrapper* wrapper = new V8SVGDynamicPODTypeWrapper<PODType, PODTypeCreator>(
- creator, getter, setter, forgetWrapper);
- map.set(info, wrapper);
- return wrapper;
- }
-
- static void forgetWrapper(V8SVGPODTypeWrapper<PODType>* wrapper)
- {
- DynamicWrapperHashMap& map(dynamicWrapperHashMap());
-
- DynamicWrapperHashMapIterator it = map.begin();
- DynamicWrapperHashMapIterator end = map.end();
-
- for (; it != end; ++it) {
- if (it->second != wrapper)
- continue;
-
- // It's guaranteed that there's just one object we need to take care of.
- map.remove(it->first);
- break;
- }
- }
-};
-
-
-class V8SVGPODTypeUtil {
-public:
- template <class P>
- static P ToSVGPODType(V8ClassIndex::V8WrapperType type,
- v8::Handle<v8::Value> object, bool& ok);
-};
-
-
-template <class P>
-P V8SVGPODTypeUtil::ToSVGPODType(V8ClassIndex::V8WrapperType type,
- v8::Handle<v8::Value> object,
- bool& ok) {
- void *wrapper = V8Proxy::ToSVGPODTypeImpl(type, object);
- if (wrapper == NULL) {
- ok = false;
- return P();
- } else {
- ok = true;
- return *static_cast<V8SVGPODTypeWrapper<P>*>(wrapper);
- }
-}
-
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG)
-#endif // V8SVGPODTypeWrapper_h
diff --git a/V8Binding/binding/npruntime.cpp b/V8Binding/binding/npruntime.cpp
deleted file mode 100644
index 6a2faeb..0000000
--- a/V8Binding/binding/npruntime.cpp
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "NPV8Object.h"
-#include "npruntime_priv.h"
-#include "V8NPObject.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/Assertions.h>
-
-// 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.
-//
-// Commenting out the locks to avoid dependencies on chrome for now.
-// Need a platform abstraction which we can use.
-// static Lock StringIdentifierMapLock;
-
-namespace {
-
-// We use StringKey here as the key-type to avoid a string copy to
-// construct the map key and for faster comparisons than strcmp.
-class StringKey {
- public:
- explicit StringKey(const char* str)
- : m_string(str), m_length(strlen(str)) {}
- StringKey() : m_string(0), m_length(0) {}
- explicit StringKey(WTF::HashTableDeletedValueType)
- : m_string(hashTableDeletedValue()), m_length(0) { }
-
- StringKey& operator=(const StringKey& other) {
- this->m_string = other.m_string;
- this->m_length = other.m_length;
- return *this;
- }
-
- bool isHashTableDeletedValue() const {
- return m_string == hashTableDeletedValue();
- }
-
- const char* m_string;
- size_t m_length;
- private:
- const char* hashTableDeletedValue() const {
- return reinterpret_cast<const char*>(-1);
- }
-};
-
-inline bool operator==(const StringKey& x, const StringKey& y) {
- if (x.m_length != y.m_length) {
- return false;
- } else if (x.m_string == y.m_string) {
- return true;
- } else {
- ASSERT(!x.isHashTableDeletedValue() && !y.isHashTableDeletedValue());
- return memcmp(x.m_string, y.m_string, y.m_length) == 0;
- }
-}
-
-// Implement WTF::DefaultHash<StringKey>::Hash interface.
-struct StringKeyHash {
- static unsigned hash(const StringKey& key) {
- // Compute string hash.
- unsigned hash = 0;
- size_t len = key.m_length;
- const char* str = key.m_string;
- for (size_t i = 0; i < len; i++) {
- char c = str[i];
- hash += c;
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
- if (hash == 0) {
- hash = 27;
- }
- return hash;
- }
-
- static bool equal(const StringKey& x, const StringKey& y) {
- return x == y;
- }
-
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-} // namespace
-
-// Implement HashTraits<StringKey>
-struct StringKeyHashTraits : WTF::GenericHashTraits<StringKey> {
- static void constructDeletedValue(StringKey& slot) {
- new (&slot) StringKey(WTF::HashTableDeletedValue);
- }
- static bool isDeletedValue(const StringKey& value) {
- return value.isHashTableDeletedValue();
- }
-};
-
-typedef WTF::HashMap<StringKey, PrivateIdentifier*, \
- StringKeyHash, StringKeyHashTraits> StringIdentifierMap;
-
-static StringIdentifierMap* getStringIdentifierMap() {
- static StringIdentifierMap* stringIdentifierMap = 0;
- if (!stringIdentifierMap)
- stringIdentifierMap = new StringIdentifierMap();
- return stringIdentifierMap;
-}
-
-// FIXME: Consider removing locks if we're singlethreaded already.
-// static Lock IntIdentifierMapLock;
-
-typedef WTF::HashMap<int, PrivateIdentifier*> IntIdentifierMap;
-
-static IntIdentifierMap* getIntIdentifierMap() {
- static IntIdentifierMap* intIdentifierMap = 0;
- if (!intIdentifierMap)
- intIdentifierMap = new IntIdentifierMap();
- return intIdentifierMap;
-}
-
-extern "C" {
-
-NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name) {
- ASSERT(name);
-
- if (name) {
- // AutoLock safeLock(StringIdentifierMapLock);
-
- StringKey key(name);
- StringIdentifierMap* identMap = getStringIdentifierMap();
- StringIdentifierMap::iterator iter = identMap->find(key);
- if (iter != identMap->end())
- return static_cast<NPIdentifier>(iter->second);
-
- size_t nameLen = key.m_length;
-
- // We never release identifiers, so this dictionary will grow.
- PrivateIdentifier* identifier = static_cast<PrivateIdentifier*>(
- malloc(sizeof(PrivateIdentifier) + nameLen + 1));
- char* nameStorage = reinterpret_cast<char*>(identifier + 1);
- memcpy(nameStorage, name, nameLen + 1);
- identifier->isString = true;
- identifier->value.string = reinterpret_cast<NPUTF8*>(nameStorage);
- key.m_string = nameStorage;
- identMap->set(key, identifier);
- return (NPIdentifier)identifier;
- }
-
- return 0;
-}
-
-void NPN_GetStringIdentifiers(const NPUTF8** names, int32_t nameCount,
- NPIdentifier* identifiers) {
- ASSERT(names);
- ASSERT(identifiers);
-
- if (names && identifiers)
- for (int i = 0; i < nameCount; i++)
- identifiers[i] = NPN_GetStringIdentifier(names[i]);
-}
-
-NPIdentifier NPN_GetIntIdentifier(int32_t intid) {
- // AutoLock safeLock(IntIdentifierMapLock);
- // Special case for -1 and 0, both cannot be used as key in HashMap.
- if (intid == 0 || intid == -1) {
- static PrivateIdentifier* minusOneOrZeroIds[2];
- PrivateIdentifier* id = minusOneOrZeroIds[intid + 1];
- if (!id) {
- id = reinterpret_cast<PrivateIdentifier*>(
- malloc(sizeof(PrivateIdentifier)));
- id->isString = false;
- id->value.number = intid;
- minusOneOrZeroIds[intid + 1] = id;
- }
- return (NPIdentifier)id;
- }
-
- IntIdentifierMap* identMap = getIntIdentifierMap();
- IntIdentifierMap::iterator iter = identMap->find(intid);
- if (iter != identMap->end())
- return static_cast<NPIdentifier>(iter->second);
-
- // We never release identifiers, so this dictionary will grow.
- PrivateIdentifier* identifier = reinterpret_cast<PrivateIdentifier*>(
- malloc(sizeof(PrivateIdentifier)));
- identifier->isString = false;
- identifier->value.number = intid;
- identMap->set(intid, identifier);
- return (NPIdentifier)identifier;
-}
-
-bool NPN_IdentifierIsString(NPIdentifier identifier) {
- PrivateIdentifier* i = reinterpret_cast<PrivateIdentifier*>(identifier);
- return i->isString;
-}
-
-NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier) {
- PrivateIdentifier* i = reinterpret_cast<PrivateIdentifier*>(identifier);
- if (!i->isString || !i->value.string)
- return NULL;
-
- return (NPUTF8 *)strdup(i->value.string);
-}
-
-int32_t NPN_IntFromIdentifier(NPIdentifier identifier) {
- PrivateIdentifier* i = reinterpret_cast<PrivateIdentifier*>(identifier);
- if (i->isString)
- return 0;
- return i->value.number;
-}
-
-void NPN_ReleaseVariantValue(NPVariant* variant) {
- ASSERT(variant);
-
- if (variant->type == NPVariantType_Object) {
- NPN_ReleaseObject(variant->value.objectValue);
- variant->value.objectValue = 0;
- } else if (variant->type == NPVariantType_String) {
- free((void*)variant->value.stringValue.UTF8Characters);
- variant->value.stringValue.UTF8Characters = 0;
- variant->value.stringValue.UTF8Length = 0;
- }
-
- variant->type = NPVariantType_Void;
-}
-
-NPObject *NPN_CreateObject(NPP npp, NPClass* aClass) {
- ASSERT(aClass);
-
- if (aClass) {
- NPObject* obj;
- if (aClass->allocate != NULL)
- obj = aClass->allocate(npp, aClass);
- else
- obj = reinterpret_cast<NPObject*>(malloc(sizeof(NPObject)));
-
- obj->_class = aClass;
- obj->referenceCount = 1;
- return obj;
- }
-
- return 0;
-}
-
-NPObject* NPN_RetainObject(NPObject* obj) {
- ASSERT(obj);
- ASSERT(obj->referenceCount > 0);
-
- if (obj)
- obj->referenceCount++;
-
- return obj;
-}
-
-// _NPN_DeallocateObject actually deletes the object. Technically,
-// callers should use NPN_ReleaseObject. Webkit exposes this function
-// to kill objects which plugins may not have properly released.
-void _NPN_DeallocateObject(NPObject *obj) {
- ASSERT(obj);
- ASSERT(obj->referenceCount >= 0);
-
- if (obj) {
- // NPObjects that remain in pure C++ may never have wrappers.
- // Hence, if it's not already alive, don't unregister it.
- // If it is alive, unregister it as the *last* thing we do
- // so that it can do as much cleanup as possible on its own.
- if (_NPN_IsAlive(obj))
- _NPN_UnregisterObject(obj);
-
- obj->referenceCount = -1;
- if (obj->_class->deallocate)
- obj->_class->deallocate(obj);
- else
- free(obj);
- }
-}
-
-void NPN_ReleaseObject(NPObject* obj) {
- ASSERT(obj);
- ASSERT(obj->referenceCount >= 1);
-
- if (obj && obj->referenceCount >= 1) {
- if (--obj->referenceCount == 0)
- _NPN_DeallocateObject(obj);
- }
-}
-
-void _NPN_InitializeVariantWithStringCopy(NPVariant* variant,
- const NPString* value) {
- variant->type = NPVariantType_String;
- variant->value.stringValue.UTF8Length = value->UTF8Length;
- variant->value.stringValue.UTF8Characters =
- reinterpret_cast<NPUTF8*>(malloc(sizeof(NPUTF8) * value->UTF8Length));
- memcpy((void*)variant->value.stringValue.UTF8Characters,
- value->UTF8Characters,
- sizeof(NPUTF8) * value->UTF8Length);
-}
-
-
-// NPN_Registry
-//
-// The registry is designed for quick lookup of NPObjects.
-// JS needs to be able to quickly lookup a given NPObject to determine
-// if it is alive or not.
-// The browser needs to be able to quickly lookup all NPObjects which are
-// "owned" by an object.
-//
-// The g_live_objects is a hash table of all live objects to their owner
-// objects. Presence in this table is used primarily to determine if
-// objects are live or not.
-//
-// The g_root_objects is a hash table of root objects to a set of
-// objects that should be deactivated in sync with the root. A
-// root is defined as a top-level owner object. This is used on
-// Frame teardown to deactivate all objects associated
-// with a particular plugin.
-
-typedef WTF::HashSet<NPObject*> NPObjectSet;
-typedef WTF::HashMap<NPObject*, NPObject*> NPObjectMap;
-typedef WTF::HashMap<NPObject*, NPObjectSet*> NPRootObjectMap;
-
-// A map of live NPObjects with pointers to their Roots.
-NPObjectMap g_live_objects;
-
-// A map of the root objects and the list of NPObjects
-// associated with that object.
-NPRootObjectMap g_root_objects;
-
-void _NPN_RegisterObject(NPObject* obj, NPObject* owner) {
- ASSERT(obj);
-
- // Check if already registered.
- if (g_live_objects.find(obj) != g_live_objects.end()) {
- return;
- }
-
- if (!owner) {
- // Registering a new owner object.
- ASSERT(g_root_objects.find(obj) == g_root_objects.end());
- g_root_objects.set(obj, new NPObjectSet());
- } else {
- // Always associate this object with it's top-most parent.
- // Since we always flatten, we only have to look up one level.
- NPObjectMap::iterator owner_entry = g_live_objects.find(owner);
- NPObject* parent = NULL;
- if (g_live_objects.end() != owner_entry)
- parent = owner_entry->second;
-
- if (parent) {
- owner = parent;
- }
- ASSERT(g_root_objects.find(obj) == g_root_objects.end());
- if (g_root_objects.find(owner) != g_root_objects.end())
- g_root_objects.get(owner)->add(obj);
- }
-
- ASSERT(g_live_objects.find(obj) == g_live_objects.end());
- g_live_objects.set(obj, owner);
-}
-
-void _NPN_UnregisterObject(NPObject* obj) {
- ASSERT(obj);
- ASSERT(g_live_objects.find(obj) != g_live_objects.end());
-
- NPObject* owner = NULL;
- if (g_live_objects.find(obj) != g_live_objects.end())
- owner = g_live_objects.find(obj)->second;
-
- if (owner == NULL) {
- // Unregistering a owner object; also unregister it's descendants.
- ASSERT(g_root_objects.find(obj) != g_root_objects.end());
- NPObjectSet* set = g_root_objects.get(obj);
- while (set->size() > 0) {
-#ifndef NDEBUG
- int size = set->size();
-#endif
- NPObject* sub_object = *(set->begin());
- // The sub-object should not be a owner!
- ASSERT(g_root_objects.find(sub_object) == g_root_objects.end());
-
- // First, unregister the object.
- set->remove(sub_object);
- g_live_objects.remove(sub_object);
-
- // Remove the JS references to the object.
- forgetV8ObjectForNPObject(sub_object);
-
- ASSERT(set->size() < size);
- }
- delete set;
- g_root_objects.remove(obj);
- } else {
- NPRootObjectMap::iterator owner_entry = g_root_objects.find(owner);
- if (owner_entry != g_root_objects.end()) {
- NPObjectSet* list = owner_entry->second;
- ASSERT(list->find(obj) != list->end());
- list->remove(obj);
- }
- }
-
- g_live_objects.remove(obj);
- forgetV8ObjectForNPObject(obj);
-}
-
-bool _NPN_IsAlive(NPObject* obj) {
- return g_live_objects.find(obj) != g_live_objects.end();
-}
-
-} // extern "C"
diff --git a/V8Binding/binding/npruntime_impl.h b/V8Binding/binding/npruntime_impl.h
deleted file mode 100644
index 31db922..0000000
--- a/V8Binding/binding/npruntime_impl.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2008, 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 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 npruntime_impl_h
-#define npruntime_impl_h
-
-#if PLATFORM(CHROMIUM)
-#include "bindings/npruntime.h"
-#else
-#include "npruntime.h" // use V8Binding/npapi version
-#endif
-
-// This file exists to support WebCore, which expects to be able to call upon
-// portions of the NPRuntime implementation.
-
-// A simple mapping for now. FIXME We should probably just adopt the
-// underscore prefix as our naming convention too.
-
-#define _NPN_ReleaseVariantValue NPN_ReleaseVariantValue
-#define _NPN_GetStringIdentifier NPN_GetStringIdentifier
-#define _NPN_GetStringIdentifiers NPN_GetStringIdentifiers
-#define _NPN_GetIntIdentifier NPN_GetIntIdentifier
-#define _NPN_IdentifierIsString NPN_IdentifierIsString
-#define _NPN_UTF8FromIdentifier NPN_UTF8FromIdentifier
-#define _NPN_IntFromIdentifier NPN_IntFromIdentifier
-#define _NPN_CreateObject NPN_CreateObject
-#define _NPN_RetainObject NPN_RetainObject
-#define _NPN_ReleaseObject NPN_ReleaseObject
-#define _NPN_DeallocateObject NPN_DeallocateObject
-#define _NPN_Invoke NPN_Invoke
-#define _NPN_InvokeDefault NPN_InvokeDefault
-#define _NPN_Evaluate NPN_Evaluate
-#define _NPN_GetProperty NPN_GetProperty
-#define _NPN_SetProperty NPN_SetProperty
-#define _NPN_RemoveProperty NPN_RemoveProperty
-#define _NPN_HasProperty NPN_HasProperty
-#define _NPN_HasMethod NPN_HasMethod
-#define _NPN_SetException NPN_SetException
-#define _NPN_Enumerate NPN_Enumerate
-#define _NPN_Construct NPN_Construct
-
-#endif
diff --git a/V8Binding/binding/npruntime_internal.h b/V8Binding/binding/npruntime_internal.h
deleted file mode 100644
index 75bf2b0..0000000
--- a/V8Binding/binding/npruntime_internal.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2007 Collabora, Ltd. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- * This is a internal include header for npapi.h
- *
- * Some of the #defines which are in X11 headers conflict with type and enum
- * names in JavaScriptCore and WebCore
- * This header #undefs those defines to fix the conflicts
- * If you need to include npapi.h or npruntime.h when building on X11,
- * include this file instead of the actual npapi.h or npruntime.h
- */
-
-#include "npapi.h"
-#include "npruntime.h"
-#include "npfunctions.h"
-
-#ifdef XP_UNIX
- #include <X11/Xresource.h>
-
- #undef None
- #undef Above
- #undef Below
- #undef Auto
- #undef Complex
- #undef Status
-#endif
diff --git a/V8Binding/binding/npruntime_priv.h b/V8Binding/binding/npruntime_priv.h
deleted file mode 100644
index cbcc668..0000000
--- a/V8Binding/binding/npruntime_priv.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 NP_RUNTIME_PRIV_H_
-#define NP_RUNTIME_PRIV_H_
-
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): look at the diff between the two npruntime.h files
-// and try to consolidate them.
-#include "third_party/npapi/bindings/npruntime.h"
-#else
-#include "bridge/npruntime.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- _NPN_InitializeVariantWithStringCopy() will copy string data. The string data
- will be deallocated by calls to NPReleaseVariantValue().
-*/
-void _NPN_InitializeVariantWithStringCopy(NPVariant*, const NPString*);
-void _NPN_DeallocateObject(NPObject *obj);
-
-// The following routines allow the browser to aggressively cleanup NPObjects
-// on a per plugin basis. All NPObjects used through the NPRuntime API should
-// be "registered" while they are alive. After an object has been
-// deleted, it is possible for Javascript to have a reference to that object
-// which has not yet been garbage collected. Javascript access to NPObjects
-// will reference this registry to determine if the object is accessible or
-// not.
-
-// Windows introduces an additional complication for objects created by the
-// plugin. Plugins load inside of a DLL. Each DLL has it's own heap. If
-// the browser unloads the plugin DLL, all objects created within the DLL's
-// heap instantly become invalid. Normally, when WebKit drops the reference
-// on the top-level plugin object, it tells the plugin manager that the
-// plugin can be destroyed, which can unload the DLL. So, we must eliminate
-// all pointers to any object ever created by the plugin.
-
-// We generally associate NPObjects with an owner. The owner of an NPObject
-// is an NPObject which, when destroyed, also destroys all objects it owns.
-// For example, if an NPAPI plugin creates 10 sub-NPObjects, all 11 objects
-// (the NPAPI plugin + its 10 sub-objects) should become inaccessible
-// simultaneously.
-
-// The ownership hierarchy is flat, and not a tree. Imagine the following
-// object creation:
-// PluginObject
-// |
-// +-- Creates -----> Object1
-// |
-// +-- Creates -----> Object2
-//
-// PluginObject will be the "owner" for both Object1 and Object2.
-
-// Register an NPObject with the runtime. If the owner is NULL, the
-// object is treated as an owning object. If owner is not NULL,
-// this object will be registered as owned by owner's top-level owner.
-void _NPN_RegisterObject(NPObject* obj, NPObject* owner);
-
-// Unregister an NPObject with the runtime. If obj is an owning
-// object, this call will also unregister all of the owned objects.
-void _NPN_UnregisterObject(NPObject* obj);
-
-// Check to see if an object is registered with the runtime.
-// Return true if registered, false otherwise.
-bool _NPN_IsAlive(NPObject* obj);
-
-#ifdef __cplusplus
-} /* end extern "C" */
-#endif
-
-#endif
diff --git a/V8Binding/binding/v8_binding.cpp b/V8Binding/binding/v8_binding.cpp
deleted file mode 100644
index 616d7b2..0000000
--- a/V8Binding/binding/v8_binding.cpp
+++ /dev/null
@@ -1,130 +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.
-
-#include "v8_binding.h"
-
-#include "AtomicString.h"
-#include "CString.h"
-#include "MathExtras.h"
-#include "PlatformString.h"
-#include "StringBuffer.h"
-
-#include <v8.h>
-
-namespace WebCore {
-
-// WebCoreStringResource is a helper class for v8ExternalString. It is used
-// to manage the life-cycle of the underlying buffer of the external string.
-class WebCoreStringResource: public v8::String::ExternalStringResource {
- public:
- explicit WebCoreStringResource(const String& str)
- : impl_(str.impl()) { }
-
- virtual ~WebCoreStringResource() {}
-
- const uint16_t* data() const {
- return reinterpret_cast<const uint16_t*>(impl_.characters());
- }
-
- size_t length() const { return impl_.length(); }
-
- String webcore_string() { return impl_; }
-
- private:
- // A shallow copy of the string.
- // Keeps the string buffer alive until the V8 engine garbage collects it.
- String impl_;
-};
-
-
-String v8StringToWebCoreString(
- v8::Handle<v8::String> v8_str, bool externalize) {
- WebCoreStringResource* str_resource = static_cast<WebCoreStringResource*>(
- v8_str->GetExternalStringResource());
- if (str_resource) {
- return str_resource->webcore_string();
- }
-
- int length = v8_str->Length();
- if (length == 0) {
- // Avoid trying to morph empty strings, as they do not have enough room to
- // contain the external reference.
- return StringImpl::empty();
- }
-
- UChar* buffer;
- String result = String::createUninitialized(length, buffer);
- v8_str->Write(reinterpret_cast<uint16_t*>(buffer), 0, length);
-
- if (externalize) {
- WebCoreStringResource* resource = new WebCoreStringResource(result);
- if (!v8_str->MakeExternal(resource)) {
- // In case of a failure delete the external resource as it was not used.
- delete resource;
- }
- }
- return result;
-}
-
-
-String v8ValueToWebCoreString(v8::Handle<v8::Value> obj) {
- if (obj->IsString()) {
- v8::Handle<v8::String> v8_str = v8::Handle<v8::String>::Cast(obj);
- String webCoreString = v8StringToWebCoreString(v8_str, true);
- return webCoreString;
- } else if (obj->IsInt32()) {
- int value = obj->Int32Value();
- // Most numbers used are <= 100. Even if they aren't used
- // there's very little in using the space.
- const int kLowNumbers = 100;
- static AtomicString lowNumbers[kLowNumbers + 1];
- String webCoreString;
- if (0 <= value && value <= kLowNumbers) {
- webCoreString = lowNumbers[value];
- if (!webCoreString) {
- AtomicString valueString = AtomicString(String::number(value));
- lowNumbers[value] = valueString;
- webCoreString = valueString;
- }
- } else {
- webCoreString = String::number(value);
- }
- return webCoreString;
- } else {
- v8::TryCatch block;
- v8::Handle<v8::String> v8_str = obj->ToString();
- // Check for empty handles to handle the case where an exception
- // is thrown as part of invoking toString on the object.
- if (v8_str.IsEmpty())
- return StringImpl::empty();
- return v8StringToWebCoreString(v8_str, false);
- }
-}
-
-
-AtomicString v8StringToAtomicWebCoreString(v8::Handle<v8::String> v8_str) {
- String str = v8StringToWebCoreString(v8_str, true);
- return AtomicString(str);
-}
-
-
-AtomicString v8ValueToAtomicWebCoreString(v8::Handle<v8::Value> v8_str) {
- String str = v8ValueToWebCoreString(v8_str);
- return AtomicString(str);
-}
-
-
-v8::Handle<v8::String> v8String(const String& str) {
- if (!str.length())
- return v8::String::Empty();
- return v8::String::NewExternal(new WebCoreStringResource(str));
-}
-
-v8::Local<v8::String> v8ExternalString(const String& str) {
- if (!str.length())
- return v8::String::Empty();
- return v8::String::NewExternal(new WebCoreStringResource(str));
-}
-
-} // namespace WebCore
diff --git a/V8Binding/binding/v8_binding.h b/V8Binding/binding/v8_binding.h
deleted file mode 100644
index 2882026..0000000
--- a/V8Binding/binding/v8_binding.h
+++ /dev/null
@@ -1,135 +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_BINDING_H__
-#define V8_BINDING_H__
-
-#include "config.h"
-
-#include "MathExtras.h"
-#include "PlatformString.h"
-
-#include <v8.h>
-
-namespace WebCore {
-
-// The string returned by this function is still owned by the argument
-// and will be deallocated when the argument is deallocated.
-inline const uint16_t* FromWebCoreString(const String& str) {
- return reinterpret_cast<const uint16_t*>(str.characters());
-}
-
-// Convert v8 types to a WebCore::String. If the V8 string is not already
-// an external string then it is transformed into an external string at this
-// point to avoid repeated conversions.
-String v8StringToWebCoreString(
- v8::Handle<v8::String> obj, bool externalize);
-String v8ValueToWebCoreString(v8::Handle<v8::Value> obj);
-
-// TODO(mbelshe): drop this in favor of the type specific
-// v8ValueToWebCoreString when we rework the code generation.
-inline String ToWebCoreString(v8::Handle<v8::Value> obj) {
- return v8ValueToWebCoreString(obj);
-}
-
-inline String ToWebCoreString(v8::Handle<v8::String> string) {
- return v8StringToWebCoreString(string, true);
-}
-
-// Convert v8 types to a WebCore::AtomicString.
-AtomicString v8StringToAtomicWebCoreString(v8::Handle<v8::String> obj);
-AtomicString v8ValueToAtomicWebCoreString(v8::Handle<v8::Value> obj);
-
-inline String valueToStringWithNullCheck(v8::Handle<v8::Value> value) {
- if (value->IsNull()) return String();
- return ToWebCoreString(value);
-}
-
-inline String valueToStringWithNullOrUndefinedCheck(
- v8::Handle<v8::Value> value) {
- if (value->IsNull() || value->IsUndefined()) return String();
- return ToWebCoreString(value);
-}
-
-// Convert a value to a 32-bit integer. The conversion fails if the
-// value cannot be converted to an integer or converts to nan or to an
-// infinity.
-// FIXME: Rename to toInt32() once V8 bindings migration is complete.
-inline int ToInt32(v8::Handle<v8::Value> value, bool& ok) {
- ok = true;
-
- // Fast case. The value is already a 32-bit integer.
- if (value->IsInt32()) {
- return value->Int32Value();
- }
-
- // Can the value be converted to a number?
- v8::Local<v8::Number> number_object = value->ToNumber();
- if (number_object.IsEmpty()) {
- ok = false;
- return 0;
- }
-
- // Does the value convert to nan or to an infinity?
- double number_value = number_object->Value();
- if (isnan(number_value) || isinf(number_value)) {
- ok = false;
- return 0;
- }
-
- // Can the value be converted to a 32-bit integer?
- v8::Local<v8::Int32> int_value = value->ToInt32();
- if (int_value.IsEmpty()) {
- ok = false;
- return 0;
- }
-
- // Return the result of the int32 conversion.
- return int_value->Value();
-}
-
-// Convert a value to a 32-bit integer assuming the conversion cannot fail.
-// FIXME: Rename to toInt32() once V8 bindings migration is complete.
-inline int ToInt32(v8::Handle<v8::Value> value) {
- bool ok;
- return ToInt32(value, ok);
-}
-
-inline String ToString(const String& string) {
- return string;
-}
-
-// Convert a string to a V8 string.
-v8::Handle<v8::String> v8String(const String& str);
-
-inline v8::Handle<v8::String> v8UndetectableString(const String& str) {
- return v8::String::NewUndetectable(FromWebCoreString(str), str.length());
-}
-
-// Return a V8 external string that shares the underlying buffer with the given
-// WebCore string. The reference counting mechanism is used to keep the
-// underlying buffer alive while the string is still live in the V8 engine.
-v8::Local<v8::String> v8ExternalString(const String& str);
-
-inline v8::Handle<v8::Value> v8StringOrNull(const String& str) {
- return str.isNull()
- ? v8::Handle<v8::Value>(v8::Null())
- : v8::Handle<v8::Value>(v8String(str));
-}
-
-inline v8::Handle<v8::Value> v8StringOrUndefined(const String& str) {
- return str.isNull()
- ? v8::Handle<v8::Value>(v8::Undefined())
- : v8::Handle<v8::Value>(v8String(str));
-}
-
-inline v8::Handle<v8::Value> v8StringOrFalse(const String& str) {
- return str.isNull()
- ? v8::Handle<v8::Value>(v8::False())
- : v8::Handle<v8::Value>(v8String(str));
-}
-
-} // namespace WebCore
-
-#endif // V8_BINDING_H__
diff --git a/V8Binding/binding/v8_helpers.cpp b/V8Binding/binding/v8_helpers.cpp
deleted file mode 100644
index 7a72ab5..0000000
--- a/V8Binding/binding/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/V8Binding/binding/v8_helpers.h b/V8Binding/binding/v8_helpers.h
deleted file mode 100644
index e741e82..0000000
--- a/V8Binding/binding/v8_helpers.h
+++ /dev/null
@@ -1,30 +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__
-
-#if PLATFORM(CHROMIUM)
-// TODO(andreip): diff and consolidate
-#include "third_party/npapi/bindings/npruntime.h"
-#else
-#include "bridge/npruntime.h" // use WebCore version
-#endif
-
-#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/V8Binding/binding/v8_npobject.h b/V8Binding/binding/v8_npobject.h
deleted file mode 100644
index c2d8550..0000000
--- a/V8Binding/binding/v8_npobject.h
+++ /dev/null
@@ -1,7 +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.
-
-// This is a temporary file until V8HTMLPlugInElementCustom.cpp in WebKit
-// includes the new name of this file.
-#include "V8NPObject.h"
diff --git a/V8Binding/binding/v8_utility.h b/V8Binding/binding/v8_utility.h
deleted file mode 100644
index a7c3325..0000000
--- a/V8Binding/binding/v8_utility.h
+++ /dev/null
@@ -1,68 +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_UTILITY_H__
-#define V8_UTILITY_H__
-
-#include "V8Utilities.h"
-
-// To break a cycle dependency during upstreaming this block of code,
-// ifdefing it out based on this #define.
-//
-// TODO(ajwong): After https://bugs.webkit.org/show_bug.cgi?id=25595
-// lands and is rolled down into chromium, migrate all headaers to use
-// the code in V8Utilities.h directly, and then, remove this code.
-#ifndef V8UTILITIES_DEFINED
-namespace WebCore {
-
-class AllowAllocation {
- public:
- inline AllowAllocation() {
- m_prev = m_current;
- m_current = true;
- }
- inline ~AllowAllocation() {
- m_current = m_prev;
- }
- static bool m_current;
- private:
- bool m_prev;
-};
-
-class SafeAllocation {
- public:
- static inline v8::Local<v8::Object> NewInstance(
- v8::Handle<v8::Function> fun);
- static inline v8::Local<v8::Object> NewInstance(
- v8::Handle<v8::ObjectTemplate> templ);
- static inline v8::Local<v8::Object> NewInstance(
- v8::Handle<v8::Function> fun, int argc, v8::Handle<v8::Value> argv[]);
-};
-
-v8::Local<v8::Object> SafeAllocation::NewInstance(
- v8::Handle<v8::Function> fun) {
- if (fun.IsEmpty())
- return v8::Local<v8::Object>();
- AllowAllocation allow;
- return fun->NewInstance();
-}
-
-v8::Local<v8::Object> SafeAllocation::NewInstance(
- v8::Handle<v8::ObjectTemplate> templ) {
- if (templ.IsEmpty()) return v8::Local<v8::Object>();
- AllowAllocation allow;
- return templ->NewInstance();
-}
-
-v8::Local<v8::Object> SafeAllocation::NewInstance(
- v8::Handle<v8::Function> fun, int argc, v8::Handle<v8::Value> argv[]) {
- if (fun.IsEmpty()) return v8::Local<v8::Object>();
- AllowAllocation allow;
- return fun->NewInstance(argc, argv);
-}
-
-} // namespace WebCore
-#endif // V8UTILITIES_DEFINED
-
-#endif // V8_UTILITY_H__