summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8')
-rw-r--r--WebCore/bindings/v8/IDBBindingUtilities.cpp34
-rw-r--r--WebCore/bindings/v8/IDBBindingUtilities.h3
-rw-r--r--WebCore/bindings/v8/ScriptCallStack.cpp2
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp19
-rw-r--r--WebCore/bindings/v8/ScriptController.h2
-rw-r--r--WebCore/bindings/v8/ScriptDebugServer.cpp36
-rw-r--r--WebCore/bindings/v8/ScriptDebugServer.h12
-rw-r--r--WebCore/bindings/v8/ScriptProfile.cpp4
-rwxr-xr-xWebCore/bindings/v8/ScriptValue.cpp6
-rw-r--r--WebCore/bindings/v8/SerializedScriptValue.cpp73
-rw-r--r--WebCore/bindings/v8/V8Binding.cpp6
-rw-r--r--WebCore/bindings/v8/V8Binding.h2
-rw-r--r--WebCore/bindings/v8/V8DOMWindowShell.cpp42
-rw-r--r--WebCore/bindings/v8/V8DOMWindowShell.h5
-rw-r--r--WebCore/bindings/v8/V8DOMWrapper.cpp2
-rw-r--r--WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp6
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp65
-rw-r--r--WebCore/bindings/v8/custom/V8GeolocationCustom.cpp4
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp75
-rw-r--r--WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp3
-rw-r--r--WebCore/bindings/v8/specialization/V8BindingState.cpp3
23 files changed, 261 insertions, 151 deletions
diff --git a/WebCore/bindings/v8/IDBBindingUtilities.cpp b/WebCore/bindings/v8/IDBBindingUtilities.cpp
index 4b38a61..a000a7d 100644
--- a/WebCore/bindings/v8/IDBBindingUtilities.cpp
+++ b/WebCore/bindings/v8/IDBBindingUtilities.cpp
@@ -29,7 +29,10 @@
#if ENABLE(INDEXED_DATABASE)
#include "IDBKey.h"
+#include "IDBKeyPath.h"
+#include "SerializedScriptValue.h"
#include "V8Binding.h"
+#include <wtf/Vector.h>
namespace WebCore {
@@ -45,6 +48,37 @@ PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value)
return 0;
}
+template<typename T>
+bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value)
+{
+ v8::Local<v8::Object> object = v8Value->ToObject();
+ if (!object->Has(indexOrName))
+ return false;
+ v8Value = object->Get(indexOrName);
+ return true;
+}
+
+PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const Vector<IDBKeyPathElement>& keyPath)
+{
+ v8::HandleScope scope;
+ v8::Handle<v8::Value> v8Value(value->deserialize());
+ for (size_t i = 0; i < keyPath.size(); ++i) {
+ switch (keyPath[i].type) {
+ case IDBKeyPathElement::IsIndexed:
+ if (!v8Value->IsArray() || !getValueFrom(keyPath[i].index, v8Value))
+ return 0;
+ break;
+ case IDBKeyPathElement::IsNamed:
+ if (!v8Value->IsObject() || !getValueFrom(v8String(keyPath[i].identifier), v8Value))
+ return 0;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+ return createIDBKeyFromValue(v8Value);
+}
+
} // namespace WebCore
#endif
diff --git a/WebCore/bindings/v8/IDBBindingUtilities.h b/WebCore/bindings/v8/IDBBindingUtilities.h
index 76f2bba..1a794b0 100644
--- a/WebCore/bindings/v8/IDBBindingUtilities.h
+++ b/WebCore/bindings/v8/IDBBindingUtilities.h
@@ -34,8 +34,11 @@
namespace WebCore {
class IDBKey;
+class SerializedScriptValue;
+struct IDBKeyPathElement;
PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>);
+PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const Vector<IDBKeyPathElement, 0>& keyPath);
}
diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStack.cpp
index 98ddb90..7c07829 100644
--- a/WebCore/bindings/v8/ScriptCallStack.cpp
+++ b/WebCore/bindings/v8/ScriptCallStack.cpp
@@ -171,7 +171,7 @@ bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& s
frameObject->setString("functionName", functionName.IsEmpty() ? "" : toWebCoreString(functionName));
frameObject->setNumber("lineNumber", frame->GetLineNumber());
frameObject->setNumber("column", frame->GetColumn());
- stackTrace->push(frameObject);
+ stackTrace->pushObject(frameObject);
}
return true;
#else
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index a27c5cf..903b11c 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -160,15 +160,18 @@ void ScriptController::updatePlatformScriptObjects()
notImplemented();
}
-bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
+bool ScriptController::processingUserGesture()
{
+ Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
// No script is running, so it is user-initiated unless the gesture stack
// explicitly says it is not.
- if (!m_proxy->executingScript())
+ if (!activeFrame)
return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
+ V8Proxy* activeProxy = activeFrame->script()->proxy();
+
v8::HandleScope handleScope;
- v8::Handle<v8::Context> v8Context = m_proxy->mainWorldContext();
+ v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame);
// FIXME: find all cases context can be empty:
// 1) JS is disabled;
// 2) page is NULL;
@@ -188,7 +191,11 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
// Event::fromUserGesture will return false when UserGestureIndicator::processingUserGesture() returns false.
return event->fromUserGesture();
}
- if (m_sourceURL && m_sourceURL->isNull() && !m_proxy->timerCallback()) {
+ // FIXME: We check the javascript anchor navigation from the last entered
+ // frame becuase it should only be initiated on the last entered frame in
+ // which execution began if it does happen.
+ const String* sourceURL = activeFrame->script()->sourceURL();
+ if (sourceURL && sourceURL->isNull() && !activeProxy->timerCallback()) {
// This is the <a href="javascript:window.open('...')> case -> we let it through.
return true;
}
@@ -201,7 +208,7 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
bool ScriptController::anyPageIsProcessingUserGesture() const
{
// FIXME: is this right?
- return processingUserGesture();
+ return ScriptController::processingUserGesture();
}
void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources)
@@ -484,10 +491,12 @@ void ScriptController::updateDocument()
void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& name)
{
+ m_proxy->windowShell()->namedItemAdded(doc, name);
}
void ScriptController::namedItemRemoved(HTMLDocument* doc, const AtomicString& name)
{
+ m_proxy->windowShell()->namedItemRemoved(doc, name);
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h
index cd20cda..525476d 100644
--- a/WebCore/bindings/v8/ScriptController.h
+++ b/WebCore/bindings/v8/ScriptController.h
@@ -154,7 +154,7 @@ public:
void setProcessingTimerCallback(bool processingTimerCallback) { m_processingTimerCallback = processingTimerCallback; }
// FIXME: Currently we don't use the parameter world at all.
// See http://trac.webkit.org/changeset/54182
- bool processingUserGesture(DOMWrapperWorld* world = 0) const;
+ static bool processingUserGesture();
bool anyPageIsProcessingUserGesture() const;
void setPaused(bool paused) { m_paused = paused; }
diff --git a/WebCore/bindings/v8/ScriptDebugServer.cpp b/WebCore/bindings/v8/ScriptDebugServer.cpp
index 0a432b7..0c24678 100644
--- a/WebCore/bindings/v8/ScriptDebugServer.cpp
+++ b/WebCore/bindings/v8/ScriptDebugServer.cpp
@@ -44,6 +44,19 @@
namespace WebCore {
+namespace {
+
+class ClientDataImpl : public v8::Debug::ClientData {
+public:
+ ClientDataImpl(PassOwnPtr<ScriptDebugServer::Task> task) : m_task(task) { }
+ virtual ~ClientDataImpl() { }
+ ScriptDebugServer::Task* task() const { return m_task.get(); }
+private:
+ OwnPtr<ScriptDebugServer::Task> m_task;
+};
+
+}
+
static Frame* retrieveFrame(v8::Handle<v8::Context> context)
{
if (context.IsEmpty())
@@ -209,6 +222,12 @@ void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOn
setPauseOnExceptionsFunction->Call(m_debuggerScript.get(), 1, argv);
}
+void ScriptDebugServer::pause()
+{
+ if (!m_pausedPage)
+ v8::Debug::DebugBreak();
+}
+
void ScriptDebugServer::continueProgram()
{
if (m_pausedPage)
@@ -294,6 +313,16 @@ bool ScriptDebugServer::isDebuggerAlwaysEnabled()
return m_enabled;
}
+void ScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task)
+{
+ v8::Debug::DebugBreakForCommand(new ClientDataImpl(task));
+}
+
+void ScriptDebugServer::runPendingTasks()
+{
+ v8::Debug::ProcessDebugMessages();
+}
+
void ScriptDebugServer::v8DebugEventCallback(const v8::Debug::EventDetails& eventDetails)
{
ScriptDebugServer::shared().handleV8DebugEvent(eventDetails);
@@ -302,6 +331,13 @@ void ScriptDebugServer::v8DebugEventCallback(const v8::Debug::EventDetails& even
void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventDetails)
{
v8::DebugEvent event = eventDetails.GetEvent();
+
+ if (event == v8::BreakForCommand) {
+ ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClientData());
+ data->task()->run();
+ return;
+ }
+
if (event != v8::Break && event != v8::Exception && event != v8::AfterCompile)
return;
diff --git a/WebCore/bindings/v8/ScriptDebugServer.h b/WebCore/bindings/v8/ScriptDebugServer.h
index a55388f..a1e0a47 100644
--- a/WebCore/bindings/v8/ScriptDebugServer.h
+++ b/WebCore/bindings/v8/ScriptDebugServer.h
@@ -36,12 +36,12 @@
#include "JavaScriptCallFrame.h"
#include "PlatformString.h"
#include "ScriptBreakpoint.h"
-#include "StringHash.h"
#include "Timer.h"
#include <v8-debug.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringHash.h>
namespace WebCore {
@@ -70,7 +70,7 @@ public:
PauseOnExceptionsState pauseOnExceptionsState();
void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState);
- void pause() { }
+ void pause();
void continueProgram();
void stepIntoStatement();
void stepOverStatement();
@@ -99,6 +99,14 @@ public:
void setEnabled(bool);
bool isDebuggerAlwaysEnabled();
+ class Task {
+ public:
+ virtual ~Task() { }
+ virtual void run() = 0;
+ };
+ static void interruptAndRun(PassOwnPtr<Task>);
+ void runPendingTasks();
+
private:
ScriptDebugServer();
~ScriptDebugServer() { }
diff --git a/WebCore/bindings/v8/ScriptProfile.cpp b/WebCore/bindings/v8/ScriptProfile.cpp
index 32e0066..95ac0de 100644
--- a/WebCore/bindings/v8/ScriptProfile.cpp
+++ b/WebCore/bindings/v8/ScriptProfile.cpp
@@ -72,9 +72,9 @@ static PassRefPtr<InspectorObject> buildInspectorObjectFor(const v8::CpuProfileN
const int childrenCount = node->GetChildrenCount();
for (int i = 0; i < childrenCount; i++) {
const v8::CpuProfileNode* child = node->GetChild(i);
- children->push(buildInspectorObjectFor(child));
+ children->pushObject(buildInspectorObjectFor(child));
}
- result->set("children", children);
+ result->setArray("children", children);
return result;
}
diff --git a/WebCore/bindings/v8/ScriptValue.cpp b/WebCore/bindings/v8/ScriptValue.cpp
index 6d3fe20..ebe9ccc 100755
--- a/WebCore/bindings/v8/ScriptValue.cpp
+++ b/WebCore/bindings/v8/ScriptValue.cpp
@@ -93,7 +93,7 @@ static PassRefPtr<InspectorValue> v8ToInspectorValue(v8::Handle<v8::Value> value
ASSERT_NOT_REACHED();
element = InspectorValue::null();
}
- inspectorArray->push(element);
+ inspectorArray->pushValue(element);
}
return inspectorArray;
}
@@ -105,14 +105,14 @@ static PassRefPtr<InspectorValue> v8ToInspectorValue(v8::Handle<v8::Value> value
for (uint32_t i = 0; i < length; i++) {
v8::Local<v8::Value> name = propertyNames->Get(v8::Int32::New(i));
// FIXME(yurys): v8::Object should support GetOwnPropertyNames
- if (!object->HasRealNamedProperty(v8::Handle<v8::String>::Cast(name)))
+ if (name->IsString() && !object->HasRealNamedProperty(v8::Handle<v8::String>::Cast(name)))
continue;
RefPtr<InspectorValue> propertyValue = v8ToInspectorValue(object->Get(name));
if (!propertyValue) {
ASSERT_NOT_REACHED();
continue;
}
- inspectorObject->set(toWebCoreStringWithNullCheck(name), propertyValue);
+ inspectorObject->setValue(toWebCoreStringWithNullCheck(name), propertyValue);
}
return inspectorObject;
}
diff --git a/WebCore/bindings/v8/SerializedScriptValue.cpp b/WebCore/bindings/v8/SerializedScriptValue.cpp
index 9dc4d0f..395ef1a 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.cpp
+++ b/WebCore/bindings/v8/SerializedScriptValue.cpp
@@ -183,16 +183,20 @@ public:
doWriteNumber(number);
}
- void writeBlob(const String& path)
+ void writeBlob(const String& url, const String& type, unsigned long long size)
{
append(BlobTag);
- doWriteWebCoreString(path);
+ doWriteWebCoreString(url);
+ doWriteWebCoreString(type);
+ doWriteUint64(size);
}
- void writeFile(const String& path)
+ void writeFile(const String& path, const String& url, const String& type)
{
append(FileTag);
doWriteWebCoreString(path);
+ doWriteWebCoreString(url);
+ doWriteWebCoreString(type);
}
void writeFileList(const FileList& fileList)
@@ -200,8 +204,11 @@ public:
append(FileListTag);
uint32_t length = fileList.length();
doWriteUint32(length);
- for (unsigned i = 0; i < length; ++i)
+ for (unsigned i = 0; i < length; ++i) {
doWriteWebCoreString(fileList.item(i)->path());
+ doWriteWebCoreString(fileList.item(i)->url().string());
+ doWriteWebCoreString(fileList.item(i)->type());
+ }
}
void writeImageData(uint32_t width, uint32_t height, const uint8_t* pixelData, uint32_t pixelDataLength)
@@ -251,7 +258,8 @@ private:
doWriteString(buffer->data(), buffer->size());
}
- void doWriteUint32(uint32_t value)
+ template<class T>
+ void doWriteUintHelper(T value)
{
while (true) {
uint8_t b = (value & varIntMask);
@@ -264,6 +272,16 @@ private:
}
}
+ void doWriteUint32(uint32_t value)
+ {
+ doWriteUintHelper(value);
+ }
+
+ void doWriteUint64(uint64_t value)
+ {
+ doWriteUintHelper(value);
+ }
+
void doWriteNumber(double number)
{
append(reinterpret_cast<uint8_t*>(&number), sizeof(number));
@@ -560,7 +578,7 @@ private:
Blob* blob = V8Blob::toNative(value.As<v8::Object>());
if (!blob)
return;
- m_writer.writeBlob(blob->path());
+ m_writer.writeBlob(blob->url().string(), blob->type(), blob->size());
}
void writeFile(v8::Handle<v8::Value> value)
@@ -568,7 +586,7 @@ private:
File* file = V8File::toNative(value.As<v8::Object>());
if (!file)
return;
- m_writer.writeFile(file->path());
+ m_writer.writeFile(file->path(), file->url().string(), file->type());
}
void writeFileList(v8::Handle<v8::Value> value)
@@ -852,10 +870,16 @@ private:
bool readBlob(v8::Handle<v8::Value>* value)
{
- String path;
- if (!readWebCoreString(&path))
+ String url;
+ String type;
+ uint64_t size;
+ if (!readWebCoreString(&url))
return false;
- PassRefPtr<Blob> blob = Blob::create(getScriptExecutionContext(), path);
+ if (!readWebCoreString(&type))
+ return false;
+ if (!doReadUint64(&size))
+ return false;
+ PassRefPtr<Blob> blob = Blob::create(getScriptExecutionContext(), KURL(ParsedURLString, url), type, size);
*value = toV8(blob);
return true;
}
@@ -863,9 +887,15 @@ private:
bool readFile(v8::Handle<v8::Value>* value)
{
String path;
+ String url;
+ String type;
if (!readWebCoreString(&path))
return false;
- PassRefPtr<File> file = File::create(getScriptExecutionContext(), path);
+ if (!readWebCoreString(&url))
+ return false;
+ if (!readWebCoreString(&type))
+ return false;
+ PassRefPtr<File> file = File::create(getScriptExecutionContext(), path, KURL(ParsedURLString, url), type);
*value = toV8(file);
return true;
}
@@ -878,15 +908,22 @@ private:
PassRefPtr<FileList> fileList = FileList::create();
for (unsigned i = 0; i < length; ++i) {
String path;
+ String urlString;
+ String type;
if (!readWebCoreString(&path))
return false;
- fileList->append(File::create(getScriptExecutionContext(), path));
+ if (!readWebCoreString(&urlString))
+ return false;
+ if (!readWebCoreString(&type))
+ return false;
+ fileList->append(File::create(getScriptExecutionContext(), path, KURL(ParsedURLString, urlString), type));
}
*value = toV8(fileList);
return true;
}
- bool doReadUint32(uint32_t* value)
+ template<class T>
+ bool doReadUintHelper(T* value)
{
*value = 0;
uint8_t currentByte;
@@ -901,6 +938,16 @@ private:
return true;
}
+ bool doReadUint32(uint32_t* value)
+ {
+ return doReadUintHelper(value);
+ }
+
+ bool doReadUint64(uint64_t* value)
+ {
+ return doReadUintHelper(value);
+ }
+
bool doReadNumber(double* number)
{
if (m_position + sizeof(double) > m_length)
diff --git a/WebCore/bindings/v8/V8Binding.cpp b/WebCore/bindings/v8/V8Binding.cpp
index 1272fd4..3799cdb 100644
--- a/WebCore/bindings/v8/V8Binding.cpp
+++ b/WebCore/bindings/v8/V8Binding.cpp
@@ -31,18 +31,18 @@
#include "config.h"
#include "V8Binding.h"
-#include "AtomicString.h"
#include "Element.h"
#include "MathExtras.h"
#include "PlatformString.h"
#include "QualifiedName.h"
#include "StdLibExtras.h"
-#include "StringBuffer.h"
-#include "StringHash.h"
#include "Threading.h"
#include "V8Element.h"
#include "V8Proxy.h"
+#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuffer.h>
+#include <wtf/text/StringHash.h>
namespace WebCore {
diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h
index 4656aa2..087c128 100644
--- a/WebCore/bindings/v8/V8Binding.h
+++ b/WebCore/bindings/v8/V8Binding.h
@@ -31,11 +31,11 @@
#ifndef V8Binding_h
#define V8Binding_h
-#include "AtomicString.h"
#include "BindingSecurity.h"
#include "MathExtras.h"
#include "PlatformString.h"
#include "V8DOMWrapper.h"
+#include <wtf/text/AtomicString.h>
#include <v8.h>
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index 6676f6c..435876c 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -50,6 +50,7 @@
#include "V8DOMWindow.h"
#include "V8Document.h"
#include "V8GCForContextDispose.h"
+#include "V8HTMLDocument.h"
#include "V8HiddenPropertyName.h"
#include "V8History.h"
#include "V8Location.h"
@@ -418,6 +419,12 @@ void V8DOMWindowShell::clearDocumentWrapper()
}
}
+static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* document)
+{
+ ASSERT(V8Document::toNative(wrapper) == document);
+ ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::Object>::Cast(wrapper->GetPrototype())) == document));
+}
+
void V8DOMWindowShell::updateDocumentWrapperCache()
{
v8::HandleScope handleScope;
@@ -436,6 +443,10 @@ void V8DOMWindowShell::updateDocumentWrapperCache()
}
v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document());
+ ASSERT(documentWrapper == m_document || m_document.IsEmpty());
+ if (m_document.IsEmpty())
+ updateDocumentWrapper(v8::Handle<v8::Object>::Cast(documentWrapper));
+ checkDocumentWrapper(m_document, m_frame->document());
// If instantiation of the document wrapper fails, clear the cache
// and let the DOMWindow accessor handle access to the document.
@@ -513,6 +524,37 @@ void V8DOMWindowShell::updateDocument()
updateSecurityOrigin();
}
+v8::Handle<v8::Value> getter(v8::Local<v8::String> property, const v8::AccessorInfo& info)
+{
+ // FIXME(antonm): consider passing AtomicStringImpl directly.
+ AtomicString name = v8StringToAtomicWebCoreString(property);
+ HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
+ ASSERT(htmlDocument);
+ v8::Handle<v8::Value> result = V8HTMLDocument::GetNamedProperty(htmlDocument, name);
+ if (!result.IsEmpty())
+ return result;
+ v8::Handle<v8::Value> prototype = info.Holder()->GetPrototype();
+ if (prototype->IsObject())
+ return prototype.As<v8::Object>()->Get(property);
+ return v8::Undefined();
+}
+
+void V8DOMWindowShell::namedItemAdded(HTMLDocument* doc, const AtomicString& name)
+{
+ initContextIfNeeded();
+
+ v8::HandleScope handleScope;
+ v8::Context::Scope contextScope(m_context);
+
+ ASSERT(!m_document.IsEmpty());
+ checkDocumentWrapper(m_document, doc);
+ m_document->SetAccessor(v8String(name), getter);
+}
+
+void V8DOMWindowShell::namedItemRemoved(HTMLDocument* doc, const AtomicString& name)
+{
+}
+
void V8DOMWindowShell::updateSecurityOrigin()
{
v8::HandleScope scope;
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.h b/WebCore/bindings/v8/V8DOMWindowShell.h
index 2ccb410..7958bf1 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.h
+++ b/WebCore/bindings/v8/V8DOMWindowShell.h
@@ -37,11 +37,13 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
+#include <wtf/text/AtomicString.h>
namespace WebCore {
class DOMWindow;
class Frame;
+class HTMLDocument;
// V8WindowShell represents all the per-global object state for a Frame that
// persist between navigations.
@@ -54,6 +56,9 @@ public:
// Update document object of the frame.
void updateDocument();
+ void namedItemAdded(HTMLDocument*, const AtomicString&);
+ void namedItemRemoved(HTMLDocument*, const AtomicString&);
+
// Update the security origin of a document
// (e.g., after setting docoument.domain).
void updateSecurityOrigin();
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index d6f05f4..8a72a3a 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -284,6 +284,8 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, WrapperT
if (!instance.IsEmpty()) {
// Avoid setting the DOM wrapper for failed allocations.
setDOMWrapper(instance, type, impl);
+ if (type == &V8HTMLDocument::info)
+ instance = V8HTMLDocument::WrapInShadowObject(instance, static_cast<Node*>(impl));
}
return instance;
}
diff --git a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
index 26fc626..3491170 100644
--- a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp
@@ -63,13 +63,13 @@ static v8::Handle<v8::Value> toV8Object(CanvasStyle* style)
static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value)
{
if (value->IsString())
- return CanvasStyle::create(toWebCoreString(value));
+ return CanvasStyle::createFromString(toWebCoreString(value));
if (V8CanvasGradient::HasInstance(value))
- return CanvasStyle::create(V8CanvasGradient::toNative(v8::Handle<v8::Object>::Cast(value)));
+ return CanvasStyle::createFromGradient(V8CanvasGradient::toNative(v8::Handle<v8::Object>::Cast(value)));
if (V8CanvasPattern::HasInstance(value))
- return CanvasStyle::create(V8CanvasPattern::toNative(v8::Handle<v8::Object>::Cast(value)));
+ return CanvasStyle::createFromPattern(V8CanvasPattern::toNative(v8::Handle<v8::Object>::Cast(value)));
return 0;
}
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
index 18f27cb..97d0dde 100644
--- a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "V8CustomPositionCallback.h"
+#if ENABLE(GEOLOCATION)
+
#include "ScriptExecutionContext.h"
#include "V8CustomVoidCallback.h" // For invokeCallback
#include "V8Geoposition.h"
@@ -76,3 +78,5 @@ void V8CustomPositionCallback::handleEvent(Geoposition* position)
}
} // namespace WebCore
+
+#endif // ENABLE(GEOLOCATION)
diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
index 36b5e04..906a909 100644
--- a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
+++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "V8CustomPositionErrorCallback.h"
+#if ENABLE(GEOLOCATION)
+
#include "ScriptExecutionContext.h"
#include "V8CustomVoidCallback.h" // For invokeCallback
#include "V8PositionError.h"
@@ -76,3 +78,5 @@ void V8CustomPositionErrorCallback::handleEvent(PositionError* error)
}
} // namespace WebCore
+
+#endif // ENABLE(GEOLOCATION)
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index a74faee..45cb1b4 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -67,16 +67,6 @@
#if ENABLE(WEB_SOCKETS)
#include "WebSocket.h"
#endif
-#if ENABLE(3D_CANVAS)
-#include "V8ArrayBuffer.h"
-#include "V8Int8Array.h"
-#include "V8Float32Array.h"
-#include "V8Int32Array.h"
-#include "V8Int16Array.h"
-#include "V8Uint8Array.h"
-#include "V8Uint32Array.h"
-#include "V8Uint16Array.h"
-#endif
#include "WindowFeatures.h"
namespace WebCore {
@@ -253,61 +243,6 @@ v8::Handle<v8::Value> V8DOMWindow::OptionAccessorGetter(v8::Local<v8::String> na
return V8DOMWrapper::getConstructor(&V8HTMLOptionElementConstructor::info, window);
}
-#if ENABLE(3D_CANVAS)
-
-// Temporary aliases to keep current WebGL content working during transition period to TypedArray spec.
-// To be removed before WebGL spec is finalized. (FIXME)
-v8::Handle<v8::Value> V8DOMWindow::WebGLArrayBufferAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8ArrayBuffer::info, window);
-}
-
-v8::Handle<v8::Value> V8DOMWindow::WebGLByteArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8Int8Array::info, window);
-}
-
-v8::Handle<v8::Value> V8DOMWindow::WebGLUnsignedByteArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8Uint8Array::info, window);
-}
-
-v8::Handle<v8::Value> V8DOMWindow::WebGLShortArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8Int16Array::info, window);
-}
-
-v8::Handle<v8::Value> V8DOMWindow::WebGLUnsignedShortArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8Uint16Array::info, window);
-}
-
-v8::Handle<v8::Value> V8DOMWindow::WebGLIntArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8Int32Array::info, window);
-}
-
-v8::Handle<v8::Value> V8DOMWindow::WebGLUnsignedIntArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8Uint32Array::info, window);
-}
-
-v8::Handle<v8::Value> V8DOMWindow::WebGLFloatArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- DOMWindow* window = V8DOMWindow::toNative(info.Holder());
- return V8DOMWrapper::getConstructor(&V8Float32Array::info, window);
-}
-
-#endif
-
-
v8::Handle<v8::Value> V8DOMWindow::addEventListenerCallback(const v8::Arguments& args)
{
INC_STATS("DOM.DOMWindow.addEventListener()");
diff --git a/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp b/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp
index 649c45f..54bd11c 100644
--- a/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "V8Geolocation.h"
+#if ENABLE(GEOLOCATION)
+
#include "Frame.h"
#include "Geolocation.h"
#include "V8Binding.h"
@@ -215,3 +217,5 @@ v8::Handle<v8::Value> V8Geolocation::watchPositionCallback(const v8::Arguments&
}
} // namespace WebCore
+
+#endif // ENABLE(GEOLOCATION)
diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 86f2eb5..24ac47c 100644
--- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -49,48 +49,38 @@
namespace WebCore {
-v8::Handle<v8::Boolean> V8HTMLDocument::namedPropertyDeleter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+v8::Local<v8::Object> V8HTMLDocument::WrapInShadowObject(v8::Local<v8::Object> wrapper, Node* impl)
{
- // Only handle document.all. Insert the marker object into the
- // shadow internal field to signal that document.all is no longer
- // shadowed.
- AtomicString key = v8StringToAtomicWebCoreString(name);
- DEFINE_STATIC_LOCAL(const AtomicString, all, ("all"));
- if (key != all)
- return deletionNotHandledByInterceptor();
-
- ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- v8::Local<v8::Value> marker = info.Holder()->GetInternalField(V8HTMLDocument::markerIndex);
- info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, marker);
- return v8::True();
-}
-
-v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
- INC_STATS("DOM.HTMLDocument.NamedPropertyGetter");
- AtomicString key = v8StringToAtomicWebCoreString(name);
-
- // Special case for document.all. If the value in the shadow
- // internal field is not the marker object, then document.all has
- // been temporarily shadowed and we return the value.
- DEFINE_STATIC_LOCAL(const AtomicString, all, ("all"));
- if (key == all) {
- ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- v8::Local<v8::Value> marker = info.Holder()->GetInternalField(V8HTMLDocument::markerIndex);
- v8::Local<v8::Value> value = info.Holder()->GetInternalField(V8HTMLDocument::shadowIndex);
- if (marker != value)
- return value;
+ DEFINE_STATIC_LOCAL(v8::Persistent<v8::FunctionTemplate>, shadowTemplate, ());
+ if (shadowTemplate.IsEmpty()) {
+ shadowTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New());
+ if (shadowTemplate.IsEmpty())
+ return v8::Local<v8::Object>();
+ shadowTemplate->SetClassName(v8::String::New("HTMLDocument"));
+ shadowTemplate->Inherit(V8HTMLDocument::GetTemplate());
+ shadowTemplate->InstanceTemplate()->SetInternalFieldCount(V8HTMLDocument::internalFieldCount);
}
- HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
+ v8::Local<v8::Function> shadowConstructor = shadowTemplate->GetFunction();
+ if (shadowConstructor.IsEmpty())
+ return v8::Local<v8::Object>();
- // Fast case for named elements that are not there.
+ v8::Local<v8::Object> shadow = shadowConstructor->NewInstance();
+ if (shadow.IsEmpty())
+ return v8::Local<v8::Object>();
+ V8DOMWrapper::setDOMWrapper(shadow, &V8HTMLDocument::info, impl);
+ shadow->SetPrototype(wrapper);
+ return shadow;
+}
+
+v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key)
+{
if (!htmlDocument->hasNamedItem(key.impl()) && !htmlDocument->hasExtraNamedItem(key.impl()))
return v8::Handle<v8::Value>();
RefPtr<HTMLCollection> items = htmlDocument->documentNamedItems(key);
if (!items->length())
- return notHandledByInterceptor();
+ return v8::Handle<v8::Value>();
if (items->length() == 1) {
Node* node = items->firstItem();
@@ -104,13 +94,6 @@ v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String>
return toV8(items.release());
}
-v8::Handle<v8::Value> V8HTMLDocument::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo &info)
-{
- INC_STATS("DOM.HTMLDocument.IndexedPropertyGetter");
- v8::Local<v8::Integer> indexV8 = v8::Integer::NewFromUnsigned(index);
- return namedPropertyGetter(indexV8->ToString(), info);
-}
-
// HTMLDocument ----------------------------------------------------------------
// Concatenates "args" to a string. If args is empty, returns empty string.
@@ -193,10 +176,8 @@ v8::Handle<v8::Value> V8HTMLDocument::allAccessorGetter(v8::Local<v8::String> na
void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
- INC_STATS("DOM.HTMLDocument.all._set");
- v8::Handle<v8::Object> holder = info.Holder();
- ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, value);
+ // Just emulate a normal JS behaviour---install a property on this.
+ info.This()->ForceSet(name, value);
}
v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject)
@@ -210,12 +191,6 @@ v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject)
if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
proxy->windowShell()->updateDocumentWrapper(wrapper);
}
- // Create marker object and insert it in two internal fields.
- // This is used to implement temporary shadowing of document.all.
- ASSERT(wrapper->InternalFieldCount() == V8HTMLDocument::internalFieldCount);
- v8::Local<v8::Object> marker = v8::Object::New();
- wrapper->SetInternalField(V8HTMLDocument::markerIndex, marker);
- wrapper->SetInternalField(V8HTMLDocument::shadowIndex, marker);
return wrapper;
}
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 435cf73..1b069cf 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -211,6 +211,9 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScrip
if (!val.IsEmpty() && val->IsObject())
return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
+ if (!canAccessInspectedWindow(inspectedScriptState))
+ return InjectedScript();
+
ASSERT(!m_injectedScriptSource.isEmpty());
pair<long, ScriptObject> injectedScript = injectScript(m_injectedScriptSource, inspectedScriptState);
InjectedScript result(injectedScript.second);
diff --git a/WebCore/bindings/v8/specialization/V8BindingState.cpp b/WebCore/bindings/v8/specialization/V8BindingState.cpp
index d95d578..ccdd7c8 100644
--- a/WebCore/bindings/v8/specialization/V8BindingState.cpp
+++ b/WebCore/bindings/v8/specialization/V8BindingState.cpp
@@ -81,8 +81,7 @@ void State<V8Binding>::immediatelyReportUnsafeAccessTo(Frame* target)
bool State<V8Binding>::processingUserGesture()
{
- Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
- return frame && frame->script()->processingUserGesture();
+ return ScriptController::processingUserGesture();
}
} // namespace WebCore