summaryrefslogtreecommitdiffstats
path: root/V8Binding/v8
diff options
context:
space:
mode:
authorFeng Qian <fqian@google.com>2009-04-24 16:01:03 -0700
committerFeng Qian <fqian@google.com>2009-04-24 16:01:03 -0700
commit109a58c31072b14f5b2c0493ed6c5a1855f82fd7 (patch)
tree134f7efdba4ea4d9b6dfb660bbcb47b4d54f9ad7 /V8Binding/v8
parentac888b0a574d343996d06d2b084eaebab7846d81 (diff)
downloadexternal_webkit-109a58c31072b14f5b2c0493ed6c5a1855f82fd7.zip
external_webkit-109a58c31072b14f5b2c0493ed6c5a1855f82fd7.tar.gz
external_webkit-109a58c31072b14f5b2c0493ed6c5a1855f82fd7.tar.bz2
Make WebCore built with V8.
Picked up several new files from Chrome port.
Diffstat (limited to 'V8Binding/v8')
-rw-r--r--V8Binding/v8/DOMObjectsInclude.h19
-rw-r--r--V8Binding/v8/NPV8Object.cpp25
-rw-r--r--V8Binding/v8/NPV8Object.h5
-rw-r--r--V8Binding/v8/ScriptController.cpp8
-rw-r--r--V8Binding/v8/ScriptController.h4
-rw-r--r--V8Binding/v8/V8NPObject.h4
-rw-r--r--V8Binding/v8/V8NPUtils.h4
-rw-r--r--V8Binding/v8/npruntime.cpp108
-rw-r--r--V8Binding/v8/npruntime_impl.h26
-rw-r--r--V8Binding/v8/npruntime_priv.h5
-rw-r--r--V8Binding/v8/v8_custom.cpp186
-rw-r--r--V8Binding/v8/v8_helpers.h5
-rw-r--r--V8Binding/v8/v8_index.cpp37
-rw-r--r--V8Binding/v8/v8_index.h36
-rw-r--r--V8Binding/v8/v8_proxy.cpp58
-rw-r--r--V8Binding/v8/v8_proxy.h9
16 files changed, 284 insertions, 255 deletions
diff --git a/V8Binding/v8/DOMObjectsInclude.h b/V8Binding/v8/DOMObjectsInclude.h
index 5e067b4..b7b941e 100644
--- a/V8Binding/v8/DOMObjectsInclude.h
+++ b/V8Binding/v8/DOMObjectsInclude.h
@@ -94,8 +94,6 @@
#include "SQLResultSetRowList.h"
#include "StyleSheet.h"
#include "StyleSheetList.h"
-#include "SVGColor.h"
-#include "SVGPaint.h"
#include "TextEvent.h"
#include "TextMetrics.h"
#include "TimeRanges.h"
@@ -121,6 +119,7 @@
#include "XMLHttpRequestProgressEvent.h"
#include "XMLHttpRequestUpload.h"
#include "XMLSerializer.h"
+#include "XPathEvaluator.h"
#include "XPathException.h"
#include "XPathExpression.h"
#include "XPathNSResolver.h"
@@ -129,6 +128,7 @@
#if ENABLE(SVG)
#include "SVGAngle.h"
#include "SVGAnimatedPoints.h"
+#include "SVGColor.h"
#include "SVGElement.h"
#include "SVGElementInstance.h"
#include "SVGElementInstanceList.h"
@@ -136,6 +136,7 @@
#include "SVGLength.h"
#include "SVGLengthList.h"
#include "SVGNumberList.h"
+#include "SVGPaint.h"
#include "SVGPathSeg.h"
#include "SVGPathSegArc.h"
#include "SVGPathSegClosePath.h"
@@ -167,9 +168,17 @@
#include "WorkerNavigator.h"
#endif // WORKERS
-#if ENABLE(XPATH)
-#include "XPathEvaluator.h"
-#endif // XPATH
+#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 {
diff --git a/V8Binding/v8/NPV8Object.cpp b/V8Binding/v8/NPV8Object.cpp
index 411439f..defe6bf 100644
--- a/V8Binding/v8/NPV8Object.cpp
+++ b/V8Binding/v8/NPV8Object.cpp
@@ -32,9 +32,10 @@
#define min min
#include <v8.h>
#include "NPV8Object.h"
+#if PLATFORM(CHROMIUM)
#include "ChromiumBridge.h"
+#endif
#include "Frame.h"
-#include "bindings/npruntime.h"
#include "npruntime_priv.h"
#include "PlatformString.h"
#include "ScriptController.h"
@@ -241,12 +242,9 @@ bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args,
return true;
}
-bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *npscript, NPVariant *result)
-{
- bool popupsAllowed = WebCore::ChromiumBridge::popupsAllowed(npp);
- return NPN_EvaluateHelper(npp, popupsAllowed, npobj, npscript, result);
-}
-
+#if PLATFORM(ANDROID)
+static
+#endif
bool NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npobj, NPString* npscript, NPVariant *result)
{
VOID_TO_NPVARIANT(*result);
@@ -282,6 +280,17 @@ bool NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npobj, NPString*
return true;
}
+bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *npscript, NPVariant *result)
+{
+#if PLATFORM(CHROMIUM)
+ bool popupsAllowed = WebCore::ChromiumBridge::popupsAllowed(npp);
+#else
+ // TODO(fqian): create an Android bridge
+ 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)
@@ -456,7 +465,7 @@ bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t
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), ARRAYSIZE_UNSAFE(argv), argv);
+ v8::Local<v8::Value> propsObj = enumerator->Call(v8::Handle<v8::Object>::Cast(enumeratorObj), 1, argv);
if (propsObj.IsEmpty())
return false;
diff --git a/V8Binding/v8/NPV8Object.h b/V8Binding/v8/NPV8Object.h
index bfe7bb7..1b9713e 100644
--- a/V8Binding/v8/NPV8Object.h
+++ b/V8Binding/v8/NPV8Object.h
@@ -5,7 +5,12 @@
#ifndef np_v8object_h
#define np_v8object_h
+#if PLATFORM(CHROMIUM)
#include "bindings/npruntime.h"
+#else
+#include "bridge/npruntime.h" // use WebCore version
+#endif
+
#include <v8.h>
namespace WebCore {
diff --git a/V8Binding/v8/ScriptController.cpp b/V8Binding/v8/ScriptController.cpp
index 84ad8b4..83dc52c 100644
--- a/V8Binding/v8/ScriptController.cpp
+++ b/V8Binding/v8/ScriptController.cpp
@@ -30,7 +30,10 @@
#include "config.h"
#include "ScriptController.h"
+#if PLATFORM(CHROMIUM)
#include "ChromiumBridge.h"
+#endif
+
#include "CString.h"
#include "Document.h"
#include "DOMWindow.h"
@@ -312,10 +315,13 @@ PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widge
if (widget->isFrameView())
return 0;
+#if PLATFORM(CHROMIUM)
NPObject* npObject = ChromiumBridge::pluginScriptableObject(widget);
+#else
+ NPObject* npObject = 0; // TODO(fqian): fix this
+#endif
if (!npObject)
return 0;
-
// Frame Memory Management for NPObjects
// -------------------------------------
// NPObjects are treated differently than other objects wrapped by JS.
diff --git a/V8Binding/v8/ScriptController.h b/V8Binding/v8/ScriptController.h
index e1e9e25..d26dbcc 100644
--- a/V8Binding/v8/ScriptController.h
+++ b/V8Binding/v8/ScriptController.h
@@ -39,7 +39,11 @@
#include "ScriptValue.h"
#include "SecurityOrigin.h"
+#if PLATFORM(CHROMIUM)
#include "bindings/npruntime.h"
+#else
+#include "bridge/npruntime.h" // use WebCore version
+#endif
#include <wtf/HashMap.h>
#include <wtf/Vector.h>
diff --git a/V8Binding/v8/V8NPObject.h b/V8Binding/v8/V8NPObject.h
index c236c60..04cbff1 100644
--- a/V8Binding/v8/V8NPObject.h
+++ b/V8Binding/v8/V8NPObject.h
@@ -6,7 +6,11 @@
#define v8_npobject_h
#include <v8.h>
+#if PLATFORM(CHROMIUM)
#include "third_party/npapi/bindings/npruntime.h"
+#else
+#include "bridge/npruntime.h" // use WebCore version
+#endif
// These functions can be replaced by normal JS operation.
// Getters
diff --git a/V8Binding/v8/V8NPUtils.h b/V8Binding/v8/V8NPUtils.h
index 08409f2..2e07e66 100644
--- a/V8Binding/v8/V8NPUtils.h
+++ b/V8Binding/v8/V8NPUtils.h
@@ -6,7 +6,11 @@
#define v8_np_utils_h
#include <v8.h>
+#if PLATFORM(CHROMIUM)
#include "third_party/npapi/bindings/npruntime.h"
+#else
+#include "bridge/npruntime.h" // use WebCore version
+#endif
namespace WebCore {
class Frame;
diff --git a/V8Binding/v8/npruntime.cpp b/V8Binding/v8/npruntime.cpp
index 1ecb68c..d1138ab 100644
--- a/V8Binding/v8/npruntime.cpp
+++ b/V8Binding/v8/npruntime.cpp
@@ -26,17 +26,17 @@
#include "config.h"
-#include <map>
-#include <set>
-#include <string>
#include <v8.h>
-#include "bindings/npruntime.h"
#include "NPV8Object.h"
#include "npruntime_priv.h"
#include "V8NPObject.h"
#include <wtf/Assertions.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+
+#include <utility>
using namespace v8;
@@ -49,29 +49,78 @@ using namespace v8;
// 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.
struct StringKey {
+ StringKey() : string(NULL), length(0) {}
StringKey(const char* str) : string(str), length(strlen(str)) {}
const char* string;
- const size_t length;
+ size_t length;
+
+ StringKey& operator=(const StringKey& other) {
+ this->string = other.string;
+ this->length = other.length;
+ return *this;
+ }
+
};
-inline bool operator<(const StringKey& x, const StringKey& y) {
+inline bool operator==(const StringKey& x, const StringKey& y) {
// Shorter strings are less than longer strings, memcmp breaks ties.
- if (x.length < y.length)
- return true;
- else if (x.length > y.length)
+ if (x.length != y.length) {
return false;
- else
- return memcmp(x.string, y.string, y.length) < 0;
+ } else {
+ ASSERT(x.string != NULL && y.string != NULL);
+ return memcmp(x.string, y.string, y.length) == 0;
+ }
}
-} // namespace
+struct StringKeyHash {
+ static unsigned hash(StringKey key) {
+ // sdbm hash function
+ unsigned hash = 0;
+ for (size_t i = 0; i < key.length; i++) {
+ char c = key.string[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(StringKey x, StringKey y) {
+ return x == y;
+ }
+
+ static const bool safeToCompareToEmptyOrDeleted = false;
+};
+
+namespace WTF {
+ template<> struct HashTraits<StringKey> : GenericHashTraits<StringKey> {
+ static const bool emptyValueIsZero = true;
+ static const bool needsDestruction = false;
+ static void constructDeletedValue(StringKey& slot) {
+ slot.string = NULL;
+ slot.length = 0;
+ }
-typedef std::map<const StringKey, PrivateIdentifier*> StringIdentifierMap;
+ static bool isDeletedValue(const StringKey& slot) {
+ return slot.string == NULL;
+ }
+ };
+}
+
+typedef WTF::HashMap<StringKey, PrivateIdentifier*, StringKeyHash> StringIdentifierMap;
static StringIdentifierMap* getStringIdentifierMap() {
static StringIdentifierMap* stringIdentifierMap = 0;
@@ -83,7 +132,7 @@ static StringIdentifierMap* getStringIdentifierMap() {
// FIXME: Consider removing locks if we're singlethreaded already.
// static Lock IntIdentifierMapLock;
-typedef std::map<int, PrivateIdentifier*> IntIdentifierMap;
+typedef WTF::HashMap<int, PrivateIdentifier*> IntIdentifierMap;
static IntIdentifierMap* getIntIdentifierMap() {
static IntIdentifierMap* intIdentifierMap = 0;
@@ -99,7 +148,6 @@ NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name) {
if (name) {
// AutoLock safeLock(StringIdentifierMapLock);
-
StringKey key(name);
StringIdentifierMap* identMap = getStringIdentifierMap();
StringIdentifierMap::iterator iter = identMap->find(key);
@@ -116,7 +164,7 @@ NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name) {
identifier->isString = true;
identifier->value.string = reinterpret_cast<NPUTF8*>(nameStorage);
key.string = nameStorage;
- (*identMap)[key] = identifier;
+ identMap->set(key, identifier);
return (NPIdentifier)identifier;
}
@@ -146,7 +194,7 @@ NPIdentifier NPN_GetIntIdentifier(int32_t intid) {
malloc(sizeof(PrivateIdentifier)));
identifier->isString = false;
identifier->value.number = intid;
- (*identMap)[intid] = identifier;
+ identMap->set(intid, identifier);
return (NPIdentifier)identifier;
}
@@ -276,9 +324,9 @@ void _NPN_InitializeVariantWithStringCopy(NPVariant* variant,
// Frame teardown to deactivate all objects associated
// with a particular plugin.
-typedef std::set<NPObject*> NPObjectSet;
-typedef std::map<NPObject*, NPObject*> NPObjectMap;
-typedef std::map<NPObject*, NPObjectSet*> NPRootObjectMap;
+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;
@@ -298,7 +346,7 @@ void _NPN_RegisterObject(NPObject* obj, NPObject* owner) {
if (!owner) {
// Registering a new owner object.
ASSERT(g_root_objects.find(obj) == g_root_objects.end());
- g_root_objects[obj] = new NPObjectSet();
+ 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.
@@ -312,11 +360,11 @@ void _NPN_RegisterObject(NPObject* obj, NPObject* owner) {
}
ASSERT(g_root_objects.find(obj) == g_root_objects.end());
if (g_root_objects.find(owner) != g_root_objects.end())
- (g_root_objects[owner])->insert(obj);
+ g_root_objects.get(owner)->add(obj);
}
ASSERT(g_live_objects.find(obj) == g_live_objects.end());
- g_live_objects[obj] = owner;
+ g_live_objects.set(obj, owner);
}
void _NPN_UnregisterObject(NPObject* obj) {
@@ -330,7 +378,7 @@ void _NPN_UnregisterObject(NPObject* obj) {
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[obj];
+ NPObjectSet* set = g_root_objects.get(obj);
while (set->size() > 0) {
#ifndef NDEBUG
size_t size = set->size();
@@ -340,8 +388,8 @@ void _NPN_UnregisterObject(NPObject* obj) {
ASSERT(g_root_objects.find(sub_object) == g_root_objects.end());
// First, unregister the object.
- set->erase(sub_object);
- g_live_objects.erase(sub_object);
+ set->remove(sub_object);
+ g_live_objects.remove(sub_object);
// Remove the JS references to the object.
ForgetV8ObjectForNPObject(sub_object);
@@ -349,18 +397,18 @@ void _NPN_UnregisterObject(NPObject* obj) {
ASSERT(set->size() < size);
}
delete set;
- g_root_objects.erase(obj);
+ 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->erase(obj);
+ list->remove(obj);
}
}
ForgetV8ObjectForNPObject(obj);
- g_live_objects.erase(obj);
+ g_live_objects.remove(obj);
}
bool _NPN_IsAlive(NPObject* obj) {
diff --git a/V8Binding/v8/npruntime_impl.h b/V8Binding/v8/npruntime_impl.h
index 9a9b612..31db922 100644
--- a/V8Binding/v8/npruntime_impl.h
+++ b/V8Binding/v8/npruntime_impl.h
@@ -31,13 +31,39 @@
#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/v8/npruntime_priv.h b/V8Binding/v8/npruntime_priv.h
index 0aa952c..8b1ddec 100644
--- a/V8Binding/v8/npruntime_priv.h
+++ b/V8Binding/v8/npruntime_priv.h
@@ -26,8 +26,11 @@
#ifndef NP_RUNTIME_PRIV_H_
#define NP_RUNTIME_PRIV_H_
-
+#if PLATFORM(CHROMIUM)
#include "third_party/npapi/bindings/npruntime.h"
+#else
+#include "bridge/npruntime.h"
+#endif
#ifdef __cplusplus
extern "C" {
diff --git a/V8Binding/v8/v8_custom.cpp b/V8Binding/v8/v8_custom.cpp
index 4b2e545..855e192 100644
--- a/V8Binding/v8/v8_custom.cpp
+++ b/V8Binding/v8/v8_custom.cpp
@@ -42,8 +42,11 @@
#include "V8HTMLImageElement.h"
#include "V8HTMLOptionElement.h"
#include "V8Node.h"
+
+#if ENABLE(XPATH)
#include "V8XPathNSResolver.h"
#include "V8XPathResult.h"
+#endif
#include "Base64.h"
#include "CanvasGradient.h"
@@ -692,149 +695,8 @@ static bool AllowSettingFrameSrcToJavascriptUrl(HTMLFrameElementBase* frame,
}
-// Element ---------------------------------------------------------------------
-
-CALLBACK_FUNC_DECL(ElementSetAttribute) {
- INC_STATS("DOM.Element.setAttribute()");
- Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
- ExceptionCode ec = 0;
- String name = ToWebCoreString(args[0]);
- String value = ToWebCoreString(args[1]);
-
- if (!AllowSettingSrcToJavascriptURL(imp, name, value)) {
- return v8::Undefined();
- }
-
- imp->setAttribute(name, value, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- return v8::Undefined();
-}
-
-CALLBACK_FUNC_DECL(ElementSetAttributeNode) {
- INC_STATS("DOM.Element.setAttributeNode()");
- if (!V8Attr::HasInstance(args[0])) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
-
- Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]);
- Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
- ExceptionCode ec = 0;
-
- if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) {
- return v8::Undefined();
- }
-
- RefPtr<Attr> result = imp->setAttributeNode(newAttr, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- return V8Proxy::NodeToV8Object(result.get());
-}
-
-CALLBACK_FUNC_DECL(ElementSetAttributeNS) {
- INC_STATS("DOM.Element.setAttributeNS()");
- Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
- ExceptionCode ec = 0;
- String namespaceURI = valueToStringWithNullCheck(args[0]);
- String qualifiedName = ToWebCoreString(args[1]);
- String value = ToWebCoreString(args[2]);
-
- if (!AllowSettingSrcToJavascriptURL(imp, qualifiedName, value)) {
- return v8::Undefined();
- }
-
- imp->setAttributeNS(namespaceURI, qualifiedName, value, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- return v8::Undefined();
-}
-
-CALLBACK_FUNC_DECL(ElementSetAttributeNodeNS) {
- INC_STATS("DOM.Element.setAttributeNodeNS()");
- if (!V8Attr::HasInstance(args[0])) {
- V8Proxy::SetDOMException(TYPE_MISMATCH_ERR);
- return v8::Handle<v8::Value>();
- }
-
- Attr* newAttr = V8Proxy::DOMWrapperToNode<Attr>(args[0]);
- Element* imp = V8Proxy::DOMWrapperToNode<Element>(args.Holder());
- ExceptionCode ec = 0;
-
- if (!AllowSettingSrcToJavascriptURL(imp, newAttr->name(), newAttr->value())) {
- return v8::Undefined();
- }
-
- RefPtr<Attr> result = imp->setAttributeNodeNS(newAttr, ec);
- if (ec != 0) {
- V8Proxy::SetDOMException(ec);
- return v8::Handle<v8::Value>();
- }
- return V8Proxy::NodeToV8Object(result.get());
-}
-
-
-
-// Attr ------------------------------------------------------------------------
-
-ACCESSOR_SETTER(AttrValue) {
- Attr* imp =
- V8Proxy::DOMWrapperToNode<Attr>(info.Holder());
- String v = valueToStringWithNullCheck(value);
- Element* ownerElement = imp->ownerElement();
-
- if (ownerElement &&
- !AllowSettingSrcToJavascriptURL(ownerElement, imp->name(), v))
- return;
-
- ExceptionCode ec = 0;
- imp->setValue(v, ec);
- V8Proxy::SetDOMException(ec);
-}
-
-
-// HTMLFrameElement ------------------------------------------------------------
-
-ACCESSOR_SETTER(HTMLFrameElementSrc) {
- HTMLFrameElement* imp =
- V8Proxy::DOMWrapperToNode<HTMLFrameElement>(info.Holder());
- String v = valueToStringWithNullCheck(value);
-
- if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return;
-
- imp->setSrc(v);
-}
-
-ACCESSOR_SETTER(HTMLFrameElementLocation) {
- HTMLFrameElement* imp =
- V8Proxy::DOMWrapperToNode<HTMLFrameElement>(info.Holder());
- String v = valueToStringWithNullCheck(value);
-
- if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return;
-
- imp->setLocation(v);
-}
-
-
// HTMLIFrameElement -----------------------------------------------------------
-ACCESSOR_SETTER(HTMLIFrameElementSrc) {
- HTMLIFrameElement* imp =
- V8Proxy::DOMWrapperToNode<HTMLIFrameElement>(info.Holder());
- String v = valueToStringWithNullCheck(value);
-
- if (!AllowSettingFrameSrcToJavascriptUrl(imp, v)) return;
-
- imp->setSrc(v);
-}
-
-
// TODO(mbelshe): This should move into V8DOMWindowCustom.cpp
// Can't move it right now because it depends on V8ScheduledAction,
// which is private to this file (v8_custom.cpp).
@@ -1080,48 +942,6 @@ ACCESSOR_GETTER(DOMWindowEventHandler) {
}
-ACCESSOR_SETTER(ElementEventHandler) {
- Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder());
-
- // Name starts with 'on', remove them.
- String key = ToWebCoreString(name);
- ASSERT(key.startsWith("on"));
- String event_type = key.substring(2);
-
- // Set handler if the value is a function. Otherwise, clear the
- // event handler.
- if (value->IsFunction()) {
- V8Proxy* proxy = V8Proxy::retrieve(node->document()->frame());
- // the document might be created using createDocument,
- // which does not have a frame, use the active frame
- if (!proxy)
- proxy = V8Proxy::retrieve(V8Proxy::retrieveActiveFrame());
- if (!proxy)
- return;
-
- RefPtr<EventListener> listener =
- proxy->FindOrCreateV8EventListener(value, true);
- if (listener) {
- node->setInlineEventListenerForType(event_type, listener);
- }
- } else {
- node->removeInlineEventListenerForType(event_type);
- }
-}
-
-
-ACCESSOR_GETTER(ElementEventHandler) {
- Node* node = V8Proxy::DOMWrapperToNode<Node>(info.Holder());
-
- // Name starts with 'on', remove them.
- String key = ToWebCoreString(name);
- ASSERT(key.startsWith("on"));
- String event_type = key.substring(2);
-
- EventListener* listener = node->inlineEventListenerForType(event_type);
- return V8Proxy::EventListenerToV8Object(listener);
-}
-
// --------------- Security Checks -------------------------
NAMED_ACCESS_CHECK(DOMWindow) {
ASSERT(V8ClassIndex::FromInt(data->Int32Value()) == V8ClassIndex::DOMWINDOW);
diff --git a/V8Binding/v8/v8_helpers.h b/V8Binding/v8/v8_helpers.h
index eebdd1e..b7f15aa 100644
--- a/V8Binding/v8/v8_helpers.h
+++ b/V8Binding/v8/v8_helpers.h
@@ -5,7 +5,12 @@
#ifndef V8_HELPERS_H__
#define V8_HELPERS_H__
+#if PLATFORM(CHROMIUM)
#include "third_party/npapi/bindings/npruntime.h"
+#else
+#include "bridge/npruntime.h" // use WebCore version
+#endif
+
#include <v8.h>
namespace WebCore {
diff --git a/V8Binding/v8/v8_index.cpp b/V8Binding/v8/v8_index.cpp
index 60757b6..1078847 100644
--- a/V8Binding/v8/v8_index.cpp
+++ b/V8Binding/v8/v8_index.cpp
@@ -62,7 +62,6 @@
#include "V8CSSStyleSheet.h"
#include "V8CSSVariablesDeclaration.h"
#include "V8CSSVariablesRule.h"
-#include "V8Database.h"
#include "V8Document.h"
#include "V8DocumentFragment.h"
#include "V8DocumentType.h"
@@ -135,7 +134,6 @@
#include "V8HTMLTitleElement.h"
#include "V8HTMLUListElement.h"
#include "V8ImageData.h"
-#include "V8InspectorController.h"
#include "V8MediaList.h"
#include "V8MessageChannel.h"
#include "V8MessageEvent.h"
@@ -180,28 +178,39 @@
#include "V8Range.h"
#include "V8RangeException.h"
#include "V8Rect.h"
-#include "V8SQLError.h"
-#include "V8SQLResultSet.h"
-#include "V8SQLResultSetRowList.h"
-#include "V8SQLTransaction.h"
#include "V8NodeIterator.h"
#include "V8TextMetrics.h"
#include "V8TreeWalker.h"
#include "V8StyleSheetList.h"
#include "V8DOMImplementation.h"
+
+#if ENABLE(XPATH)
#include "V8XPathResult.h"
#include "V8XPathException.h"
#include "V8XPathExpression.h"
#include "V8XPathNSResolver.h"
+#include "V8XPathEvaluator.h"
+#endif
+#if ENABLE(XSLT)
+#include "V8XSLTProcessor.h"
+#endif
+
#include "V8XMLHttpRequest.h"
#include "V8XMLHttpRequestException.h"
#include "V8XMLHttpRequestProgressEvent.h"
#include "V8XMLHttpRequestUpload.h"
#include "V8XMLSerializer.h"
-#include "V8XPathEvaluator.h"
-#include "V8XSLTProcessor.h"
#include "V8RGBColor.h"
+#if PLATFORM(CHROMIUM)
+#include "V8InspectorController.h"
+#include "V8Database.h"
+#include "V8SQLError.h"
+#include "V8SQLResultSet.h"
+#include "V8SQLResultSetRowList.h"
+#include "V8SQLTransaction.h"
+#endif
+
#if ENABLE(SVG_ANIMATION)
#include "V8SVGAnimateColorElement.h"
#include "V8SVGAnimateElement.h"
@@ -368,6 +377,18 @@
#include "V8WorkerNavigator.h"
#endif
+#if PLATFORM(ANDROID)
+#include "V8Coordinates.h"
+#include "V8Geolocation.h"
+#include "V8Geoposition.h"
+#include "V8PositionError.h"
+#include "V8PositionErrorCallback.h"
+#include "V8Touch.h"
+#include "V8TouchList.h"
+#include "V8TouchEvent.h"
+#include "V8VoidCallback.h"
+#endif
+
namespace WebCore {
FunctionTemplateFactory V8ClassIndex::GetFactory(V8WrapperType type) {
diff --git a/V8Binding/v8/v8_index.h b/V8Binding/v8/v8_index.h
index f567e5d..ae32ba2 100644
--- a/V8Binding/v8/v8_index.h
+++ b/V8Binding/v8/v8_index.h
@@ -284,7 +284,6 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(HTMLOPTIONSCOLLECTION, HTMLOptionsCollection) \
V(IMAGEDATA, ImageData) \
V(CANVASPIXELARRAY, CanvasPixelArray) \
- V(INSPECTORCONTROLLER, InspectorController) \
V(KEYBOARDEVENT, KeyboardEvent) \
V(LOCATION, Location) \
V(MEDIALIST, MediaList)
@@ -328,15 +327,16 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(XMLHTTPREQUESTEXCEPTION, XMLHttpRequestException) \
V(XMLHTTPREQUESTPROGRESSEVENT, XMLHttpRequestProgressEvent) \
V(XMLSERIALIZER, XMLSerializer) \
+ ACTIVE_DOM_OBJECT_TYPES(V) \
+ VIDEO_NONNODE_TYPES(V) \
+ WORKER_NONNODE_WRAPPER_TYPES(V)
+
+#define DOM_OBJECT_XPATH_TYPES(V) \
V(XPATHEVALUATOR, XPathEvaluator) \
V(XPATHEXCEPTION, XPathException) \
V(XPATHEXPRESSION, XPathExpression) \
V(XPATHNSRESOLVER, XPathNSResolver) \
- V(XPATHRESULT, XPathResult) \
- V(XSLTPROCESSOR, XSLTProcessor) \
- ACTIVE_DOM_OBJECT_TYPES(V) \
- VIDEO_NONNODE_TYPES(V) \
- WORKER_NONNODE_WRAPPER_TYPES(V)
+ V(XPATHRESULT, XPathResult)
#define DOM_OBJECT_DATABASE_TYPES(V) \
V(DATABASE, Database) \
@@ -345,10 +345,32 @@ typedef v8::Persistent<v8::FunctionTemplate> (*FunctionTemplateFactory)();
V(SQLRESULTSETROWLIST, SQLResultSetRowList) \
V(SQLTRANSACTION, SQLTransaction)
+#if PLATFORM(CHROMIUM)
#define DOM_OBJECT_TYPES(V) \
DOM_OBJECT_TYPES_1(V) \
DOM_OBJECT_TYPES_2(V) \
- DOM_OBJECT_DATABASE_TYPES(V)
+ DOM_OBJECT_DATABASE_TYPES(V) \
+ DOM_OBJECT_XPATH_TYPES(V) \
+ V(XSLTPROCESSOR, XSLTProcessor) \
+ V(INSPECTORCONTROLLER, InspectorController)
+#endif
+
+#if PLATFORM(ANDROID)
+#define DOM_OBJECT_TYPES(V) \
+ DOM_OBJECT_TYPES_1(V) \
+ DOM_OBJECT_TYPES_2(V) \
+ V(COORDINATES, Coordinates) \
+ V(GEOLOCATION, Geolocation) \
+ V(GEOPOSITION, Geoposition) \
+ V(POSITIONERROR, PositionError) \
+ V(POSITIONERRORCALLBACK, PositionErrorCallback) \
+ V(TOUCHLIST, TouchList) \
+ V(TOUCHEVENT, TouchEvent) \
+ V(TOUCH, Touch) \
+ V(VOIDCALLBACK, VoidCallback)
+#endif
+
+// Other platform must define DOM_OBJECT_TYPES
#if ENABLE(SVG)
// SVG_OBJECT_TYPES are svg non-node, non-pod types.
diff --git a/V8Binding/v8/v8_proxy.cpp b/V8Binding/v8/v8_proxy.cpp
index deb47fd..204b2bc 100644
--- a/V8Binding/v8/v8_proxy.cpp
+++ b/V8Binding/v8/v8_proxy.cpp
@@ -33,7 +33,10 @@
#include <utility>
#include <v8.h>
+
+#ifdef ENABLE_DEBUGGER_SUPPORT
#include <v8-debug.h>
+#endif
#include "v8_proxy.h"
#include "v8_index.h"
@@ -42,12 +45,17 @@
#include "V8Collection.h"
#include "V8DOMWindow.h"
+#if PLATFORM(CHROMIUM)
#include "ChromiumBridge.h"
+#endif
+
#include "DOMObjectsInclude.h"
#include "ScriptController.h"
#include "V8DOMMap.h"
+#include "CString.h"
+
namespace WebCore {
V8EventListenerList::V8EventListenerList(const char* name)
@@ -402,6 +410,17 @@ void V8Proxy::GCUnprotect(void* dom_object)
}
+typedef std::pair<uintptr_t, Node*> GrouperPair;
+typedef Vector<GrouperPair> GrouperList;
+
+#if PLATFORM(ANDROID)
+// Sort GrouperPair by the group id. Node* is only involved to sort within
+// a group id, so it will be fine.
+static bool ComparePair(const GrouperPair& p1, const GrouperPair& p2) {
+ return p1.first < p2.first;
+}
+#endif
+
// Create object groups for DOM tree nodes.
static void GCPrologue()
{
@@ -473,9 +492,6 @@ ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
}
// Create object groups.
- typedef std::pair<uintptr_t, Node*> GrouperPair;
- typedef Vector<GrouperPair> GrouperList;
-
DOMNodeMap node_map = getDOMNodeMap().impl();
GrouperList grouper;
grouper.reserveCapacity(node_map.size());
@@ -512,10 +528,14 @@ ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
grouper.append(GrouperPair(group_id, node));
}
+#if PLATFORM(ANDROID)
+ std::stable_sort<GrouperPair>(grouper.begin(), grouper.end(), ComparePair);
+#else
// Group by sorting by the group id. This will use the std::pair operator<,
// which will really sort by both the group id and the Node*. However the
// Node* is only involved to sort within a group id, so it will be fine.
std::sort(grouper.begin(), grouper.end());
+#endif
// TODO(deanm): Should probably work in iterators here, but indexes were
// easier for my simple mind.
@@ -1066,8 +1086,9 @@ bool V8Proxy::HandleOutOfMemory()
// Destroy the global object.
proxy->DestroyGlobal();
+#if PLATFORM(CHROMIUM)
ChromiumBridge::notifyJSOutOfMemory(frame);
-
+#endif
// Disable JS.
Settings* settings = frame->settings();
ASSERT(settings);
@@ -1122,15 +1143,19 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* n)
// Compile the script.
v8::Local<v8::String> code = v8ExternalString(source.source());
+#if PLATFORM(CHROMIUM)
ChromiumBridge::traceEventBegin("v8.compile", n, "");
+#endif
// NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at
// 1, whereas v8 starts at 0.
v8::Handle<v8::Script> script = CompileScript(code, source.url(),
source.startLine() - 1);
+#if PLATFORM(CHROMIUM)
ChromiumBridge::traceEventEnd("v8.compile", n, "");
-
ChromiumBridge::traceEventBegin("v8.run", n, "");
+#endif
+
v8::Local<v8::Value> result;
{
// Isolate exceptions that occur when executing the code. These
@@ -1144,7 +1169,9 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* n)
// this based on whether the script source has a URL.
result = RunScript(script, source.url().string().isNull());
}
+#if PLATFORM(CHROMIUM)
ChromiumBridge::traceEventEnd("v8.run", n, "");
+#endif
return result;
}
@@ -1662,12 +1689,16 @@ v8::Persistent<v8::FunctionTemplate> V8Proxy::GetTemplate(
V8Custom::kXMLHttpRequestInternalFieldCount);
break;
}
+#if ENABLE(XPATH)
case V8ClassIndex::XPATHEVALUATOR:
desc->SetCallHandler(USE_CALLBACK(XPathEvaluatorConstructor));
break;
+#endif
+#if ENABLE(XSLT)
case V8ClassIndex::XSLTPROCESSOR:
desc->SetCallHandler(USE_CALLBACK(XSLTProcessorConstructor));
break;
+#endif
default:
break;
}
@@ -1788,13 +1819,20 @@ bool V8Proxy::isEnabled()
// not be made at this layer. instead, we should bridge out to the
// embedder to allow them to override policy here.
+#if PLATFORM(CHROMIUM)
if (origin->protocol() == ChromiumBridge::uiResourceProtocol())
return true; // Embedder's scripts are ok to run
+#endif
// If the scheme is ftp: or file:, an empty file name indicates a directory
// listing, which requires JavaScript to function properly.
const char* kDirProtocols[] = { "ftp", "file" };
+#if PLATFORM(ANDROID)
+ // TODO(fqian): port arraysize function to Android.
+ for (size_t i = 0; i < 2; ++i) {
+#else
for (size_t i = 0; i < arraysize(kDirProtocols); ++i) {
+#endif
if (origin->protocol() == kDirProtocols[i]) {
const KURL& url = document->url();
return url.pathAfterLastSlash() == url.pathEnd();
@@ -3300,6 +3338,9 @@ void V8Proxy::CreateUtilityContext() {
int V8Proxy::GetSourceLineNumber() {
+#if PLATFORM(ANDROID)
+ return 0;
+#else
v8::HandleScope scope;
v8::Handle<v8::Context> utility_context = V8Proxy::GetUtilityContext();
if (utility_context.IsEmpty()) {
@@ -3317,10 +3358,14 @@ int V8Proxy::GetSourceLineNumber() {
return 0;
}
return result->Int32Value();
+#endif
}
String V8Proxy::GetSourceName() {
+#if PLATFORM(ANDROID)
+ return String();
+#else
v8::HandleScope scope;
v8::Handle<v8::Context> utility_context = GetUtilityContext();
if (utility_context.IsEmpty()) {
@@ -3334,13 +3379,14 @@ String V8Proxy::GetSourceName() {
return String();
}
return ToWebCoreString(v8::Debug::Call(frame_source_name));
+#endif
}
void V8Proxy::RegisterExtension(v8::Extension* extension,
const String& schemeRestriction) {
v8::RegisterExtension(extension);
V8ExtensionInfo info = {schemeRestriction, extension};
- m_extensions.push_back(info);
+ m_extensions.append(info);
}
} // namespace WebCore
diff --git a/V8Binding/v8/v8_proxy.h b/V8Binding/v8/v8_proxy.h
index d1a7a9f..45f9f39 100644
--- a/V8Binding/v8/v8_proxy.h
+++ b/V8Binding/v8/v8_proxy.h
@@ -9,7 +9,6 @@
#include "v8_index.h"
#include "v8_custom.h"
#include "v8_utility.h"
-#include "ChromiumBridge.h"
#include "Node.h"
#include "NodeFilter.h"
#include "PlatformString.h" // for WebCore::String
@@ -20,10 +19,8 @@
#include <wtf/PassRefPtr.h> // so generated bindings don't have to
#include <wtf/Vector.h>
-#include <iterator>
-#include <list>
-
-#ifdef ENABLE_DOM_STATS_COUNTERS
+#if defined(ENABLE_DOM_STATS_COUNTERS) && PLATFORM(CHROMIUM)
+#include "ChromiumBridge.h"
#define INC_STATS(name) ChromiumBridge::incrementStatsCounter(name)
#else
#define INC_STATS(name)
@@ -185,7 +182,7 @@ struct V8ExtensionInfo {
String scheme;
v8::Extension* extension;
};
-typedef std::list<V8ExtensionInfo> V8ExtensionList;
+typedef WTF::Vector<V8ExtensionInfo> V8ExtensionList;
class V8Proxy {
public: