summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings')
-rw-r--r--WebCore/bindings/generic/RuntimeEnabledFeatures.cpp9
-rw-r--r--WebCore/bindings/generic/RuntimeEnabledFeatures.h4
-rw-r--r--WebCore/bindings/gobject/GNUmakefile.am3
-rw-r--r--WebCore/bindings/js/JSClipboardCustom.cpp2
-rw-r--r--WebCore/bindings/js/JSDeviceMotionEventCustom.cpp159
-rw-r--r--WebCore/bindings/js/JSDirectoryEntryCustom.cpp4
-rw-r--r--WebCore/bindings/js/JSElementCustom.cpp1
-rw-r--r--WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp2
-rw-r--r--WebCore/bindings/js/ScriptFunctionCall.cpp72
-rw-r--r--WebCore/bindings/js/ScriptFunctionCall.h35
-rw-r--r--WebCore/bindings/objc/ObjCEventListener.h19
-rw-r--r--WebCore/bindings/objc/ObjCEventListener.mm16
-rw-r--r--WebCore/bindings/scripts/CodeGeneratorJS.pm2
-rw-r--r--WebCore/bindings/scripts/CodeGeneratorV8.pm1
-rw-r--r--WebCore/bindings/v8/NPV8Object.cpp10
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp4
-rw-r--r--WebCore/bindings/v8/ScriptController.h4
-rw-r--r--WebCore/bindings/v8/ScriptFunctionCall.cpp72
-rw-r--r--WebCore/bindings/v8/ScriptFunctionCall.h27
-rw-r--r--WebCore/bindings/v8/V8DOMWindowShell.cpp17
-rw-r--r--WebCore/bindings/v8/V8Proxy.cpp17
-rw-r--r--WebCore/bindings/v8/V8Proxy.h6
-rw-r--r--WebCore/bindings/v8/custom/V8ClipboardCustom.cpp2
-rw-r--r--WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp10
-rw-r--r--WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp8
-rw-r--r--WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp56
-rw-r--r--WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp146
-rw-r--r--WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp6
-rw-r--r--WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp2
-rw-r--r--WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp3
31 files changed, 520 insertions, 203 deletions
diff --git a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp
index a15fd6d..9a96f22 100644
--- a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp
+++ b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp
@@ -36,6 +36,10 @@
#include "SharedWorkerRepository.h"
#include "WebSocket.h"
+#if ENABLE(FILE_SYSTEM)
+#include "AsyncFileSystem.h"
+#endif
+
namespace WebCore {
bool RuntimeEnabledFeatures::isLocalStorageEnabled = true;
@@ -57,6 +61,11 @@ bool RuntimeEnabledFeatures::isXHRResponseBlobEnabled = false;
#if ENABLE(FILE_SYSTEM)
bool RuntimeEnabledFeatures::isFileSystemEnabled = false;
+
+bool RuntimeEnabledFeatures::fileSystemEnabled()
+{
+ return isFileSystemEnabled && AsyncFileSystem::isAvailable();
+}
#endif
#if ENABLE(VIDEO)
diff --git a/WebCore/bindings/generic/RuntimeEnabledFeatures.h b/WebCore/bindings/generic/RuntimeEnabledFeatures.h
index 91768b0..88350c7 100644
--- a/WebCore/bindings/generic/RuntimeEnabledFeatures.h
+++ b/WebCore/bindings/generic/RuntimeEnabledFeatures.h
@@ -138,7 +138,7 @@ public:
static void setSpeechInputEnabled(bool isEnabled) { isSpeechInputEnabled = isEnabled; }
static bool speechInputEnabled() { return isSpeechInputEnabled; }
- static bool speechEnabled() { return isSpeechInputEnabled; }
+ static bool webkitspeechEnabled() { return isSpeechInputEnabled; }
#if ENABLE(XHR_RESPONSE_BLOB)
static bool xhrResponseBlobEnabled() { return isXHRResponseBlobEnabled; }
@@ -148,7 +148,7 @@ public:
#endif
#if ENABLE(FILE_SYSTEM)
- static bool fileSystemEnabled() { return isFileSystemEnabled; }
+ static bool fileSystemEnabled();
static void setFileSystemEnabled(bool isEnabled) { isFileSystemEnabled = isEnabled; }
static bool requestFileSystemEnabled() { return isFileSystemEnabled; }
#endif
diff --git a/WebCore/bindings/gobject/GNUmakefile.am b/WebCore/bindings/gobject/GNUmakefile.am
index 12835cc..d808e18 100644
--- a/WebCore/bindings/gobject/GNUmakefile.am
+++ b/WebCore/bindings/gobject/GNUmakefile.am
@@ -49,6 +49,8 @@ webkitgtk_gdom_built_sources += \
DerivedSources/webkit/WebKitDOMDOMStringListPrivate.h \
DerivedSources/webkit/WebKitDOMDOMStringMap.cpp \
DerivedSources/webkit/WebKitDOMDOMStringMapPrivate.h \
+ DerivedSources/webkit/WebKitDOMDOMTokenList.cpp \
+ DerivedSources/webkit/WebKitDOMDOMTokenListPrivate.h \
DerivedSources/webkit/WebKitDOMDOMWindow.cpp \
DerivedSources/webkit/WebKitDOMDOMWindowPrivate.h \
DerivedSources/webkit/WebKitDOMElement.cpp \
@@ -263,6 +265,7 @@ webkitgtk_built_h_api += \
DerivedSources/webkit/WebKitDOMDOMImplementation.h \
DerivedSources/webkit/WebKitDOMDOMStringList.h \
DerivedSources/webkit/WebKitDOMDOMStringMap.h \
+ DerivedSources/webkit/WebKitDOMDOMTokenList.h \
DerivedSources/webkit/WebKitDOMElement.h \
DerivedSources/webkit/WebKitDOMEntityReference.h \
DerivedSources/webkit/WebKitDOMEvent.h \
diff --git a/WebCore/bindings/js/JSClipboardCustom.cpp b/WebCore/bindings/js/JSClipboardCustom.cpp
index 2a8d309..17c6640 100644
--- a/WebCore/bindings/js/JSClipboardCustom.cpp
+++ b/WebCore/bindings/js/JSClipboardCustom.cpp
@@ -101,7 +101,7 @@ JSValue JSClipboard::setDragImage(ExecState* exec)
{
Clipboard* clipboard = impl();
- if (!clipboard->isForDragging())
+ if (!clipboard->isForDragAndDrop())
return jsUndefined();
// FIXME: It does not match the rest of the JS bindings to throw on invalid number of arguments.
diff --git a/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp b/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp
index 225a626..f1c1bc0 100644
--- a/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp
+++ b/WebCore/bindings/js/JSDeviceMotionEventCustom.cpp
@@ -35,54 +35,124 @@ using namespace JSC;
namespace WebCore {
-JSValue JSDeviceMotionEvent::xAcceleration(ExecState* exec) const
+static PassRefPtr<DeviceMotionData::Acceleration> readAccelerationArgument(JSValue value, ExecState* exec)
{
- DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
- if (!imp->deviceMotionData()->canProvideXAcceleration())
- return jsNull();
- return jsNumber(exec, imp->deviceMotionData()->xAcceleration());
+ if (value.isUndefinedOrNull())
+ return 0;
+
+ // Given the above test, this will always yield an object.
+ JSObject* object = value.toObject(exec);
+
+ JSValue xValue = object->get(exec, Identifier(exec, "x"));
+ if (exec->hadException())
+ return 0;
+ bool canProvideX = !xValue.isUndefinedOrNull();
+ double x = xValue.toNumber(exec);
+ if (exec->hadException())
+ return 0;
+
+ JSValue yValue = object->get(exec, Identifier(exec, "y"));
+ if (exec->hadException())
+ return 0;
+ bool canProvideY = !yValue.isUndefinedOrNull();
+ double y = yValue.toNumber(exec);
+ if (exec->hadException())
+ return 0;
+
+ JSValue zValue = object->get(exec, Identifier(exec, "z"));
+ if (exec->hadException())
+ return 0;
+ bool canProvideZ = !zValue.isUndefinedOrNull();
+ double z = zValue.toNumber(exec);
+ if (exec->hadException())
+ return 0;
+
+ if (!canProvideX && !canProvideY && !canProvideZ)
+ return 0;
+
+ return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y, canProvideZ, z);
}
-JSValue JSDeviceMotionEvent::yAcceleration(ExecState* exec) const
+static PassRefPtr<DeviceMotionData::RotationRate> readRotationRateArgument(JSValue value, ExecState* exec)
{
- DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
- if (!imp->deviceMotionData()->canProvideYAcceleration())
- return jsNull();
- return jsNumber(exec, imp->deviceMotionData()->yAcceleration());
+ if (value.isUndefinedOrNull())
+ return 0;
+
+ // Given the above test, this will always yield an object.
+ JSObject* object = value.toObject(exec);
+
+ JSValue alphaValue = object->get(exec, Identifier(exec, "alpha"));
+ if (exec->hadException())
+ return 0;
+ bool canProvideAlpha = !alphaValue.isUndefinedOrNull();
+ double alpha = alphaValue.toNumber(exec);
+ if (exec->hadException())
+ return 0;
+
+ JSValue betaValue = object->get(exec, Identifier(exec, "beta"));
+ if (exec->hadException())
+ return 0;
+ bool canProvideBeta = !betaValue.isUndefinedOrNull();
+ double beta = betaValue.toNumber(exec);
+ if (exec->hadException())
+ return 0;
+
+ JSValue gammaValue = object->get(exec, Identifier(exec, "gamma"));
+ if (exec->hadException())
+ return 0;
+ bool canProvideGamma = !gammaValue.isUndefinedOrNull();
+ double gamma = gammaValue.toNumber(exec);
+ if (exec->hadException())
+ return 0;
+
+ if (!canProvideAlpha && !canProvideBeta && !canProvideGamma)
+ return 0;
+
+ return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
}
-JSValue JSDeviceMotionEvent::zAcceleration(ExecState* exec) const
+static JSObject* createAccelerationObject(const DeviceMotionData::Acceleration* acceleration, ExecState* exec)
{
- DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
- if (!imp->deviceMotionData()->canProvideZAcceleration())
- return jsNull();
- return jsNumber(exec, imp->deviceMotionData()->zAcceleration());
+ JSObject* object = constructEmptyObject(exec);
+ object->putDirect(Identifier(exec, "x"), acceleration->canProvideX() ? jsNumber(exec, acceleration->x()) : jsNull());
+ object->putDirect(Identifier(exec, "y"), acceleration->canProvideY() ? jsNumber(exec, acceleration->y()) : jsNull());
+ object->putDirect(Identifier(exec, "z"), acceleration->canProvideZ() ? jsNumber(exec, acceleration->z()) : jsNull());
+ return object;
+}
+
+static JSObject* createRotationRateObject(const DeviceMotionData::RotationRate* rotationRate, ExecState* exec)
+{
+ JSObject* object = constructEmptyObject(exec);
+ object->putDirect(Identifier(exec, "alpha"), rotationRate->canProvideAlpha() ? jsNumber(exec, rotationRate->alpha()) : jsNull());
+ object->putDirect(Identifier(exec, "beta"), rotationRate->canProvideBeta() ? jsNumber(exec, rotationRate->beta()) : jsNull());
+ object->putDirect(Identifier(exec, "gamma"), rotationRate->canProvideGamma() ? jsNumber(exec, rotationRate->gamma()) : jsNull());
+ return object;
}
-JSValue JSDeviceMotionEvent::xRotationRate(ExecState* exec) const
+JSValue JSDeviceMotionEvent::acceleration(ExecState* exec) const
{
DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
- if (!imp->deviceMotionData()->canProvideXRotationRate())
+ if (!imp->deviceMotionData()->acceleration())
return jsNull();
- return jsNumber(exec, imp->deviceMotionData()->xRotationRate());
+ return createAccelerationObject(imp->deviceMotionData()->acceleration(), exec);
}
-JSValue JSDeviceMotionEvent::yRotationRate(ExecState* exec) const
+JSValue JSDeviceMotionEvent::accelerationIncludingGravity(ExecState* exec) const
{
DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
- if (!imp->deviceMotionData()->canProvideYRotationRate())
+ if (!imp->deviceMotionData()->accelerationIncludingGravity())
return jsNull();
- return jsNumber(exec, imp->deviceMotionData()->yRotationRate());
+ return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity(), exec);
}
-JSValue JSDeviceMotionEvent::zRotationRate(ExecState* exec) const
+JSValue JSDeviceMotionEvent::rotationRate(ExecState* exec) const
{
DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
- if (!imp->deviceMotionData()->canProvideZRotationRate())
+ if (!imp->deviceMotionData()->rotationRate())
return jsNull();
- return jsNumber(exec, imp->deviceMotionData()->zRotationRate());
+ return createRotationRateObject(imp->deviceMotionData()->rotationRate(), exec);
}
-
+
JSValue JSDeviceMotionEvent::interval(ExecState* exec) const
{
DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
@@ -90,35 +160,30 @@ JSValue JSDeviceMotionEvent::interval(ExecState* exec) const
return jsNull();
return jsNumber(exec, imp->deviceMotionData()->interval());
}
-
+
JSValue JSDeviceMotionEvent::initDeviceMotionEvent(ExecState* exec)
{
const String& type = ustringToString(exec->argument(0).toString(exec));
bool bubbles = exec->argument(1).toBoolean(exec);
bool cancelable = exec->argument(2).toBoolean(exec);
+
// If any of the parameters are null or undefined, mark them as not provided.
// Otherwise, use the standard JavaScript conversion.
- bool xAccelerationProvided = !exec->argument(3).isUndefinedOrNull();
- double xAcceleration = exec->argument(3).toNumber(exec);
- bool yAccelerationProvided = !exec->argument(4).isUndefinedOrNull();
- double yAcceleration = exec->argument(4).toNumber(exec);
- bool zAccelerationProvided = !exec->argument(5).isUndefinedOrNull();
- double zAcceleration = exec->argument(5).toNumber(exec);
- bool xRotationRateProvided = !exec->argument(6).isUndefinedOrNull();
- double xRotationRate = exec->argument(6).toNumber(exec);
- bool yRotationRateProvided = !exec->argument(7).isUndefinedOrNull();
- double yRotationRate = exec->argument(7).toNumber(exec);
- bool zRotationRateProvided = !exec->argument(8).isUndefinedOrNull();
- double zRotationRate = exec->argument(8).toNumber(exec);
- bool intervalProvided = !exec->argument(9).isUndefinedOrNull();
- double interval = exec->argument(9).toNumber(exec);
- RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(xAccelerationProvided, xAcceleration,
- yAccelerationProvided, yAcceleration,
- zAccelerationProvided, zAcceleration,
- xRotationRateProvided, xRotationRate,
- yRotationRateProvided, yRotationRate,
- zRotationRateProvided, zRotationRate,
- intervalProvided, interval);
+ RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(exec->argument(3), exec);
+ if (exec->hadException())
+ return jsUndefined();
+
+ RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(exec->argument(4), exec);
+ if (exec->hadException())
+ return jsUndefined();
+
+ RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(exec->argument(5), exec);
+ if (exec->hadException())
+ return jsUndefined();
+
+ bool intervalProvided = !exec->argument(6).isUndefinedOrNull();
+ double interval = exec->argument(6).toNumber(exec);
+ RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
DeviceMotionEvent* imp = static_cast<DeviceMotionEvent*>(impl());
imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get());
return jsUndefined();
diff --git a/WebCore/bindings/js/JSDirectoryEntryCustom.cpp b/WebCore/bindings/js/JSDirectoryEntryCustom.cpp
index 35a6c32..a0e0455 100644
--- a/WebCore/bindings/js/JSDirectoryEntryCustom.cpp
+++ b/WebCore/bindings/js/JSDirectoryEntryCustom.cpp
@@ -66,7 +66,7 @@ JSValue JSDirectoryEntry::getFile(ExecState* exec)
JSValue jsExclusive = object->get(exec, Identifier(exec, "exclusive"));
flags->setExclusive(jsExclusive.toBoolean(exec));
} else
- flags = adoptRef(toFlags(exec->argument(1)));
+ flags = toFlags(exec->argument(1));
if (exec->hadException())
return jsUndefined();
RefPtr<EntryCallback> successCallback;
@@ -112,7 +112,7 @@ JSValue JSDirectoryEntry::getDirectory(ExecState* exec)
JSValue jsExclusive = object->get(exec, Identifier(exec, "exclusive"));
flags->setExclusive(jsExclusive.toBoolean(exec));
} else
- flags = adoptRef(toFlags(exec->argument(1)));
+ flags = toFlags(exec->argument(1));
if (exec->hadException())
return jsUndefined();
RefPtr<EntryCallback> successCallback;
diff --git a/WebCore/bindings/js/JSElementCustom.cpp b/WebCore/bindings/js/JSElementCustom.cpp
index 8a1df5c..f691620 100644
--- a/WebCore/bindings/js/JSElementCustom.cpp
+++ b/WebCore/bindings/js/JSElementCustom.cpp
@@ -60,6 +60,7 @@ void JSElement::markChildren(MarkStack& markStack)
JSGlobalData& globalData = *Heap::heap(this)->globalData();
markDOMObjectWrapper(markStack, globalData, element->attributeMap());
+ markDOMObjectWrapper(markStack, globalData, element->optionalClassList());
markDOMObjectWrapper(markStack, globalData, element->optionalDataset());
if (element->isStyledElement())
diff --git a/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp b/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
index 1df1af0..ee79a38 100644
--- a/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
+++ b/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
@@ -58,6 +58,8 @@ JSValue JSInspectorFrontendHost::platform(ExecState* execState)
DEFINE_STATIC_LOCAL(const String, platform, ("windows"));
#elif OS(LINUX)
DEFINE_STATIC_LOCAL(const String, platform, ("linux"));
+#elif OS(FREEBSD)
+ DEFINE_STATIC_LOCAL(const String, platform, ("freebsd"));
#else
DEFINE_STATIC_LOCAL(const String, platform, ("unknown"));
#endif
diff --git a/WebCore/bindings/js/ScriptFunctionCall.cpp b/WebCore/bindings/js/ScriptFunctionCall.cpp
index 9baf809..2e4d536 100644
--- a/WebCore/bindings/js/ScriptFunctionCall.cpp
+++ b/WebCore/bindings/js/ScriptFunctionCall.cpp
@@ -43,14 +43,7 @@ using namespace JSC;
namespace WebCore {
-ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name)
- : m_exec(thisObject.scriptState())
- , m_thisObject(thisObject)
- , m_name(name)
-{
-}
-
-void ScriptFunctionCall::appendArgument(const ScriptObject& argument)
+void ScriptCallArgumentHandler::appendArgument(const ScriptObject& argument)
{
if (argument.scriptState() != m_exec) {
ASSERT_NOT_REACHED();
@@ -59,74 +52,81 @@ void ScriptFunctionCall::appendArgument(const ScriptObject& argument)
m_arguments.append(argument.jsObject());
}
-void ScriptFunctionCall::appendArgument(const ScriptString& argument)
+void ScriptCallArgumentHandler::appendArgument(const ScriptString& argument)
{
m_arguments.append(jsString(m_exec, argument.ustring()));
}
-void ScriptFunctionCall::appendArgument(const ScriptValue& argument)
+void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument)
{
m_arguments.append(argument.jsValue());
}
-void ScriptFunctionCall::appendArgument(const String& argument)
+void ScriptCallArgumentHandler::appendArgument(const String& argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsString(m_exec, argument));
}
-void ScriptFunctionCall::appendArgument(const JSC::UString& argument)
+void ScriptCallArgumentHandler::appendArgument(const JSC::UString& argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsString(m_exec, argument));
}
-void ScriptFunctionCall::appendArgument(const char* argument)
+void ScriptCallArgumentHandler::appendArgument(const char* argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsString(m_exec, UString(argument)));
}
-void ScriptFunctionCall::appendArgument(JSC::JSValue argument)
+void ScriptCallArgumentHandler::appendArgument(JSC::JSValue argument)
{
m_arguments.append(argument);
}
-void ScriptFunctionCall::appendArgument(long argument)
+void ScriptCallArgumentHandler::appendArgument(long argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsNumber(m_exec, argument));
}
-void ScriptFunctionCall::appendArgument(long long argument)
+void ScriptCallArgumentHandler::appendArgument(long long argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsNumber(m_exec, argument));
}
-void ScriptFunctionCall::appendArgument(unsigned int argument)
+void ScriptCallArgumentHandler::appendArgument(unsigned int argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsNumber(m_exec, argument));
}
-void ScriptFunctionCall::appendArgument(unsigned long argument)
+void ScriptCallArgumentHandler::appendArgument(unsigned long argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsNumber(m_exec, argument));
}
-void ScriptFunctionCall::appendArgument(int argument)
+void ScriptCallArgumentHandler::appendArgument(int argument)
{
JSLock lock(SilenceAssertionsOnly);
m_arguments.append(jsNumber(m_exec, argument));
}
-void ScriptFunctionCall::appendArgument(bool argument)
+void ScriptCallArgumentHandler::appendArgument(bool argument)
{
m_arguments.append(jsBoolean(argument));
}
+ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name)
+ : ScriptCallArgumentHandler(thisObject.scriptState())
+ , m_thisObject(thisObject)
+ , m_name(name)
+{
+}
+
ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions)
{
JSObject* thisObject = m_thisObject.jsObject();
@@ -197,4 +197,36 @@ ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
return ScriptObject(m_exec, asObject(result));
}
+ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
+ : ScriptCallArgumentHandler(state)
+ , m_function(function)
+{
+}
+
+ScriptValue ScriptCallback::call()
+{
+ bool hadException;
+ return call(hadException);
+}
+
+ScriptValue ScriptCallback::call(bool& hadException)
+{
+ JSLock lock(SilenceAssertionsOnly);
+
+ CallData callData;
+ CallType callType = getCallData(m_function.jsValue(), callData);
+ if (callType == CallTypeNone)
+ return ScriptValue();
+
+ JSValue result = JSC::call(m_exec, m_function.jsValue(), callType, callData, m_function.jsValue(), m_arguments);
+ hadException = m_exec->hadException();
+
+ if (hadException) {
+ reportException(m_exec, m_exec->exception());
+ return ScriptValue();
+ }
+
+ return ScriptValue(result);
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/js/ScriptFunctionCall.h b/WebCore/bindings/js/ScriptFunctionCall.h
index 9742e8f..037a336 100644
--- a/WebCore/bindings/js/ScriptFunctionCall.h
+++ b/WebCore/bindings/js/ScriptFunctionCall.h
@@ -46,10 +46,9 @@ namespace WebCore {
class ScriptValue;
class ScriptString;
- class ScriptFunctionCall {
+ class ScriptCallArgumentHandler {
public:
- ScriptFunctionCall(const ScriptObject& thisObject, const String& name);
- virtual ~ScriptFunctionCall() {};
+ ScriptCallArgumentHandler(ScriptState* state) : m_exec(state) { }
void appendArgument(const ScriptObject&);
void appendArgument(const ScriptString&);
@@ -64,15 +63,10 @@ namespace WebCore {
void appendArgument(unsigned long);
void appendArgument(int);
void appendArgument(bool);
- ScriptValue call(bool& hadException, bool reportExceptions = true);
- ScriptValue call();
- ScriptObject construct(bool& hadException, bool reportExceptions = true);
protected:
- ScriptState* m_exec;
- ScriptObject m_thisObject;
- String m_name;
JSC::MarkedArgumentBuffer m_arguments;
+ ScriptState* m_exec;
private:
// MarkedArgumentBuffer must be stack allocated, so prevent heap
@@ -81,6 +75,29 @@ namespace WebCore {
void* operator new[](size_t) { ASSERT_NOT_REACHED(); return reinterpret_cast<void*>(0xbadbeef); }
};
+ class ScriptFunctionCall : public ScriptCallArgumentHandler {
+ public:
+ ScriptFunctionCall(const ScriptObject& thisObject, const String& name);
+ ScriptValue call(bool& hadException, bool reportExceptions = true);
+ ScriptValue call();
+ ScriptObject construct(bool& hadException, bool reportExceptions = true);
+
+ protected:
+ ScriptObject m_thisObject;
+ String m_name;
+ };
+
+ class ScriptCallback : public ScriptCallArgumentHandler {
+ public:
+ ScriptCallback(ScriptState*, ScriptValue);
+
+ ScriptValue call();
+ ScriptValue call(bool& hadException);
+
+ private:
+ ScriptValue m_function;
+ };
+
} // namespace WebCore
#endif // ScriptFunctionCall
diff --git a/WebCore/bindings/objc/ObjCEventListener.h b/WebCore/bindings/objc/ObjCEventListener.h
index 434ef45..5a2941f 100644
--- a/WebCore/bindings/objc/ObjCEventListener.h
+++ b/WebCore/bindings/objc/ObjCEventListener.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2006, 2008 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2006, 2008, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
@@ -28,8 +28,8 @@
#define ObjCEventListener_h
#include "EventListener.h"
-
-#include <wtf/PassRefPtr.h>
+#include <wtf/Forward.h>
+#include <wtf/RetainPtr.h>
@protocol DOMEventListener;
@@ -37,7 +37,8 @@ namespace WebCore {
class ObjCEventListener : public EventListener {
public:
- static PassRefPtr<ObjCEventListener> wrap(id <DOMEventListener>);
+ typedef id<DOMEventListener> ObjCListener;
+ static PassRefPtr<ObjCEventListener> wrap(ObjCListener);
static const ObjCEventListener* cast(const EventListener* listener)
{
@@ -46,17 +47,15 @@ namespace WebCore {
: 0;
}
- virtual bool operator==(const EventListener& other);
-
private:
- static ObjCEventListener* find(id <DOMEventListener>);
+ static ObjCEventListener* find(ObjCListener);
- ObjCEventListener(id <DOMEventListener>);
+ ObjCEventListener(ObjCListener);
virtual ~ObjCEventListener();
-
+ virtual bool operator==(const EventListener&);
virtual void handleEvent(ScriptExecutionContext*, Event*);
- id <DOMEventListener> m_listener;
+ RetainPtr<ObjCListener> m_listener;
};
} // namespace WebCore
diff --git a/WebCore/bindings/objc/ObjCEventListener.mm b/WebCore/bindings/objc/ObjCEventListener.mm
index c1b8aa5..6e2a9fa 100644
--- a/WebCore/bindings/objc/ObjCEventListener.mm
+++ b/WebCore/bindings/objc/ObjCEventListener.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2006 James G. Speth (speth@end.com)
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
*
@@ -40,7 +40,7 @@ namespace WebCore {
typedef HashMap<id, ObjCEventListener*> ListenerMap;
static ListenerMap* listenerMap;
-ObjCEventListener* ObjCEventListener::find(id <DOMEventListener> listener)
+ObjCEventListener* ObjCEventListener::find(ObjCListener listener)
{
ListenerMap* map = listenerMap;
if (!map)
@@ -48,7 +48,7 @@ ObjCEventListener* ObjCEventListener::find(id <DOMEventListener> listener)
return map->get(listener);
}
-PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(id <DOMEventListener> listener)
+PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(ObjCListener listener)
{
RefPtr<ObjCEventListener> wrapper = find(listener);
if (wrapper)
@@ -56,9 +56,9 @@ PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(id <DOMEventListener> list
return adoptRef(new ObjCEventListener(listener));
}
-ObjCEventListener::ObjCEventListener(id <DOMEventListener> listener)
+ObjCEventListener::ObjCEventListener(ObjCListener listener)
: EventListener(ObjCEventListenerType)
- , m_listener([listener retain])
+ , m_listener(listener)
{
ListenerMap* map = listenerMap;
if (!map) {
@@ -70,13 +70,13 @@ ObjCEventListener::ObjCEventListener(id <DOMEventListener> listener)
ObjCEventListener::~ObjCEventListener()
{
- listenerMap->remove(m_listener);
- [m_listener release];
+ listenerMap->remove(m_listener.get());
}
void ObjCEventListener::handleEvent(ScriptExecutionContext*, Event* event)
{
- [m_listener handleEvent:kit(event)];
+ ObjCListener listener = m_listener.get();
+ [listener handleEvent:kit(event)];
}
bool ObjCEventListener::operator==(const EventListener& listener)
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 1a114a4..803542e 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -240,7 +240,7 @@ sub IndexGetterReturnsStrings
{
my $type = shift;
- return 1 if $type eq "CSSStyleDeclaration" or $type eq "MediaList" or $type eq "CSSVariablesDeclaration" or $type eq "DOMStringList";
+ return 1 if $type eq "CSSStyleDeclaration" or $type eq "MediaList" or $type eq "CSSVariablesDeclaration" or $type eq "DOMStringList" or $type eq "DOMTokenList";
return 0;
}
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index f74f2b1..3353f0f 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -2510,6 +2510,7 @@ sub HasCustomToV8Implementation {
return 1 if $interfaceName eq "CanvasPixelArray";
return 1 if $interfaceName eq "DOMStringMap";
return 1 if $interfaceName eq "DOMWindow";
+ return 1 if $interfaceName eq "DOMTokenList";
return 1 if $interfaceName eq "Element";
return 1 if $interfaceName eq "HTMLDocument";
return 1 if $interfaceName eq "HTMLElement";
diff --git a/WebCore/bindings/v8/NPV8Object.cpp b/WebCore/bindings/v8/NPV8Object.cpp
index fb97d59..e4be0d8 100644
--- a/WebCore/bindings/v8/NPV8Object.cpp
+++ b/WebCore/bindings/v8/NPV8Object.cpp
@@ -34,6 +34,7 @@
#include "OwnArrayPtr.h"
#include "PlatformString.h"
#include "ScriptController.h"
+#include "UserGestureIndicator.h"
#include "V8GCController.h"
#include "V8Helpers.h"
#include "V8NPUtils.h"
@@ -278,8 +279,17 @@ bool _NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npObject, NPStri
if (!popupsAllowed)
filename = "npscript";
+ // Set popupsAllowed flag to the current execution frame, so WebKit can get
+ // right gesture status for popups initiated from plugins.
+ Frame* frame = proxy->frame();
+ ASSERT(frame);
+ bool oldAllowPopups = frame->script()->allowPopupsFromPlugin();
+ frame->script()->setAllowPopupsFromPlugin(popupsAllowed);
+
String script = String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
v8::Local<v8::Value> v8result = proxy->evaluate(ScriptSourceCode(script, KURL(ParsedURLString, filename)), 0);
+ // Restore the old flag.
+ frame->script()->setAllowPopupsFromPlugin(oldAllowPopups);
if (v8result.IsEmpty())
return false;
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 5023254..8018a18 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -121,6 +121,7 @@ ScriptController::ScriptController(Frame* frame)
, m_inExecuteScript(false)
, m_processingTimerCallback(false)
, m_paused(false)
+ , m_allowPopupsFromPlugin(false)
, m_proxy(new V8Proxy(frame))
#if ENABLE(NETSCAPE_PLUGIN_API)
, m_windowScriptNPObject(0)
@@ -203,7 +204,8 @@ bool ScriptController::processingUserGesture()
// This is the <a href="javascript:window.open('...')> case -> we let it through.
return true;
}
-
+ if (activeFrame->script()->allowPopupsFromPlugin())
+ return true;
// This is the <script>window.open(...)</script> case or a timer callback -> block it.
// Based on JSC version, use returned value of UserGestureIndicator::processingUserGesture for all other situations.
return UserGestureIndicator::processingUserGesture();
diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h
index 3bc42ef..8ac9064 100644
--- a/WebCore/bindings/v8/ScriptController.h
+++ b/WebCore/bindings/v8/ScriptController.h
@@ -193,6 +193,9 @@ public:
void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
+ void setAllowPopupsFromPlugin(bool allowPopupsFromPlugin) { m_allowPopupsFromPlugin = allowPopupsFromPlugin; }
+ bool allowPopupsFromPlugin() const { return m_allowPopupsFromPlugin; }
+
private:
Frame* m_frame;
const String* m_sourceURL;
@@ -201,6 +204,7 @@ private:
bool m_processingTimerCallback;
bool m_paused;
+ bool m_allowPopupsFromPlugin;
OwnPtr<V8Proxy> m_proxy;
typedef HashMap<Widget*, NPObject*> PluginObjectMap;
diff --git a/WebCore/bindings/v8/ScriptFunctionCall.cpp b/WebCore/bindings/v8/ScriptFunctionCall.cpp
index e6b22ee..29dbb02 100644
--- a/WebCore/bindings/v8/ScriptFunctionCall.cpp
+++ b/WebCore/bindings/v8/ScriptFunctionCall.cpp
@@ -45,14 +45,7 @@
namespace WebCore {
-ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name)
- : m_scriptState(thisObject.scriptState())
- , m_thisObject(thisObject)
- , m_name(name)
-{
-}
-
-void ScriptFunctionCall::appendArgument(const ScriptObject& argument)
+void ScriptCallArgumentHandler::appendArgument(const ScriptObject& argument)
{
if (argument.scriptState() != m_scriptState) {
ASSERT_NOT_REACHED();
@@ -61,64 +54,71 @@ void ScriptFunctionCall::appendArgument(const ScriptObject& argument)
m_arguments.append(argument);
}
-void ScriptFunctionCall::appendArgument(const ScriptString& argument)
+void ScriptCallArgumentHandler::appendArgument(const ScriptString& argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8String(argument));
}
-void ScriptFunctionCall::appendArgument(const ScriptValue& argument)
+void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument)
{
m_arguments.append(argument);
}
-void ScriptFunctionCall::appendArgument(const String& argument)
+void ScriptCallArgumentHandler::appendArgument(const String& argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8String(argument));
}
-void ScriptFunctionCall::appendArgument(const char* argument)
+void ScriptCallArgumentHandler::appendArgument(const char* argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8String(argument));
}
-void ScriptFunctionCall::appendArgument(long argument)
+void ScriptCallArgumentHandler::appendArgument(long argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8::Number::New(argument));
}
-void ScriptFunctionCall::appendArgument(long long argument)
+void ScriptCallArgumentHandler::appendArgument(long long argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8::Number::New(argument));
}
-void ScriptFunctionCall::appendArgument(unsigned int argument)
+void ScriptCallArgumentHandler::appendArgument(unsigned int argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8::Number::New(argument));
}
-void ScriptFunctionCall::appendArgument(unsigned long argument)
+void ScriptCallArgumentHandler::appendArgument(unsigned long argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8::Number::New(argument));
}
-void ScriptFunctionCall::appendArgument(int argument)
+void ScriptCallArgumentHandler::appendArgument(int argument)
{
ScriptScope scope(m_scriptState);
m_arguments.append(v8::Number::New(argument));
}
-void ScriptFunctionCall::appendArgument(bool argument)
+void ScriptCallArgumentHandler::appendArgument(bool argument)
{
m_arguments.append(v8Boolean(argument));
}
+ScriptFunctionCall::ScriptFunctionCall(const ScriptObject& thisObject, const String& name)
+ : ScriptCallArgumentHandler(thisObject.scriptState())
+ , m_thisObject(thisObject)
+ , m_name(name)
+{
+}
+
ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions)
{
ScriptScope scope(m_scriptState, reportExceptions);
@@ -179,4 +179,40 @@ ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
return ScriptObject(m_scriptState, result);
}
+ScriptCallback::ScriptCallback(ScriptState* state, ScriptValue function)
+ : ScriptCallArgumentHandler(state)
+ , m_function(function)
+{
+}
+
+ScriptValue ScriptCallback::call()
+{
+ bool hadException = false;
+ return call(hadException);
+}
+
+ScriptValue ScriptCallback::call(bool& hadException)
+{
+ ASSERT(v8::Context::InContext());
+ ASSERT(m_function.v8Value()->IsFunction());
+
+ v8::TryCatch exceptionCatcher;
+ v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(m_function.v8Value());
+
+ OwnArrayPtr<v8::Handle<v8::Value> > args(new v8::Handle<v8::Value>[m_arguments.size()]);
+ for (size_t i = 0; i < m_arguments.size(); ++i)
+ args[i] = m_arguments[i].v8Value();
+
+ v8::Handle<v8::Value> result = V8Proxy::callFunctionWithoutFrame(function, object, m_arguments.size(), args.get());
+
+ if (exceptionCatcher.HasCaught()) {
+ hadException = true;
+ m_scriptState->setException(exceptionCatcher.Exception());
+ return ScriptValue();
+ }
+
+ return ScriptValue(result);
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptFunctionCall.h b/WebCore/bindings/v8/ScriptFunctionCall.h
index 4cbbf7e..04dddc8 100644
--- a/WebCore/bindings/v8/ScriptFunctionCall.h
+++ b/WebCore/bindings/v8/ScriptFunctionCall.h
@@ -41,10 +41,9 @@ namespace WebCore {
class ScriptState;
class ScriptString;
- class ScriptFunctionCall {
+ class ScriptCallArgumentHandler {
public:
- ScriptFunctionCall(const ScriptObject& thisObject, const String& name);
- virtual ~ScriptFunctionCall() {};
+ ScriptCallArgumentHandler(ScriptState* scriptState) : m_scriptState(scriptState) { }
void appendArgument(const ScriptObject&);
void appendArgument(const ScriptString&);
@@ -57,15 +56,33 @@ namespace WebCore {
void appendArgument(unsigned long);
void appendArgument(int);
void appendArgument(bool);
+
+ protected:
+ ScriptState* m_scriptState;
+ Vector<ScriptValue> m_arguments;
+ };
+
+ class ScriptFunctionCall : public ScriptCallArgumentHandler {
+ public:
+ ScriptFunctionCall(const ScriptObject& thisObject, const String& name);
ScriptValue call(bool& hadException, bool reportExceptions = true);
ScriptValue call();
ScriptObject construct(bool& hadException, bool reportExceptions = true);
protected:
- ScriptState* m_scriptState;
ScriptObject m_thisObject;
String m_name;
- Vector<ScriptValue> m_arguments;
+ };
+
+ class ScriptCallback : public ScriptCallArgumentHandler {
+ public:
+ ScriptCallback(ScriptState*, ScriptValue);
+
+ ScriptValue call();
+ ScriptValue call(bool& hadException);
+
+ private:
+ ScriptValue m_function;
};
} // namespace WebCore
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index f0f473d..bea1eb8 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -352,11 +352,18 @@ v8::Persistent<v8::Context> V8DOMWindowShell::createNewContext(v8::Handle<v8::Ob
if (extensions[i].group && extensions[i].group != extensionGroup)
continue;
- // Note: we check the loader URL here instead of the document URL
- // because we might be currently loading an URL into a blank page.
- // See http://code.google.com/p/chromium/issues/detail?id=10924
- if (extensions[i].scheme.length() > 0 && (extensions[i].scheme != m_frame->loader()->activeDocumentLoader()->url().protocol()))
- continue;
+ if (extensions[i].useCallback) {
+ // Ensure our date extension is always allowed.
+ if (extensions[i].extension != DateExtension::get()
+ && !m_frame->loader()->client()->allowScriptExtension(extensions[i].extension->name(), extensionGroup))
+ continue;
+ } else {
+ // Note: we check the loader URL here instead of the document URL
+ // because we might be currently loading an URL into a blank page.
+ // See http://code.google.com/p/chromium/issues/detail?id=10924
+ if (extensions[i].scheme.length() > 0 && (extensions[i].scheme != m_frame->loader()->activeDocumentLoader()->url().protocol()))
+ continue;
+ }
extensionNames[index++] = extensions[i].extension->name();
}
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index 27e09e6..be2be07 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -687,11 +687,7 @@ void V8Proxy::didLeaveScriptContext()
// If we've just left a script context and indexed database has been
// instantiated, we must let its transaction coordinator know so it can terminate
// any not-yet-started transactions.
- if (IDBPendingTransactionMonitor::hasPendingTransactions()) {
- ASSERT(page->group().hasIDBFactory());
- page->group().idbFactory()->abortPendingTransactions(IDBPendingTransactionMonitor::pendingTransactions());
- IDBPendingTransactionMonitor::clearPendingTransactions();
- }
+ IDBPendingTransactionMonitor::abortPendingTransactions();
#endif // ENABLE(INDEXED_DATABASE)
// If we've just left a top level script context and local storage has been
// instantiated, we must ensure that any storage locks have been freed.
@@ -876,14 +872,21 @@ bool V8Proxy::registeredExtensionWithV8(v8::Extension* extension)
void V8Proxy::registerExtension(v8::Extension* extension, const String& schemeRestriction)
{
registerExtensionWithV8(extension);
- V8ExtensionInfo info = {schemeRestriction, 0, extension};
+ V8ExtensionInfo info = {schemeRestriction, 0, extension, false};
m_extensions.append(info);
}
void V8Proxy::registerExtension(v8::Extension* extension, int extensionGroup)
{
registerExtensionWithV8(extension);
- V8ExtensionInfo info = {String(), extensionGroup, extension};
+ V8ExtensionInfo info = {String(), extensionGroup, extension, false};
+ m_extensions.append(info);
+}
+
+void V8Proxy::registerExtension(v8::Extension* extension)
+{
+ registerExtensionWithV8(extension);
+ V8ExtensionInfo info = {String(), 0, extension, true};
m_extensions.append(info);
}
diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h
index 4d2404f..169883b 100644
--- a/WebCore/bindings/v8/V8Proxy.h
+++ b/WebCore/bindings/v8/V8Proxy.h
@@ -128,6 +128,7 @@ namespace WebCore {
String scheme;
int group;
v8::Extension* extension;
+ bool useCallback; // FIXME: remove
};
typedef WTF::Vector<V8ExtensionInfo> V8Extensions;
@@ -337,6 +338,11 @@ namespace WebCore {
static void registerExtension(v8::Extension*, const String& schemeRestriction);
static void registerExtension(v8::Extension*, int extensionGroup);
+ // Same as above, but new version.
+ // FIXME: remove the other 2 versions in phase 3 of multipart checkin:
+ // https://bugs.webkit.org/show_bug.cgi?id=45721
+ static void registerExtension(v8::Extension*);
+
static void registerExtensionWithV8(v8::Extension*);
static bool registeredExtensionWithV8(v8::Extension*);
diff --git a/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp b/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp
index 69742f8..d85d7a0 100644
--- a/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp
@@ -101,7 +101,7 @@ v8::Handle<v8::Value> V8Clipboard::setDragImageCallback(const v8::Arguments& arg
INC_STATS("DOM.Clipboard.setDragImage()");
Clipboard* clipboard = V8Clipboard::toNative(args.Holder());
- if (!clipboard->isForDragging())
+ if (!clipboard->isForDragAndDrop())
return v8::Undefined();
if (args.Length() != 3)
diff --git a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp
index 25e7e0d..11f309b 100644
--- a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp
@@ -66,6 +66,7 @@ void V8CustomVoidCallback::handleEvent()
bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext)
{
v8::TryCatch exceptionCatcher;
+ exceptionCatcher.SetVerbose(true);
v8::Local<v8::Function> callbackFunction;
if (callback->IsFunction()) {
@@ -84,14 +85,7 @@ bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8
v8::Handle<v8::Value> result = callbackFunction->Call(thisObject, argc, argv);
callbackReturnValue = !result.IsEmpty() && result->BooleanValue();
-
- if (exceptionCatcher.HasCaught()) {
- v8::Local<v8::Message> message = exceptionCatcher.Message();
- scriptExecutionContext->reportException(toWebCoreString(message->Get()), message->GetLineNumber(), toWebCoreString(message->GetScriptResourceName()));
- return true;
- }
-
- return false;
+ return exceptionCatcher.HasCaught();
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp b/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
index c8a975b..71ff357 100644
--- a/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
@@ -34,6 +34,7 @@
#include "DOMStringMap.h"
#include "V8Binding.h"
#include "V8DOMWrapper.h"
+#include "V8Element.h"
namespace WebCore {
@@ -101,8 +102,11 @@ v8::Handle<v8::Value> toV8(DOMStringMap* impl)
v8::Handle<v8::Object> wrapper = V8DOMStringMap::wrap(impl);
// Add a hidden reference from the element to the DOMStringMap.
Element* element = impl->element();
- if (!wrapper.IsEmpty() && element)
- V8DOMWrapper::setHiddenWindowReference(element->document()->frame(), wrapper);
+ if (!wrapper.IsEmpty() && element) {
+ v8::Handle<v8::Value> elementValue = toV8(element);
+ if (!elementValue.IsEmpty() && elementValue->IsObject())
+ V8DOMWrapper::setHiddenReference(elementValue.As<v8::Object>(), wrapper);
+ }
return wrapper;
}
diff --git a/WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp b/WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp
new file mode 100644
index 0000000..171ff5c
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 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 "V8DOMTokenList.h"
+
+#include "DOMTokenList.h"
+#include "V8Binding.h"
+#include "V8DOMWrapper.h"
+#include "V8Element.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(DOMTokenList* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8DOMTokenList::wrap(impl);
+ // Add a hidden reference from the element to the DOMTokenList.
+ Element* element = impl->element();
+ if (!wrapper.IsEmpty() && element) {
+ v8::Handle<v8::Value> elementValue = toV8(element);
+ if (!elementValue.IsEmpty() && elementValue->IsObject())
+ V8DOMWrapper::setHiddenReference(elementValue.As<v8::Object>(), wrapper);
+ }
+ return wrapper;
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp b/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp
index 67f27c5..f7a03f9 100644
--- a/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp
@@ -37,67 +37,122 @@
namespace WebCore {
-v8::Handle<v8::Value> V8DeviceMotionEvent::xAccelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+namespace {
+
+v8::Handle<v8::Value> createAccelerationObject(const DeviceMotionData::Acceleration* acceleration)
{
- INC_STATS("DOM.DeviceMotionEvent.xAcceleration._get");
- v8::Handle<v8::Object> holder = info.Holder();
- DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
- if (!imp->deviceMotionData()->canProvideXAcceleration())
- return v8::Null();
- return v8::Number::New(imp->deviceMotionData()->xAcceleration());
+ v8::Local<v8::Object> object = v8::Object::New();
+ object->Set(v8::String::New("x"), acceleration->canProvideX() ? v8::Number::New(acceleration->x()) : v8::Null());
+ object->Set(v8::String::New("y"), acceleration->canProvideY() ? v8::Number::New(acceleration->y()) : v8::Null());
+ object->Set(v8::String::New("z"), acceleration->canProvideZ() ? v8::Number::New(acceleration->z()) : v8::Null());
+ return object;
}
-v8::Handle<v8::Value> V8DeviceMotionEvent::yAccelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+v8::Handle<v8::Value> createRotationRateObject(const DeviceMotionData::RotationRate* rotationRate)
{
- INC_STATS("DOM.DeviceMotionEvent.yAcceleration._get");
- v8::Handle<v8::Object> holder = info.Holder();
- DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
- if (!imp->deviceMotionData()->canProvideYAcceleration())
- return v8::Null();
- return v8::Number::New(imp->deviceMotionData()->yAcceleration());
+ v8::Local<v8::Object> object = v8::Object::New();
+ object->Set(v8::String::New("alpha"), rotationRate->canProvideAlpha() ? v8::Number::New(rotationRate->alpha()) : v8::Null());
+ object->Set(v8::String::New("beta"), rotationRate->canProvideBeta() ? v8::Number::New(rotationRate->beta()) : v8::Null());
+ object->Set(v8::String::New("gamma"), rotationRate->canProvideGamma() ? v8::Number::New(rotationRate->gamma()) : v8::Null());
+ return object;
}
-v8::Handle<v8::Value> V8DeviceMotionEvent::zAccelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+RefPtr<DeviceMotionData::Acceleration> readAccelerationArgument(v8::Local<v8::Value> value)
{
- INC_STATS("DOM.DeviceMotionEvent.zAcceleration._get");
- v8::Handle<v8::Object> holder = info.Holder();
- DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
- if (!imp->deviceMotionData()->canProvideZAcceleration())
- return v8::Null();
- return v8::Number::New(imp->deviceMotionData()->zAcceleration());
+ if (isUndefinedOrNull(value))
+ return 0;
+
+ // Given the test above, this will always yield an object.
+ v8::Local<v8::Object> object = value->ToObject();
+
+ v8::Local<v8::Value> xValue = object->Get(v8::String::New("x"));
+ if (xValue.IsEmpty())
+ return 0;
+ bool canProvideX = !isUndefinedOrNull(xValue);
+ double x = xValue->NumberValue();
+
+ v8::Local<v8::Value> yValue = object->Get(v8::String::New("y"));
+ if (yValue.IsEmpty())
+ return 0;
+ bool canProvideY = !isUndefinedOrNull(yValue);
+ double y = yValue->NumberValue();
+
+ v8::Local<v8::Value> zValue = object->Get(v8::String::New("z"));
+ if (zValue.IsEmpty())
+ return 0;
+ bool canProvideZ = !isUndefinedOrNull(zValue);
+ double z = zValue->NumberValue();
+
+ if (!canProvideX && !canProvideY && !canProvideZ)
+ return 0;
+
+ return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y, canProvideZ, z);
}
-v8::Handle<v8::Value> V8DeviceMotionEvent::xRotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+RefPtr<DeviceMotionData::RotationRate> readRotationRateArgument(v8::Local<v8::Value> value)
{
- INC_STATS("DOM.DeviceMotionEvent.xRotationRate._get");
+ if (isUndefinedOrNull(value))
+ return 0;
+
+ // Given the test above, this will always yield an object.
+ v8::Local<v8::Object> object = value->ToObject();
+
+ v8::Local<v8::Value> alphaValue = object->Get(v8::String::New("alpha"));
+ if (alphaValue.IsEmpty())
+ return 0;
+ bool canProvideAlpha = !isUndefinedOrNull(alphaValue);
+ double alpha = alphaValue->NumberValue();
+
+ v8::Local<v8::Value> betaValue = object->Get(v8::String::New("beta"));
+ if (betaValue.IsEmpty())
+ return 0;
+ bool canProvideBeta = !isUndefinedOrNull(betaValue);
+ double beta = betaValue->NumberValue();
+
+ v8::Local<v8::Value> gammaValue = object->Get(v8::String::New("gamma"));
+ if (gammaValue.IsEmpty())
+ return 0;
+ bool canProvideGamma = !isUndefinedOrNull(gammaValue);
+ double gamma = gammaValue->NumberValue();
+
+ if (!canProvideAlpha && !canProvideBeta && !canProvideGamma)
+ return 0;
+
+ return DeviceMotionData::RotationRate::create(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
+}
+
+} // namespace
+
+v8::Handle<v8::Value> V8DeviceMotionEvent::accelerationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+ INC_STATS("DOM.DeviceMotionEvent.acceleration._get");
v8::Handle<v8::Object> holder = info.Holder();
DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
- if (!imp->deviceMotionData()->canProvideXRotationRate())
+ if (!imp->deviceMotionData()->acceleration())
return v8::Null();
- return v8::Number::New(imp->deviceMotionData()->xRotationRate());
+ return createAccelerationObject(imp->deviceMotionData()->acceleration());
}
-v8::Handle<v8::Value> V8DeviceMotionEvent::yRotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+v8::Handle<v8::Value> V8DeviceMotionEvent::accelerationIncludingGravityAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
- INC_STATS("DOM.DeviceMotionEvent.yRotationRate._get");
+ INC_STATS("DOM.DeviceMotionEvent.accelerationIncludingGravity._get");
v8::Handle<v8::Object> holder = info.Holder();
DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
- if (!imp->deviceMotionData()->canProvideYRotationRate())
+ if (!imp->deviceMotionData()->accelerationIncludingGravity())
return v8::Null();
- return v8::Number::New(imp->deviceMotionData()->yRotationRate());
+ return createAccelerationObject(imp->deviceMotionData()->accelerationIncludingGravity());
}
-v8::Handle<v8::Value> V8DeviceMotionEvent::zRotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+v8::Handle<v8::Value> V8DeviceMotionEvent::rotationRateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
- INC_STATS("DOM.DeviceMotionEvent.zRotationRate._get");
+ INC_STATS("DOM.DeviceMotionEvent.rotationRate._get");
v8::Handle<v8::Object> holder = info.Holder();
DeviceMotionEvent* imp = V8DeviceMotionEvent::toNative(holder);
- if (!imp->deviceMotionData()->canProvideZRotationRate())
+ if (!imp->deviceMotionData()->rotationRate())
return v8::Null();
- return v8::Number::New(imp->deviceMotionData()->zRotationRate());
+ return createRotationRateObject(imp->deviceMotionData()->rotationRate());
}
-
v8::Handle<v8::Value> V8DeviceMotionEvent::intervalAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
INC_STATS("DOM.DeviceMotionEvent.interval._get");
@@ -114,23 +169,12 @@ v8::Handle<v8::Value> V8DeviceMotionEvent::initDeviceMotionEventCallback(const v
STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, args[0]);
bool bubbles = args[1]->BooleanValue();
bool cancelable = args[2]->BooleanValue();
- // If any of the parameters are null or undefined, mark them as not provided.
- // Otherwise, use the standard JavaScript conversion.
- bool xAccelerationProvided = !isUndefinedOrNull(args[3]);
- double xAcceleration = static_cast<double>(args[3]->NumberValue());
- bool yAccelerationProvided = !isUndefinedOrNull(args[4]);
- double yAcceleration = static_cast<double>(args[4]->NumberValue());
- bool zAccelerationProvided = !isUndefinedOrNull(args[5]);
- double zAcceleration = static_cast<double>(args[5]->NumberValue());
- bool xRotationRateProvided = !isUndefinedOrNull(args[6]);
- double xRotationRate = static_cast<double>(args[6]->NumberValue());
- bool yRotationRateProvided = !isUndefinedOrNull(args[7]);
- double yRotationRate = static_cast<double>(args[7]->NumberValue());
- bool zRotationRateProvided = !isUndefinedOrNull(args[8]);
- double zRotationRate = static_cast<double>(args[8]->NumberValue());
- bool intervalProvided = !isUndefinedOrNull(args[9]);
- double interval = static_cast<double>(args[9]->NumberValue());
- RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(xAccelerationProvided, xAcceleration, yAccelerationProvided, yAcceleration, zAccelerationProvided, zAcceleration, xRotationRateProvided, xRotationRate, yRotationRateProvided, yRotationRate, zRotationRateProvided, zRotationRate, intervalProvided, interval);
+ RefPtr<DeviceMotionData::Acceleration> acceleration = readAccelerationArgument(args[3]);
+ RefPtr<DeviceMotionData::Acceleration> accelerationIncludingGravity = readAccelerationArgument(args[4]);
+ RefPtr<DeviceMotionData::RotationRate> rotationRate = readRotationRateArgument(args[5]);
+ bool intervalProvided = !isUndefinedOrNull(args[6]);
+ double interval = args[6]->NumberValue();
+ RefPtr<DeviceMotionData> deviceMotionData = DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, intervalProvided, interval);
imp->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData.get());
return v8::Handle<v8::Value>();
}
diff --git a/WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp b/WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp
index 72f759a..ce8eaf3 100644
--- a/WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DeviceOrientationEventCustom.cpp
@@ -76,11 +76,11 @@ v8::Handle<v8::Value> V8DeviceOrientationEvent::initDeviceOrientationEventCallba
// If alpha, beta or gamma are null or undefined, mark them as not provided.
// Otherwise, use the standard JavaScript conversion.
bool alphaProvided = !isUndefinedOrNull(args[3]);
- double alpha = static_cast<double>(args[3]->NumberValue());
+ double alpha = args[3]->NumberValue();
bool betaProvided = !isUndefinedOrNull(args[4]);
- double beta = static_cast<double>(args[4]->NumberValue());
+ double beta = args[4]->NumberValue();
bool gammaProvided = !isUndefinedOrNull(args[5]);
- double gamma = static_cast<double>(args[5]->NumberValue());
+ double gamma = args[5]->NumberValue();
RefPtr<DeviceOrientation> orientation = DeviceOrientation::create(alphaProvided, alpha, betaProvided, beta, gammaProvided, gamma);
imp->initDeviceOrientationEvent(type, bubbles, cancelable, orientation.get());
return v8::Handle<v8::Value>();
diff --git a/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp b/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
index 286b154..fc8cf98 100644
--- a/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
@@ -71,7 +71,7 @@ v8::Handle<v8::Value> V8DirectoryEntry::getDirectoryCallback(const v8::Arguments
}
} else {
EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
- flags = adoptRef(tmp_flags);
+ flags = tmp_flags;
}
RefPtr<EntryCallback> successCallback;
if (args.Length() > 2 && !args[2]->IsNull() && !args[2]->IsUndefined()) {
@@ -114,7 +114,7 @@ v8::Handle<v8::Value> V8DirectoryEntry::getFileCallback(const v8::Arguments& arg
}
} else {
EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
- flags = adoptRef(tmp_flags);
+ flags = tmp_flags;
}
RefPtr<EntryCallback> successCallback;
if (args.Length() > 2 && !args[2]->IsNull() && !args[2]->IsUndefined()) {
diff --git a/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp b/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
index 25b9010..94fa86e 100644
--- a/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
@@ -47,6 +47,8 @@ v8::Handle<v8::Value> V8InspectorFrontendHost::platformCallback(const v8::Argume
return v8String("mac");
#elif defined(OS_LINUX)
return v8String("linux");
+#elif defined(OS_FREEBSD)
+ return v8String("freebsd");
#elif defined(OS_WIN)
return v8String("windows");
#else
diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
index cfeb503..2355d2a 100644
--- a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp
@@ -32,6 +32,7 @@
#include "V8XMLHttpRequest.h"
#include "Frame.h"
+#include "InspectorController.h"
#include "V8Binding.h"
#include "V8Blob.h"
#include "V8DOMFormData.h"
@@ -113,6 +114,8 @@ v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args)
INC_STATS("DOM.XMLHttpRequest.send()");
XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder());
+ InspectorController::instrumentWillSendXMLHttpRequest(xmlHttpRequest->scriptExecutionContext(), xmlHttpRequest->url());
+
ExceptionCode ec = 0;
if (args.Length() < 1)
xmlHttpRequest->send(ec);