summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-09-29 17:32:26 +0100
committerSteve Block <steveblock@google.com>2010-09-29 17:35:08 +0100
commit68513a70bcd92384395513322f1b801e7bf9c729 (patch)
tree161b50f75a5921d61731bb25e730005994fcec85 /WebCore/bindings/v8
parentfd5c6425ce58eb75211be7718d5dee960842a37e (diff)
downloadexternal_webkit-68513a70bcd92384395513322f1b801e7bf9c729.zip
external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.gz
external_webkit-68513a70bcd92384395513322f1b801e7bf9c729.tar.bz2
Merge WebKit at r67908: Initial merge by Git
Change-Id: I43a553e7b3299b28cb6ee8aa035ed70fe342b972
Diffstat (limited to 'WebCore/bindings/v8')
-rw-r--r--WebCore/bindings/v8/DebuggerScript.js290
-rw-r--r--WebCore/bindings/v8/NPV8Object.cpp2
-rw-r--r--WebCore/bindings/v8/ScriptCachedFrameData.h2
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp4
-rw-r--r--WebCore/bindings/v8/ScriptController.h14
-rw-r--r--WebCore/bindings/v8/ScriptControllerQt.cpp49
-rw-r--r--[-rwxr-xr-x]WebCore/bindings/v8/ScriptValue.cpp0
-rw-r--r--WebCore/bindings/v8/SerializedScriptValue.cpp6
-rw-r--r--WebCore/bindings/v8/V8Binding.cpp2
-rw-r--r--WebCore/bindings/v8/V8Helpers.h2
-rw-r--r--WebCore/bindings/v8/V8NPObject.h2
-rw-r--r--WebCore/bindings/v8/V8NPUtils.h2
-rw-r--r--WebCore/bindings/v8/V8Proxy.cpp1
-rw-r--r--WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp13
-rw-r--r--WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp15
-rw-r--r--WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp139
-rw-r--r--WebCore/bindings/v8/custom/V8EntryCustom.cpp61
-rw-r--r--WebCore/bindings/v8/custom/V8EventCustom.cpp3
-rw-r--r--WebCore/bindings/v8/npruntime_internal.h12
19 files changed, 605 insertions, 14 deletions
diff --git a/WebCore/bindings/v8/DebuggerScript.js b/WebCore/bindings/v8/DebuggerScript.js
new file mode 100644
index 0000000..0222296
--- /dev/null
+++ b/WebCore/bindings/v8/DebuggerScript.js
@@ -0,0 +1,290 @@
+/*
+ * 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.
+ */
+
+(function () {
+
+var DebuggerScript = {};
+DebuggerScript._breakpoints = {};
+
+DebuggerScript.PauseOnExceptionsState = {
+ DontPauseOnExceptions : 0,
+ PauseOnAllExceptions : 1,
+ PauseOnUncaughtExceptions: 2
+};
+
+DebuggerScript.ScriptWorldType = {
+ MainWorld : 0,
+ ExtensionsWorld : 1
+};
+
+DebuggerScript._pauseOnExceptionsState = DebuggerScript.PauseOnExceptionsState.DontPauseOnExceptions;
+Debug.clearBreakOnException();
+Debug.clearBreakOnUncaughtException();
+
+DebuggerScript.getAfterCompileScript = function(eventData)
+{
+ return DebuggerScript._formatScript(eventData.script_.script_);
+}
+
+DebuggerScript.getScripts = function(contextData)
+{
+ var result = [];
+
+ if (!contextData)
+ return result;
+ var comma = contextData.indexOf(",");
+ if (comma === -1)
+ return result;
+ // Context data is a string in the following format:
+ // ("page"|"injected")","<page id>
+ var idSuffix = contextData.substring(comma); // including the comma
+
+ var scripts = Debug.scripts();
+ for (var i = 0; i < scripts.length; ++i) {
+ var script = scripts[i];
+ if (script.context_data && script.context_data.lastIndexOf(idSuffix) != -1)
+ result.push(DebuggerScript._formatScript(script));
+ }
+ return result;
+}
+
+DebuggerScript._formatScript = function(script)
+{
+ var scriptWorldType = DebuggerScript.ScriptWorldType.MainWorld;
+ if (script.context_data && script.context_data.indexOf("injected") == 0)
+ scriptWorldType = DebuggerScript.ScriptWorldType.ExtensionsWorld;
+ return {
+ id: script.id,
+ name: script.nameOrSourceURL(),
+ source: script.source,
+ lineOffset: DebuggerScript._v8ToWebkitLineNumber(script.line_offset),
+ lineCount: script.lineCount(),
+ scriptWorldType: scriptWorldType
+ };
+}
+
+DebuggerScript.setBreakpoint = function(execState, args)
+{
+ args.lineNumber = DebuggerScript._webkitToV8LineNumber(args.lineNumber);
+ var breakId = Debug.setScriptBreakPointById(args.scriptId, args.lineNumber, 0 /* column */, args.condition);
+ if (!args.enabled)
+ Debug.disableScriptBreakPoint(breakId);
+
+ var locations = Debug.findBreakPointActualLocations(breakId);
+ var actualLineNumber = locations.length ? locations[0].line : args.lineNumber;
+
+ var key = args.scriptId + ":" + actualLineNumber;
+ if (key in DebuggerScript._breakpoints) {
+ // Remove old breakpoint.
+ Debug.findBreakPoint(DebuggerScript._breakpoints[key], true);
+ }
+ DebuggerScript._breakpoints[key] = breakId;
+ return DebuggerScript._v8ToWebkitLineNumber(actualLineNumber);
+}
+
+DebuggerScript.removeBreakpoint = function(execState, args)
+{
+ args.lineNumber = DebuggerScript._webkitToV8LineNumber(args.lineNumber);
+ var key = args.scriptId + ":" + args.lineNumber;
+ var breakId = DebuggerScript._breakpoints[key];
+ if (breakId)
+ Debug.findBreakPoint(breakId, true);
+ delete DebuggerScript._breakpoints[key];
+}
+
+DebuggerScript.pauseOnExceptionsState = function()
+{
+ return DebuggerScript._pauseOnExceptionsState;
+}
+
+DebuggerScript.setPauseOnExceptionsState = function(newState)
+{
+ DebuggerScript._pauseOnExceptionsState = newState;
+
+ if (DebuggerScript.PauseOnExceptionsState.PauseOnAllExceptions === newState)
+ Debug.setBreakOnException();
+ else
+ Debug.clearBreakOnException();
+
+ if (DebuggerScript.PauseOnExceptionsState.PauseOnUncaughtExceptions === newState)
+ Debug.setBreakOnUncaughtException();
+ else
+ Debug.clearBreakOnUncaughtException();
+}
+
+DebuggerScript.currentCallFrame = function(execState, args)
+{
+ var frameCount = execState.frameCount();
+ if (frameCount === 0)
+ return undefined;
+
+ var topFrame;
+ for (var i = frameCount - 1; i >= 0; i--) {
+ var frameMirror = execState.frame(i);
+ topFrame = DebuggerScript._frameMirrorToJSCallFrame(frameMirror, topFrame);
+ }
+ return topFrame;
+}
+
+DebuggerScript.stepIntoStatement = function(execState)
+{
+ execState.prepareStep(Debug.StepAction.StepIn, 1);
+}
+
+DebuggerScript.stepOverStatement = function(execState)
+{
+ execState.prepareStep(Debug.StepAction.StepNext, 1);
+}
+
+DebuggerScript.stepOutOfFunction = function(execState)
+{
+ execState.prepareStep(Debug.StepAction.StepOut, 1);
+}
+
+DebuggerScript.editScriptSource = function(scriptId, newSource)
+{
+ var scripts = Debug.scripts();
+ var scriptToEdit = null;
+ for (var i = 0; i < scripts.length; i++) {
+ if (scripts[i].id == scriptId) {
+ scriptToEdit = scripts[i];
+ break;
+ }
+ }
+ if (!scriptToEdit)
+ throw("Script not found");
+
+ var changeLog = [];
+ Debug.LiveEdit.SetScriptSource(scriptToEdit, newSource, false, changeLog);
+ return scriptToEdit.source;
+}
+
+DebuggerScript.clearBreakpoints = function(execState, args)
+{
+ for (var key in DebuggerScript._breakpoints) {
+ var breakId = DebuggerScript._breakpoints[key];
+ Debug.findBreakPoint(breakId, true);
+ }
+ DebuggerScript._breakpoints = {};
+}
+
+DebuggerScript.setBreakpointsActivated = function(execState, args)
+{
+ Debug.debuggerFlags().breakPointsActive.setValue(args.enabled);
+}
+
+DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame)
+{
+ // Get function name.
+ var func;
+ try {
+ func = frameMirror.func();
+ } catch(e) {
+ }
+ var functionName;
+ if (func)
+ functionName = func.name() || func.inferredName();
+
+ // Get script ID.
+ var script = func.script();
+ var sourceID = script && script.id();
+
+ // Get line number.
+ var line = DebuggerScript._v8ToWebkitLineNumber(frameMirror.sourceLine());
+
+ // Get this object.
+ var thisObject = frameMirror.details_.receiver();
+
+ // Get scope chain array in format: [<scope type>, <scope object>, <scope type>, <scope object>,...]
+ var scopeChain = [];
+ var scopeType = [];
+ for (var i = 0; i < frameMirror.scopeCount(); i++) {
+ var scopeMirror = frameMirror.scope(i);
+ var scopeObjectMirror = scopeMirror.scopeObject();
+
+ var scopeObject;
+ switch (scopeMirror.scopeType()) {
+ case ScopeType.Local:
+ case ScopeType.Closure:
+ // For transient objects we create a "persistent" copy that contains
+ // the same properties.
+ scopeObject = {};
+ // Reset scope object prototype to null so that the proto properties
+ // don't appear in the local scope section.
+ scopeObject.__proto__ = null;
+ var properties = scopeObjectMirror.properties();
+ for (var j = 0; j < properties.length; j++) {
+ var name = properties[j].name();
+ if (name.charAt(0) === ".")
+ continue; // Skip internal variables like ".arguments"
+ scopeObject[name] = properties[j].value_;
+ }
+ break;
+ case ScopeType.Global:
+ case ScopeType.With:
+ case ScopeType.Catch:
+ scopeObject = scopeMirror.details_.object();
+ break;
+ }
+
+ scopeType.push(scopeMirror.scopeType());
+ scopeChain.push(scopeObject);
+ }
+
+ function evaluate(expression) {
+ return frameMirror.evaluate(expression, false).value();
+ }
+
+ return {
+ "sourceID": sourceID,
+ "line": line,
+ "functionName": functionName,
+ "type": "function",
+ "thisObject": thisObject,
+ "scopeChain": scopeChain,
+ "scopeType": scopeType,
+ "evaluate": evaluate,
+ "caller": callerFrame
+ };
+}
+
+DebuggerScript._webkitToV8LineNumber = function(line)
+{
+ return line - 1;
+};
+
+DebuggerScript._v8ToWebkitLineNumber = function(line)
+{
+ return line + 1;
+};
+
+return DebuggerScript;
+
+})();
diff --git a/WebCore/bindings/v8/NPV8Object.cpp b/WebCore/bindings/v8/NPV8Object.cpp
index 15382ad..fb97d59 100644
--- a/WebCore/bindings/v8/NPV8Object.cpp
+++ b/WebCore/bindings/v8/NPV8Object.cpp
@@ -107,7 +107,7 @@ NPObject* v8ObjectToNPObject(v8::Handle<v8::Object> object)
static NPClass V8NPObjectClass = { NP_CLASS_STRUCT_VERSION,
allocV8NPObject,
freeV8NPObject,
- 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// NPAPI's npruntime functions.
NPClass* npScriptObjectClass = &V8NPObjectClass;
diff --git a/WebCore/bindings/v8/ScriptCachedFrameData.h b/WebCore/bindings/v8/ScriptCachedFrameData.h
index f700a48..1aa1f62 100644
--- a/WebCore/bindings/v8/ScriptCachedFrameData.h
+++ b/WebCore/bindings/v8/ScriptCachedFrameData.h
@@ -51,7 +51,7 @@ public:
} // namespace WebCore
-#elif PLATFORM(ANDROID)
+#elif PLATFORM(ANDROID) || PLATFORM(QT)
// FIXME: the right guard should be ENABLE(PAGE_CACHE). Replace with the right guard, once
// https://bugs.webkit.org/show_bug.cgi?id=35061 is fixed.
//
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 903b11c..5023254 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -64,6 +64,10 @@
#include <wtf/StdLibExtras.h>
#include <wtf/text/CString.h>
+#if PLATFORM(QT)
+#include <QScriptEngine>
+#endif
+
namespace WebCore {
void ScriptController::initializeThreading()
diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h
index 525476d..3bc42ef 100644
--- a/WebCore/bindings/v8/ScriptController.h
+++ b/WebCore/bindings/v8/ScriptController.h
@@ -44,6 +44,13 @@
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
+#if PLATFORM(QT)
+#include <qglobal.h>
+QT_BEGIN_NAMESPACE
+class QScriptEngine;
+QT_END_NAMESPACE
+#endif
+
struct NPObject;
namespace WebCore {
@@ -178,6 +185,10 @@ public:
NPObject* windowScriptNPObject();
#endif
+#if PLATFORM(QT)
+ QScriptEngine* qtScriptEngine();
+#endif
+
// Dummy method to avoid a bunch of ifdef's in WebCore.
void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
@@ -193,6 +204,9 @@ private:
OwnPtr<V8Proxy> m_proxy;
typedef HashMap<Widget*, NPObject*> PluginObjectMap;
+#if PLATFORM(QT)
+ OwnPtr<QScriptEngine> m_qtScriptEngine;
+#endif
// A mapping between Widgets and their corresponding script object.
// This list is used so that when the plugin dies, we can immediately
diff --git a/WebCore/bindings/v8/ScriptControllerQt.cpp b/WebCore/bindings/v8/ScriptControllerQt.cpp
new file mode 100644
index 0000000..246921e
--- /dev/null
+++ b/WebCore/bindings/v8/ScriptControllerQt.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ScriptController.h"
+
+#include <QScriptEngine>
+
+namespace WebCore {
+
+QScriptEngine* ScriptController::qtScriptEngine()
+{
+ if (!m_qtScriptEngine) {
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(m_frame);
+ v8::Context::Scope scope(v8Context);
+ if (v8Context.IsEmpty())
+ return 0;
+ m_qtScriptEngine = new QScriptEngine(QScriptEngine::AdoptCurrentContext);
+ }
+ return m_qtScriptEngine.get();
+}
+
+}
+// vim: ts=4 sw=4 et
diff --git a/WebCore/bindings/v8/ScriptValue.cpp b/WebCore/bindings/v8/ScriptValue.cpp
index ebe9ccc..ebe9ccc 100755..100644
--- a/WebCore/bindings/v8/ScriptValue.cpp
+++ b/WebCore/bindings/v8/ScriptValue.cpp
diff --git a/WebCore/bindings/v8/SerializedScriptValue.cpp b/WebCore/bindings/v8/SerializedScriptValue.cpp
index 0b908b8..4e5354e 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.cpp
+++ b/WebCore/bindings/v8/SerializedScriptValue.cpp
@@ -879,7 +879,7 @@ private:
return false;
if (!doReadUint64(&size))
return false;
- PassRefPtr<Blob> blob = Blob::create(getScriptExecutionContext(), KURL(ParsedURLString, url), type, size);
+ PassRefPtr<Blob> blob = Blob::create(KURL(ParsedURLString, url), type, size);
*value = toV8(blob);
return true;
}
@@ -895,7 +895,7 @@ private:
return false;
if (!readWebCoreString(&type))
return false;
- PassRefPtr<File> file = File::create(getScriptExecutionContext(), path, KURL(ParsedURLString, url), type);
+ PassRefPtr<File> file = File::create(path, KURL(ParsedURLString, url), type);
*value = toV8(file);
return true;
}
@@ -916,7 +916,7 @@ private:
return false;
if (!readWebCoreString(&type))
return false;
- fileList->append(File::create(getScriptExecutionContext(), path, KURL(ParsedURLString, urlString), type));
+ fileList->append(File::create(path, KURL(ParsedURLString, urlString), type));
}
*value = toV8(fileList);
return true;
diff --git a/WebCore/bindings/v8/V8Binding.cpp b/WebCore/bindings/v8/V8Binding.cpp
index bfbc647..d0bf0ca 100644
--- a/WebCore/bindings/v8/V8Binding.cpp
+++ b/WebCore/bindings/v8/V8Binding.cpp
@@ -61,7 +61,7 @@ public:
}
explicit WebCoreStringResource(const AtomicString& string)
- : m_plainString(string)
+ : m_plainString(string.string())
, m_atomicString(string)
{
#ifndef NDEBUG
diff --git a/WebCore/bindings/v8/V8Helpers.h b/WebCore/bindings/v8/V8Helpers.h
index e90f5d6..43d765a 100644
--- a/WebCore/bindings/v8/V8Helpers.h
+++ b/WebCore/bindings/v8/V8Helpers.h
@@ -31,7 +31,7 @@
#ifndef V8Helpers_h
#define V8Helpers_h
-#include "npruntime.h"
+#include "npruntime_internal.h"
#include <v8.h>
namespace WebCore {
diff --git a/WebCore/bindings/v8/V8NPObject.h b/WebCore/bindings/v8/V8NPObject.h
index a540ca9..832d649 100644
--- a/WebCore/bindings/v8/V8NPObject.h
+++ b/WebCore/bindings/v8/V8NPObject.h
@@ -34,7 +34,7 @@
#if PLATFORM(CHROMIUM)
#include <bindings/npruntime.h>
#else
-#include "npruntime.h"
+#include "npruntime_internal.h"
#endif
#include <v8.h>
diff --git a/WebCore/bindings/v8/V8NPUtils.h b/WebCore/bindings/v8/V8NPUtils.h
index 78414b4..dc6185b 100644
--- a/WebCore/bindings/v8/V8NPUtils.h
+++ b/WebCore/bindings/v8/V8NPUtils.h
@@ -33,7 +33,7 @@
#if PLATFORM(CHROMIUM)
#include <bindings/npruntime.h>
#else
-#include "npruntime.h"
+#include "npruntime_internal.h"
#endif
#include <v8.h>
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index b9e4b7f..27e09e6 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -77,6 +77,7 @@
#include <wtf/StdLibExtras.h>
#include <wtf/StringExtras.h>
#include <wtf/UnusedParam.h>
+#include <wtf/text/CString.h>
#ifdef ANDROID_INSTRUMENT
#include "TimeCounter.h"
diff --git a/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp b/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
index 7ca18ab..c8a975b 100644
--- a/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
@@ -33,6 +33,7 @@
#include "DOMStringMap.h"
#include "V8Binding.h"
+#include "V8DOMWrapper.h"
namespace WebCore {
@@ -93,4 +94,16 @@ v8::Handle<v8::Value> V8DOMStringMap::namedPropertySetter(v8::Local<v8::String>
return value;
}
+v8::Handle<v8::Value> toV8(DOMStringMap* impl)
+{
+ if (!impl)
+ return v8::Null();
+ 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);
+ return wrapper;
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 45cb1b4..f7c75f7 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -605,9 +605,11 @@ bool V8DOMWindow::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::V
if (key->IsString()) {
String name = toWebCoreString(key);
-
- // Allow access of GET and HAS if index is a subframe.
- if ((type == v8::ACCESS_GET || type == v8::ACCESS_HAS) && target->tree()->child(name))
+ // Notice that we can't call HasRealNamedProperty for ACCESS_HAS
+ // because that would generate infinite recursion.
+ if (type == v8::ACCESS_HAS && target->tree()->child(name))
+ return true;
+ if (type == v8::ACCESS_GET && target->tree()->child(name) && !host->HasRealNamedProperty(key->ToString()))
return true;
}
@@ -628,8 +630,11 @@ bool V8DOMWindow::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t inde
if (!target)
return false;
- // Allow access of GET and HAS if index is a subframe.
- if ((type == v8::ACCESS_GET || type == v8::ACCESS_HAS) && target->tree()->child(index))
+ // Notice that we can't call HasRealNamedProperty for ACCESS_HAS
+ // because that would generate infinite recursion.
+ if (type == v8::ACCESS_HAS && target->tree()->child(index))
+ return true;
+ if (type == v8::ACCESS_GET && target->tree()->child(index) && !host->HasRealIndexedProperty(index))
return true;
return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false);
diff --git a/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp b/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
new file mode 100644
index 0000000..286b154
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
@@ -0,0 +1,139 @@
+/*
+ * 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 "V8DirectoryEntry.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "DirectoryEntry.h"
+#include "ExceptionCode.h"
+#include "V8Binding.h"
+#include "V8BindingMacros.h"
+#include "V8EntryCallback.h"
+#include "V8ErrorCallback.h"
+#include "V8Flags.h"
+#include "V8Proxy.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8DirectoryEntry::getDirectoryCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.DirectoryEntry.getDirectory");
+ DirectoryEntry* imp = V8DirectoryEntry::toNative(args.Holder());
+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, path, args[0]);
+ if (args.Length() <= 1) {
+ imp->getDirectory(path);
+ return v8::Handle<v8::Value>();
+ }
+ RefPtr<Flags> flags;
+ if (!isUndefinedOrNull(args[1]) && args[1]->IsObject() && !V8Flags::HasInstance(args[1])) {
+ EXCEPTION_BLOCK(v8::Handle<v8::Object>, object, v8::Handle<v8::Object>::Cast(args[1]));
+ flags = Flags::create();
+ v8::Local<v8::Value> v8Create = object->Get(v8::String::New("create"));
+ if (!v8Create.IsEmpty() && !isUndefinedOrNull(v8Create)) {
+ EXCEPTION_BLOCK(bool, isCreate, v8Create->BooleanValue());
+ flags->setCreate(isCreate);
+ }
+ v8::Local<v8::Value> v8Exclusive = object->Get(v8::String::New("exclusive"));
+ if (!v8Exclusive.IsEmpty() && !isUndefinedOrNull(v8Exclusive)) {
+ EXCEPTION_BLOCK(bool, isExclusive, v8Exclusive->BooleanValue());
+ flags->setExclusive(isExclusive);
+ }
+ } else {
+ EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
+ flags = adoptRef(tmp_flags);
+ }
+ RefPtr<EntryCallback> successCallback;
+ if (args.Length() > 2 && !args[2]->IsNull() && !args[2]->IsUndefined()) {
+ if (!args[2]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ successCallback = V8EntryCallback::create(args[2], getScriptExecutionContext());
+ }
+ RefPtr<ErrorCallback> errorCallback;
+ if (args.Length() > 3 && !args[3]->IsNull() && !args[3]->IsUndefined()) {
+ if (!args[3]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ errorCallback = V8ErrorCallback::create(args[3], getScriptExecutionContext());
+ }
+ imp->getDirectory(path, flags, successCallback, errorCallback);
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> V8DirectoryEntry::getFileCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.DirectoryEntry.getFile");
+ DirectoryEntry* imp = V8DirectoryEntry::toNative(args.Holder());
+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, path, args[0]);
+ if (args.Length() <= 1) {
+ imp->getFile(path);
+ return v8::Handle<v8::Value>();
+ }
+ RefPtr<Flags> flags;
+ if (!isUndefinedOrNull(args[1]) && args[1]->IsObject() && !V8Flags::HasInstance(args[1])) {
+ EXCEPTION_BLOCK(v8::Handle<v8::Object>, object, v8::Handle<v8::Object>::Cast(args[1]));
+ flags = Flags::create();
+ v8::Local<v8::Value> v8Create = object->Get(v8::String::New("create"));
+ if (!v8Create.IsEmpty() && !isUndefinedOrNull(v8Create)) {
+ EXCEPTION_BLOCK(bool, isCreate, v8Create->BooleanValue());
+ flags->setCreate(isCreate);
+ }
+ v8::Local<v8::Value> v8Exclusive = object->Get(v8::String::New("exclusive"));
+ if (!v8Exclusive.IsEmpty() && !isUndefinedOrNull(v8Exclusive)) {
+ EXCEPTION_BLOCK(bool, isExclusive, v8Exclusive->BooleanValue());
+ flags->setExclusive(isExclusive);
+ }
+ } else {
+ EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
+ flags = adoptRef(tmp_flags);
+ }
+ RefPtr<EntryCallback> successCallback;
+ if (args.Length() > 2 && !args[2]->IsNull() && !args[2]->IsUndefined()) {
+ if (!args[2]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ successCallback = V8EntryCallback::create(args[2], getScriptExecutionContext());
+ }
+ RefPtr<ErrorCallback> errorCallback;
+ if (args.Length() > 3 && !args[3]->IsNull() && !args[3]->IsUndefined()) {
+ if (!args[3]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ errorCallback = V8ErrorCallback::create(args[3], getScriptExecutionContext());
+ }
+ imp->getFile(path, flags, successCallback, errorCallback);
+ return v8::Handle<v8::Value>();
+}
+
+
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/WebCore/bindings/v8/custom/V8EntryCustom.cpp b/WebCore/bindings/v8/custom/V8EntryCustom.cpp
new file mode 100644
index 0000000..c02cd6f
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8EntryCustom.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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 "Entry.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "V8Attr.h"
+#include "V8Binding.h"
+#include "V8BindingState.h"
+#include "V8DirectoryEntry.h"
+#include "V8Entry.h"
+#include "V8FileEntry.h"
+#include "V8Proxy.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(Entry* impl)
+{
+ if (!impl)
+ return v8::Null();
+
+ if (impl->isFile())
+ return toV8(static_cast<FileEntry*>(impl));
+
+ ASSERT(impl->isDirectory());
+ return toV8(static_cast<DirectoryEntry*>(impl));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp
index e0bb02b..f96ba7a 100644
--- a/WebCore/bindings/v8/custom/V8EventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp
@@ -43,6 +43,7 @@
#include "V8DeviceMotionEvent.h"
#include "V8DeviceOrientationEvent.h"
#include "V8ErrorEvent.h"
+#include "V8HashChangeEvent.h"
#include "V8IDBErrorEvent.h"
#include "V8IDBSuccessEvent.h"
#include "V8KeyboardEvent.h"
@@ -120,6 +121,8 @@ v8::Handle<v8::Value> toV8(Event* impl)
#endif
return toV8(static_cast<UIEvent*>(impl));
}
+ if (impl->isHashChangeEvent())
+ return toV8(static_cast<HashChangeEvent*>(impl));
if (impl->isMutationEvent())
return toV8(static_cast<MutationEvent*>(impl));
if (impl->isOverflowEvent())
diff --git a/WebCore/bindings/v8/npruntime_internal.h b/WebCore/bindings/v8/npruntime_internal.h
index 75bf2b0..40d639f 100644
--- a/WebCore/bindings/v8/npruntime_internal.h
+++ b/WebCore/bindings/v8/npruntime_internal.h
@@ -38,4 +38,16 @@
#undef Auto
#undef Complex
#undef Status
+ #undef CursorShape
+ #undef FocusIn
+ #undef FocusOut
+ #undef KeyPress
+ #undef KeyRelease
+ #undef Unsorted
+ #undef Bool
+ #undef FontChange
+ #undef GrayScale
+ #undef NormalState
+ #undef True
+ #undef False
#endif