summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-07-08 12:51:48 +0100
committerSteve Block <steveblock@google.com>2010-07-09 15:33:40 +0100
commitca9cb53ed1119a3fd98fafa0972ffeb56dee1c24 (patch)
treebb45155550ec013adc0ad10f4d7d354c6469b022 /WebCore/bindings/v8
parentd4b24d9a829ed7de70381c8b99fb75a07ab40466 (diff)
downloadexternal_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.zip
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.gz
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.bz2
Merge WebKit at r62496: Initial merge by git
Change-Id: Ie3da0770eca22a70a632e3571f31cfabc80facb2
Diffstat (limited to 'WebCore/bindings/v8')
-rw-r--r--WebCore/bindings/v8/IDBBindingUtilities.cpp50
-rw-r--r--WebCore/bindings/v8/IDBBindingUtilities.h44
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp43
-rw-r--r--WebCore/bindings/v8/ScriptDebugServer.cpp13
-rw-r--r--WebCore/bindings/v8/ScriptDebugServer.h2
-rw-r--r--WebCore/bindings/v8/SerializedScriptValue.cpp1
-rw-r--r--WebCore/bindings/v8/V8AbstractEventListener.cpp3
-rw-r--r--WebCore/bindings/v8/V8Binding.h2
-rw-r--r--WebCore/bindings/v8/V8HiddenPropertyName.h3
-rw-r--r--WebCore/bindings/v8/V8Proxy.cpp5
-rw-r--r--WebCore/bindings/v8/V8Proxy.h3
-rw-r--r--WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h14
-rw-r--r--WebCore/bindings/v8/custom/V8BindingMacros.h24
-rw-r--r--WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp11
-rw-r--r--WebCore/bindings/v8/custom/V8DatabaseCustom.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp11
-rw-r--r--WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp (renamed from WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp)43
-rw-r--r--WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp33
-rwxr-xr-xWebCore/bindings/v8/custom/V8WorkerContextCustom.cpp12
22 files changed, 244 insertions, 93 deletions
diff --git a/WebCore/bindings/v8/IDBBindingUtilities.cpp b/WebCore/bindings/v8/IDBBindingUtilities.cpp
new file mode 100644
index 0000000..2f977e0
--- /dev/null
+++ b/WebCore/bindings/v8/IDBBindingUtilities.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBBindingUtilities.h"
+
+#include "IDBKey.h"
+#include "V8Binding.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value)
+{
+ if (value->IsNull())
+ return IDBKey::create();
+ if (value->IsInt32())
+ return IDBKey::create(value->Int32Value());
+ if (value->IsString())
+ return IDBKey::create(v8ValueToWebCoreString(value));
+ // FIXME: Implement dates.
+ return 0;
+}
+
+} // namespace WebCore
+
+#endif
diff --git a/WebCore/bindings/v8/IDBBindingUtilities.h b/WebCore/bindings/v8/IDBBindingUtilities.h
new file mode 100644
index 0000000..04e5c29
--- /dev/null
+++ b/WebCore/bindings/v8/IDBBindingUtilities.h
@@ -0,0 +1,44 @@
+/*
+ * 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:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IDBBindingUtilities_h
+#define IDBBindingUtilities_h
+
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+class IDBKey;
+
+PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>);
+
+}
+
+#endif // ENABLE(INDEXED_DATABASE)
+
+#endif // IDBBindingUtilities_h
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 6f17373..889642f 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -34,7 +34,7 @@
#include "PlatformBridge.h"
#include "Document.h"
-#include "DocumentParser.h"
+#include "ScriptableDocumentParser.h"
#include "DOMWindow.h"
#include "Event.h"
#include "EventListener.h"
@@ -53,6 +53,7 @@
#include "V8BindingState.h"
#include "V8DOMWindow.h"
#include "V8Event.h"
+#include "V8HiddenPropertyName.h"
#include "V8HTMLEmbedElement.h"
#include "V8IsolatedContext.h"
#include "V8NPObject.h"
@@ -160,16 +161,13 @@ void ScriptController::updatePlatformScriptObjects()
bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
{
- Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
// No script is running, so it is user-initiated unless the gesture stack
// explicitly says it is not.
- if (!activeFrame)
+ if (!m_proxy->executingScript())
return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
- V8Proxy* activeProxy = activeFrame->script()->proxy();
-
v8::HandleScope handleScope;
- v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame);
+ v8::Handle<v8::Context> v8Context = m_proxy->mainWorldContext();
// FIXME: find all cases context can be empty:
// 1) JS is disabled;
// 2) page is NULL;
@@ -179,33 +177,24 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
v8::Context::Scope scope(v8Context);
v8::Handle<v8::Object> global = v8Context->Global();
- v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
+ v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
+ v8::Handle<v8::Value> jsEvent = global->GetHiddenValue(eventSymbol);
Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
- // Based on code from kjs_bindings.cpp.
+ // Based on code from JSC's ScriptController::processingUserGesture.
// Note: This is more liberal than Firefox's implementation.
if (event) {
- if (!UserGestureIndicator::processingUserGesture())
- return false;
-
- const AtomicString& type = event->type();
- bool eventOk =
- // mouse events
- type == eventNames().clickEvent || type == eventNames().mousedownEvent || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent
- // keyboard events
- || type == eventNames().keydownEvent || type == eventNames().keypressEvent || type == eventNames().keyupEvent
- // other accepted events
- || type == eventNames().selectEvent || type == eventNames().changeEvent || type == eventNames().focusEvent || type == eventNames().blurEvent || type == eventNames().submitEvent;
-
- if (eventOk)
- return true;
- } else if (m_sourceURL && m_sourceURL->isNull() && !activeProxy->timerCallback()) {
+ // Event::fromUserGesture will return false when UserGestureIndicator::processingUserGesture() returns false.
+ return event->fromUserGesture();
+ }
+ if (m_sourceURL && m_sourceURL->isNull() && !m_proxy->timerCallback()) {
// This is the <a href="javascript:window.open('...')> case -> we let it through.
return true;
}
// This is the <script>window.open(...)</script> case or a timer callback -> block it.
- return false;
+ // Based on JSC version, use returned value of UserGestureIndicator::processingUserGesture for all other situations.
+ return UserGestureIndicator::processingUserGesture();
}
bool ScriptController::anyPageIsProcessingUserGesture() const
@@ -261,14 +250,16 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode, Shoul
int ScriptController::eventHandlerLineNumber() const
{
- if (DocumentParser* parser = m_frame->document()->parser())
+ ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser();
+ if (parser)
return parser->lineNumber();
return 0;
}
int ScriptController::eventHandlerColumnNumber() const
{
- if (DocumentParser* parser = m_frame->document()->parser())
+ ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser();
+ if (parser)
return parser->columnNumber();
return 0;
}
diff --git a/WebCore/bindings/v8/ScriptDebugServer.cpp b/WebCore/bindings/v8/ScriptDebugServer.cpp
index 38fcd8a..8553ee5 100644
--- a/WebCore/bindings/v8/ScriptDebugServer.cpp
+++ b/WebCore/bindings/v8/ScriptDebugServer.cpp
@@ -126,7 +126,7 @@ void ScriptDebugServer::removeListener(ScriptDebugListener* listener, Page* page
// FIXME: Remove all breakpoints set by the agent.
}
-void ScriptDebugServer::setBreakpoint(const String& sourceID, unsigned lineNumber, ScriptBreakpoint breakpoint)
+bool ScriptDebugServer::setBreakpoint(const String& sourceID, ScriptBreakpoint breakpoint, unsigned lineNumber, unsigned* actualLineNumber)
{
#if ENABLE(V8_SCRIPT_DEBUG_SERVER)
v8::HandleScope scope;
@@ -140,7 +140,14 @@ void ScriptDebugServer::setBreakpoint(const String& sourceID, unsigned lineNumbe
args->Set(v8::String::New("enabled"), v8::Boolean::New(breakpoint.enabled));
v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setBreakpoint")));
- v8::Debug::Call(setBreakpointFunction, args);
+ v8::Handle<v8::Value> result = v8::Debug::Call(setBreakpointFunction, args);
+ if (!result->IsNumber())
+ return false;
+ ASSERT(result->Int32Value() >= 0);
+ *actualLineNumber = result->Int32Value();
+ return true;
+#else
+ return false;
#endif
}
@@ -299,7 +306,7 @@ PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::currentCallFrame()
v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame")));
v8::Handle<v8::Value> argv[] = { m_executionState.get() };
v8::Handle<v8::Value> currentCallFrameV8 = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv);
- m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8));
+ m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8));
}
return m_currentCallFrame;
}
diff --git a/WebCore/bindings/v8/ScriptDebugServer.h b/WebCore/bindings/v8/ScriptDebugServer.h
index b46f673..26ca785 100644
--- a/WebCore/bindings/v8/ScriptDebugServer.h
+++ b/WebCore/bindings/v8/ScriptDebugServer.h
@@ -55,7 +55,7 @@ public:
void addListener(ScriptDebugListener*, Page*);
void removeListener(ScriptDebugListener*, Page*);
- void setBreakpoint(const String& sourceID, unsigned lineNumber, ScriptBreakpoint breakpoint);
+ bool setBreakpoint(const String& sourceID, ScriptBreakpoint breakpoint, unsigned lineNumber, unsigned* actualLineNumber);
void removeBreakpoint(const String& sourceID, unsigned lineNumber);
void clearBreakpoints();
void setBreakpointsActivated(bool activated);
diff --git a/WebCore/bindings/v8/SerializedScriptValue.cpp b/WebCore/bindings/v8/SerializedScriptValue.cpp
index 8e91920..47c4c2e 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.cpp
+++ b/WebCore/bindings/v8/SerializedScriptValue.cpp
@@ -34,6 +34,7 @@
#include "Blob.h"
#include "ByteArray.h"
#include "CanvasPixelArray.h"
+#include "ExceptionCode.h"
#include "File.h"
#include "FileList.h"
#include "ImageData.h"
diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp
index b6c53df..bda4345 100644
--- a/WebCore/bindings/v8/V8AbstractEventListener.cpp
+++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp
@@ -38,6 +38,7 @@
#include "V8Binding.h"
#include "V8Event.h"
#include "V8EventListenerList.h"
+#include "V8HiddenPropertyName.h"
#include "V8Proxy.h"
#include "V8Utilities.h"
#include "WorkerContext.h"
@@ -126,7 +127,7 @@ void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context
return;
// We push the event being processed into the global object, so that it can be exposed by DOMWindow's bindings.
- v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event");
+ v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
v8::Local<v8::Value> returnValue;
// In beforeunload/unload handlers, we want to avoid sleeps which do tight loops of calling Date.getTime().
diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h
index 9eebf51..a15ece1 100644
--- a/WebCore/bindings/v8/V8Binding.h
+++ b/WebCore/bindings/v8/V8Binding.h
@@ -32,7 +32,6 @@
#define V8Binding_h
#include "AtomicString.h"
-#include "BindingElement.h"
#include "BindingSecurity.h"
#include "MathExtras.h"
#include "PlatformString.h"
@@ -53,7 +52,6 @@ namespace WebCore {
typedef V8BindingDOMWindow DOMWindow;
};
typedef BindingSecurity<V8Binding> V8BindingSecurity;
- typedef BindingElement<V8Binding> V8BindingElement;
enum ExternalMode {
Externalize,
diff --git a/WebCore/bindings/v8/V8HiddenPropertyName.h b/WebCore/bindings/v8/V8HiddenPropertyName.h
index 0bfadd9..2d0e8d6 100644
--- a/WebCore/bindings/v8/V8HiddenPropertyName.h
+++ b/WebCore/bindings/v8/V8HiddenPropertyName.h
@@ -41,7 +41,8 @@ namespace WebCore {
V(attributeListener) \
V(scriptState) \
V(sleepFunction) \
- V(toStringString)
+ V(toStringString) \
+ V(event)
class V8HiddenPropertyName {
public:
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index adaea81..50e9fdc 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -380,6 +380,11 @@ PassOwnPtr<v8::ScriptData> V8Proxy::precompileScript(v8::Handle<v8::String> code
return scriptData.release();
}
+bool V8Proxy::executingScript() const
+{
+ return m_recursion;
+}
+
v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* node)
{
ASSERT(v8::Context::InContext());
diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h
index ec9352c..4dc28ef 100644
--- a/WebCore/bindings/v8/V8Proxy.h
+++ b/WebCore/bindings/v8/V8Proxy.h
@@ -210,6 +210,9 @@ namespace WebCore {
// constructors.
void evaluateInIsolatedWorld(int worldId, const Vector<ScriptSourceCode>& sources, int extensionGroup);
+ // Returns true if the proxy is currently executing a script in V8.
+ bool executingScript() const;
+
// Evaluate a script file in the current execution environment.
// The caller must hold an execution context.
// If cannot evalute the script, it returns an error.
diff --git a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
index 1c5d731..afaf6bf 100644
--- a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
+++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
@@ -50,12 +50,20 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType
int argLen = args.Length();
if (argLen == 0) {
// This happens when we return a previously constructed
- // ArrayBufferView, e.g. from the call to WebGL<T>Array.slice().
+ // ArrayBufferView, e.g. from the call to <Type>Array.slice().
// The V8DOMWrapper will set the internal pointer in the
// created object. Unfortunately it doesn't look like it's
// possible to distinguish between this case and that where
- // the user calls "new WebGL<T>Array()" from JavaScript.
- return args.Holder();
+ // the user calls "new <Type>Array()" from JavaScript. We must
+ // construct an empty view to avoid crashes when fetching the
+ // length.
+ RefPtr<ArrayClass> array = ArrayClass::create(0);
+ // Transform the holder into a wrapper object for the array.
+ V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get());
+ // Do not call SetIndexedPropertiesToExternalArrayData on this
+ // object. Not only is there no point from a performance
+ // perspective, but doing so causes errors in the slice() case.
+ return toV8(array.release(), args.Holder());
}
// Supported constructors:
diff --git a/WebCore/bindings/v8/custom/V8BindingMacros.h b/WebCore/bindings/v8/custom/V8BindingMacros.h
index 16c3651..4c8ecd3 100644
--- a/WebCore/bindings/v8/custom/V8BindingMacros.h
+++ b/WebCore/bindings/v8/custom/V8BindingMacros.h
@@ -28,11 +28,21 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#define EXCEPTION_BLOCK(type, var, value) \
- type var; \
- { \
- v8::TryCatch block; \
- var = value; \
- if (block.HasCaught()) \
- return throwError(block.Exception()); \
+#define EXCEPTION_BLOCK(type, var, value) \
+ type var; \
+ { \
+ v8::TryCatch block; \
+ var = (value); \
+ if (block.HasCaught()) \
+ return block.ReThrow(); \
+ }
+
+#define TO_WEBCORE_STRING_EXCEPTION_BLOCK(var, value) \
+ String var; \
+ { \
+ v8::TryCatch block; \
+ v8::Handle<v8::String> v8String = (value)->ToString(); \
+ if (block.HasCaught()) \
+ return block.ReThrow(); \
+ var = v8StringToWebCoreString<String>(v8String, DoNotExternalize); \
}
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 25564ee..210e974 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -58,6 +58,7 @@
#include "V8Database.h"
#include "V8DatabaseCallback.h"
#include "V8GCForContextDispose.h"
+#include "V8HiddenPropertyName.h"
#include "V8HTMLAudioElementConstructor.h"
#include "V8HTMLCollection.h"
#include "V8HTMLImageElementConstructor.h"
@@ -175,7 +176,7 @@ v8::Handle<v8::Value> V8DOMWindow::eventAccessorGetter(v8::Local<v8::String> nam
if (context.IsEmpty())
return v8::Undefined();
- v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event");
+ v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
v8::Handle<v8::Value> jsEvent = context->Global()->GetHiddenValue(eventSymbol);
if (jsEvent.IsEmpty())
return v8::Undefined();
@@ -196,7 +197,7 @@ void V8DOMWindow::eventAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::
if (context.IsEmpty())
return;
- v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event");
+ v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
context->Global()->SetHiddenValue(eventSymbol, value);
}
@@ -795,9 +796,9 @@ v8::Handle<v8::Value> V8DOMWindow::openDatabaseCallback(const v8::Arguments& arg
if (args.Length() < 4)
return throwError(SYNTAX_ERR);
- EXCEPTION_BLOCK(String, name, toWebCoreString(args[0]));
- EXCEPTION_BLOCK(String, version, toWebCoreString(args[1]));
- EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2]));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
DOMWindow* imp = V8DOMWindow::toNative(args.Holder());
diff --git a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp
index 20f7c40..44a6eeb 100644
--- a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp
@@ -34,6 +34,7 @@
#include "V8Database.h"
#include "Database.h"
+#include "ExceptionCode.h"
#include "V8Binding.h"
#include "V8BindingMacros.h"
#include "V8SQLTransactionCallback.h"
@@ -50,8 +51,8 @@ v8::Handle<v8::Value> V8Database::changeVersionCallback(const v8::Arguments& arg
if (args.Length() < 2)
return throwError(SYNTAX_ERR);
- EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0]));
- EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1]));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(oldVersion, args[0]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(newVersion, args[1]);
Database* database = V8Database::toNative(args.Holder());
diff --git a/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp
index 4fe30dc..8a317d7 100644
--- a/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp
@@ -34,6 +34,7 @@
#include "V8DatabaseSync.h"
#include "DatabaseSync.h"
+#include "ExceptionCode.h"
#include "V8Binding.h"
#include "V8BindingMacros.h"
#include "V8Proxy.h"
@@ -48,8 +49,8 @@ v8::Handle<v8::Value> V8DatabaseSync::changeVersionCallback(const v8::Arguments&
if (args.Length() < 2)
return throwError(SYNTAX_ERR);
- EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0]));
- EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1]));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(oldVersion, args[0]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(newVersion, args[1]);
DatabaseSync* database = V8DatabaseSync::toNative(args.Holder());
diff --git a/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp
index d3de1dc..35818af 100644
--- a/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp
@@ -41,17 +41,6 @@ namespace WebCore {
using namespace HTMLNames;
-void V8HTMLFrameElement::srcAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
-{
- HTMLFrameElement* frame = V8HTMLFrameElement::toNative(info.Holder());
- String srcValue = toWebCoreStringWithNullCheck(value);
-
- if (!V8BindingSecurity::allowSettingFrameSrcToJavascriptUrl(V8BindingState::Only(), frame, srcValue))
- return;
-
- frame->setAttribute(srcAttr, srcValue);
-}
-
void V8HTMLFrameElement::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
HTMLFrameElement* frame = V8HTMLFrameElement::toNative(info.Holder());
diff --git a/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp b/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp
index 5f22400..2afa55f 100644
--- a/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007-2009 Google Inc. All rights reserved.
+ * 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
@@ -11,9 +11,6 @@
* 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
@@ -29,27 +26,35 @@
*/
#include "config.h"
-#include "V8HTMLIFrameElement.h"
-#include "HTMLIFrameElement.h"
-#include "HTMLNames.h"
+#if ENABLE(INDEXED_DATABASE)
+#include "V8IDBAny.h"
+
+#include "IDBBindingUtilities.h"
+#include "IDBKey.h"
#include "V8Binding.h"
-#include "V8BindingState.h"
-#include "V8Proxy.h"
namespace WebCore {
-using namespace HTMLNames;
-
-void V8HTMLIFrameElement::srcAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+v8::Handle<v8::Value> toV8(IDBKey* key)
{
- HTMLIFrameElement* iframe = V8HTMLIFrameElement::toNative(info.Holder());
- String v = toWebCoreStringWithNullCheck(value);
-
- if (!V8BindingSecurity::allowSettingFrameSrcToJavascriptUrl(V8BindingState::Only(), iframe, v))
- return;
-
- iframe->setAttribute(srcAttr, v);
+ if (!key)
+ return v8::Null();
+
+ switch (key->type()) {
+ case IDBKey::NullType:
+ return v8::Null();
+ case IDBKey::NumberType:
+ return v8::Integer::New(key->number());
+ case IDBKey::StringType:
+ return v8String(key->string());
+ // FIXME: Implement dates.
+ }
+
+ ASSERT_NOT_REACHED();
+ return v8::Undefined();
}
+#endif // ENABLE(INDEXED_DATABASE)
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp
index f1b708a..e2a5070 100644
--- a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp
@@ -35,6 +35,7 @@
#include "V8SQLTransaction.h"
#include "Database.h"
+#include "ExceptionCode.h"
#include "SQLValue.h"
#include "V8Binding.h"
#include "V8BindingMacros.h"
@@ -54,7 +55,7 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments&
if (args.Length() == 0)
return throwError(SYNTAX_ERR);
- EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0]));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(statement, args[0]);
Vector<SQLValue> sqlValues;
@@ -81,7 +82,7 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments&
EXCEPTION_BLOCK(double, sqlValue, value->NumberValue());
sqlValues.append(SQLValue(sqlValue));
} else {
- EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(sqlValue, value);
sqlValues.append(SQLValue(sqlValue));
}
}
diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
index 651c79b..8ef11ce 100644
--- a/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp
@@ -35,6 +35,7 @@
#include "V8SQLTransactionSync.h"
#include "DatabaseSync.h"
+#include "ExceptionCode.h"
#include "SQLResultSet.h"
#include "SQLValue.h"
#include "V8Binding.h"
@@ -53,7 +54,7 @@ v8::Handle<v8::Value> V8SQLTransactionSync::executeSqlCallback(const v8::Argumen
if (!args.Length())
return throwError(SYNTAX_ERR);
- EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0]));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(statement, args[0]);
Vector<SQLValue> sqlValues;
@@ -80,7 +81,7 @@ v8::Handle<v8::Value> V8SQLTransactionSync::executeSqlCallback(const v8::Argumen
EXCEPTION_BLOCK(double, sqlValue, value->NumberValue());
sqlValues.append(SQLValue(sqlValue));
} else {
- EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(sqlValue, value);
sqlValues.append(SQLValue(sqlValue));
}
}
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index 5da4b3e..e1a9c0e 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -110,6 +110,13 @@ static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info)
switch (info.getType()) {
case WebGLGetInfo::kTypeBool:
return v8::Boolean::New(info.getBool());
+ case WebGLGetInfo::kTypeBoolArray: {
+ const Vector<bool>& value = info.getBoolArray();
+ v8::Local<v8::Array> array = v8::Array::New(value.size());
+ for (size_t ii = 0; ii < value.size(); ++ii)
+ array->Set(v8::Integer::New(ii), v8::Boolean::New(value[ii]));
+ return array;
+ }
case WebGLGetInfo::kTypeFloat:
return v8::Number::New(info.getFloat());
case WebGLGetInfo::kTypeLong:
@@ -209,6 +216,32 @@ enum WhichProgramCall {
kProgramParameter, kUniform
};
+v8::Handle<v8::Value> V8WebGLRenderingContext::getAttachedShadersCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.WebGLRenderingContext.getAttachedShaders()");
+
+ if (args.Length() < 1) {
+ V8Proxy::setDOMException(SYNTAX_ERR);
+ return notHandledByInterceptor();
+ }
+
+ ExceptionCode ec = 0;
+ WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
+ Vector<WebGLShader*> shaders;
+ bool succeed = context->getAttachedShaders(program, shaders, ec);
+ if (ec) {
+ V8Proxy::setDOMException(ec);
+ return v8::Undefined();
+ }
+ if (!succeed)
+ return v8::Undefined();
+ v8::Local<v8::Array> array = v8::Array::New(shaders.size());
+ for (size_t ii = 0; ii < shaders.size(); ++ii)
+ array->Set(v8::Integer::New(ii), toV8(shaders[ii]));
+ return array;
+}
+
v8::Handle<v8::Value> V8WebGLRenderingContext::getBufferParameterCallback(const v8::Arguments& args)
{
INC_STATS("DOM.WebGLRenderingContext.getBufferParameter()");
diff --git a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp
index acf10b7..f66ff3d 100755
--- a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp
@@ -150,9 +150,9 @@ v8::Handle<v8::Value> V8WorkerContext::openDatabaseCallback(const v8::Arguments&
if (args.Length() < 4)
return throwError(SYNTAX_ERR);
- EXCEPTION_BLOCK(String, name, toWebCoreString(args[0]));
- EXCEPTION_BLOCK(String, version, toWebCoreString(args[1]));
- EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2]));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());
@@ -178,9 +178,9 @@ v8::Handle<v8::Value> V8WorkerContext::openDatabaseSyncCallback(const v8::Argume
if (args.Length() < 4)
return throwError(SYNTAX_ERR);
- EXCEPTION_BLOCK(String, name, toWebCoreString(args[0]));
- EXCEPTION_BLOCK(String, version, toWebCoreString(args[1]));
- EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2]));
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]);
+ TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]);
EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value());
WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder());