summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/WebCore/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/bindings')
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/ScriptControllerBase.cpp88
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSBindingsAllInOne.cpp150
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.cpp82
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.h73
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayBufferConstructor.h3
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayCustom.cpp33
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp34
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.h9
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp33
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.h8
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp45
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.h8
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp59
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h10
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp69
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.h6
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp48
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h6
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp43
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.h7
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp361
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h117
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.cpp31
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h14
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp43
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h14
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp43
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp8
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h6
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp5
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp20
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h7
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSEventSourceCustom.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp64
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h (renamed from src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.cpp)22
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h56
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp135
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSHTMLDocumentCustom.cpp5
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp48
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp6
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.h6
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSLocationCustom.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp14
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSMessageEventCustom.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp19
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.h2
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp26
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp2
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp8
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h4
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp12
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerCustom.cpp7
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSWebSocketCustom.cpp21
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp8
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp19
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp19
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp15
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.h10
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp15
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp199
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h51
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm2
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp6
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp8
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h1
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp6
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h8
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp5
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h1
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.cpp839
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.h199
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp3
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h3
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm14
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm16
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm139
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm43
-rw-r--r--src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm463
87 files changed, 3051 insertions, 1053 deletions
diff --git a/src/3rdparty/webkit/WebCore/bindings/ScriptControllerBase.cpp b/src/3rdparty/webkit/WebCore/bindings/ScriptControllerBase.cpp
new file mode 100644
index 0000000000..7dc68ef196
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/ScriptControllerBase.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "ScriptController.h"
+
+#include "Frame.h"
+#include "Page.h"
+#include "ScriptSourceCode.h"
+#include "ScriptValue.h"
+#include "Settings.h"
+#include "XSSAuditor.h"
+
+namespace WebCore {
+
+ScriptValue ScriptController::executeScript(const String& script, bool forceUserGesture)
+{
+ return executeScript(ScriptSourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url()));
+}
+
+ScriptValue ScriptController::executeScript(const ScriptSourceCode& sourceCode)
+{
+ if (!isEnabled() || isPaused())
+ return ScriptValue();
+
+ bool wasInExecuteScript = m_inExecuteScript;
+ m_inExecuteScript = true;
+
+ ScriptValue result = evaluate(sourceCode);
+
+ if (!wasInExecuteScript) {
+ m_inExecuteScript = false;
+ Document::updateStyleForAllDocuments();
+ }
+
+ return result;
+}
+
+
+bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument)
+{
+ if (!protocolIsJavaScript(url))
+ return false;
+
+ if (m_frame->page() && !m_frame->page()->javaScriptURLsAreAllowed())
+ return true;
+
+ if (m_frame->inViewSourceMode())
+ return true;
+
+ const int javascriptSchemeLength = sizeof("javascript:") - 1;
+
+ String script = decodeURLEscapeSequences(url.string().substring(javascriptSchemeLength));
+ ScriptValue result;
+ if (xssAuditor()->canEvaluateJavaScriptURL(script))
+ result = executeScript(script, userGesture);
+
+ String scriptResult;
+ if (!result.getString(scriptResult))
+ return true;
+
+ // FIXME: We should always replace the document, but doing so
+ // synchronously can cause crashes:
+ // http://bugs.webkit.org/show_bug.cgi?id=16782
+ if (replaceDocument)
+ m_frame->loader()->replaceDocument(scriptResult);
+
+ return true;
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp
index 9411ad80f7..6eca7bdbed 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp
@@ -46,29 +46,21 @@ namespace WebCore {
JSValue JSAbstractWorker::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSAbstractWorker::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSBindingsAllInOne.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSBindingsAllInOne.cpp
new file mode 100644
index 0000000000..f08303a0c6
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSBindingsAllInOne.cpp
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2009 Apple 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 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 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.
+ */
+
+// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
+
+#include "GCController.cpp"
+#include "JSAbstractWorkerCustom.cpp"
+#include "JSAttrCustom.cpp"
+#include "JSAudioConstructor.cpp"
+#include "JSCDATASectionCustom.cpp"
+#include "JSCSSRuleCustom.cpp"
+#include "JSCSSRuleListCustom.cpp"
+#include "JSCSSStyleDeclarationCustom.cpp"
+#include "JSCSSValueCustom.cpp"
+#include "JSCallbackData.cpp"
+#include "JSCanvasRenderingContext2DCustom.cpp"
+#include "JSCanvasRenderingContextCustom.cpp"
+#include "JSClipboardCustom.cpp"
+#include "JSConsoleCustom.cpp"
+#include "JSCoordinatesCustom.cpp"
+#include "JSCustomSQLStatementCallback.cpp"
+#include "JSCustomSQLStatementErrorCallback.cpp"
+#include "JSCustomSQLTransactionCallback.cpp"
+#include "JSCustomSQLTransactionErrorCallback.cpp"
+#include "JSCustomVoidCallback.cpp"
+#include "JSCustomXPathNSResolver.cpp"
+#include "JSDOMApplicationCacheCustom.cpp"
+#include "JSDOMBinding.cpp"
+#include "JSDOMGlobalObject.cpp"
+#include "JSDOMWindowBase.cpp"
+#include "JSDOMWindowCustom.cpp"
+#include "JSDOMWindowShell.cpp"
+#include "JSDataGridColumnListCustom.cpp"
+#include "JSDataGridDataSource.cpp"
+#include "JSDatabaseCustom.cpp"
+#include "JSDedicatedWorkerContextCustom.cpp"
+#include "JSDesktopNotificationsCustom.cpp"
+#include "JSDocumentCustom.cpp"
+#include "JSDocumentFragmentCustom.cpp"
+#include "JSElementCustom.cpp"
+#include "JSEventCustom.cpp"
+#include "JSEventListener.cpp"
+#include "JSEventSourceConstructor.cpp"
+#include "JSEventSourceCustom.cpp"
+#include "JSEventTarget.cpp"
+#include "JSExceptionBase.cpp"
+#include "JSHTMLAllCollectionCustom.cpp"
+#include "JSHTMLAppletElementCustom.cpp"
+#include "JSHTMLCanvasElementCustom.cpp"
+#include "JSHTMLCollectionCustom.cpp"
+#include "JSHTMLDataGridElementCustom.cpp"
+#include "JSHTMLDocumentCustom.cpp"
+#include "JSHTMLElementCustom.cpp"
+#include "JSHTMLEmbedElementCustom.cpp"
+#include "JSHTMLFormElementCustom.cpp"
+#include "JSHTMLFrameElementCustom.cpp"
+#include "JSHTMLFrameSetElementCustom.cpp"
+#include "JSHTMLIFrameElementCustom.cpp"
+#include "JSHTMLInputElementCustom.cpp"
+#include "JSHTMLObjectElementCustom.cpp"
+#include "JSHTMLOptionsCollectionCustom.cpp"
+#include "JSHTMLSelectElementCustom.cpp"
+#include "JSHistoryCustom.cpp"
+#include "JSImageConstructor.cpp"
+#include "JSImageDataCustom.cpp"
+#include "JSInspectedObjectWrapper.cpp"
+#include "JSInspectorBackendCustom.cpp"
+#include "JSJavaScriptCallFrameCustom.cpp"
+#include "JSLazyEventListener.cpp"
+#include "JSLocationCustom.cpp"
+#include "JSMessageChannelConstructor.cpp"
+#include "JSMessageChannelCustom.cpp"
+#include "JSMessageEventCustom.cpp"
+#include "JSMessagePortCustom.cpp"
+#include "JSMimeTypeArrayCustom.cpp"
+#include "JSNamedNodeMapCustom.cpp"
+#include "JSNavigatorCustom.cpp"
+#include "JSNodeCustom.cpp"
+#include "JSNodeFilterCondition.cpp"
+#include "JSNodeFilterCustom.cpp"
+#include "JSNodeIteratorCustom.cpp"
+#include "JSNodeListCustom.cpp"
+#include "JSOptionConstructor.cpp"
+#include "JSPluginArrayCustom.cpp"
+#include "JSPluginCustom.cpp"
+#include "JSPluginElementFunctions.cpp"
+#include "JSQuarantinedObjectWrapper.cpp"
+#include "JSSQLResultSetRowListCustom.cpp"
+#include "JSSQLTransactionCustom.cpp"
+#include "JSSVGElementInstanceCustom.cpp"
+#include "JSSVGLengthCustom.cpp"
+#include "JSSVGMatrixCustom.cpp"
+#include "JSSVGPathSegCustom.cpp"
+#include "JSSVGPathSegListCustom.cpp"
+#include "JSSVGPointListCustom.cpp"
+#include "JSSharedWorkerConstructor.cpp"
+#include "JSSharedWorkerCustom.cpp"
+#include "JSStorageCustom.cpp"
+#include "JSStyleSheetCustom.cpp"
+#include "JSStyleSheetListCustom.cpp"
+#include "JSTextCustom.cpp"
+#include "JSTreeWalkerCustom.cpp"
+#include "JSWebKitCSSMatrixConstructor.cpp"
+#include "JSWebKitPointConstructor.cpp"
+#include "JSWebSocketConstructor.cpp"
+#include "JSWebSocketCustom.cpp"
+#include "JSWorkerConstructor.cpp"
+#include "JSWorkerContextBase.cpp"
+#include "JSWorkerContextCustom.cpp"
+#include "JSWorkerCustom.cpp"
+#include "JSXMLHttpRequestConstructor.cpp"
+#include "JSXMLHttpRequestCustom.cpp"
+#include "JSXMLHttpRequestUploadCustom.cpp"
+#include "JSXSLTProcessorConstructor.cpp"
+#include "JSXSLTProcessorCustom.cpp"
+#include "ScheduledAction.cpp"
+#include "ScriptArray.cpp"
+#include "ScriptCachedFrameData.cpp"
+#include "ScriptCallFrame.cpp"
+#include "ScriptCallStack.cpp"
+#include "ScriptController.cpp"
+#include "ScriptControllerWin.cpp"
+#include "ScriptEventListener.cpp"
+#include "ScriptFunctionCall.cpp"
+#include "ScriptObjectQuarantine.cpp"
+#include "ScriptState.cpp"
+#include "SerializedScriptValue.cpp"
+#include "WorkerScriptController.cpp"
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.cpp
new file mode 100644
index 0000000000..38292c7b68
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2007, 2008, 2009 Apple 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 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 "JSCallbackData.h"
+
+#include "Document.h"
+#include "JSDOMBinding.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+void JSCallbackData::deleteData(void* context)
+{
+ delete static_cast<JSCallbackData*>(context);
+}
+
+JSValue JSCallbackData::invokeCallback(MarkedArgumentBuffer& args, bool* raisedException)
+{
+ ASSERT(callback());
+ ASSERT(globalObject());
+
+ ExecState* exec = globalObject()->globalExec();
+
+ JSValue function;
+ {
+ // Switch worlds, just in case handleEvent is a getter and causes JS execution!
+ EnterDOMWrapperWorld worldEntry(exec, m_isolatedWorld.get());
+ function = callback()->get(exec, Identifier(exec, "handleEvent"));
+ }
+ CallData callData;
+ CallType callType = function.getCallData(callData);
+ if (callType == CallTypeNone) {
+ callType = callback()->getCallData(callData);
+ if (callType == CallTypeNone)
+ return JSValue();
+ function = callback();
+ }
+
+ globalObject()->globalData()->timeoutChecker.start();
+ JSValue result = callInWorld(exec, function, callType, callData, callback(), args, m_isolatedWorld.get());
+ globalObject()->globalData()->timeoutChecker.stop();
+
+ Document::updateStyleForAllDocuments();
+
+ if (exec->hadException()) {
+ reportCurrentException(exec);
+ if (raisedException)
+ *raisedException = true;
+ return result;
+ }
+
+ return result;
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.h
new file mode 100644
index 0000000000..5c867019c1
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2007, 2008, 2009 Apple 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 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 JSCallbackData_h
+#define JSCallbackData_h
+
+#include "JSDOMBinding.h"
+#include "JSDOMGlobalObject.h"
+#include <runtime/JSObject.h>
+#include <runtime/Protect.h>
+#include <wtf/Threading.h>
+
+namespace WebCore {
+
+// We have to clean up this data on the main thread because unprotecting a
+// JSObject on a non-main thread without synchronization would corrupt the heap
+// (and synchronization would be slow).
+
+class JSCallbackData {
+public:
+ static void deleteData(void*);
+
+ JSCallbackData(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
+ : m_callback(callback)
+ , m_globalObject(globalObject)
+ , m_isolatedWorld(currentWorld(globalObject->globalExec()))
+ {
+ }
+
+ ~JSCallbackData()
+ {
+ ASSERT(isMainThread());
+ }
+
+ JSC::JSObject* callback() { return m_callback.get(); }
+ JSDOMGlobalObject* globalObject() { return m_globalObject.get(); }
+
+ JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer&, bool* raisedException = 0);
+
+private:
+ JSC::ProtectedPtr<JSC::JSObject> m_callback;
+ JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
+ RefPtr<DOMWrapperWorld> m_isolatedWorld;
+};
+
+} // namespace WebCore
+
+#endif // JSCallbackData_h
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayBufferConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayBufferConstructor.h
index 44c9000c42..5f1254ed96 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayBufferConstructor.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayBufferConstructor.h
@@ -47,8 +47,9 @@ namespace WebCore {
//
RefPtr<C> arrayObject;
+ // For the 0 args case, just create an object without a buffer
if (args.size() < 1)
- return 0;
+ return C::create(0, 0, 0);
if (args.at(0).isObject()) {
RefPtr<CanvasArrayBuffer> buffer = toCanvasArrayBuffer(args.at(0));
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayCustom.cpp
index 4aa15475b1..14548d7e39 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCanvasArrayCustom.cpp
@@ -29,6 +29,13 @@
#include "config.h"
#include "JSCanvasArray.h"
+#include "JSCanvasByteArray.h"
+#include "JSCanvasUnsignedByteArray.h"
+#include "JSCanvasShortArray.h"
+#include "JSCanvasUnsignedShortArray.h"
+#include "JSCanvasIntArray.h"
+#include "JSCanvasUnsignedIntArray.h"
+#include "JSCanvasFloatArray.h"
#include "CanvasArray.h"
@@ -38,17 +45,21 @@ namespace WebCore {
JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, CanvasArray* object)
{
- if (!object)
- return jsUndefined();
-
-
-
-#if ENABLE(3D_CANVAS)
- if (object->is3d())
- return getDOMObjectWrapper<JSCanvasRenderingContext3D>(exec, globalObject, static_cast<CanvasRenderingContext3D*>(object));
-#endif
- ASSERT(object->is2d());
- return getDOMObjectWrapper<JSCanvasRenderingContext2D>(exec, globalObject, static_cast<CanvasRenderingContext2D*>(object));
+ if (object->isFloatArray())
+ return getDOMObjectWrapper<JSCanvasFloatArray>(exec, globalObject, static_cast<CanvasFloatArray*>(object));
+ if (object->isUnsignedByteArray())
+ return getDOMObjectWrapper<JSCanvasUnsignedByteArray>(exec, globalObject, static_cast<CanvasUnsignedByteArray*>(object));
+ if (object->isByteArray())
+ return getDOMObjectWrapper<JSCanvasByteArray>(exec, globalObject, static_cast<CanvasByteArray*>(object));
+ if (object->isIntArray())
+ return getDOMObjectWrapper<JSCanvasIntArray>(exec, globalObject, static_cast<CanvasIntArray*>(object));
+ if (object->isUnsignedIntArray())
+ return getDOMObjectWrapper<JSCanvasUnsignedIntArray>(exec, globalObject, static_cast<CanvasUnsignedIntArray*>(object));
+ if (object->isShortArray())
+ return getDOMObjectWrapper<JSCanvasShortArray>(exec, globalObject, static_cast<CanvasShortArray*>(object));
+ if (object->isUnsignedShortArray())
+ return getDOMObjectWrapper<JSCanvasUnsignedShortArray>(exec, globalObject, static_cast<CanvasUnsignedShortArray*>(object));
+ return jsUndefined();
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp
index 707442362c..e5f83aa10d 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp
@@ -36,45 +36,19 @@ namespace WebCore {
using namespace JSC;
JSCustomPositionCallback::JSCustomPositionCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_callback(callback)
- , m_globalObject(globalObject)
+ : m_data(callback, globalObject)
{
}
void JSCustomPositionCallback::handleEvent(Geoposition* geoposition)
{
- ASSERT(m_callback);
- ASSERT(m_globalObject);
-
- ExecState* exec = m_globalObject->globalExec();
-
- JSC::JSLock lock(SilenceAssertionsOnly);
-
- JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent"));
- CallData callData;
- CallType callType = function.getCallData(callData);
- if (callType == CallTypeNone) {
- callType = m_callback->getCallData(callData);
- if (callType == CallTypeNone) {
- // FIXME: Should an exception be thrown here?
- return;
- }
- function = m_callback;
- }
-
RefPtr<JSCustomPositionCallback> protect(this);
+ JSC::JSLock lock(SilenceAssertionsOnly);
+ ExecState* exec = m_data.globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), geoposition));
-
- m_globalObject->globalData()->timeoutChecker.start();
- call(exec, function, callType, callData, m_callback, args);
- m_globalObject->globalData()->timeoutChecker.stop();
-
- if (exec->hadException())
- reportCurrentException(exec);
-
- Document::updateStyleForAllDocuments();
+ m_data.invokeCallback(args);
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.h
index 15a166af1a..ad5528dc23 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.h
@@ -26,14 +26,14 @@
#ifndef JSCustomPositionCallback_h
#define JSCustomPositionCallback_h
+#include "JSCallbackData.h"
#include "PositionCallback.h"
-#include "JSDOMGlobalObject.h"
-#include <runtime/Protect.h>
#include <wtf/Forward.h>
namespace WebCore {
class Geoposition;
+class JSDOMGlobalObject;
class JSCustomPositionCallback : public PositionCallback {
public:
@@ -46,9 +46,8 @@ private:
JSCustomPositionCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
virtual void handleEvent(Geoposition*);
-
- JSC::ProtectedPtr<JSC::JSObject> m_callback;
- JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
+
+ JSCallbackData m_data;
};
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp
index 9109cd1e2c..bd64deb48d 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp
@@ -36,45 +36,20 @@ namespace WebCore {
using namespace JSC;
JSCustomPositionErrorCallback::JSCustomPositionErrorCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_callback(callback)
- , m_globalObject(globalObject)
+ : m_data(callback, globalObject)
{
}
void JSCustomPositionErrorCallback::handleEvent(PositionError* positionError)
{
- ASSERT(m_callback);
- ASSERT(m_globalObject);
+ RefPtr<JSCustomPositionErrorCallback> protect(this);
- ExecState* exec = m_globalObject->globalExec();
-
JSC::JSLock lock(SilenceAssertionsOnly);
-
- JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent"));
- CallData callData;
- CallType callType = function.getCallData(callData);
- if (callType == CallTypeNone) {
- callType = m_callback->getCallData(callData);
- if (callType == CallTypeNone) {
- // FIXME: Should an exception be thrown here?
- return;
- }
- function = m_callback;
- }
-
- RefPtr<JSCustomPositionErrorCallback> protect(this);
-
+ ExecState* exec = m_data.globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), positionError));
- m_globalObject->globalData()->timeoutChecker.start();
- call(exec, function, callType, callData, m_callback, args);
- m_globalObject->globalData()->timeoutChecker.stop();
-
- if (exec->hadException())
- reportCurrentException(exec);
-
- Document::updateStyleForAllDocuments();
+ m_data.invokeCallback(args);
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.h
index d97e967e06..59328ca9eb 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.h
@@ -26,9 +26,8 @@
#ifndef JSCustomPositionErrorCallback_h
#define JSCustomPositionErrorCallback_h
+#include "JSCallbackData.h"
#include "PositionErrorCallback.h"
-#include "JSDOMGlobalObject.h"
-#include <runtime/Protect.h>
#include <wtf/Forward.h>
namespace WebCore {
@@ -45,9 +44,8 @@ public:
private:
JSCustomPositionErrorCallback(JSC::JSObject* callback, JSDOMGlobalObject* globalObject);
virtual void handleEvent(PositionError*);
-
- JSC::ProtectedPtr<JSC::JSObject> m_callback;
- JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
+
+ JSCallbackData m_data;
};
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp
index cdeda8fe42..1f6bd95e9a 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp
@@ -36,55 +36,38 @@
#include "JSSQLResultSet.h"
#include "JSSQLTransaction.h"
#include <runtime/JSLock.h>
+#include <wtf/MainThread.h>
namespace WebCore {
using namespace JSC;
JSCustomSQLStatementCallback::JSCustomSQLStatementCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_callback(callback)
- , m_globalObject(globalObject)
+ : m_data(new JSCallbackData(callback, globalObject))
{
}
-void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLResultSet* resultSet, bool& raisedException)
+JSCustomSQLStatementCallback::~JSCustomSQLStatementCallback()
{
- ASSERT(m_callback);
- ASSERT(m_globalObject);
-
- ExecState* exec = m_globalObject->globalExec();
-
- JSC::JSLock lock(SilenceAssertionsOnly);
+ callOnMainThread(JSCallbackData::deleteData, m_data);
+#ifndef NDEBUG
+ m_data = 0;
+#endif
+}
- JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent"));
- CallData callData;
- CallType callType = function.getCallData(callData);
- if (callType == CallTypeNone) {
- callType = m_callback->getCallData(callData);
- if (callType == CallTypeNone) {
- // FIXME: Should an exception be thrown here?
- return;
- }
- function = m_callback;
- }
+void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLResultSet* resultSet, bool& raisedException)
+{
+ ASSERT(m_data);
RefPtr<JSCustomSQLStatementCallback> protect(this);
+ JSC::JSLock lock(SilenceAssertionsOnly);
+ ExecState* exec = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction));
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), resultSet));
-
- m_globalObject->globalData()->timeoutChecker.start();
- call(exec, function, callType, callData, m_callback, args);
- m_globalObject->globalData()->timeoutChecker.stop();
-
- if (exec->hadException()) {
- reportCurrentException(exec);
-
- raisedException = true;
- }
- Document::updateStyleForAllDocuments();
+ m_data->invokeCallback(args, &raisedException);
}
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.h
index e6600c5cf9..259aecf130 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.h
@@ -31,9 +31,8 @@
#if ENABLE(DATABASE)
-#include "JSDOMGlobalObject.h"
+#include "JSCallbackData.h"
#include "SQLStatementCallback.h"
-#include <runtime/Protect.h>
#include <wtf/Forward.h>
namespace WebCore {
@@ -46,14 +45,15 @@ public:
{
return adoptRef(new JSCustomSQLStatementCallback(callback, globalObject));
}
+
+ virtual ~JSCustomSQLStatementCallback();
virtual void handleEvent(SQLTransaction*, SQLResultSet*, bool& raisedException);
private:
JSCustomSQLStatementCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
- JSC::ProtectedPtr<JSC::JSObject> m_callback;
- JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
+ JSCallbackData* m_data;
};
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
index ea47c647f7..61785092bf 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
@@ -32,70 +32,51 @@
#if ENABLE(DATABASE)
#include "Frame.h"
-#include "ScriptController.h"
+#include "JSCallbackData.h"
#include "JSSQLError.h"
#include "JSSQLTransaction.h"
+#include "ScriptController.h"
#include <runtime/JSLock.h>
+#include <wtf/MainThread.h>
namespace WebCore {
using namespace JSC;
JSCustomSQLStatementErrorCallback::JSCustomSQLStatementErrorCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_callback(callback)
- , m_globalObject(globalObject)
+ : m_data(new JSCallbackData(callback, globalObject))
{
}
-
-bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
+
+JSCustomSQLStatementErrorCallback::~JSCustomSQLStatementErrorCallback()
{
- ASSERT(m_callback);
- ASSERT(m_globalObject);
-
- ExecState* exec = m_globalObject->globalExec();
-
- JSC::JSLock lock(SilenceAssertionsOnly);
-
- JSValue handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent"));
- CallData handleEventCallData;
- CallType handleEventCallType = handleEventFunction.getCallData(handleEventCallData);
- CallData callbackCallData;
- CallType callbackCallType = CallTypeNone;
+ callOnMainThread(JSCallbackData::deleteData, m_data);
+#ifndef NDEBUG
+ m_data = 0;
+#endif
+}
- if (handleEventCallType == CallTypeNone) {
- callbackCallType = m_callback->getCallData(callbackCallData);
- if (callbackCallType == CallTypeNone) {
- // FIXME: Should an exception be thrown here?
- return true;
- }
- }
+bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
+{
+ ASSERT(m_data);
RefPtr<JSCustomSQLStatementErrorCallback> protect(this);
+ JSC::JSLock lock(SilenceAssertionsOnly);
+ ExecState* exec = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction));
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), error));
-
- JSValue result;
- m_globalObject->globalData()->timeoutChecker.start();
- if (handleEventCallType != CallTypeNone)
- result = call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_callback, args);
- else
- result = call(exec, m_callback, callbackCallType, callbackCallData, m_callback, args);
- m_globalObject->globalData()->timeoutChecker.stop();
-
- if (exec->hadException()) {
- reportCurrentException(exec);
-
+
+ bool raisedException = false;
+ JSValue result = m_data->invokeCallback(args, &raisedException);
+ if (raisedException) {
// The spec says:
// "If the error callback returns false, then move on to the next statement..."
// "Otherwise, the error callback did not return false, or there was no error callback"
// Therefore an exception and returning true are the same thing - so, return true on an exception
return true;
}
-
- Document::updateStyleForAllDocuments();
-
return result.toBoolean(exec);
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h
index e03ac35bd6..ac4e45f9f7 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h
@@ -37,7 +37,8 @@
#include <wtf/Forward.h>
namespace WebCore {
-
+
+class JSCallbackData;
class SQLError;
class JSCustomSQLStatementErrorCallback : public SQLStatementErrorCallback {
@@ -46,14 +47,15 @@ public:
{
return adoptRef(new JSCustomSQLStatementErrorCallback(callback, globalObject));
}
-
+
+ virtual ~JSCustomSQLStatementErrorCallback();
+
virtual bool handleEvent(SQLTransaction*, SQLError*);
private:
JSCustomSQLStatementErrorCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
- JSC::ProtectedPtr<JSC::JSObject> m_callback;
- JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
+ JSCallbackData* m_data;
};
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
index 18863455ac..456022f9f7 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
@@ -32,6 +32,7 @@
#if ENABLE(DATABASE)
#include "Frame.h"
+#include "JSCallbackData.h"
#include "JSDOMGlobalObject.h"
#include "JSSQLTransaction.h"
#include "Page.h"
@@ -48,42 +49,17 @@ using namespace JSC;
static WTF::RefCountedLeakCounter counter("JSCustomSQLTransactionCallback");
#endif
-// We have to clean up the data on the main thread because unprotecting the
-// JSObject on a non-main thread would register that thread for JavaScript
-// garbage collection, which could unnecessarily slow things down.
-
-class JSCustomSQLTransactionCallback::Data {
-public:
- Data(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_callback(callback)
- , m_globalObject(globalObject)
- {
- }
-
- JSObject* callback() { return m_callback; }
- JSDOMGlobalObject* globalObject() { return m_globalObject.get(); }
-
-private:
- ProtectedPtr<JSObject> m_callback;
- ProtectedPtr<JSDOMGlobalObject> m_globalObject;
-};
-
JSCustomSQLTransactionCallback::JSCustomSQLTransactionCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_data(new Data(callback, globalObject))
+ : m_data(new JSCallbackData(callback, globalObject))
{
#ifndef NDEBUG
counter.increment();
#endif
}
-void JSCustomSQLTransactionCallback::deleteData(void* context)
-{
- delete static_cast<Data*>(context);
-}
-
JSCustomSQLTransactionCallback::~JSCustomSQLTransactionCallback()
{
- callOnMainThread(deleteData, m_data);
+ callOnMainThread(JSCallbackData::deleteData, m_data);
#ifndef NDEBUG
m_data = 0;
counter.decrement();
@@ -93,47 +69,14 @@ JSCustomSQLTransactionCallback::~JSCustomSQLTransactionCallback()
void JSCustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bool& raisedException)
{
ASSERT(m_data);
- ASSERT(m_data->callback());
- ASSERT(m_data->globalObject());
- JSDOMGlobalObject* globalObject = m_data->globalObject();
- ExecState* exec = globalObject->globalExec();
-
- JSC::JSLock lock(SilenceAssertionsOnly);
-
- JSValue handleEventFunction = m_data->callback()->get(exec, Identifier(exec, "handleEvent"));
- CallData handleEventCallData;
- CallType handleEventCallType = handleEventFunction.getCallData(handleEventCallData);
- CallData callbackCallData;
- CallType callbackCallType = CallTypeNone;
-
- if (handleEventCallType == CallTypeNone) {
- callbackCallType = m_data->callback()->getCallData(callbackCallData);
- if (callbackCallType == CallTypeNone) {
- // FIXME: Should an exception be thrown here?
- return;
- }
- }
-
RefPtr<JSCustomSQLTransactionCallback> protect(this);
+ JSC::JSLock lock(SilenceAssertionsOnly);
+ ExecState* exec = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction));
-
- globalObject->globalData()->timeoutChecker.start();
- if (handleEventCallType != CallTypeNone)
- call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_data->callback(), args);
- else
- call(exec, m_data->callback(), callbackCallType, callbackCallData, m_data->callback(), args);
- globalObject->globalData()->timeoutChecker.stop();
-
- if (exec->hadException()) {
- reportCurrentException(exec);
-
- raisedException = true;
- }
-
- Document::updateStyleForAllDocuments();
+ m_data->invokeCallback(args, &raisedException);
}
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.h
index f7f78f244e..f142e59b81 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.h
@@ -41,6 +41,7 @@ namespace JSC {
namespace WebCore {
class Frame;
+class JSCallbackData;
class JSDOMGlobalObject;
class JSCustomSQLTransactionCallback : public SQLTransactionCallback {
@@ -57,10 +58,7 @@ public:
private:
JSCustomSQLTransactionCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
- static void deleteData(void*);
-
- class Data;
- Data* m_data;
+ JSCallbackData* m_data;
};
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp
index b2f828018d..331e014c79 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp
@@ -32,54 +32,40 @@
#if ENABLE(DATABASE)
#include "Frame.h"
-#include "ScriptController.h"
+#include "JSCallbackData.h"
#include "JSSQLError.h"
+#include "ScriptController.h"
#include <runtime/JSLock.h>
+#include <wtf/MainThread.h>
namespace WebCore {
using namespace JSC;
JSCustomSQLTransactionErrorCallback::JSCustomSQLTransactionErrorCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_callback(callback)
- , m_globalObject(globalObject)
+ : m_data(new JSCallbackData(callback, globalObject))
{
}
-
-void JSCustomSQLTransactionErrorCallback::handleEvent(SQLError* error)
-{
- ASSERT(m_callback);
- ASSERT(m_globalObject);
-
- ExecState* exec = m_globalObject->globalExec();
- JSC::JSLock lock(SilenceAssertionsOnly);
+JSCustomSQLTransactionErrorCallback::~JSCustomSQLTransactionErrorCallback()
+{
+ callOnMainThread(JSCallbackData::deleteData, m_data);
+#ifndef NDEBUG
+ m_data = 0;
+#endif
+}
- JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent"));
- CallData callData;
- CallType callType = function.getCallData(callData);
- if (callType == CallTypeNone) {
- callType = m_callback->getCallData(callData);
- if (callType == CallTypeNone) {
- // FIXME: Should an exception be thrown here?
- return;
- }
- function = m_callback;
- }
+void JSCustomSQLTransactionErrorCallback::handleEvent(SQLError* error)
+{
+ ASSERT(m_data);
RefPtr<JSCustomSQLTransactionErrorCallback> protect(this);
+ JSC::JSLock lock(SilenceAssertionsOnly);
+ ExecState* exec = m_data->globalObject()->globalExec();
MarkedArgumentBuffer args;
args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), error));
-
- m_globalObject->globalData()->timeoutChecker.start();
- call(exec, function, callType, callData, m_callback, args);
- m_globalObject->globalData()->timeoutChecker.stop();
-
- if (exec->hadException())
- reportCurrentException(exec);
-
- Document::updateStyleForAllDocuments();
+ m_data->invokeCallback(args);
}
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h
index 42fcbce667..54bf33b8c5 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h
@@ -38,6 +38,7 @@
namespace WebCore {
+class JSCallbackData;
class SQLError;
class JSCustomSQLTransactionErrorCallback : public SQLTransactionErrorCallback {
@@ -47,13 +48,14 @@ public:
return adoptRef(new JSCustomSQLTransactionErrorCallback(callback, globalObject));
}
+ virtual ~JSCustomSQLTransactionErrorCallback();
+
virtual void handleEvent(SQLError*);
private:
JSCustomSQLTransactionErrorCallback(JSC::JSObject* callback, JSDOMGlobalObject* globalObject);
- JSC::ProtectedPtr<JSC::JSObject> m_callback;
- JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
+ JSCallbackData* m_data;
};
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp
index 5300c42b5d..0edd66fdde 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp
@@ -30,53 +30,38 @@
#include "JSCustomVoidCallback.h"
#include "Frame.h"
+#include "JSCallbackData.h"
#include "JSDOMWindowCustom.h"
#include "ScriptController.h"
#include <runtime/JSLock.h>
+#include <wtf/MainThread.h>
namespace WebCore {
using namespace JSC;
JSCustomVoidCallback::JSCustomVoidCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
- : m_callback(callback)
- , m_globalObject(globalObject)
+ : m_data(new JSCallbackData(callback, globalObject))
{
}
+
+JSCustomVoidCallback::~JSCustomVoidCallback()
+{
+ callOnMainThread(JSCallbackData::deleteData, m_data);
+#ifndef NDEBUG
+ m_data = 0;
+#endif
+}
void JSCustomVoidCallback::handleEvent()
{
- ASSERT(m_callback);
- ASSERT(m_globalObject);
+ ASSERT(m_data);
- ExecState* exec = m_globalObject->globalExec();
-
- JSC::JSLock lock(SilenceAssertionsOnly);
-
- JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent"));
- CallData callData;
- CallType callType = function.getCallData(callData);
- if (callType == CallTypeNone) {
- callType = m_callback->getCallData(callData);
- if (callType == CallTypeNone) {
- // FIXME: Should an exception be thrown here?
- return;
- }
- function = m_callback;
- }
-
RefPtr<JSCustomVoidCallback> protect(this);
+ JSC::JSLock lock(SilenceAssertionsOnly);
MarkedArgumentBuffer args;
-
- m_globalObject->globalData()->timeoutChecker.start();
- call(exec, function, callType, callData, m_callback, args);
- m_globalObject->globalData()->timeoutChecker.stop();
-
- if (exec->hadException())
- reportCurrentException(exec);
-
- Document::updateStyleForAllDocuments();
+ m_data->invokeCallback(args);
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.h b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.h
index f3db49f0de..4b8d7ea394 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.h
@@ -36,6 +36,8 @@
namespace WebCore {
+class JSCallbackData;
+
class JSCustomVoidCallback : public VoidCallback {
public:
static PassRefPtr<JSCustomVoidCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)
@@ -43,13 +45,14 @@ public:
return adoptRef(new JSCustomVoidCallback(callback, globalObject));
}
+ virtual ~JSCustomVoidCallback();
+
virtual void handleEvent();
private:
JSCustomVoidCallback(JSC::JSObject* callback, JSDOMGlobalObject*);
- JSC::ProtectedPtr<JSC::JSObject> m_callback;
- JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
+ JSCallbackData* m_data;
};
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
index da4a53a952..c2884d7a3a 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
@@ -90,7 +90,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
args.append(jsString(exec, prefix));
m_globalObject->globalData()->timeoutChecker.start();
- JSValue retval = call(exec, function, callType, callData, m_customResolver, args);
+ JSValue retval = callInWorld(exec, function, callType, callData, m_customResolver, args, currentWorld(m_globalObject->globalExec()));
m_globalObject->globalData()->timeoutChecker.stop();
String result;
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp
index 49ef5e3aca..91ee51ada4 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp
@@ -87,29 +87,21 @@ JSValue JSDOMApplicationCache::remove(ExecState* exec, const ArgList& args)
JSValue JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp
index 515c0883f6..ef69c7b1e9 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp
@@ -21,10 +21,13 @@
#include "config.h"
#include "JSDOMBinding.h"
+#include "debugger/DebuggerCallFrame.h"
+
#include "ActiveDOMObject.h"
#include "DOMCoreException.h"
#include "Document.h"
#include "EventException.h"
+#include "ExceptionBase.h"
#include "ExceptionCode.h"
#include "Frame.h"
#include "HTMLAudioElement.h"
@@ -35,6 +38,7 @@
#include "JSDOMCoreException.h"
#include "JSDOMWindowCustom.h"
#include "JSEventException.h"
+#include "JSExceptionBase.h"
#include "JSNode.h"
#include "JSRangeException.h"
#include "JSXMLHttpRequestException.h"
@@ -42,6 +46,7 @@
#include "MessagePort.h"
#include "RangeException.h"
#include "ScriptController.h"
+#include "Settings.h"
#include "XMLHttpRequestException.h"
#include <runtime/Error.h>
#include <runtime/JSFunction.h>
@@ -70,6 +75,7 @@ namespace WebCore {
using namespace HTMLNames;
typedef Document::JSWrapperCache JSWrapperCache;
+typedef Document::JSWrapperCacheMap JSWrapperCacheMap;
// For debugging, keep a set of wrappers currently registered, and check that
// all are unregistered before they are destroyed. This has helped us fix at
@@ -78,6 +84,7 @@ typedef Document::JSWrapperCache JSWrapperCache;
static void addWrapper(DOMObject* wrapper);
static void removeWrapper(DOMObject* wrapper);
static void removeWrappers(const JSWrapperCache& wrappers);
+static void removeWrappers(const DOMObjectWrapperMap& wrappers);
#ifdef NDEBUG
@@ -93,6 +100,10 @@ static inline void removeWrappers(const JSWrapperCache&)
{
}
+static inline void removeWrappers(const DOMObjectWrapperMap&)
+{
+}
+
#else
static HashSet<DOMObject*>& wrapperSet()
@@ -122,7 +133,15 @@ static void removeWrapper(DOMObject* wrapper)
static void removeWrappers(const JSWrapperCache& wrappers)
{
- for (JSWrapperCache::const_iterator it = wrappers.begin(); it != wrappers.end(); ++it)
+ JSWrapperCache::const_iterator wrappersEnd = wrappers.end();
+ for (JSWrapperCache::const_iterator it = wrappers.begin(); it != wrappersEnd; ++it)
+ removeWrapper(it->second);
+}
+
+static inline void removeWrappers(const DOMObjectWrapperMap& wrappers)
+{
+ DOMObjectWrapperMap::const_iterator wrappersEnd = wrappers.end();
+ for (DOMObjectWrapperMap::const_iterator it = wrappers.begin(); it != wrappersEnd; ++it)
removeWrapper(it->second);
}
@@ -133,67 +152,120 @@ DOMObject::~DOMObject()
#endif
-class DOMObjectWrapperMap {
-public:
- static DOMObjectWrapperMap& mapFor(JSGlobalData&);
+DOMWrapperWorld::DOMWrapperWorld(JSC::JSGlobalData* globalData)
+ : m_globalData(globalData)
+{
+}
+
+DOMWrapperWorld::~DOMWrapperWorld()
+{
+ JSGlobalData::ClientData* clientData = m_globalData->clientData;
+ ASSERT(clientData);
+ static_cast<WebCoreJSClientData*>(clientData)->forgetWorld(this);
+
+ removeWrappers(m_wrappers);
- DOMObject* get(void* objectHandle)
+ for (HashSet<Document*>::iterator iter = documentsWithWrappers.begin(); iter != documentsWithWrappers.end(); ++iter)
+ forgetWorldOfDOMNodesForDocument(*iter, this);
+ for (HashSet<ScriptController*>::iterator iter = scriptControllersWithShells.begin(); iter != scriptControllersWithShells.end(); ++iter)
+ (*iter)->forgetWorld(this);
+}
+
+EnterDOMWrapperWorld::EnterDOMWrapperWorld(JSC::JSGlobalData& globalData, DOMWrapperWorld* isolatedWorld)
+{
+ JSGlobalData::ClientData* clientData = globalData.clientData;
+ ASSERT(clientData);
+ m_clientData = static_cast<WebCoreJSClientData*>(clientData);
+ m_clientData->m_worldStack.append(isolatedWorld);
+}
+
+EnterDOMWrapperWorld::EnterDOMWrapperWorld(JSC::ExecState* exec, DOMWrapperWorld* isolatedWorld)
+{
+ JSGlobalData::ClientData* clientData = exec->globalData().clientData;
+ ASSERT(clientData);
+ m_clientData = static_cast<WebCoreJSClientData*>(clientData);
+ m_clientData->m_worldStack.append(isolatedWorld);
+}
+
+EnterDOMWrapperWorld::~EnterDOMWrapperWorld()
+{
+ m_clientData->m_worldStack.removeLast();
+}
+
+class JSGlobalDataWorldIterator {
+public:
+ JSGlobalDataWorldIterator(JSGlobalData* globalData)
+ : m_pos(static_cast<WebCoreJSClientData*>(globalData->clientData)->m_worldSet.begin())
+ , m_end(static_cast<WebCoreJSClientData*>(globalData->clientData)->m_worldSet.end())
{
- return m_map.get(objectHandle);
}
- void set(void* objectHandle, DOMObject* wrapper)
+ operator bool()
{
- addWrapper(wrapper);
- m_map.set(objectHandle, wrapper);
+ return m_pos != m_end;
}
- void remove(void* objectHandle)
+ DOMWrapperWorld* operator*()
{
- removeWrapper(m_map.take(objectHandle));
+ ASSERT(m_pos != m_end);
+ return *m_pos;
}
-private:
- HashMap<void*, DOMObject*> m_map;
-};
-
-// Map from static HashTable instances to per-GlobalData ones.
-class DOMObjectHashTableMap {
-public:
- static DOMObjectHashTableMap& mapFor(JSGlobalData&);
-
- ~DOMObjectHashTableMap()
+ DOMWrapperWorld* operator->()
{
- HashMap<const JSC::HashTable*, JSC::HashTable>::iterator mapEnd = m_map.end();
- for (HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.begin(); iter != m_map.end(); ++iter)
- iter->second.deleteTable();
+ ASSERT(m_pos != m_end);
+ return *m_pos;
}
- const JSC::HashTable* get(const JSC::HashTable* staticTable)
+ JSGlobalDataWorldIterator& operator++()
{
- HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.find(staticTable);
- if (iter != m_map.end())
- return &iter->second;
- return &m_map.set(staticTable, JSC::HashTable(*staticTable)).first->second;
+ ++m_pos;
+ return *this;
}
private:
- HashMap<const JSC::HashTable*, JSC::HashTable> m_map;
+ HashSet<DOMWrapperWorld*>::iterator m_pos;
+ HashSet<DOMWrapperWorld*>::iterator m_end;
};
-class WebCoreJSClientData : public JSGlobalData::ClientData {
-public:
- DOMObjectHashTableMap hashTableMap;
- DOMObjectWrapperMap wrapperMap;
-};
+static inline DOMWrapperWorld* currentWorld(JSC::JSGlobalData& globalData)
+{
+ JSGlobalData::ClientData* clientData = globalData.clientData;
+ ASSERT(clientData);
+ return static_cast<WebCoreJSClientData*>(clientData)->currentWorld();
+}
+
+DOMWrapperWorld* currentWorld(JSC::ExecState* exec)
+{
+ return currentWorld(exec->globalData());
+}
+
+DOMWrapperWorld* normalWorld(JSC::JSGlobalData& globalData)
+{
+ JSGlobalData::ClientData* clientData = globalData.clientData;
+ ASSERT(clientData);
+ return static_cast<WebCoreJSClientData*>(clientData)->normalWorld();
+}
+
+DOMWrapperWorld* mainThreadNormalWorld()
+{
+ ASSERT(isMainThread());
+ return normalWorld(*JSDOMWindow::commonJSGlobalData());
+}
+
+DOMWrapperWorld* mainThreadCurrentWorld()
+{
+ ASSERT(isMainThread());
+
+ JSGlobalData::ClientData* clientData = JSDOMWindowBase::commonJSGlobalData()->clientData;
+ ASSERT(clientData);
+ return static_cast<WebCoreJSClientData*>(clientData)->currentWorld();
+}
DOMObjectHashTableMap& DOMObjectHashTableMap::mapFor(JSGlobalData& globalData)
{
JSGlobalData::ClientData* clientData = globalData.clientData;
- if (!clientData) {
- clientData = new WebCoreJSClientData;
- globalData.clientData = clientData;
- }
+ ASSERT(clientData);
return static_cast<WebCoreJSClientData*>(clientData)->hashTableMap;
}
@@ -202,64 +274,102 @@ const JSC::HashTable* getHashTableForGlobalData(JSGlobalData& globalData, const
return DOMObjectHashTableMap::mapFor(globalData).get(staticTable);
}
-inline DOMObjectWrapperMap& DOMObjectWrapperMap::mapFor(JSGlobalData& globalData)
+//inline DOMObjectWrapperMap& DOMObjectWrapperMap::mapFor(JSGlobalData& globalData)
+inline DOMObjectWrapperMap& DOMObjectWrapperMapFor(JSGlobalData& globalData)
{
- JSGlobalData::ClientData* clientData = globalData.clientData;
- if (!clientData) {
- clientData = new WebCoreJSClientData;
- globalData.clientData = clientData;
- }
- return static_cast<WebCoreJSClientData*>(clientData)->wrapperMap;
+ return currentWorld(globalData)->m_wrappers;
}
DOMObject* getCachedDOMObjectWrapper(JSGlobalData& globalData, void* objectHandle)
{
- return DOMObjectWrapperMap::mapFor(globalData).get(objectHandle);
+ return DOMObjectWrapperMapFor(globalData).get(objectHandle);
}
void cacheDOMObjectWrapper(JSGlobalData& globalData, void* objectHandle, DOMObject* wrapper)
{
- DOMObjectWrapperMap::mapFor(globalData).set(objectHandle, wrapper);
+ addWrapper(wrapper);
+ DOMObjectWrapperMapFor(globalData).set(objectHandle, wrapper);
}
-void forgetDOMObject(JSGlobalData& globalData, void* objectHandle)
+JSNode* getCachedDOMNodeWrapper(Document* document, Node* node)
{
- DOMObjectWrapperMap::mapFor(globalData).remove(objectHandle);
+ if (document)
+ return document->getWrapperCache(mainThreadCurrentWorld())->get(node);
+ return static_cast<JSNode*>(DOMObjectWrapperMapFor(*JSDOMWindow::commonJSGlobalData()).get(node));
}
-JSNode* getCachedDOMNodeWrapper(Document* document, Node* node)
+void forgetDOMObject(DOMObject* wrapper, void* objectHandle)
{
- if (!document)
- return static_cast<JSNode*>(DOMObjectWrapperMap::mapFor(*JSDOMWindow::commonJSGlobalData()).get(node));
- return document->wrapperCache().get(node);
+ JSC::JSGlobalData* globalData = Heap::heap(wrapper)->globalData();
+ for (JSGlobalDataWorldIterator worldIter(globalData); worldIter; ++worldIter) {
+ DOMObjectWrapperMap& wrappers = worldIter->m_wrappers;
+ DOMObjectWrapperMap::iterator iter = wrappers.find(objectHandle);
+ if ((iter != wrappers.end()) && (iter->second == wrapper)) {
+ removeWrapper(wrapper);
+ wrappers.remove(iter);
+ return;
+ }
+ }
+
+ // If the world went away, it should have removed this wrapper from the set.
+ ASSERT(!wrapperSet().contains(wrapper));
}
-void forgetDOMNode(Document* document, Node* node)
+void forgetDOMNode(DOMObject* wrapper, Node* node, Document* document)
{
if (!document) {
- DOMObjectWrapperMap::mapFor(*JSDOMWindow::commonJSGlobalData()).remove(node);
+ forgetDOMObject(wrapper, node);
return;
}
- removeWrapper(document->wrapperCache().take(node));
+
+ JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap();
+ for (JSWrapperCacheMap::iterator wrappersIter = wrapperCacheMap.begin(); wrappersIter != wrapperCacheMap.end(); ++wrappersIter) {
+ JSWrapperCache* wrappers = wrappersIter->second;
+ JSWrapperCache::iterator iter = wrappers->find(node);
+ if ((iter != wrappers->end()) && (iter->second == wrapper)) {
+ wrappers->remove(iter);
+ removeWrapper(wrapper);
+ return;
+ }
+ }
+
+ // If the world went away, it should have removed this wrapper from the set.
+ ASSERT(!wrapperSet().contains(wrapper));
}
void cacheDOMNodeWrapper(Document* document, Node* node, JSNode* wrapper)
{
if (!document) {
- DOMObjectWrapperMap::mapFor(*JSDOMWindow::commonJSGlobalData()).set(node, wrapper);
+ addWrapper(wrapper);
+ DOMObjectWrapperMapFor(*JSDOMWindow::commonJSGlobalData()).set(node, wrapper);
return;
}
addWrapper(wrapper);
- document->wrapperCache().set(node, wrapper);
+ document->getWrapperCache(mainThreadCurrentWorld())->set(node, wrapper);
}
void forgetAllDOMNodesForDocument(Document* document)
{
ASSERT(document);
- removeWrappers(document->wrapperCache());
+ JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap();
+ JSWrapperCacheMap::const_iterator wrappersMapEnd = wrapperCacheMap.end();
+ for (JSWrapperCacheMap::const_iterator wrappersMapIter = wrapperCacheMap.begin(); wrappersMapIter != wrappersMapEnd; ++wrappersMapIter) {
+ JSWrapperCache* wrappers = wrappersMapIter->second;
+ removeWrappers(*wrappers);
+ delete wrappers;
+ wrappersMapIter->first->forgetDocument(document);
+ }
+}
+
+void forgetWorldOfDOMNodesForDocument(Document* document, DOMWrapperWorld* world)
+{
+ JSWrapperCache* wrappers = document->wrapperCacheMap().take(world);
+ ASSERT(wrappers); // 'world' should only know about 'document' if 'document' knows about 'world'!
+ removeWrappers(*wrappers);
+ delete wrappers;
}
-static inline bool isObservableThroughDOM(JSNode* jsNode)
+static inline bool isObservableThroughDOM(JSNode* jsNode, DOMWrapperWorld* world)
{
// Certain conditions implicitly make a JS DOM node wrapper observable
// through the DOM, even if no explicit reference to it remains.
@@ -285,14 +395,14 @@ static inline bool isObservableThroughDOM(JSNode* jsNode)
// the custom markChildren functions rather than here.
if (node->isElementNode()) {
if (NamedNodeMap* attributes = static_cast<Element*>(node)->attributeMap()) {
- if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), attributes)) {
+ if (DOMObject* wrapper = world->m_wrappers.get(attributes)) {
if (wrapper->hasCustomProperties())
return true;
}
}
if (node->isStyledElement()) {
if (CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(node)->inlineStyleDecl()) {
- if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), style)) {
+ if (DOMObject* wrapper = world->m_wrappers.get(style)) {
if (wrapper->hasCustomProperties())
return true;
}
@@ -300,7 +410,7 @@ static inline bool isObservableThroughDOM(JSNode* jsNode)
}
if (static_cast<Element*>(node)->hasTagName(canvasTag)) {
if (CanvasRenderingContext* context = static_cast<HTMLCanvasElement*>(node)->renderingContext()) {
- if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), context)) {
+ if (DOMObject* wrapper = world->m_wrappers.get(context)) {
if (wrapper->hasCustomProperties())
return true;
}
@@ -331,14 +441,19 @@ static inline bool isObservableThroughDOM(JSNode* jsNode)
return false;
}
-void markDOMNodesForDocument(MarkStack& markStack, Document* doc)
+void markDOMNodesForDocument(MarkStack& markStack, Document* document)
{
- JSWrapperCache& nodeDict = doc->wrapperCache();
- JSWrapperCache::iterator nodeEnd = nodeDict.end();
- for (JSWrapperCache::iterator nodeIt = nodeDict.begin(); nodeIt != nodeEnd; ++nodeIt) {
- JSNode* jsNode = nodeIt->second;
- if (isObservableThroughDOM(jsNode))
- markStack.append(jsNode);
+ JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap();
+ for (JSWrapperCacheMap::iterator wrappersIter = wrapperCacheMap.begin(); wrappersIter != wrapperCacheMap.end(); ++wrappersIter) {
+ DOMWrapperWorld* world = wrappersIter->first;
+ JSWrapperCache* nodeDict = wrappersIter->second;
+
+ JSWrapperCache::iterator nodeEnd = nodeDict->end();
+ for (JSWrapperCache::iterator nodeIt = nodeDict->begin(); nodeIt != nodeEnd; ++nodeIt) {
+ JSNode* jsNode = nodeIt->second;
+ if (isObservableThroughDOM(jsNode, world))
+ markStack.append(jsNode);
+ }
}
}
@@ -351,12 +466,10 @@ void markActiveObjectsForContext(MarkStack& markStack, JSGlobalData& globalData,
HashMap<ActiveDOMObject*, void*>::const_iterator activeObjectsEnd = activeObjects.end();
for (HashMap<ActiveDOMObject*, void*>::const_iterator iter = activeObjects.begin(); iter != activeObjectsEnd; ++iter) {
if (iter->first->hasPendingActivity()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, iter->second);
// Generally, an active object with pending activity must have a wrapper to mark its listeners.
// However, some ActiveDOMObjects don't have JS wrappers (timers created by setTimeout is one example).
// FIXME: perhaps need to make sure even timers have a markable 'wrapper'.
- if (wrapper)
- markStack.append(wrapper);
+ markDOMObjectWrapper(markStack, globalData, iter->second);
}
}
@@ -364,10 +477,31 @@ void markActiveObjectsForContext(MarkStack& markStack, JSGlobalData& globalData,
HashSet<MessagePort*>::const_iterator portsEnd = messagePorts.end();
for (HashSet<MessagePort*>::const_iterator iter = messagePorts.begin(); iter != portsEnd; ++iter) {
// If the message port is remotely entangled, then always mark it as in-use because we can't determine reachability across threads.
- if (!(*iter)->locallyEntangledPort() || (*iter)->hasPendingActivity()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, *iter);
- if (wrapper)
- markStack.append(wrapper);
+ if (!(*iter)->locallyEntangledPort() || (*iter)->hasPendingActivity())
+ markDOMObjectWrapper(markStack, globalData, *iter);
+ }
+}
+
+typedef std::pair<JSNode*, DOMWrapperWorld*> WrapperAndWorld;
+typedef WTF::Vector<WrapperAndWorld, 8> WrapperSet;
+
+static inline void takeWrappers(Node* node, Document* document, WrapperSet& wrapperSet)
+{
+ if (document) {
+ JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap();
+ for (JSWrapperCacheMap::iterator iter = wrapperCacheMap.begin(); iter != wrapperCacheMap.end(); ++iter) {
+ if (JSNode* wrapper = iter->second->take(node)) {
+ removeWrapper(wrapper);
+ wrapperSet.append(WrapperAndWorld(wrapper, iter->first));
+ }
+ }
+ } else {
+ for (JSGlobalDataWorldIterator worldIter(JSDOMWindow::commonJSGlobalData()); worldIter; ++worldIter) {
+ DOMWrapperWorld* world = *worldIter;
+ if (JSNode* wrapper = static_cast<JSNode*>(world->m_wrappers.take(node))) {
+ removeWrapper(wrapper);
+ wrapperSet.append(WrapperAndWorld(wrapper, world));
+ }
}
}
}
@@ -375,13 +509,18 @@ void markActiveObjectsForContext(MarkStack& markStack, JSGlobalData& globalData,
void updateDOMNodeDocument(Node* node, Document* oldDocument, Document* newDocument)
{
ASSERT(oldDocument != newDocument);
- JSNode* wrapper = getCachedDOMNodeWrapper(oldDocument, node);
- if (!wrapper)
- return;
- removeWrapper(wrapper);
- cacheDOMNodeWrapper(newDocument, node, wrapper);
- forgetDOMNode(oldDocument, node);
- addWrapper(wrapper);
+
+ WrapperSet wrapperSet;
+ takeWrappers(node, oldDocument, wrapperSet);
+
+ for (unsigned i = 0; i < wrapperSet.size(); ++i) {
+ JSNode* wrapper = wrapperSet[i].first;
+ if (newDocument)
+ newDocument->getWrapperCache(wrapperSet[i].second)->set(node, wrapper);
+ else
+ wrapperSet[i].second->m_wrappers.set(node, wrapper);
+ addWrapper(wrapper);
+ }
}
void markDOMObjectWrapper(MarkStack& markStack, JSGlobalData& globalData, void* object)
@@ -391,10 +530,11 @@ void markDOMObjectWrapper(MarkStack& markStack, JSGlobalData& globalData, void*
// but doing this correctly would be challenging.
if (!object)
return;
- DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, object);
- if (!wrapper)
- return;
- markStack.append(wrapper);
+
+ for (JSGlobalDataWorldIterator worldIter(&globalData); worldIter; ++worldIter) {
+ if (DOMObject* wrapper = worldIter->m_wrappers.get(object))
+ markStack.append(wrapper);
+ }
}
JSValue jsStringOrNull(ExecState* exec, const String& s)
@@ -468,6 +608,9 @@ void reportException(ExecState* exec, JSValue exception)
UString exceptionSourceURL = exceptionObject->get(exec, Identifier(exec, "sourceURL")).toString(exec);
exec->clearException();
+ if (ExceptionBase* exceptionBase = toExceptionBase(exception))
+ errorMessage = exceptionBase->message() + ": " + exceptionBase->description();
+
ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
ASSERT(scriptExecutionContext);
@@ -538,7 +681,7 @@ bool allowsAccessFromFrame(ExecState* exec, Frame* frame)
{
if (!frame)
return false;
- JSDOMWindow* window = toJSDOMWindow(frame);
+ JSDOMWindow* window = toJSDOMWindow(frame, currentWorld(exec));
return window && window->allowsAccessFrom(exec);
}
@@ -546,7 +689,7 @@ bool allowsAccessFromFrame(ExecState* exec, Frame* frame, String& message)
{
if (!frame)
return false;
- JSDOMWindow* window = toJSDOMWindow(frame);
+ JSDOMWindow* window = toJSDOMWindow(frame, currentWorld(exec));
return window && window->allowsAccessFrom(exec, message);
}
@@ -560,8 +703,16 @@ void printErrorMessageForFrame(Frame* frame, const String& message)
{
if (!frame)
return;
- if (JSDOMWindow* window = toJSDOMWindow(frame))
- window->printErrorMessage(message);
+ if (message.isEmpty())
+ return;
+
+ Settings* settings = frame->settings();
+ if (!settings)
+ return;
+ if (settings->privateBrowsingEnabled())
+ return;
+
+ frame->domWindow()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String()); // FIXME: provide a real line number and source URL.
}
Frame* toLexicalFrame(ExecState* exec)
@@ -659,4 +810,28 @@ bool DOMObject::defineOwnProperty(ExecState* exec, const Identifier&, PropertyDe
return false;
}
+JSValue DebuggerCallFrame_evaluateInWorld(const JSC::DebuggerCallFrame& debuggerCallFrame, const UString& script, JSValue& exception)
+{
+ EnterDOMWrapperWorld worldEntry(debuggerCallFrame.dynamicGlobalObject()->globalExec(), debuggerWorld());
+ return debuggerCallFrame.evaluate(script, exception);
+}
+
+JSValue callInWorld(ExecState* exec, JSValue function, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args, DOMWrapperWorld* isolatedWorld)
+{
+ EnterDOMWrapperWorld worldEntry(exec, isolatedWorld);
+ return JSC::call(exec, function, callType, callData, thisValue, args);
+}
+
+JSObject* constructInWorld(ExecState* exec, JSValue object, ConstructType constructType, const ConstructData& constructData, const ArgList& args, DOMWrapperWorld* isolatedWorld)
+{
+ EnterDOMWrapperWorld worldEntry(exec, isolatedWorld);
+ return JSC::construct(exec, object, constructType, constructData, args);
+}
+
+Completion evaluateInWorld(ExecState* exec, ScopeChain& scopeChain, const SourceCode& sourceCode, JSValue thisValue, DOMWrapperWorld* isolatedWorld)
+{
+ EnterDOMWrapperWorld worldEntry(exec, isolatedWorld);
+ return JSC::evaluate(exec, scopeChain, sourceCode, thisValue);
+}
+
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h
index 9c0ad7ec13..ba41d85992 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h
@@ -30,16 +30,18 @@
namespace JSC {
class JSGlobalData;
+ class DebuggerCallFrame;
}
namespace WebCore {
class Document;
class Frame;
+ class JSNode;
class KURL;
class Node;
class String;
- class JSNode;
+ class ScriptController;
typedef int ExceptionCode;
@@ -76,10 +78,12 @@ namespace WebCore {
static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
{
- return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, JSC::HasStandardGetOwnPropertySlot));
+ return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));
}
protected:
+ static const unsigned StructureFlags = JSC::OverridesMarkChildren | DOMObject::StructureFlags;
+
DOMObjectWithGlobalPointer(NonNullPassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject)
: DOMObject(structure)
, m_globalObject(globalObject)
@@ -106,10 +110,11 @@ namespace WebCore {
public:
static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
{
- return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, JSC::HasStandardGetOwnPropertySlot | JSC::ImplementsHasInstance));
+ return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));
}
protected:
+ static const unsigned StructureFlags = JSC::ImplementsHasInstance | JSC::OverridesMarkChildren | DOMObjectWithGlobalPointer::StructureFlags;
DOMConstructorObject(NonNullPassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject)
: DOMObjectWithGlobalPointer(structure, globalObject)
{
@@ -133,14 +138,104 @@ namespace WebCore {
}
};
+ typedef HashMap<void*, DOMObject*> DOMObjectWrapperMap;
+
+ class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
+ public:
+ DOMWrapperWorld(JSC::JSGlobalData*);
+ ~DOMWrapperWorld();
+
+ void rememberDocument(Document* document) { documentsWithWrappers.add(document); }
+ void forgetDocument(Document* document) { documentsWithWrappers.remove(document); }
+ void rememberScriptController(ScriptController* scriptController) { scriptControllersWithShells.add(scriptController); }
+ void forgetScriptController(ScriptController* scriptController) { scriptControllersWithShells.remove(scriptController); }
+
+ // FIXME: can we make this private?
+ DOMObjectWrapperMap m_wrappers;
+
+ private:
+ JSC::JSGlobalData* m_globalData;
+ HashSet<Document*> documentsWithWrappers;
+ HashSet<ScriptController*> scriptControllersWithShells;
+ };
+
+ // Map from static HashTable instances to per-GlobalData ones.
+ class DOMObjectHashTableMap {
+ public:
+ static DOMObjectHashTableMap& mapFor(JSC::JSGlobalData&);
+
+ ~DOMObjectHashTableMap()
+ {
+ HashMap<const JSC::HashTable*, JSC::HashTable>::iterator mapEnd = m_map.end();
+ for (HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.begin(); iter != m_map.end(); ++iter)
+ iter->second.deleteTable();
+ }
+
+ const JSC::HashTable* get(const JSC::HashTable* staticTable)
+ {
+ HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.find(staticTable);
+ if (iter != m_map.end())
+ return &iter->second;
+ return &m_map.set(staticTable, JSC::HashTable(*staticTable)).first->second;
+ }
+
+ private:
+ HashMap<const JSC::HashTable*, JSC::HashTable> m_map;
+ };
+
+ class WebCoreJSClientData : public JSC::JSGlobalData::ClientData {
+ friend class EnterDOMWrapperWorld;
+ friend class JSGlobalDataWorldIterator;
+
+ public:
+ WebCoreJSClientData(JSC::JSGlobalData* globalData)
+ : m_normalWorld(globalData)
+ {
+ m_worldStack.append(&m_normalWorld);
+ m_worldSet.add(&m_normalWorld);
+ }
+ // FIXME: add a destructor to assert m_worldSet only contains m_normalWorld?
+
+ DOMWrapperWorld* currentWorld() { return m_worldStack.last(); }
+ DOMWrapperWorld* normalWorld() { return &m_normalWorld; }
+
+ void rememberWorld(DOMWrapperWorld* world)
+ {
+ ASSERT(!m_worldSet.contains(world));
+ m_worldSet.add(world);
+ }
+ void forgetWorld(DOMWrapperWorld* world)
+ {
+ ASSERT(m_worldSet.contains(world));
+ m_worldSet.remove(world);
+ }
+
+ DOMObjectHashTableMap hashTableMap;
+ private:
+ Vector<DOMWrapperWorld*> m_worldStack;
+ HashSet<DOMWrapperWorld*> m_worldSet;
+ DOMWrapperWorld m_normalWorld;
+ };
+
+ class EnterDOMWrapperWorld {
+ public:
+ EnterDOMWrapperWorld(JSC::JSGlobalData&, DOMWrapperWorld*);
+ EnterDOMWrapperWorld(JSC::ExecState*, DOMWrapperWorld*);
+ ~EnterDOMWrapperWorld();
+
+ private:
+ WebCoreJSClientData* m_clientData;
+ };
+
DOMObject* getCachedDOMObjectWrapper(JSC::JSGlobalData&, void* objectHandle);
void cacheDOMObjectWrapper(JSC::JSGlobalData&, void* objectHandle, DOMObject* wrapper);
- void forgetDOMObject(JSC::JSGlobalData&, void* objectHandle);
+ void forgetDOMNode(DOMObject* wrapper, Node* node, Document* document);
+ void forgetDOMObject(DOMObject* wrapper, void* objectHandle);
JSNode* getCachedDOMNodeWrapper(Document*, Node*);
void cacheDOMNodeWrapper(Document*, Node*, JSNode* wrapper);
- void forgetDOMNode(Document*, Node*);
void forgetAllDOMNodesForDocument(Document*);
+ void forgetWorldOfDOMNodesForDocument(Document*, DOMWrapperWorld*);
void updateDOMNodeDocument(Node*, Document* oldDocument, Document* newDocument);
void markDOMNodesForDocument(JSC::MarkStack&, Document*);
void markActiveObjectsForContext(JSC::MarkStack&, JSC::JSGlobalData&, ScriptExecutionContext*);
@@ -151,6 +246,13 @@ namespace WebCore {
JSC::Structure* getCachedDOMStructure(JSC::ExecState*, const JSC::ClassInfo*);
JSC::Structure* cacheDOMStructure(JSC::ExecState*, NonNullPassRefPtr<JSC::Structure>, const JSC::ClassInfo*);
+ DOMWrapperWorld* currentWorld(JSC::ExecState*);
+ DOMWrapperWorld* normalWorld(JSC::JSGlobalData&);
+ DOMWrapperWorld* mainThreadCurrentWorld();
+ DOMWrapperWorld* mainThreadNormalWorld();
+ inline DOMWrapperWorld* debuggerWorld() { return mainThreadNormalWorld(); }
+ inline DOMWrapperWorld* pluginWorld() { return mainThreadNormalWorld(); }
+
JSC::JSObject* getCachedDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*);
void cacheDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*, JSC::JSObject* constructor);
@@ -302,6 +404,11 @@ namespace WebCore {
bool processingUserGesture(JSC::ExecState*);
KURL completeURL(JSC::ExecState*, const String& relativeURL);
+ JSC::JSValue DebuggerCallFrame_evaluateInWorld(const JSC::DebuggerCallFrame& debuggerCallFrame, const JSC::UString& script, JSC::JSValue& exception);
+ JSC::JSValue callInWorld(JSC::ExecState*, JSC::JSValue function, JSC::CallType, const JSC::CallData&, JSC::JSValue thisValue, const JSC::ArgList&, DOMWrapperWorld*);
+ JSC::JSObject* constructInWorld(JSC::ExecState* exec, JSC::JSValue object, JSC::ConstructType constructType, const JSC::ConstructData& constructData, const JSC::ArgList& args, DOMWrapperWorld*);
+ JSC::Completion evaluateInWorld(JSC::ExecState*, JSC::ScopeChain&, const JSC::SourceCode&, JSC::JSValue thisValue, DOMWrapperWorld*);
+
} // namespace WebCore
#endif // JSDOMBinding_h
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.cpp
index 372684c01e..011a4e4c91 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.cpp
@@ -51,7 +51,7 @@ void JSDOMGlobalObject::markChildren(MarkStack& markStack)
JSDOMStructureMap::iterator end = structures().end();
for (JSDOMStructureMap::iterator it = structures().begin(); it != end; ++it)
- it->second->markAggregate(markStack);
+ markStack.append(it->second->storedPrototype());
JSDOMConstructorMap::iterator end2 = constructors().end();
for (JSDOMConstructorMap::iterator it2 = constructors().begin(); it2 != end2; ++it2)
@@ -63,7 +63,7 @@ PassRefPtr<JSEventListener> JSDOMGlobalObject::createJSAttributeEventListener(JS
if (!val.isObject())
return 0;
- return JSEventListener::create(asObject(val), true).get();
+ return JSEventListener::create(asObject(val), true, currentWorld(globalExec())).get();
}
void JSDOMGlobalObject::setCurrentEvent(Event* evt)
@@ -81,15 +81,34 @@ void JSDOMGlobalObject::destroyJSDOMGlobalObjectData(void* jsDOMGlobalObjectData
delete static_cast<JSDOMGlobalObjectData*>(jsDOMGlobalObjectData);
}
-JSDOMGlobalObject* toJSDOMGlobalObject(Document* document)
+JSDOMGlobalObject* toJSDOMGlobalObject(Document* document, JSC::ExecState* exec)
{
- return toJSDOMWindow(document->frame());
+ return toJSDOMWindow(document->frame(), currentWorld(exec));
}
-JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext* scriptExecutionContext)
+JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext* scriptExecutionContext, JSC::ExecState* exec)
{
if (scriptExecutionContext->isDocument())
- return toJSDOMGlobalObject(static_cast<Document*>(scriptExecutionContext));
+ return toJSDOMGlobalObject(static_cast<Document*>(scriptExecutionContext), exec);
+
+#if ENABLE(WORKERS)
+ if (scriptExecutionContext->isWorkerContext())
+ return static_cast<WorkerContext*>(scriptExecutionContext)->script()->workerContextWrapper();
+#endif
+
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+JSDOMGlobalObject* toJSDOMGlobalObject(Document* document, DOMWrapperWorld* world)
+{
+ return toJSDOMWindow(document->frame(), world);
+}
+
+JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext* scriptExecutionContext, DOMWrapperWorld* world)
+{
+ if (scriptExecutionContext->isDocument())
+ return toJSDOMGlobalObject(static_cast<Document*>(scriptExecutionContext), world);
#if ENABLE(WORKERS)
if (scriptExecutionContext->isWorkerContext())
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h
index 00c3bbf1bc..6b75a6f6d0 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h
@@ -33,6 +33,7 @@ namespace WebCore {
class Document;
class Event;
+ class DOMWrapperWorld;
class JSLazyEventListener;
class JSEventListener;
class ScriptExecutionContext;
@@ -73,6 +74,12 @@ namespace WebCore {
{
}
+ JSDOMGlobalObjectData(Destructor destructor)
+ : JSGlobalObjectData(destructor)
+ , evt(0)
+ {
+ }
+
JSDOMStructureMap structures;
JSDOMConstructorMap constructors;
@@ -96,8 +103,11 @@ namespace WebCore {
return constructor;
}
- JSDOMGlobalObject* toJSDOMGlobalObject(Document*);
- JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext*);
+ JSDOMGlobalObject* toJSDOMGlobalObject(Document*, JSC::ExecState*);
+ JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext*, JSC::ExecState*);
+
+ JSDOMGlobalObject* toJSDOMGlobalObject(Document*, DOMWrapperWorld*);
+ JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext*, DOMWrapperWorld*);
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp
index fe4d59c012..86ff149bb4 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp
@@ -42,12 +42,6 @@ namespace WebCore {
const ClassInfo JSDOMWindowBase::s_info = { "Window", 0, 0, 0 };
-JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData(PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell)
- : impl(window)
- , shell(shell)
-{
-}
-
JSDOMWindowBase::JSDOMWindowBase(NonNullPassRefPtr<Structure> structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell)
: JSDOMGlobalObject(structure, new JSDOMWindowBaseData(window, shell), shell)
{
@@ -59,10 +53,11 @@ JSDOMWindowBase::JSDOMWindowBase(NonNullPassRefPtr<Structure> structure, PassRef
addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));
}
-void JSDOMWindowBase::updateDocument()
+void JSDOMWindowBase::updateDocument(DOMWrapperWorld* world)
{
ASSERT(d()->impl->document());
ExecState* exec = globalExec();
+ EnterDOMWrapperWorld worldEntry(exec, world);
symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, this, d()->impl->document()), DontDelete | ReadOnly);
}
@@ -85,21 +80,7 @@ String JSDOMWindowBase::crossDomainAccessErrorMessage(const JSGlobalObject* othe
void JSDOMWindowBase::printErrorMessage(const String& message) const
{
- if (message.isEmpty())
- return;
-
- Frame* frame = impl()->frame();
- if (!frame)
- return;
-
- Settings* settings = frame->settings();
- if (!settings)
- return;
-
- if (settings->privateBrowsingEnabled())
- return;
-
- impl()->console()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String()); // FIXME: provide a real line number and source URL.
+ printErrorMessageForFrame(impl()->frame(), message);
}
ExecState* JSDOMWindowBase::globalExec()
@@ -163,18 +144,26 @@ JSDOMWindowShell* JSDOMWindowBase::shell() const
JSGlobalData* JSDOMWindowBase::commonJSGlobalData()
{
- static JSGlobalData* globalData;
+ ASSERT(isMainThread());
+
+ static JSGlobalData* globalData = 0;
if (!globalData) {
globalData = JSGlobalData::createLeaked().releaseRef();
globalData->timeoutChecker.setTimeoutInterval(10000); // 10 seconds
#ifndef NDEBUG
globalData->mainThreadOnly = true;
#endif
+ globalData->clientData = new WebCoreJSClientData(globalData);
}
return globalData;
}
+void JSDOMWindowBase::destroyJSDOMWindowBaseData(void* jsDOMWindowBaseData)
+{
+ delete static_cast<JSDOMWindowBaseData*>(jsDOMWindowBaseData);
+}
+
// JSDOMGlobalObject* is ignored, accesing a window in any context will
// use that DOMWindow's prototype chain.
JSValue toJS(ExecState* exec, JSDOMGlobalObject*, DOMWindow* domWindow)
@@ -182,21 +171,21 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject*, DOMWindow* domWindow)
return toJS(exec, domWindow);
}
-JSValue toJS(ExecState*, DOMWindow* domWindow)
+JSValue toJS(ExecState* exec, DOMWindow* domWindow)
{
if (!domWindow)
return jsNull();
Frame* frame = domWindow->frame();
if (!frame)
return jsNull();
- return frame->script()->windowShell();
+ return frame->script()->windowShell(currentWorld(exec));
}
-JSDOMWindow* toJSDOMWindow(Frame* frame)
+JSDOMWindow* toJSDOMWindow(Frame* frame, DOMWrapperWorld* world)
{
if (!frame)
return 0;
- return frame->script()->windowShell()->window();
+ return frame->script()->windowShell(world)->window();
}
JSDOMWindow* toJSDOMWindow(JSValue value)
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h
index 09fe4bc4a8..31e24868fe 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h
@@ -32,6 +32,7 @@ namespace WebCore {
class DOMWindow;
class Event;
class Frame;
+ class DOMWrapperWorld;
class JSDOMWindow;
class JSDOMWindowShell;
class JSLocation;
@@ -46,7 +47,7 @@ namespace WebCore {
JSDOMWindowBase(NonNullPassRefPtr<JSC::Structure>, PassRefPtr<DOMWindow>, JSDOMWindowShell*);
public:
- void updateDocument();
+ void updateDocument(DOMWrapperWorld*);
DOMWindow* impl() const { return d()->impl.get(); }
virtual ScriptExecutionContext* scriptExecutionContext() const;
@@ -76,7 +77,12 @@ namespace WebCore {
private:
struct JSDOMWindowBaseData : public JSDOMGlobalObjectData {
- JSDOMWindowBaseData(PassRefPtr<DOMWindow>, JSDOMWindowShell*);
+ JSDOMWindowBaseData(PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell)
+ : JSDOMGlobalObjectData(destroyJSDOMWindowBaseData)
+ , impl(window)
+ , shell(shell)
+ {
+ }
RefPtr<DOMWindow> impl;
JSDOMWindowShell* shell;
@@ -85,6 +91,8 @@ namespace WebCore {
bool allowsAccessFromPrivate(const JSC::JSGlobalObject*) const;
String crossDomainAccessErrorMessage(const JSC::JSGlobalObject*) const;
+ static void destroyJSDOMWindowBaseData(void*);
+
JSDOMWindowBaseData* d() const { return static_cast<JSDOMWindowBaseData*>(JSC::JSVariableObject::d); }
};
@@ -95,7 +103,7 @@ namespace WebCore {
JSC::JSValue toJS(JSC::ExecState*, DOMWindow*);
// Returns JSDOMWindow or 0
- JSDOMWindow* toJSDOMWindow(Frame*);
+ JSDOMWindow* toJSDOMWindow(Frame*, DOMWrapperWorld*);
JSDOMWindow* toJSDOMWindow(JSC::JSValue);
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 7410107560..2804b3ce65 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -79,7 +79,9 @@
#include "RegisteredEventListener.h"
#include "ScheduledAction.h"
#include "ScriptController.h"
+#include "SerializedScriptValue.h"
#include "Settings.h"
+#include "SharedWorkerRepository.h"
#include "WindowFeatures.h"
#include <runtime/Error.h>
#include <runtime/JSFunction.h>
@@ -589,7 +591,7 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value)
if (!protocolIsJavaScript(url) || allowsAccessFrom(exec)) {
// We want a new history item if this JS was called via a user gesture
- frame->loader()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, processingUserGesture(exec));
+ frame->redirectScheduler()->scheduleLocationChange(url, lexicalFrame->loader()->outgoingReferrer(), !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, processingUserGesture(exec));
}
}
@@ -713,7 +715,9 @@ JSValue JSDOMWindow::worker(ExecState* exec) const
#if ENABLE(SHARED_WORKERS)
JSValue JSDOMWindow::sharedWorker(ExecState* exec) const
{
- return getDOMConstructor<JSSharedWorkerConstructor>(exec, this);
+ if (SharedWorkerRepository::isAvailable())
+ return getDOMConstructor<JSSharedWorkerConstructor>(exec, this);
+ return jsUndefined();
}
#endif
@@ -726,8 +730,6 @@ JSValue JSDOMWindow::webSocket(ExecState* exec) const
Settings* settings = frame->settings();
if (!settings)
return jsUndefined();
- if (!settings->experimentalWebSocketsEnabled())
- return jsUndefined();
return getDOMConstructor<JSWebSocketConstructor>(exec, this);
}
#endif
@@ -767,9 +769,10 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF
return 0;
newFrame->loader()->setOpener(openerFrame);
- newFrame->loader()->setOpenedByDOM();
+ newFrame->page()->setOpenedByDOM();
- JSDOMWindow* newWindow = toJSDOMWindow(newFrame);
+ // FIXME: If a window is created from an isolated world, what are the consequences of this? 'dialogArguments' only appears back in the normal world?
+ JSDOMWindow* newWindow = toJSDOMWindow(newFrame, normalWorld(exec->globalData()));
if (dialogArgs)
newWindow->putDirect(Identifier(exec, "dialogArguments"), dialogArgs);
@@ -781,7 +784,7 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF
if (created)
newFrame->loader()->changeLocation(completedURL, referrer, false, false, userGesture);
else if (!url.isEmpty())
- newFrame->loader()->scheduleLocationChange(completedURL.string(), referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
+ newFrame->redirectScheduler()->scheduleLocationChange(completedURL.string(), referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
}
return newFrame;
@@ -829,7 +832,7 @@ JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args)
if (!shouldAllowNavigation(exec, frame))
return jsUndefined();
- const JSDOMWindow* targetedWindow = toJSDOMWindow(frame);
+ const JSDOMWindow* targetedWindow = toJSDOMWindow(frame, currentWorld(exec));
if (!completedURL.isEmpty() && (!protocolIsJavaScript(completedURL) || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) {
bool userGesture = processingUserGesture(exec);
@@ -838,7 +841,7 @@ JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args)
// here.
String referrer = dynamicFrame->loader()->outgoingReferrer();
- frame->loader()->scheduleLocationChange(completedURL, referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
+ frame->redirectScheduler()->scheduleLocationChange(completedURL, referrer, !lexicalFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
}
return toJS(exec, frame->domWindow());
}
@@ -930,10 +933,18 @@ JSValue JSDOMWindow::showModalDialog(ExecState* exec, const ArgList& args)
if (!dialogFrame)
return jsUndefined();
- JSDOMWindow* dialogWindow = toJSDOMWindow(dialogFrame);
+ JSDOMWindow* dialogWindow = toJSDOMWindow(dialogFrame, currentWorld(exec));
dialogFrame->page()->chrome()->runModal();
- return dialogWindow->getDirect(Identifier(exec, "returnValue"));
+ Identifier returnValue(exec, "returnValue");
+ if (dialogWindow->allowsAccessFromNoErrorMessage(exec)) {
+ PropertySlot slot;
+ // This is safe, we have already performed the origin security check and we are
+ // not interested in any of the DOM properties of the window.
+ if (dialogWindow->JSGlobalObject::getOwnPropertySlot(exec, returnValue, slot))
+ return slot.getValue(exec, returnValue);
+ }
+ return jsUndefined();
}
JSValue JSDOMWindow::postMessage(ExecState* exec, const ArgList& args)
@@ -941,7 +952,7 @@ JSValue JSDOMWindow::postMessage(ExecState* exec, const ArgList& args)
DOMWindow* window = impl();
DOMWindow* source = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
- String message = args.at(0).toString(exec);
+ PassRefPtr<SerializedScriptValue> message = SerializedScriptValue::create(exec, args.at(0));
if (exec->hadException())
return jsUndefined();
@@ -965,7 +976,7 @@ JSValue JSDOMWindow::postMessage(ExecState* exec, const ArgList& args)
JSValue JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args);
+ ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
@@ -974,7 +985,7 @@ JSValue JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args)
JSValue JSDOMWindow::setInterval(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args);
+ ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
@@ -1042,7 +1053,7 @@ JSValue JSDOMWindow::addEventListener(ExecState* exec, const ArgList& args)
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
@@ -1056,7 +1067,7 @@ JSValue JSDOMWindow::removeEventListener(ExecState* exec, const ArgList& args)
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp
index 3c3ff4c239..9072f91bc3 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.cpp
@@ -171,18 +171,18 @@ void* JSDOMWindowShell::operator new(size_t size)
// Conversion methods
// ----
-JSValue toJS(ExecState*, Frame* frame)
+JSValue toJS(ExecState* exec, Frame* frame)
{
if (!frame)
return jsNull();
- return frame->script()->windowShell();
+ return frame->script()->windowShell(currentWorld(exec));
}
-JSDOMWindowShell* toJSDOMWindowShell(Frame* frame)
+JSDOMWindowShell* toJSDOMWindowShell(Frame* frame, DOMWrapperWorld* isolatedWorld)
{
if (!frame)
return 0;
- return frame->script()->windowShell();
+ return frame->script()->windowShell(isolatedWorld);
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h
index 23af3407dc..36cb8d6ad6 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowShell.h
@@ -60,10 +60,12 @@ namespace WebCore {
static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
{
- return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType));
+ return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));
}
private:
+ static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesMarkChildren | JSC::OverridesGetPropertyNames | DOMObject::StructureFlags;
+
virtual void markChildren(JSC::MarkStack&);
virtual JSC::UString className() const;
virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
@@ -86,7 +88,7 @@ namespace WebCore {
};
JSC::JSValue toJS(JSC::ExecState*, Frame*);
- JSDOMWindowShell* toJSDOMWindowShell(Frame*);
+ JSDOMWindowShell* toJSDOMWindowShell(Frame*, DOMWrapperWorld*);
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp
index 493d7bd7f4..7485c1f86e 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp
@@ -63,29 +63,21 @@ JSValue JSNotificationCenter::requestPermission(ExecState* exec, const ArgList&
JSValue JSNotification::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener)), globalObject, false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener)), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSNotification::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), globalObject, false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp
index e48b59399f..d7f8725426 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp
@@ -88,7 +88,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value)
str = activeFrame->document()->completeURL(str).string();
bool userGesture = activeFrame->script()->processingUserGesture();
- frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
+ frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
}
JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Document* document)
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp
index 162543d617..edf9151a75 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp
@@ -31,6 +31,7 @@
#include "Clipboard.h"
#include "Event.h"
+#include "JSBeforeLoadEvent.h"
#include "JSClipboard.h"
#include "JSErrorEvent.h"
#include "JSKeyboardEvent.h"
@@ -46,6 +47,7 @@
#include "JSWebKitTransitionEvent.h"
#include "JSWheelEvent.h"
#include "JSXMLHttpRequestProgressEvent.h"
+#include "BeforeLoadEvent.h"
#include "ErrorEvent.h"
#include "KeyboardEvent.h"
#include "MessageEvent.h"
@@ -120,7 +122,8 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event)
wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, XMLHttpRequestProgressEvent, event);
else
wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, ProgressEvent, event);
- }
+ } else if (event->isBeforeLoadEvent())
+ wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, BeforeLoadEvent, event);
#if ENABLE(DOM_STORAGE)
else if (event->isStorageEvent())
wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, StorageEvent, event);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp
index 4f273fe2af..1a999a859e 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp
@@ -31,10 +31,11 @@ using namespace JSC;
namespace WebCore {
-JSEventListener::JSEventListener(JSObject* function, bool isAttribute)
+JSEventListener::JSEventListener(JSObject* function, bool isAttribute, DOMWrapperWorld* isolatedWorld)
: EventListener(JSEventListenerType)
, m_jsFunction(function)
, m_isAttribute(isAttribute)
+ , m_isolatedWorld(isolatedWorld)
{
}
@@ -65,7 +66,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
if (!jsFunction)
return;
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext);
+ JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, m_isolatedWorld.get());
if (!globalObject)
return;
@@ -86,7 +87,12 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
ExecState* exec = globalObject->globalExec();
- JSValue handleEventFunction = jsFunction->get(exec, Identifier(exec, "handleEvent"));
+ JSValue handleEventFunction;
+ {
+ // Switch worlds, just in case handleEvent is a getter and causes JS execution!
+ EnterDOMWrapperWorld worldEntry(exec, m_isolatedWorld.get());
+ handleEventFunction = jsFunction->get(exec, Identifier(exec, "handleEvent"));
+ }
CallData callData;
CallType callType = handleEventFunction.getCallData(callData);
if (callType == CallTypeNone) {
@@ -108,8 +114,8 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
globalData->timeoutChecker.start();
JSValue retval = handleEventFunction
- ? call(exec, handleEventFunction, callType, callData, jsFunction, args)
- : call(exec, jsFunction, callType, callData, toJS(exec, globalObject, event->currentTarget()), args);
+ ? callInWorld(exec, handleEventFunction, callType, callData, jsFunction, args, m_isolatedWorld.get())
+ : callInWorld(exec, jsFunction, callType, callData, toJS(exec, globalObject, event->currentTarget()), args, m_isolatedWorld.get());
globalData->timeoutChecker.stop();
globalObject->setCurrentEvent(savedEvent);
@@ -140,7 +146,7 @@ bool JSEventListener::reportError(ScriptExecutionContext* context, const String&
if (!jsFunction)
return false;
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context);
+ JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
ExecState* exec = globalObject->globalExec();
CallData callData;
@@ -160,7 +166,7 @@ bool JSEventListener::reportError(ScriptExecutionContext* context, const String&
JSValue thisValue = globalObject->toThisObject(exec);
globalData->timeoutChecker.start();
- JSValue returnValue = call(exec, jsFunction, callType, callData, thisValue, args);
+ JSValue returnValue = callInWorld(exec, jsFunction, callType, callData, thisValue, args, m_isolatedWorld.get());
globalData->timeoutChecker.stop();
// If an error occurs while handling the script error, it should be bubbled up.
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h
index 285a9c49d1..bf3af4811f 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h
@@ -30,9 +30,9 @@ namespace WebCore {
class JSEventListener : public EventListener {
public:
- static PassRefPtr<JSEventListener> create(JSC::JSObject* listener, bool isAttribute)
+ static PassRefPtr<JSEventListener> create(JSC::JSObject* listener, bool isAttribute, DOMWrapperWorld* isolatedWorld)
{
- return adoptRef(new JSEventListener(listener, isAttribute));
+ return adoptRef(new JSEventListener(listener, isAttribute, isolatedWorld));
}
static const JSEventListener* cast(const EventListener* listener)
@@ -59,10 +59,11 @@ namespace WebCore {
void clearJSFunctionInline();
protected:
- JSEventListener(JSC::JSObject* function, bool isAttribute);
+ JSEventListener(JSC::JSObject* function, bool isAttribute, DOMWrapperWorld* isolatedWorld);
mutable JSC::JSObject* m_jsFunction;
bool m_isAttribute;
+ RefPtr<DOMWrapperWorld> m_isolatedWorld;
};
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventSourceCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSEventSourceCustom.cpp
index 404bf11c64..8f0dfb10a4 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventSourceCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventSourceCustom.cpp
@@ -45,29 +45,21 @@ namespace WebCore {
JSValue JSEventSource::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSEventSource::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp
index 0421d1044e..6ea11352d3 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp
@@ -128,7 +128,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ
return toJS(exec, globalObject, worker);
if (DedicatedWorkerContext* workerContext = target->toDedicatedWorkerContext())
- return toJSDOMGlobalObject(workerContext);
+ return toJSDOMGlobalObject(workerContext, exec);
#endif
#if ENABLE(SHARED_WORKERS)
@@ -136,7 +136,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ
return toJS(exec, globalObject, sharedWorker);
if (SharedWorkerContext* workerContext = target->toSharedWorkerContext())
- return toJSDOMGlobalObject(workerContext);
+ return toJSDOMGlobalObject(workerContext, exec);
#endif
#if ENABLE(NOTIFICATIONS)
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp
new file mode 100644
index 0000000000..a588ab1b14
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2009 Apple 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 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 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 "JSExceptionBase.h"
+
+#include "JSDOMCoreException.h"
+#include "JSEventException.h"
+#include "JSRangeException.h"
+#include "JSXMLHttpRequestException.h"
+#if ENABLE(SVG)
+#include "JSSVGException.h"
+#endif
+#if ENABLE(XPATH)
+#include "JSXPathException.h"
+#endif
+
+namespace WebCore {
+
+ExceptionBase* toExceptionBase(JSC::JSValue value)
+{
+ if (DOMCoreException* domException = toDOMCoreException(value))
+ return reinterpret_cast<ExceptionBase*>(domException);
+ if (RangeException* rangeException = toRangeException(value))
+ return reinterpret_cast<ExceptionBase*>(rangeException);
+ if (EventException* eventException = toEventException(value))
+ return reinterpret_cast<ExceptionBase*>(eventException);
+ if (XMLHttpRequestException* xmlHttpException = toXMLHttpRequestException(value))
+ return reinterpret_cast<ExceptionBase*>(xmlHttpException);
+#if ENABLE(SVG)
+ if (SVGException* svgException = toSVGException(value))
+ return reinterpret_cast<ExceptionBase*>(svgException);
+#endif
+#if ENABLE(XPATH)
+ if (XPathException* pathException = toXPathException(value))
+ return reinterpret_cast<ExceptionBase*>(pathException);
+#endif
+
+ return 0;
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h
index ce2609ce14..a9366ed704 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,10 +10,10 @@
* 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
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE 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
@@ -23,13 +23,21 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
-#include "JSHTMLAllCollection.h"
+#ifndef JSExceptionBase_h
+#define JSExceptionBase_h
-using namespace JSC;
+namespace JSC {
+
+class JSValue;
+
+} // namespace JSC
namespace WebCore {
-const ClassInfo JSHTMLAllCollection::s_info = { "HTMLAllCollection", 0, 0, 0 };
+class ExceptionBase;
+
+ExceptionBase* toExceptionBase(JSC::JSValue);
} // namespace WebCore
+
+#endif // JSExceptionBase_h
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h
deleted file mode 100644
index e6fe7f563d..0000000000
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple 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 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.
- */
-
-#ifndef JSHTMLAllCollection_h
-#define JSHTMLAllCollection_h
-
-#include "HTMLCollection.h"
-#include "JSHTMLCollection.h"
-
-namespace WebCore {
-
- class HTMLCollection;
-
- class JSHTMLAllCollection : public JSHTMLCollection {
- public:
- JSHTMLAllCollection(NonNullPassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<HTMLCollection> collection)
- : JSHTMLCollection(structure, globalObject, collection)
- {
- }
-
- static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue proto)
- {
- return JSC::Structure::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::MasqueradesAsUndefined));
- }
-
- static const JSC::ClassInfo s_info;
-
- private:
- virtual bool toBoolean(JSC::ExecState*) const { return false; }
- };
-
-} // namespace WebCore
-
-#endif // JSHTMLAllCollection_h
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
new file mode 100644
index 0000000000..fd1dd11ee1
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2009 Apple 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 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 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 "JSHTMLAllCollection.h"
+
+#include "AtomicString.h"
+#include "HTMLAllCollection.h"
+#include "JSDOMBinding.h"
+#include "JSHTMLAllCollection.h"
+#include "JSNode.h"
+#include "JSNodeList.h"
+#include "Node.h"
+#include "StaticNodeList.h"
+#include <wtf/Vector.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+static JSValue getNamedItems(ExecState* exec, JSHTMLAllCollection* collection, const Identifier& propertyName)
+{
+ Vector<RefPtr<Node> > namedItems;
+ collection->impl()->namedItems(propertyName, namedItems);
+
+ if (namedItems.isEmpty())
+ return jsUndefined();
+ if (namedItems.size() == 1)
+ return toJS(exec, collection->globalObject(), namedItems[0].get());
+
+ // FIXME: HTML5 specifies that this should be a DynamicNodeList.
+ // FIXME: HTML5 specifies that non-HTMLOptionsCollection collections should return
+ // the first matching item instead of a NodeList.
+ return toJS(exec, collection->globalObject(), StaticNodeList::adopt(namedItems).get());
+}
+
+// HTMLCollections are strange objects, they support both get and call,
+// so that document.forms.item(0) and document.forms(0) both work.
+static JSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec, JSObject* function, JSValue, const ArgList& args)
+{
+ if (args.size() < 1)
+ return jsUndefined();
+
+ // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case.
+ JSHTMLAllCollection* jsCollection = static_cast<JSHTMLAllCollection*>(function);
+ HTMLAllCollection* collection = static_cast<HTMLAllCollection*>(jsCollection->impl());
+
+ // Also, do we need the TypeError test here ?
+
+ if (args.size() == 1) {
+ // Support for document.all(<index>) etc.
+ bool ok;
+ UString string = args.at(0).toString(exec);
+ unsigned index = string.toUInt32(&ok, false);
+ if (ok)
+ return toJS(exec, jsCollection->globalObject(), collection->item(index));
+
+ // Support for document.images('<name>') etc.
+ return getNamedItems(exec, jsCollection, Identifier(exec, string));
+ }
+
+ // The second arg, if set, is the index of the item we want
+ bool ok;
+ UString string = args.at(0).toString(exec);
+ unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
+ if (ok) {
+ String pstr = string;
+ Node* node = collection->namedItem(pstr);
+ while (node) {
+ if (!index)
+ return toJS(exec, jsCollection->globalObject(), node);
+ node = collection->nextNamedItem(pstr);
+ --index;
+ }
+ }
+
+ return jsUndefined();
+}
+
+CallType JSHTMLAllCollection::getCallData(CallData& callData)
+{
+ callData.native.function = callHTMLAllCollection;
+ return CallTypeHost;
+}
+
+bool JSHTMLAllCollection::canGetItemsForName(ExecState*, HTMLAllCollection* collection, const Identifier& propertyName)
+{
+ Vector<RefPtr<Node> > namedItems;
+ collection->namedItems(propertyName, namedItems);
+ return !namedItems.isEmpty();
+}
+
+JSValue JSHTMLAllCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
+{
+ JSHTMLAllCollection* thisObj = static_cast<JSHTMLAllCollection*>(asObject(slot.slotBase()));
+ return getNamedItems(exec, thisObj, propertyName);
+}
+
+JSValue JSHTMLAllCollection::item(ExecState* exec, const ArgList& args)
+{
+ bool ok;
+ uint32_t index = args.at(0).toString(exec).toUInt32(&ok, false);
+ if (ok)
+ return toJS(exec, globalObject(), impl()->item(index));
+ return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
+}
+
+JSValue JSHTMLAllCollection::namedItem(ExecState* exec, const ArgList& args)
+{
+ return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec)));
+}
+
+} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
index 8ffddf7320..dd4ceaa695 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
@@ -23,6 +23,7 @@
#include "AtomicString.h"
#include "HTMLCollection.h"
#include "HTMLOptionsCollection.h"
+#include "HTMLAllCollection.h"
#include "JSDOMBinding.h"
#include "JSHTMLAllCollection.h"
#include "JSHTMLOptionsCollection.h"
@@ -143,7 +144,6 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, HTMLCollection* c
wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLOptionsCollection, collection);
break;
case DocAll:
- typedef HTMLCollection HTMLAllCollection;
wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLAllCollection, collection);
break;
default:
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLDocumentCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
index c113ec77dd..a65ca7cfbd 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
@@ -28,6 +28,7 @@
#include "CharacterNames.h"
#include "Frame.h"
+#include "HTMLAllCollection.h"
#include "HTMLBodyElement.h"
#include "HTMLCollection.h"
#include "HTMLDocument.h"
@@ -105,14 +106,14 @@ JSValue JSHTMLDocument::open(ExecState* exec, const ArgList& args)
if (args.size() > 2) {
Frame* frame = static_cast<HTMLDocument*>(impl())->frame();
if (frame) {
- JSDOMWindowShell* wrapper = toJSDOMWindowShell(frame);
+ JSDOMWindowShell* wrapper = toJSDOMWindowShell(frame, currentWorld(exec));
if (wrapper) {
JSValue function = wrapper->get(exec, Identifier(exec, "open"));
CallData callData;
CallType callType = function.getCallData(callData);
if (callType == CallTypeNone)
return throwError(exec, TypeError);
- return call(exec, function, callType, callData, wrapper, args);
+ return callInWorld(exec, function, callType, callData, wrapper, args, currentWorld(exec));
}
}
return jsUndefined();
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp
index 05972e6fb3..68769d6acc 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp
@@ -47,14 +47,14 @@ bool JSHTMLFrameSetElement::canGetItemsForName(ExecState*, HTMLFrameSetElement*
return frame && frame->hasTagName(frameTag);
}
-JSValue JSHTMLFrameSetElement::nameGetter(ExecState*, const Identifier& propertyName, const PropertySlot& slot)
+JSValue JSHTMLFrameSetElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slot.slotBase()));
HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl());
Node* frame = element->children()->namedItem(propertyName);
if (Document* doc = static_cast<HTMLFrameElement*>(frame)->contentDocument()) {
- if (JSDOMWindowShell* window = toJSDOMWindowShell(doc->frame()))
+ if (JSDOMWindowShell* window = toJSDOMWindowShell(doc->frame(), currentWorld(exec)))
return window;
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp
index 583d97133a..439f532825 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp
@@ -66,10 +66,7 @@
#if ENABLE(JAVASCRIPT_DEBUGGER)
#include "JavaScriptCallFrame.h"
#include "JavaScriptDebugServer.h"
-#include "JavaScriptProfile.h"
#include "JSJavaScriptCallFrame.h"
-#include <profiler/Profile.h>
-#include <profiler/Profiler.h>
#endif
using namespace JSC;
@@ -122,27 +119,21 @@ JSValue JSInspectorBackend::search(ExecState* exec, const ArgList& args)
}
#if ENABLE(DATABASE)
-JSValue JSInspectorBackend::databaseTableNames(ExecState* exec, const ArgList& args)
+JSValue JSInspectorBackend::databaseForId(ExecState* exec, const ArgList& args)
{
if (args.size() < 1)
return jsUndefined();
- JSQuarantinedObjectWrapper* wrapper = JSQuarantinedObjectWrapper::asWrapper(args.at(0));
- if (!wrapper)
+ InspectorController* ic = impl()->inspectorController();
+ if (!ic)
return jsUndefined();
- Database* database = toDatabase(wrapper->unwrappedObject());
+ Database* database = impl()->databaseForId(args.at(0).toInt32(exec));
if (!database)
return jsUndefined();
-
- MarkedArgumentBuffer result;
-
- Vector<String> tableNames = database->tableNames();
- unsigned length = tableNames.size();
- for (unsigned i = 0; i < length; ++i)
- result.append(jsString(exec, tableNames[i]));
-
- return constructArray(exec, result);
+ // Could use currentWorld(exec) ... but which exec! The following mixed use of exec & inspectedWindow->globalExec() scares me!
+ JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
+ return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), toJS(exec, database));
}
#endif
@@ -151,7 +142,7 @@ JSValue JSInspectorBackend::inspectedWindow(ExecState*, const ArgList&)
InspectorController* ic = impl()->inspectorController();
if (!ic)
return jsUndefined();
- JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame());
+ JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow);
}
@@ -260,21 +251,6 @@ JSValue JSInspectorBackend::currentCallFrame(ExecState* exec, const ArgList&)
return JSInspectedObjectWrapper::wrap(globalExec, toJS(exec, callFrame));
}
-JSValue JSInspectorBackend::profiles(JSC::ExecState* exec, const JSC::ArgList&)
-{
- JSLock lock(SilenceAssertionsOnly);
- MarkedArgumentBuffer result;
- InspectorController* ic = impl()->inspectorController();
- if (!ic)
- return jsUndefined();
- const Vector<RefPtr<Profile> >& profiles = ic->profiles();
-
- for (size_t i = 0; i < profiles.size(); ++i)
- result.append(toJS(exec, profiles[i].get()));
-
- return constructArray(exec, result);
-}
-
#endif
JSValue JSInspectorBackend::nodeForId(ExecState* exec, const ArgList& args)
@@ -291,16 +267,16 @@ JSValue JSInspectorBackend::nodeForId(ExecState* exec, const ArgList& args)
return jsUndefined();
JSLock lock(SilenceAssertionsOnly);
- JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame());
+ JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame(), debuggerWorld());
return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), toJS(exec, deprecatedGlobalObjectForPrototype(inspectedWindow->globalExec()), node));
}
-JSValue JSInspectorBackend::wrapObject(ExecState*, const ArgList& args)
+JSValue JSInspectorBackend::wrapObject(ExecState* exec, const ArgList& args)
{
- if (args.size() < 1)
+ if (args.size() < 2)
return jsUndefined();
- return impl()->wrapObject(ScriptValue(args.at(0))).jsValue();
+ return impl()->wrapObject(ScriptValue(args.at(0)), args.at(1).toString(exec)).jsValue();
}
JSValue JSInspectorBackend::unwrapObject(ExecState* exec, const ArgList& args)
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp
index 0d6cb57283..6d75f4fbb7 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp
@@ -35,8 +35,8 @@ namespace WebCore {
static WTF::RefCountedLeakCounter eventListenerCounter("JSLazyEventListener");
#endif
-JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& eventParameterName, const String& code, Node* node, const String& sourceURL, int lineNumber)
- : JSEventListener(0, true)
+JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& eventParameterName, const String& code, Node* node, const String& sourceURL, int lineNumber, DOMWrapperWorld* isolatedWorld)
+ : JSEventListener(0, true, isolatedWorld)
, m_functionName(functionName)
, m_eventParameterName(eventParameterName)
, m_code(code)
@@ -92,7 +92,7 @@ void JSLazyEventListener::parseCode(ScriptExecutionContext* executionContext) co
if (!scriptController->isEnabled())
return;
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(executionContext);
+ JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(executionContext, m_isolatedWorld.get());
if (!globalObject)
return;
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.h b/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.h
index e3137b8ca4..ba26ef6970 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.h
@@ -29,14 +29,14 @@ namespace WebCore {
class JSLazyEventListener : public JSEventListener {
public:
- static PassRefPtr<JSLazyEventListener> create(const String& functionName, const String& eventParameterName, const String& code, Node* node, const String& sourceURL, int lineNumber)
+ static PassRefPtr<JSLazyEventListener> create(const String& functionName, const String& eventParameterName, const String& code, Node* node, const String& sourceURL, int lineNumber, DOMWrapperWorld* isolatedWorld)
{
- return adoptRef(new JSLazyEventListener(functionName, eventParameterName, code, node, sourceURL, lineNumber));
+ return adoptRef(new JSLazyEventListener(functionName, eventParameterName, code, node, sourceURL, lineNumber, isolatedWorld));
}
virtual ~JSLazyEventListener();
private:
- JSLazyEventListener(const String& functionName, const String& eventParameterName, const String& code, Node*, const String& sourceURL, int lineNumber);
+ JSLazyEventListener(const String& functionName, const String& eventParameterName, const String& code, Node*, const String& sourceURL, int lineNumber, DOMWrapperWorld* isolatedWorld);
virtual JSC::JSObject* jsFunction(ScriptExecutionContext*) const;
virtual bool wasCreatedFromMarkup() const { return true; }
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSLocationCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSLocationCustom.cpp
index aecec5ea56..c76a2b18c9 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSLocationCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSLocationCustom.cpp
@@ -196,7 +196,7 @@ static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bo
return;
if (!protocolIsJavaScript(url) || allowsAccessFromFrame(exec, frame))
- frame->loader()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture(exec));
+ frame->redirectScheduler()->scheduleLocationChange(url.string(), lexicalFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, processingUserGesture(exec));
}
void JSLocation::setHref(ExecState* exec, JSValue value)
@@ -326,7 +326,7 @@ JSValue JSLocation::reload(ExecState* exec, const ArgList&)
return jsUndefined();
if (!protocolIsJavaScript(frame->loader()->url()))
- frame->loader()->scheduleRefresh(processingUserGesture(exec));
+ frame->redirectScheduler()->scheduleRefresh(processingUserGesture(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp
index 574e28ac08..d28d49474a 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp
@@ -36,17 +36,11 @@ void JSMessageChannel::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
- if (MessagePort* port = m_impl->port1()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), port);
- if (wrapper)
- markStack.append(wrapper);
- }
+ if (MessagePort* port = m_impl->port1())
+ markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), port);
- if (MessagePort* port = m_impl->port2()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), port);
- if (wrapper)
- markStack.append(wrapper);
- }
+ if (MessagePort* port = m_impl->port2())
+ markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), port);
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageEventCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageEventCustom.cpp
index 4c61c0409f..2e7b2d0626 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageEventCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageEventCustom.cpp
@@ -59,7 +59,7 @@ JSC::JSValue JSMessageEvent::initMessageEvent(JSC::ExecState* exec, const JSC::A
const UString& typeArg = args.at(0).toString(exec);
bool canBubbleArg = args.at(1).toBoolean(exec);
bool cancelableArg = args.at(2).toBoolean(exec);
- const UString& dataArg = args.at(3).toString(exec);
+ PassRefPtr<SerializedScriptValue> dataArg = SerializedScriptValue::create(exec, args.at(3));
const UString& originArg = args.at(4).toString(exec);
const UString& lastEventIdArg = args.at(5).toString(exec);
DOMWindow* sourceArg = toDOMWindow(args.at(6));
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp
index 210c93e283..2c09620cd3 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp
@@ -46,40 +46,29 @@ void JSMessagePort::markChildren(MarkStack& markStack)
Base::markChildren(markStack);
// If we have a locally entangled port, we can directly mark it as reachable. Ports that are remotely entangled are marked in-use by markActiveObjectsForContext().
- if (MessagePort* entangledPort = m_impl->locallyEntangledPort()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), entangledPort);
- if (wrapper)
- markStack.append(wrapper);
- }
+ if (MessagePort* entangledPort = m_impl->locallyEntangledPort())
+ markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), entangledPort);
m_impl->markEventListeners(markStack);
}
JSValue JSMessagePort::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSMessagePort::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.h b/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.h
index 7e9094392e..17b1eae80c 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.h
@@ -49,7 +49,7 @@ namespace WebCore {
template <typename T>
inline JSC::JSValue handlePostMessage(JSC::ExecState* exec, const JSC::ArgList& args, T* impl)
{
- String message = args.at(0).toString(exec);
+ PassRefPtr<SerializedScriptValue> message = SerializedScriptValue::create(exec, args.at(0));
MessagePortArray portArray;
fillMessagePortArray(exec, args.at(1), portArray);
if (exec->hadException())
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp
index 52f21e779c..2a4aa80bff 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp
@@ -110,37 +110,21 @@ JSValue JSNode::appendChild(ExecState* exec, const ArgList& args)
JSValue JSNode::addEventListener(ExecState* exec, const ArgList& args)
{
- Document* document = impl()->document();
- if (!document)
- return jsUndefined();
-
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(document);
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSNode::removeEventListener(ExecState* exec, const ArgList& args)
{
- Document* document = impl()->document();
- if (!document)
- return jsUndefined();
-
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(document);
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
@@ -159,10 +143,8 @@ void JSNode::markChildren(MarkStack& markStack)
// the document, we need to mark the document, but we don't need to explicitly
// mark any other nodes.
if (node->inDocument()) {
- if (Document* doc = node->ownerDocument()) {
- if (DOMObject* docWrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), doc))
- markStack.append(docWrapper);
- }
+ if (Document* doc = node->ownerDocument())
+ markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), doc);
return;
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp
index a199417d7a..54dc020037 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp
@@ -66,7 +66,7 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode)
if (exec->hadException())
return NodeFilter::FILTER_REJECT;
- JSValue result = call(exec, m_filter, callType, callData, m_filter, args);
+ JSValue result = callInWorld(exec, m_filter, callType, callData, m_filter, args, currentWorld(exec));
if (exec->hadException())
return NodeFilter::FILTER_REJECT;
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp
index a0551a10e4..2ab2c003cd 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "JSQuarantinedObjectWrapper.h"
+#include "JSDOMBinding.h"
+
#include <runtime/JSGlobalObject.h>
using namespace JSC;
@@ -243,7 +245,8 @@ JSObject* JSQuarantinedObjectWrapper::construct(ExecState* exec, JSObject* const
ConstructType unwrappedConstructType = wrapper->m_unwrappedObject->getConstructData(unwrappedConstructData);
ASSERT(unwrappedConstructType != ConstructTypeNone);
- JSValue unwrappedResult = JSC::construct(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedConstructType, unwrappedConstructData, preparedArgs);
+ // FIXME: Quarantined objects are all in the debuggerWorld(), for now. Instead, we should remove the quarantined objects, & replace them with an isolated world?
+ JSValue unwrappedResult = constructInWorld(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedConstructType, unwrappedConstructData, preparedArgs, debuggerWorld());
JSValue resultValue = wrapper->wrapOutgoingValue(wrapper->unwrappedExecState(), unwrappedResult);
ASSERT(resultValue.isObject());
@@ -293,7 +296,8 @@ JSValue JSQuarantinedObjectWrapper::call(ExecState* exec, JSObject* function, JS
CallType unwrappedCallType = wrapper->m_unwrappedObject->getCallData(unwrappedCallData);
ASSERT(unwrappedCallType != CallTypeNone);
- JSValue unwrappedResult = JSC::call(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedCallType, unwrappedCallData, preparedThisValue, preparedArgs);
+ // FIXME: Quarantined objects are all in the debuggerWorld(), for now. Instead, we should remove the quarantined objects, & replace them with an isolated world?
+ JSValue unwrappedResult = callInWorld(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedCallType, unwrappedCallData, preparedThisValue, preparedArgs, debuggerWorld());
JSValue result = wrapper->wrapOutgoingValue(wrapper->unwrappedExecState(), unwrappedResult);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h
index 94a92bdd0a..9f624951c0 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSQuarantinedObjectWrapper.h
@@ -47,10 +47,12 @@ namespace WebCore {
static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue proto)
{
- return JSC::Structure::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance | JSC::OverridesHasInstance));
+ return JSC::Structure::create(proto, JSC::TypeInfo(JSC::ObjectType, StructureFlags));
}
protected:
+ static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | JSC::OverridesHasInstance | JSC::OverridesMarkChildren | JSC::OverridesGetPropertyNames | JSC::JSObject::StructureFlags;
+
JSQuarantinedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, NonNullPassRefPtr<JSC::Structure>);
virtual void markChildren(JSC::MarkStack&);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp
index 571e3021ac..ba1cf22703 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp
@@ -50,29 +50,21 @@ void JSSVGElementInstance::markChildren(MarkStack& markStack)
JSValue JSSVGElementInstance::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSSVGElementInstance::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerCustom.cpp
index f21f50c9e6..4617087ea0 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerCustom.cpp
@@ -45,11 +45,8 @@ void JSSharedWorker::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
- if (MessagePort* port = impl()->port()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), port);
- if (wrapper)
- markStack.append(wrapper);
- }
+ if (MessagePort* port = impl()->port())
+ markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), port);
}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWebSocketCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWebSocketCustom.cpp
index d305502f87..33c3fcd586 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSWebSocketCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWebSocketCustom.cpp
@@ -36,6 +36,7 @@
#include "JSWebSocket.h"
#include "KURL.h"
+#include "JSEventListener.h"
#include "WebSocket.h"
#include "NotImplemented.h"
#include <runtime/Error.h>
@@ -59,7 +60,25 @@ JSValue JSWebSocket::send(ExecState* exec, const ArgList& args)
return ret;
}
-// FIXME: implement addEventListener/removeEventListener.
+JSValue JSWebSocket::addEventListener(ExecState* exec, const ArgList& args)
+{
+ JSValue listener = args.at(1);
+ if (!listener.isObject())
+ return jsUndefined();
+
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
+ return jsUndefined();
+}
+
+JSValue JSWebSocket::removeEventListener(ExecState* exec, const ArgList& args)
+{
+ JSValue listener = args.at(1);
+ if (!listener.isObject())
+ return jsUndefined();
+
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
+ return jsUndefined();
+}
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp
index e1c8a8c246..490d9b138a 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp
@@ -122,7 +122,7 @@ JSValue JSWorkerContext::addEventListener(ExecState* exec, const ArgList& args)
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
@@ -132,13 +132,13 @@ JSValue JSWorkerContext::removeEventListener(ExecState* exec, const ArgList& arg
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSWorkerContext::setTimeout(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args);
+ ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
@@ -147,7 +147,7 @@ JSValue JSWorkerContext::setTimeout(ExecState* exec, const ArgList& args)
JSValue JSWorkerContext::setInterval(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args);
+ ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
index 4b44db26eb..7ee2720180 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp
@@ -53,11 +53,8 @@ void JSXMLHttpRequest::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
- if (XMLHttpRequestUpload* upload = m_impl->optionalUpload()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), upload);
- if (wrapper)
- markStack.append(wrapper);
- }
+ if (XMLHttpRequestUpload* upload = m_impl->optionalUpload())
+ markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), upload);
m_impl->markEventListeners(markStack);
}
@@ -152,29 +149,21 @@ JSValue JSXMLHttpRequest::overrideMimeType(ExecState* exec, const ArgList& args)
JSValue JSXMLHttpRequest::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSXMLHttpRequest::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp
index dab0a3e3ba..fa7cfec41c 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp
@@ -45,40 +45,29 @@ void JSXMLHttpRequestUpload::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
- if (XMLHttpRequest* xmlHttpRequest = m_impl->associatedXMLHttpRequest()) {
- DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), xmlHttpRequest);
- if (wrapper)
- markStack.append(wrapper);
- }
+ if (XMLHttpRequest* xmlHttpRequest = m_impl->associatedXMLHttpRequest())
+ markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), xmlHttpRequest);
m_impl->markEventListeners(markStack);
}
JSValue JSXMLHttpRequestUpload::addEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false), args.at(2).toBoolean(exec));
+ impl()->addEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)), args.at(2).toBoolean(exec));
return jsUndefined();
}
JSValue JSXMLHttpRequestUpload::removeEventListener(ExecState* exec, const ArgList& args)
{
- JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext());
- if (!globalObject)
- return jsUndefined();
-
JSValue listener = args.at(1);
if (!listener.isObject())
return jsUndefined();
- impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false).get(), args.at(2).toBoolean(exec));
+ impl()->removeEventListener(args.at(0).toString(exec), JSEventListener::create(asObject(listener), false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
return jsUndefined();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp
index 9e64bceb9a..9a21b6b99d 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp
@@ -47,7 +47,7 @@ using namespace JSC;
namespace WebCore {
-ScheduledAction* ScheduledAction::create(ExecState* exec, const ArgList& args)
+ScheduledAction* ScheduledAction::create(ExecState* exec, const ArgList& args, DOMWrapperWorld* isolatedWorld)
{
JSValue v = args.at(0);
CallData callData;
@@ -55,15 +55,16 @@ ScheduledAction* ScheduledAction::create(ExecState* exec, const ArgList& args)
UString string = v.toString(exec);
if (exec->hadException())
return 0;
- return new ScheduledAction(string);
+ return new ScheduledAction(string, isolatedWorld);
}
ArgList argsTail;
args.getSlice(2, argsTail);
- return new ScheduledAction(v, argsTail);
+ return new ScheduledAction(v, argsTail, isolatedWorld);
}
-ScheduledAction::ScheduledAction(JSValue function, const ArgList& args)
+ScheduledAction::ScheduledAction(JSValue function, const ArgList& args, DOMWrapperWorld* isolatedWorld)
: m_function(function)
+ , m_isolatedWorld(isolatedWorld)
{
ArgList::const_iterator end = args.end();
for (ArgList::const_iterator it = args.begin(); it != end; ++it)
@@ -102,7 +103,7 @@ void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSV
args.append(m_args[i]);
globalObject->globalData()->timeoutChecker.start();
- call(exec, m_function, callType, callData, thisValue, args);
+ callInWorld(exec, m_function, callType, callData, thisValue, args, m_isolatedWorld.get());
globalObject->globalData()->timeoutChecker.stop();
if (exec->hadException())
@@ -111,7 +112,7 @@ void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSV
void ScheduledAction::execute(Document* document)
{
- JSDOMWindow* window = toJSDOMWindow(document->frame());
+ JSDOMWindow* window = toJSDOMWindow(document->frame(), m_isolatedWorld.get());
if (!window)
return;
@@ -125,7 +126,7 @@ void ScheduledAction::execute(Document* document)
executeFunctionInContext(window, window->shell());
Document::updateStyleForAllDocuments();
} else
- frame->loader()->executeScript(m_code);
+ frame->script()->executeScriptInIsolatedWorld(m_isolatedWorld.get(), m_code);
frame->script()->setProcessingTimerCallback(false);
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.h b/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.h
index e7d0b750b3..4ea727d5f7 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.h
@@ -21,6 +21,8 @@
#define ScheduledAction_h
#include "PlatformString.h"
+#include <JSDOMBinding.h>
+#include <runtime/JSCell.h>
#include <runtime/Protect.h>
#include <wtf/Vector.h>
@@ -40,14 +42,15 @@ namespace WebCore {
*/
class ScheduledAction {
public:
- static ScheduledAction* create(JSC::ExecState*, const JSC::ArgList&);
+ static ScheduledAction* create(JSC::ExecState*, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld);
void execute(ScriptExecutionContext*);
private:
- ScheduledAction(JSC::JSValue function, const JSC::ArgList&);
- ScheduledAction(const String& code)
+ ScheduledAction(JSC::JSValue function, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld);
+ ScheduledAction(const String& code, DOMWrapperWorld* isolatedWorld)
: m_code(code)
+ , m_isolatedWorld(isolatedWorld)
{
}
@@ -60,6 +63,7 @@ namespace WebCore {
JSC::ProtectedJSValue m_function;
Vector<JSC::ProtectedJSValue> m_args;
String m_code;
+ RefPtr<DOMWrapperWorld> m_isolatedWorld;
};
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp
index 8852611247..e01324e178 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp
@@ -48,8 +48,9 @@ ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame)
JSLock lock(SilenceAssertionsOnly);
ScriptController* scriptController = frame->script();
- if (scriptController->haveWindowShell()) {
- m_window = scriptController->windowShell()->window();
+ // FIXME: explicitly save and restore isolated worlds' global objects when using the back/forward cache. <rdar://problem/7328111>
+ if (JSDOMWindowShell* windowShell = scriptController->existingWindowShell(mainThreadNormalWorld())) {
+ m_window = windowShell->window();
scriptController->attachDebugger(0);
}
}
@@ -70,11 +71,11 @@ void ScriptCachedFrameData::restore(Frame* frame)
JSLock lock(SilenceAssertionsOnly);
ScriptController* scriptController = frame->script();
- if (scriptController->haveWindowShell()) {
- JSDOMWindowShell* windowShell = scriptController->windowShell();
- if (m_window) {
+ // FIXME: explicitly save and restore isolated worlds' global objects when using the back/forward cache. <rdar://problem/7328111>
+ if (JSDOMWindowShell* windowShell = scriptController->existingWindowShell(mainThreadNormalWorld())) {
+ if (m_window)
windowShell->setWindow(m_window.get());
- } else {
+ else {
windowShell->setWindow(frame->domWindow());
scriptController->attachDebugger(page->debugger());
windowShell->window()->setProfileGroup(page->group().identifier());
@@ -86,7 +87,7 @@ void ScriptCachedFrameData::clear()
{
JSLock lock(SilenceAssertionsOnly);
- if (!m_window) {
+ if (m_window) {
m_window = 0;
gcController().garbageCollectSoon();
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp
index dfa16026ed..4a1d413bc5 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp
@@ -21,6 +21,7 @@
#include "config.h"
#include "ScriptController.h"
+#include "CString.h"
#include "Event.h"
#include "EventNames.h"
#include "Frame.h"
@@ -38,16 +39,23 @@
#include "npruntime_impl.h"
#include "runtime_root.h"
#include <debugger/Debugger.h>
+#include <runtime/InitializeThreading.h>
#include <runtime/JSLock.h>
using namespace JSC;
namespace WebCore {
+void ScriptController::initializeThreading()
+{
+ JSC::initializeThreading();
+}
+
ScriptController::ScriptController(Frame* frame)
: m_frame(frame)
, m_handlerLineNumber(0)
, m_sourceURL(0)
+ , m_inExecuteScript(false)
, m_processingTimerCallback(false)
, m_paused(false)
, m_allowPopupsFromPlugin(false)
@@ -70,8 +78,11 @@ ScriptController::ScriptController(Frame* frame)
ScriptController::~ScriptController()
{
- if (m_windowShell) {
- m_windowShell = 0;
+ if (!m_windowShells.isEmpty()) {
+ for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
+ iter->first->forgetScriptController(this);
+
+ m_windowShells.clear();
// It's likely that releasing the global object has created a lot of garbage.
gcController().garbageCollectSoon();
@@ -80,11 +91,11 @@ ScriptController::~ScriptController()
disconnectPlatformScriptObjects();
}
-ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
+ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode, DOMWrapperWorld* world)
{
const SourceCode& jsSourceCode = sourceCode.jsSourceCode();
String sourceURL = jsSourceCode.provider()->url();
-
+
if (!m_XSSAuditor->canEvaluate(sourceCode.source())) {
// This script is not safe to be evaluated.
return JSValue();
@@ -93,12 +104,12 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
// evaluate code. Returns the JS return value or 0
// if there was none, an error occured or the type couldn't be converted.
- initScriptIfNeeded();
// inlineCode is true for <a href="javascript:doSomething()">
// and false for <script>doSomething()</script>. Check if it has the
// expected value in all cases.
// See smart window.open policy for where this is used.
- ExecState* exec = m_windowShell->window()->globalExec();
+ JSDOMWindowShell* shell = windowShell(world);
+ ExecState* exec = shell->window()->globalExec();
const String* savedSourceURL = m_sourceURL;
m_sourceURL = &sourceURL;
@@ -106,9 +117,9 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
RefPtr<Frame> protect = m_frame;
- m_windowShell->window()->globalData()->timeoutChecker.start();
- Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, m_windowShell);
- m_windowShell->window()->globalData()->timeoutChecker.stop();
+ exec->globalData().timeoutChecker.start();
+ Completion comp = WebCore::evaluateInWorld(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, shell, world);
+ exec->globalData().timeoutChecker.stop();
// Evaluating the JavaScript could cause the frame to be deallocated
// so we start the keep alive timer here.
@@ -126,52 +137,114 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
return JSValue();
}
-void ScriptController::evaluateInIsolatedWorld(unsigned /* worldID */, const Vector<ScriptSourceCode>& sourceCode)
+ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
+{
+ return evaluateInWorld(sourceCode, mainThreadNormalWorld());
+}
+
+// An DOMWrapperWorld other than the thread's normal world.
+class IsolatedWorld : public DOMWrapperWorld {
+public:
+ IsolatedWorld(JSGlobalData* globalData)
+ : DOMWrapperWorld(globalData)
+ {
+ JSGlobalData::ClientData* clientData = globalData->clientData;
+ ASSERT(clientData);
+ static_cast<WebCoreJSClientData*>(clientData)->rememberWorld(this);
+ }
+
+ static PassRefPtr<IsolatedWorld> create(JSGlobalData* globalData) { return adoptRef(new IsolatedWorld(globalData)); }
+};
+
+static PassRefPtr<IsolatedWorld> findWorld(unsigned worldID)
+{
+ if (!worldID)
+ return IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
+
+ typedef HashMap<unsigned, RefPtr<IsolatedWorld> > WorldMap;
+ DEFINE_STATIC_LOCAL(WorldMap, isolatedWorlds, ());
+
+ WorldMap::iterator iter = isolatedWorlds.find(worldID);
+ if (iter != isolatedWorlds.end())
+ return iter->second;
+
+ RefPtr<IsolatedWorld> newWorld = IsolatedWorld::create(JSDOMWindow::commonJSGlobalData());
+ isolatedWorlds.add(worldID, newWorld);
+ return newWorld;
+}
+
+JSDOMWindow* ScriptController::globalObject(unsigned worldID)
+{
+ RefPtr<DOMWrapperWorld> world = findWorld(worldID);
+ return windowShell(world.get())->window();
+}
+
+ScriptValue ScriptController::evaluateInIsolatedWorld(unsigned worldID, const ScriptSourceCode& sourceCode)
+{
+ RefPtr<DOMWrapperWorld> world = findWorld(worldID);
+ return evaluateInWorld(sourceCode, world.get());
+}
+
+void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sourceCode)
{
- // FIXME: Actually support isolated worlds!
+ RefPtr<DOMWrapperWorld> world = findWorld(worldID);
+
unsigned size = sourceCode.size();
for (unsigned i = 0; i < size; ++i)
- evaluate(sourceCode[i]);
+ evaluateInWorld(sourceCode[i], world.get());
}
void ScriptController::clearWindowShell()
{
- if (!m_windowShell)
+ if (m_windowShells.isEmpty())
return;
JSLock lock(SilenceAssertionsOnly);
// Clear the debugger from the current window before setting the new window.
+ DOMWrapperWorld* debugWorld = debuggerWorld();
attachDebugger(0);
- m_windowShell->window()->willRemoveFromWindowShell();
- m_windowShell->setWindow(m_frame->domWindow());
+ for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) {
+ DOMWrapperWorld* world = iter->first;
+ JSDOMWindowShell* windowShell = iter->second;
+ windowShell->window()->willRemoveFromWindowShell();
+ windowShell->setWindow(m_frame->domWindow());
- if (Page* page = m_frame->page()) {
- attachDebugger(page->debugger());
- m_windowShell->window()->setProfileGroup(page->group().identifier());
+ if (Page* page = m_frame->page()) {
+ if (world == debugWorld)
+ attachDebugger(page->debugger());
+ windowShell->window()->setProfileGroup(page->group().identifier());
+ }
}
// There is likely to be a lot of garbage now.
gcController().garbageCollectSoon();
}
-void ScriptController::initScript()
+JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)
{
- if (m_windowShell)
- return;
+ ASSERT(!m_windowShells.contains(world));
JSLock lock(SilenceAssertionsOnly);
- m_windowShell = new JSDOMWindowShell(m_frame->domWindow());
- m_windowShell->window()->updateDocument();
+ JSDOMWindowShell* windowShell = new JSDOMWindowShell(m_frame->domWindow());
+ m_windowShells.add(world, windowShell);
+ world->rememberScriptController(this);
+ windowShell->window()->updateDocument(world);
if (Page* page = m_frame->page()) {
- attachDebugger(page->debugger());
- m_windowShell->window()->setProfileGroup(page->group().identifier());
+ if (world == debuggerWorld())
+ attachDebugger(page->debugger());
+ windowShell->window()->setProfileGroup(page->group().identifier());
}
- m_frame->loader()->dispatchWindowObjectAvailable();
+ {
+ EnterDOMWrapperWorld worldEntry(*JSDOMWindow::commonJSGlobalData(), world);
+ m_frame->loader()->dispatchWindowObjectAvailable();
+ }
+
+ return windowShell;
}
bool ScriptController::processingUserGesture() const
@@ -181,10 +254,14 @@ bool ScriptController::processingUserGesture() const
bool ScriptController::processingUserGestureEvent() const
{
- if (!m_windowShell)
+ JSDOMWindowShell* shell = existingWindowShell(mainThreadNormalWorld());
+ if (!shell)
return false;
- if (Event* event = m_windowShell->window()->currentEvent()) {
+ if (Event* event = shell->window()->currentEvent()) {
+ if (event->createdByDOM())
+ return false;
+
const AtomicString& type = event->type();
if ( // mouse events
type == eventNames().clickEvent || type == eventNames().mousedownEvent ||
@@ -239,13 +316,16 @@ bool ScriptController::isEnabled()
void ScriptController::attachDebugger(JSC::Debugger* debugger)
{
- if (!m_windowShell)
+ // FIXME: Should be able to debug isolated worlds.
+ JSDOMWindowShell* shell = existingWindowShell(debuggerWorld());
+ if (!shell)
return;
+ JSDOMWindow* globalObject = shell->window();
if (debugger)
- debugger->attach(m_windowShell->window());
- else if (JSC::Debugger* currentDebugger = m_windowShell->window()->debugger())
- currentDebugger->detach(m_windowShell->window());
+ debugger->attach(globalObject);
+ else if (JSC::Debugger* currentDebugger = globalObject->debugger())
+ currentDebugger->detach(globalObject);
}
void ScriptController::updateDocument()
@@ -254,8 +334,8 @@ void ScriptController::updateDocument()
return;
JSLock lock(SilenceAssertionsOnly);
- if (m_windowShell)
- m_windowShell->window()->updateDocument();
+ for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
+ iter->second->window()->updateDocument(iter->first);
}
void ScriptController::updateSecurityOrigin()
@@ -270,7 +350,7 @@ Bindings::RootObject* ScriptController::bindingRootObject()
if (!m_bindingRootObject) {
JSLock lock(SilenceAssertionsOnly);
- m_bindingRootObject = Bindings::RootObject::create(0, globalObject());
+ m_bindingRootObject = Bindings::RootObject::create(0, globalObject(pluginWorld()));
}
return m_bindingRootObject.get();
}
@@ -281,7 +361,7 @@ PassRefPtr<Bindings::RootObject> ScriptController::createRootObject(void* native
if (it != m_rootObjects.end())
return it->second;
- RefPtr<Bindings::RootObject> rootObject = Bindings::RootObject::create(nativeHandle, globalObject());
+ RefPtr<Bindings::RootObject> rootObject = Bindings::RootObject::create(nativeHandle, globalObject(pluginWorld()));
m_rootObjects.set(nativeHandle, rootObject);
return rootObject.release();
@@ -296,7 +376,7 @@ NPObject* ScriptController::windowScriptNPObject()
// JavaScript is enabled, so there is a JavaScript window object.
// Return an NPObject bound to the window object.
JSC::JSLock lock(SilenceAssertionsOnly);
- JSObject* win = windowShell()->window();
+ JSObject* win = windowShell(pluginWorld())->window();
ASSERT(win);
Bindings::RootObject* root = bindingRootObject();
m_windowScriptNPObject = _NPN_CreateScriptObject(0, win, root);
@@ -330,8 +410,9 @@ JSObject* ScriptController::jsObjectForPluginElement(HTMLPlugInElement* plugin)
// Create a JSObject bound to this element
JSLock lock(SilenceAssertionsOnly);
- ExecState* exec = globalObject()->globalExec();
- JSValue jsElementValue = toJS(exec, globalObject(), plugin);
+ JSDOMWindow* globalObj = globalObject(pluginWorld());
+ // FIXME: is normal okay? - used for NP plugins?
+ JSValue jsElementValue = toJS(globalObj->globalExec(), globalObj, plugin);
if (!jsElementValue || !jsElementValue.isObject())
return 0;
@@ -387,4 +468,44 @@ void ScriptController::clearScriptObjects()
#endif
}
+ScriptValue ScriptController::executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture)
+{
+ ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
+
+ if (!isEnabled() || isPaused())
+ return ScriptValue();
+
+ bool wasInExecuteScript = m_inExecuteScript;
+ m_inExecuteScript = true;
+
+ ScriptValue result = evaluateInIsolatedWorld(worldID, sourceCode);
+
+ if (!wasInExecuteScript) {
+ m_inExecuteScript = false;
+ Document::updateStyleForAllDocuments();
+ }
+
+ return result;
+}
+
+ScriptValue ScriptController::executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
+{
+ ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
+
+ if (!isEnabled() || isPaused())
+ return ScriptValue();
+
+ bool wasInExecuteScript = m_inExecuteScript;
+ m_inExecuteScript = true;
+
+ ScriptValue result = evaluateInWorld(sourceCode, world);
+
+ if (!wasInExecuteScript) {
+ m_inExecuteScript = false;
+ Document::updateStyleForAllDocuments();
+ }
+
+ return result;
+}
+
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h
index 56e8f0c927..f2a497d191 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.h
@@ -63,25 +63,49 @@ class XSSAuditor;
typedef HashMap<void*, RefPtr<JSC::Bindings::RootObject> > RootObjectMap;
class ScriptController {
+ typedef WTF::HashMap<DOMWrapperWorld*, JSC::ProtectedPtr<JSDOMWindowShell> > ShellMap;
+
public:
ScriptController(Frame*);
~ScriptController();
- bool haveWindowShell() const { return m_windowShell; }
- JSDOMWindowShell* windowShell()
+ JSDOMWindowShell* windowShell(DOMWrapperWorld* world)
+ {
+ ShellMap::iterator iter = m_windowShells.find(world);
+ return (iter != m_windowShells.end()) ? iter->second.get() : initScript(world);
+ }
+ JSDOMWindowShell* existingWindowShell(DOMWrapperWorld* world) const
{
- initScriptIfNeeded();
- return m_windowShell;
+ ShellMap::const_iterator iter = m_windowShells.find(world);
+ return (iter != m_windowShells.end()) ? iter->second.get() : 0;
}
+ JSDOMWindow* globalObject(DOMWrapperWorld* world)
+ {
+ return windowShell(world)->window();
+ }
+ JSDOMWindow* globalObject(unsigned worldID);
- JSDOMWindow* globalObject()
+ void forgetWorld(DOMWrapperWorld* world)
{
- initScriptIfNeeded();
- return m_windowShell->window();
+ m_windowShells.remove(world);
}
+ ScriptValue executeScript(const ScriptSourceCode&);
+ ScriptValue executeScript(const String& script, bool forceUserGesture = false);
+ ScriptValue executeScriptInIsolatedWorld(unsigned worldID, const String& script, bool forceUserGesture = false);
+ ScriptValue executeScriptInIsolatedWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
+
+ // Returns true if argument is a JavaScript URL.
+ bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);
+
+ // This function must be called from the main thread. It is safe to call it repeatedly.
+ // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly.
+ static void initializeThreading();
+
ScriptValue evaluate(const ScriptSourceCode&);
- void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&);
+ ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
+ ScriptValue evaluateInIsolatedWorld(unsigned /*worldID*/, const ScriptSourceCode&);
+ void evaluateInIsolatedWorld(unsigned /*worldID*/, const Vector<ScriptSourceCode>&);
void setEventHandlerLineNumber(int lineno) { m_handlerLineNumber = lineno; }
int eventHandlerLineNumber() { return m_handlerLineNumber; }
@@ -138,23 +162,20 @@ public:
XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); }
private:
- void initScriptIfNeeded()
- {
- if (!m_windowShell)
- initScript();
- }
- void initScript();
+ JSDOMWindowShell* initScript(DOMWrapperWorld* world);
void disconnectPlatformScriptObjects();
bool processingUserGestureEvent() const;
bool isJavaScriptAnchorNavigation() const;
- JSC::ProtectedPtr<JSDOMWindowShell> m_windowShell;
+ ShellMap m_windowShells;
Frame* m_frame;
int m_handlerLineNumber;
const String* m_sourceURL;
+ bool m_inExecuteScript;
+
bool m_processingTimerCallback;
bool m_paused;
bool m_allowPopupsFromPlugin;
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm
index e6a654f06e..21ec0f2873 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm
@@ -114,7 +114,7 @@ WebScriptObject* ScriptController::windowScriptObject()
if (!m_windowScriptObject) {
JSC::JSLock lock(JSC::SilenceAssertionsOnly);
JSC::Bindings::RootObject* root = bindingRootObject();
- m_windowScriptObject = [WebScriptObject scriptObjectForJSObject:toRef(windowShell()) originRootObject:root rootObject:root];
+ m_windowScriptObject = [WebScriptObject scriptObjectForJSObject:toRef(windowShell(pluginWorld())) originRootObject:root rootObject:root];
}
ASSERT([m_windowScriptObject.get() isKindOfClass:[DOMAbstractView class]]);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp
index 0b0047b283..8399c7acb4 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp
@@ -71,7 +71,7 @@ PassRefPtr<JSLazyEventListener> createAttributeEventListener(Node* node, Attribu
sourceURL = node->document()->url().string();
}
- return JSLazyEventListener::create(attr->localName().string(), eventParameterName(node->isSVGElement()), attr->value(), node, sourceURL, lineNumber);
+ return JSLazyEventListener::create(attr->localName().string(), eventParameterName(node->isSVGElement()), attr->value(), node, sourceURL, lineNumber, mainThreadNormalWorld());
}
PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame* frame, Attribute* attr)
@@ -93,7 +93,7 @@ PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame* frame, Attri
lineNumber = scriptController->eventHandlerLineNumber();
sourceURL = frame->document()->url().string();
- return JSLazyEventListener::create(attr->localName().string(), eventParameterName(frame->document()->isSVGDocument()), attr->value(), 0, sourceURL, lineNumber);
+ return JSLazyEventListener::create(attr->localName().string(), eventParameterName(frame->document()->isSVGDocument()), attr->value(), 0, sourceURL, lineNumber, mainThreadNormalWorld());
}
String getEventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* eventListener)
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp
index 46e80acf6c..91b2a57614 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp
@@ -123,7 +123,8 @@ ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions)
if (callType == CallTypeNone)
return ScriptValue();
- JSValue result = JSC::call(m_exec, function, callType, callData, thisObject, m_arguments);
+ // FIXME: Should this function take a worldID? - only used by inspector?
+ JSValue result = callInWorld(m_exec, function, callType, callData, thisObject, m_arguments, debuggerWorld());
if (m_exec->hadException()) {
if (reportExceptions)
reportException(m_exec, m_exec->exception());
@@ -161,7 +162,8 @@ ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept
if (constructType == ConstructTypeNone)
return ScriptObject();
- JSValue result = JSC::construct(m_exec, constructor, constructType, constructData, m_arguments);
+ // FIXME: Currently this method constructs objects in debuggerWorld(). We could use the current world, or pass a worldID to this function?
+ JSValue result = constructInWorld(m_exec, constructor, constructType, constructData, m_arguments, debuggerWorld());
if (m_exec->hadException()) {
if (reportExceptions)
reportException(m_exec, m_exec->exception());
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp
index b527a96a13..1172e8e81f 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp
@@ -103,6 +103,14 @@ bool ScriptObject::set(const char* name, int value)
return handleException(m_scriptState);
}
+bool ScriptObject::set(const char* name, unsigned value)
+{
+ JSLock lock(SilenceAssertionsOnly);
+ PutPropertySlot slot;
+ jsObject()->put(m_scriptState, Identifier(m_scriptState, name), jsNumber(m_scriptState, value), slot);
+ return handleException(m_scriptState);
+}
+
bool ScriptObject::set(const char* name, bool value)
{
JSLock lock(SilenceAssertionsOnly);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h
index a8b11e076f..31381f39df 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h
@@ -52,6 +52,7 @@ namespace WebCore {
bool set(const char* name, double);
bool set(const char* name, long long);
bool set(const char* name, int);
+ bool set(const char* name, unsigned);
bool set(const char* name, bool);
static ScriptObject createNew(ScriptState*);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp
index b48556e6de..313530feca 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp
@@ -72,7 +72,7 @@ bool getQuarantinedScriptObject(Database* database, ScriptObject& quarantinedObj
if (!frame)
return false;
- JSDOMGlobalObject* globalObject = toJSDOMWindow(frame);
+ JSDOMGlobalObject* globalObject = toJSDOMWindow(frame, debuggerWorld());
ExecState* exec = globalObject->globalExec();
JSLock lock(SilenceAssertionsOnly);
@@ -89,7 +89,7 @@ bool getQuarantinedScriptObject(Storage* storage, ScriptObject& quarantinedObjec
Frame* frame = storage->frame();
ASSERT(frame);
- JSDOMGlobalObject* globalObject = toJSDOMWindow(frame);
+ JSDOMGlobalObject* globalObject = toJSDOMWindow(frame, debuggerWorld());
ExecState* exec = globalObject->globalExec();
JSLock lock(SilenceAssertionsOnly);
@@ -116,7 +116,7 @@ bool getQuarantinedScriptObject(DOMWindow* domWindow, ScriptObject& quarantinedO
{
ASSERT(domWindow);
- JSDOMWindow* window = toJSDOMWindow(domWindow->frame());
+ JSDOMWindow* window = toJSDOMWindow(domWindow->frame(), debuggerWorld());
ExecState* exec = window->globalExec();
JSLock lock(SilenceAssertionsOnly);
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h
index 1b05dedb6d..32d6298cdb 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h
@@ -44,6 +44,7 @@ public:
ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1)
: m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string()))
, m_code(m_provider, startLine)
+ , m_url(url)
{
}
@@ -59,10 +60,17 @@ public:
const String& source() const { return m_provider->source(); }
+ int startLine() const { return m_code.firstLine(); }
+
+ const KURL& url() const { return m_url; }
+
private:
RefPtr<ScriptSourceProvider> m_provider;
JSC::SourceCode m_code;
+
+ KURL m_url;
+
};
} // namespace WebCore
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp
index 8bfa33d15b..60ba2a05d7 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.cpp
@@ -32,6 +32,7 @@
#include "ScriptState.h"
#include "Frame.h"
+#include "JSDOMWindowBase.h"
#include "Node.h"
#include "Page.h"
@@ -49,12 +50,12 @@ ScriptState* scriptStateFromNode(Node* node)
return 0;
if (!frame->script()->isEnabled())
return 0;
- return frame->script()->globalObject()->globalExec();
+ return frame->script()->globalObject(mainThreadCurrentWorld())->globalExec();
}
ScriptState* scriptStateFromPage(Page* page)
{
- return page->mainFrame()->script()->globalObject()->globalExec();
+ return page->mainFrame()->script()->globalObject(mainThreadCurrentWorld())->globalExec();
}
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h
index fa5c4a8576..279234e4a8 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptState.h
@@ -35,6 +35,7 @@
#include "JSDOMBinding.h"
namespace WebCore {
+ class DOMWrapperWorld;
class Node;
class Page;
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.cpp b/src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.cpp
new file mode 100644
index 0000000000..48cd92d7c4
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -0,0 +1,839 @@
+/*
+ * Copyright (C) 2009 Apple 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 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 "SerializedScriptValue.h"
+
+#include <runtime/DateInstance.h>
+#include <runtime/ExceptionHelpers.h>
+#include <runtime/PropertyNameArray.h>
+#include <wtf/HashTraits.h>
+#include <wtf/Vector.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+class SerializedObject : public SharedSerializedData
+{
+public:
+ typedef Vector<RefPtr<StringImpl> > PropertyNameList;
+ typedef Vector<SerializedScriptValueData> ValueList;
+
+ void set(const Identifier& propertyName, const SerializedScriptValueData& value)
+ {
+ ASSERT(m_names.size() == m_values.size());
+ m_names.append(String(propertyName.ustring()).crossThreadString().impl());
+ m_values.append(value);
+ }
+
+ PropertyNameList& names() { return m_names; }
+
+ ValueList& values() { return m_values; }
+
+ static PassRefPtr<SerializedObject> create()
+ {
+ return adoptRef(new SerializedObject);
+ }
+
+ void clear()
+ {
+ m_names.clear();
+ m_values.clear();
+ }
+
+private:
+ SerializedObject() { }
+ PropertyNameList m_names;
+ ValueList m_values;
+};
+
+class SerializedArray : public SharedSerializedData
+{
+ typedef HashMap<unsigned, SerializedScriptValueData, DefaultHash<unsigned>::Hash, WTF::UnsignedWithZeroKeyHashTraits<unsigned> > SparseMap;
+public:
+ void setIndex(unsigned index, const SerializedScriptValueData& value)
+ {
+ ASSERT(index < m_length);
+ if (index == m_compactStorage.size())
+ m_compactStorage.append(value);
+ else
+ m_sparseStorage.set(index, value);
+ }
+
+ bool canDoFastRead(unsigned index) const
+ {
+ ASSERT(index < m_length);
+ return index < m_compactStorage.size();
+ }
+
+ const SerializedScriptValueData& getIndex(unsigned index)
+ {
+ ASSERT(index < m_compactStorage.size());
+ return m_compactStorage[index];
+ }
+
+ SerializedScriptValueData getSparseIndex(unsigned index, bool& hasIndex)
+ {
+ ASSERT(index >= m_compactStorage.size());
+ ASSERT(index < m_length);
+ SparseMap::iterator iter = m_sparseStorage.find(index);
+ if (iter == m_sparseStorage.end()) {
+ hasIndex = false;
+ return SerializedScriptValueData();
+ }
+ hasIndex = true;
+ return iter->second;
+ }
+
+ unsigned length() const
+ {
+ return m_length;
+ }
+
+ static PassRefPtr<SerializedArray> create(unsigned length)
+ {
+ return adoptRef(new SerializedArray(length));
+ }
+
+ void clear()
+ {
+ m_compactStorage.clear();
+ m_sparseStorage.clear();
+ m_length = 0;
+ }
+private:
+ SerializedArray(unsigned length)
+ : m_length(length)
+ {
+ }
+
+ Vector<SerializedScriptValueData> m_compactStorage;
+ SparseMap m_sparseStorage;
+ unsigned m_length;
+};
+
+SerializedScriptValueData::SerializedScriptValueData(RefPtr<SerializedObject> data)
+ : m_type(ObjectType)
+ , m_sharedData(data)
+{
+}
+
+SerializedScriptValueData::SerializedScriptValueData(RefPtr<SerializedArray> data)
+ : m_type(ArrayType)
+ , m_sharedData(data)
+{
+}
+
+SerializedArray* SharedSerializedData::asArray()
+{
+ return static_cast<SerializedArray*>(this);
+}
+
+SerializedObject* SharedSerializedData::asObject()
+{
+ return static_cast<SerializedObject*>(this);
+}
+
+static const unsigned maximumFilterRecursion = 40000;
+enum WalkerState { StateUnknown, ArrayStartState, ArrayStartVisitMember, ArrayEndVisitMember,
+ ObjectStartState, ObjectStartVisitMember, ObjectEndVisitMember };
+template <typename TreeWalker> typename TreeWalker::OutputType walk(TreeWalker& context, typename TreeWalker::InputType in)
+{
+ typedef typename TreeWalker::InputObject InputObject;
+ typedef typename TreeWalker::InputArray InputArray;
+ typedef typename TreeWalker::OutputObject OutputObject;
+ typedef typename TreeWalker::OutputArray OutputArray;
+ typedef typename TreeWalker::InputType InputType;
+ typedef typename TreeWalker::OutputType OutputType;
+ typedef typename TreeWalker::PropertyList PropertyList;
+
+ Vector<uint32_t, 16> indexStack;
+ Vector<uint32_t, 16> lengthStack;
+ Vector<PropertyList, 16> propertyStack;
+ Vector<InputObject, 16> inputObjectStack;
+ Vector<InputArray, 16> inputArrayStack;
+ Vector<OutputObject, 16> outputObjectStack;
+ Vector<OutputArray, 16> outputArrayStack;
+ Vector<WalkerState, 16> stateStack;
+ WalkerState state = StateUnknown;
+ InputType inValue = in;
+ OutputType outValue = context.null();
+
+ unsigned tickCount = context.ticksUntilNextCheck();
+ while (1) {
+ switch (state) {
+ arrayStartState:
+ case ArrayStartState: {
+ ASSERT(context.isArray(inValue));
+ if (inputObjectStack.size() + inputArrayStack.size() > maximumFilterRecursion) {
+ context.throwStackOverflow();
+ return context.null();
+ }
+
+ InputArray inArray = context.asInputArray(inValue);
+ unsigned length = context.length(inArray);
+ OutputArray outArray = context.createOutputArray(length);
+ if (!context.startArray(inArray, outArray))
+ return context.null();
+ inputArrayStack.append(inArray);
+ outputArrayStack.append(outArray);
+ indexStack.append(0);
+ lengthStack.append(length);
+ // fallthrough
+ }
+ arrayStartVisitMember:
+ case ArrayStartVisitMember: {
+ if (!--tickCount) {
+ if (context.didTimeOut()) {
+ context.throwInterruptedException();
+ return context.null();
+ }
+ tickCount = context.ticksUntilNextCheck();
+ }
+
+ InputArray array = inputArrayStack.last();
+ uint32_t index = indexStack.last();
+ if (index == lengthStack.last()) {
+ InputArray inArray = inputArrayStack.last();
+ OutputArray outArray = outputArrayStack.last();
+ context.endArray(inArray, outArray);
+ outValue = outArray;
+ inputArrayStack.removeLast();
+ outputArrayStack.removeLast();
+ indexStack.removeLast();
+ lengthStack.removeLast();
+ break;
+ }
+ if (context.canDoFastRead(array, index))
+ inValue = context.getIndex(array, index);
+ else {
+ bool hasIndex = false;
+ inValue = context.getSparseIndex(array, index, hasIndex);
+ if (!hasIndex) {
+ indexStack.last()++;
+ goto arrayStartVisitMember;
+ }
+ }
+
+ if (OutputType transformed = context.convertIfTerminal(inValue))
+ outValue = transformed;
+ else {
+ stateStack.append(ArrayEndVisitMember);
+ goto stateUnknown;
+ }
+ // fallthrough
+ }
+ case ArrayEndVisitMember: {
+ OutputArray outArray = outputArrayStack.last();
+ context.putProperty(outArray, indexStack.last(), outValue);
+ indexStack.last()++;
+ goto arrayStartVisitMember;
+ }
+ objectStartState:
+ case ObjectStartState: {
+ ASSERT(context.isObject(inValue));
+ if (inputObjectStack.size() + inputArrayStack.size() > maximumFilterRecursion) {
+ context.throwStackOverflow();
+ return context.null();
+ }
+ InputObject inObject = context.asInputObject(inValue);
+ OutputObject outObject = context.createOutputObject();
+ if (!context.startObject(inObject, outObject))
+ return context.null();
+ inputObjectStack.append(inObject);
+ outputObjectStack.append(outObject);
+ indexStack.append(0);
+ context.getPropertyNames(inObject, propertyStack);
+ // fallthrough
+ }
+ objectStartVisitMember:
+ case ObjectStartVisitMember: {
+ if (!--tickCount) {
+ if (context.didTimeOut()) {
+ context.throwInterruptedException();
+ return context.null();
+ }
+ tickCount = context.ticksUntilNextCheck();
+ }
+
+ InputObject object = inputObjectStack.last();
+ uint32_t index = indexStack.last();
+ PropertyList& properties = propertyStack.last();
+ if (index == properties.size()) {
+ InputObject inObject = inputObjectStack.last();
+ OutputObject outObject = outputObjectStack.last();
+ context.endObject(inObject, outObject);
+ outValue = outObject;
+ inputObjectStack.removeLast();
+ outputObjectStack.removeLast();
+ indexStack.removeLast();
+ propertyStack.removeLast();
+ break;
+ }
+ inValue = context.getProperty(object, properties[index], index);
+
+ if (context.shouldTerminate())
+ return context.null();
+
+ if (OutputType transformed = context.convertIfTerminal(inValue))
+ outValue = transformed;
+ else {
+ stateStack.append(ObjectEndVisitMember);
+ goto stateUnknown;
+ }
+ // fallthrough
+ }
+ case ObjectEndVisitMember: {
+ context.putProperty(outputObjectStack.last(), propertyStack.last()[indexStack.last()], outValue);
+ if (context.shouldTerminate())
+ return context.null();
+
+ indexStack.last()++;
+ goto objectStartVisitMember;
+ }
+ stateUnknown:
+ case StateUnknown:
+ if (OutputType transformed = context.convertIfTerminal(inValue)) {
+ outValue = transformed;
+ break;
+ }
+ if (context.isArray(inValue))
+ goto arrayStartState;
+ goto objectStartState;
+ }
+ if (stateStack.isEmpty())
+ break;
+
+ state = stateStack.last();
+ stateStack.removeLast();
+
+ if (!--tickCount) {
+ if (context.didTimeOut()) {
+ context.throwInterruptedException();
+ return context.null();
+ }
+ tickCount = context.ticksUntilNextCheck();
+ }
+ }
+ return outValue;
+}
+
+struct BaseWalker {
+ BaseWalker(ExecState* exec)
+ : m_exec(exec)
+ , m_timeoutChecker(exec->globalData().timeoutChecker)
+ {
+ m_timeoutChecker.reset();
+ }
+ ExecState* m_exec;
+ TimeoutChecker m_timeoutChecker;
+ MarkedArgumentBuffer m_gcBuffer;
+
+ bool shouldTerminate()
+ {
+ return m_exec->hadException();
+ }
+
+ unsigned ticksUntilNextCheck()
+ {
+ return m_timeoutChecker.ticksUntilNextCheck();
+ }
+
+ bool didTimeOut()
+ {
+ return m_timeoutChecker.didTimeOut(m_exec);
+ }
+
+ void throwStackOverflow()
+ {
+ m_exec->setException(createStackOverflowError(m_exec));
+ }
+
+ void throwInterruptedException()
+ {
+ m_exec->setException(createInterruptedExecutionException(&m_exec->globalData()));
+ }
+};
+
+struct SerializingTreeWalker : public BaseWalker {
+ typedef JSValue InputType;
+ typedef JSArray* InputArray;
+ typedef JSObject* InputObject;
+ typedef SerializedScriptValueData OutputType;
+ typedef RefPtr<SerializedArray> OutputArray;
+ typedef RefPtr<SerializedObject> OutputObject;
+ typedef PropertyNameArray PropertyList;
+
+ SerializingTreeWalker(ExecState* exec)
+ : BaseWalker(exec)
+ {
+ }
+
+ OutputType null() { return SerializedScriptValueData(); }
+
+ bool isArray(JSValue value)
+ {
+ if (!value.isObject())
+ return false;
+ JSObject* object = asObject(value);
+ return isJSArray(&m_exec->globalData(), object) || object->inherits(&JSArray::info);
+ }
+
+ bool isObject(JSValue value)
+ {
+ return value.isObject();
+ }
+
+ JSArray* asInputArray(JSValue value)
+ {
+ return asArray(value);
+ }
+
+ JSObject* asInputObject(JSValue value)
+ {
+ return asObject(value);
+ }
+
+ PassRefPtr<SerializedArray> createOutputArray(unsigned length)
+ {
+ return SerializedArray::create(length);
+ }
+
+ PassRefPtr<SerializedObject> createOutputObject()
+ {
+ return SerializedObject::create();
+ }
+
+ uint32_t length(JSValue array)
+ {
+ ASSERT(array.isObject());
+ JSObject* object = asObject(array);
+ return object->get(m_exec, m_exec->propertyNames().length).toUInt32(m_exec);
+ }
+
+ bool canDoFastRead(JSArray* array, unsigned index)
+ {
+ return isJSArray(&m_exec->globalData(), array) && array->canGetIndex(index);
+ }
+
+ JSValue getIndex(JSArray* array, unsigned index)
+ {
+ return array->getIndex(index);
+ }
+
+ JSValue getSparseIndex(JSObject* object, unsigned propertyName, bool& hasIndex)
+ {
+ PropertySlot slot(object);
+ if (object->getOwnPropertySlot(m_exec, propertyName, slot)) {
+ hasIndex = true;
+ return slot.getValue(m_exec, propertyName);
+ }
+ hasIndex = false;
+ return jsNull();
+ }
+
+ JSValue getProperty(JSObject* object, const Identifier& propertyName, unsigned)
+ {
+ PropertySlot slot(object);
+ if (object->getOwnPropertySlot(m_exec, propertyName, slot))
+ return slot.getValue(m_exec, propertyName);
+ return jsNull();
+ }
+
+ SerializedScriptValueData convertIfTerminal(JSValue value)
+ {
+ if (!value.isCell())
+ return SerializedScriptValueData(value);
+
+ if (value.isString())
+ return SerializedScriptValueData(asString(value)->value());
+
+ if (value.isNumber())
+ return SerializedScriptValueData(SerializedScriptValueData::NumberType, value.uncheckedGetNumber());
+
+ if (value.isObject() && asObject(value)->inherits(&DateInstance::info))
+ return SerializedScriptValueData(SerializedScriptValueData::DateType, asDateInstance(value)->internalNumber());
+
+ if (isArray(value))
+ return SerializedScriptValueData();
+
+ CallData unusedData;
+ if (value.isObject() && value.getCallData(unusedData) == CallTypeNone)
+ return SerializedScriptValueData();
+
+ // Any other types are expected to serialize as null.
+ return SerializedScriptValueData(jsNull());
+ }
+
+ void getPropertyNames(JSObject* object, Vector<PropertyNameArray, 16>& propertyStack)
+ {
+ propertyStack.append(PropertyNameArray(m_exec));
+ object->getOwnPropertyNames(m_exec, propertyStack.last());
+ }
+
+ void putProperty(RefPtr<SerializedArray> array, unsigned propertyName, const SerializedScriptValueData& value)
+ {
+ array->setIndex(propertyName, value);
+ }
+
+ void putProperty(RefPtr<SerializedObject> object, const Identifier& propertyName, const SerializedScriptValueData& value)
+ {
+ object->set(propertyName, value);
+ }
+
+ bool startArray(JSArray* inArray, RefPtr<SerializedArray>)
+ {
+ // Cycle detection
+ if (!m_cycleDetector.add(inArray).second) {
+ m_exec->setException(createTypeError(m_exec, "Cannot post cyclic structures."));
+ return false;
+ }
+ m_gcBuffer.append(inArray);
+ return true;
+ }
+
+ void endArray(JSArray* inArray, RefPtr<SerializedArray>)
+ {
+ m_cycleDetector.remove(inArray);
+ m_gcBuffer.removeLast();
+ }
+
+ bool startObject(JSObject* inObject, RefPtr<SerializedObject>)
+ {
+ // Cycle detection
+ if (!m_cycleDetector.add(inObject).second) {
+ m_exec->setException(createTypeError(m_exec, "Cannot post cyclic structures."));
+ return false;
+ }
+ m_gcBuffer.append(inObject);
+ return true;
+ }
+
+ void endObject(JSObject* inObject, RefPtr<SerializedObject>)
+ {
+ m_cycleDetector.remove(inObject);
+ m_gcBuffer.removeLast();
+ }
+
+private:
+ HashSet<JSObject*> m_cycleDetector;
+};
+
+SerializedScriptValueData SerializedScriptValueData::serialize(ExecState* exec, JSValue inValue)
+{
+ SerializingTreeWalker context(exec);
+ return walk<SerializingTreeWalker>(context, inValue);
+}
+
+
+struct DeserializingTreeWalker : public BaseWalker {
+ typedef SerializedScriptValueData InputType;
+ typedef RefPtr<SerializedArray> InputArray;
+ typedef RefPtr<SerializedObject> InputObject;
+ typedef JSValue OutputType;
+ typedef JSArray* OutputArray;
+ typedef JSObject* OutputObject;
+ typedef SerializedObject::PropertyNameList PropertyList;
+
+ DeserializingTreeWalker(ExecState* exec, bool mustCopy)
+ : BaseWalker(exec)
+ , m_mustCopy(mustCopy)
+ {
+ }
+
+ OutputType null() { return jsNull(); }
+
+ bool isArray(const SerializedScriptValueData& value)
+ {
+ return value.type() == SerializedScriptValueData::ArrayType;
+ }
+
+ bool isObject(const SerializedScriptValueData& value)
+ {
+ return value.type() == SerializedScriptValueData::ObjectType;
+ }
+
+ SerializedArray* asInputArray(const SerializedScriptValueData& value)
+ {
+ return value.asArray();
+ }
+
+ SerializedObject* asInputObject(const SerializedScriptValueData& value)
+ {
+ return value.asObject();
+ }
+
+ JSArray* createOutputArray(unsigned length)
+ {
+ JSArray* array = constructEmptyArray(m_exec);
+ array->setLength(length);
+ return array;
+ }
+
+ JSObject* createOutputObject()
+ {
+ return constructEmptyObject(m_exec);
+ }
+
+ uint32_t length(RefPtr<SerializedArray> array)
+ {
+ return array->length();
+ }
+
+ bool canDoFastRead(RefPtr<SerializedArray> array, unsigned index)
+ {
+ return array->canDoFastRead(index);
+ }
+
+ SerializedScriptValueData getIndex(RefPtr<SerializedArray> array, unsigned index)
+ {
+ return array->getIndex(index);
+ }
+
+ SerializedScriptValueData getSparseIndex(RefPtr<SerializedArray> array, unsigned propertyName, bool& hasIndex)
+ {
+ return array->getSparseIndex(propertyName, hasIndex);
+ }
+
+ SerializedScriptValueData getProperty(RefPtr<SerializedObject> object, const RefPtr<StringImpl>& propertyName, unsigned propertyIndex)
+ {
+ ASSERT(object->names()[propertyIndex] == propertyName);
+ UNUSED_PARAM(propertyName);
+ return object->values()[propertyIndex];
+ }
+
+ JSValue convertIfTerminal(SerializedScriptValueData& value)
+ {
+ switch (value.type()) {
+ case SerializedScriptValueData::ArrayType:
+ case SerializedScriptValueData::ObjectType:
+ return JSValue();
+ case SerializedScriptValueData::StringType:
+ return jsString(m_exec, value.asString().crossThreadString());
+ case SerializedScriptValueData::ImmediateType:
+ return value.asImmediate();
+ case SerializedScriptValueData::NumberType:
+ return jsNumber(m_exec, value.asDouble());
+ case SerializedScriptValueData::DateType:
+ return new (m_exec) DateInstance(m_exec, value.asDouble());
+ default:
+ ASSERT_NOT_REACHED();
+ return JSValue();
+ }
+ }
+
+ void getPropertyNames(RefPtr<SerializedObject> object, Vector<SerializedObject::PropertyNameList, 16>& properties)
+ {
+ properties.append(object->names());
+ }
+
+ void putProperty(JSArray* array, unsigned propertyName, JSValue value)
+ {
+ array->put(m_exec, propertyName, value);
+ }
+
+ void putProperty(JSObject* object, const RefPtr<StringImpl> propertyName, JSValue value)
+ {
+ object->putDirect(Identifier(m_exec, String(propertyName)), value);
+ }
+
+ bool startArray(RefPtr<SerializedArray>, JSArray* outArray)
+ {
+ m_gcBuffer.append(outArray);
+ return true;
+ }
+ void endArray(RefPtr<SerializedArray>, JSArray*)
+ {
+ m_gcBuffer.removeLast();
+ }
+ bool startObject(RefPtr<SerializedObject>, JSObject* outObject)
+ {
+ m_gcBuffer.append(outObject);
+ return true;
+ }
+ void endObject(RefPtr<SerializedObject>, JSObject*)
+ {
+ m_gcBuffer.removeLast();
+ }
+
+private:
+ bool m_mustCopy;
+};
+
+JSValue SerializedScriptValueData::deserialize(ExecState* exec, bool mustCopy) const
+{
+ DeserializingTreeWalker context(exec, mustCopy);
+ return walk<DeserializingTreeWalker>(context, *this);
+}
+
+struct TeardownTreeWalker {
+ typedef SerializedScriptValueData InputType;
+ typedef RefPtr<SerializedArray> InputArray;
+ typedef RefPtr<SerializedObject> InputObject;
+ typedef bool OutputType;
+ typedef bool OutputArray;
+ typedef bool OutputObject;
+ typedef SerializedObject::PropertyNameList PropertyList;
+
+ bool shouldTerminate()
+ {
+ return false;
+ }
+
+ unsigned ticksUntilNextCheck()
+ {
+ return 0xFFFFFFFF;
+ }
+
+ bool didTimeOut()
+ {
+ return false;
+ }
+
+ void throwStackOverflow()
+ {
+ }
+
+ void throwInterruptedException()
+ {
+ }
+
+ bool null() { return false; }
+
+ bool isArray(const SerializedScriptValueData& value)
+ {
+ return value.type() == SerializedScriptValueData::ArrayType;
+ }
+
+ bool isObject(const SerializedScriptValueData& value)
+ {
+ return value.type() == SerializedScriptValueData::ObjectType;
+ }
+
+ SerializedArray* asInputArray(const SerializedScriptValueData& value)
+ {
+ return value.asArray();
+ }
+
+ SerializedObject* asInputObject(const SerializedScriptValueData& value)
+ {
+ return value.asObject();
+ }
+
+ bool createOutputArray(unsigned)
+ {
+ return false;
+ }
+
+ bool createOutputObject()
+ {
+ return false;
+ }
+
+ uint32_t length(RefPtr<SerializedArray> array)
+ {
+ return array->length();
+ }
+
+ bool canDoFastRead(RefPtr<SerializedArray> array, unsigned index)
+ {
+ return array->canDoFastRead(index);
+ }
+
+ SerializedScriptValueData getIndex(RefPtr<SerializedArray> array, unsigned index)
+ {
+ return array->getIndex(index);
+ }
+
+ SerializedScriptValueData getSparseIndex(RefPtr<SerializedArray> array, unsigned propertyName, bool& hasIndex)
+ {
+ return array->getSparseIndex(propertyName, hasIndex);
+ }
+
+ SerializedScriptValueData getProperty(RefPtr<SerializedObject> object, const RefPtr<StringImpl>& propertyName, unsigned propertyIndex)
+ {
+ ASSERT(object->names()[propertyIndex] == propertyName);
+ UNUSED_PARAM(propertyName);
+ return object->values()[propertyIndex];
+ }
+
+ bool convertIfTerminal(SerializedScriptValueData& value)
+ {
+ switch (value.type()) {
+ case SerializedScriptValueData::ArrayType:
+ case SerializedScriptValueData::ObjectType:
+ return false;
+ case SerializedScriptValueData::StringType:
+ case SerializedScriptValueData::ImmediateType:
+ case SerializedScriptValueData::NumberType:
+ return true;
+ default:
+ ASSERT_NOT_REACHED();
+ return JSValue();
+ }
+ }
+
+ void getPropertyNames(RefPtr<SerializedObject> object, Vector<SerializedObject::PropertyNameList, 16>& properties)
+ {
+ properties.append(object->names());
+ }
+
+ void putProperty(bool, unsigned, bool)
+ {
+ }
+
+ void putProperty(bool, const RefPtr<StringImpl>&, bool)
+ {
+ }
+
+ bool startArray(RefPtr<SerializedArray>, bool)
+ {
+ return true;
+ }
+ void endArray(RefPtr<SerializedArray> array, bool)
+ {
+ array->clear();
+ }
+ bool startObject(RefPtr<SerializedObject>, bool)
+ {
+ return true;
+ }
+ void endObject(RefPtr<SerializedObject> object, bool)
+ {
+ object->clear();
+ }
+};
+
+void SerializedScriptValueData::tearDownSerializedData()
+{
+ if (m_sharedData && m_sharedData->refCount() > 1)
+ return;
+ TeardownTreeWalker context;
+ walk<TeardownTreeWalker>(context, *this);
+}
+
+}
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.h b/src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.h
new file mode 100644
index 0000000000..f8a126ff7b
--- /dev/null
+++ b/src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.h
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2009 Apple 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 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.
+ *
+ */
+
+#ifndef SerializedScriptValue_h
+#define SerializedScriptValue_h
+
+#include "ScriptValue.h"
+
+namespace WebCore {
+ class SerializedObject;
+ class SerializedArray;
+
+ class SharedSerializedData : public RefCounted<SharedSerializedData> {
+ public:
+ virtual ~SharedSerializedData() { }
+ SerializedArray* asArray();
+ SerializedObject* asObject();
+ };
+
+ class SerializedScriptValue;
+
+ class SerializedScriptValueData {
+ public:
+ enum SerializedType {
+ EmptyType,
+ DateType,
+ NumberType,
+ ImmediateType,
+ ObjectType,
+ ArrayType,
+ StringType
+ };
+
+ SerializedType type() const { return m_type; }
+ static SerializedScriptValueData serialize(JSC::ExecState*, JSC::JSValue);
+ JSC::JSValue deserialize(JSC::ExecState*, bool mustCopy) const;
+
+ ~SerializedScriptValueData()
+ {
+ if (m_sharedData)
+ tearDownSerializedData();
+ }
+
+ SerializedScriptValueData()
+ : m_type(EmptyType)
+ {
+ }
+
+ explicit SerializedScriptValueData(const String& string)
+ : m_type(StringType)
+ , m_string(string.crossThreadString()) // FIXME: Should be able to just share the Rep
+ {
+ }
+
+ explicit SerializedScriptValueData(JSC::JSValue value)
+ : m_type(ImmediateType)
+ {
+ ASSERT(!value.isCell());
+ m_data.m_immediate = JSC::JSValue::encode(value);
+ }
+
+ SerializedScriptValueData(SerializedType type, double value)
+ : m_type(type)
+ {
+ m_data.m_double = value;
+ }
+
+ SerializedScriptValueData(RefPtr<SerializedObject>);
+ SerializedScriptValueData(RefPtr<SerializedArray>);
+
+ JSC::JSValue asImmediate() const
+ {
+ ASSERT(m_type == ImmediateType);
+ return JSC::JSValue::decode(m_data.m_immediate);
+ }
+
+ double asDouble() const
+ {
+ ASSERT(m_type == NumberType || m_type == DateType);
+ return m_data.m_double;
+ }
+
+ String asString() const
+ {
+ ASSERT(m_type == StringType);
+ return m_string;
+ }
+
+ SerializedObject* asObject() const
+ {
+ ASSERT(m_type == ObjectType);
+ ASSERT(m_sharedData);
+ return m_sharedData->asObject();
+ }
+
+ SerializedArray* asArray() const
+ {
+ ASSERT(m_type == ArrayType);
+ ASSERT(m_sharedData);
+ return m_sharedData->asArray();
+ }
+
+ operator bool() const { return m_type != EmptyType; }
+
+ SerializedScriptValueData release()
+ {
+ SerializedScriptValueData result = *this;
+ *this = SerializedScriptValueData();
+ return result;
+ }
+
+ private:
+ void tearDownSerializedData();
+ SerializedType m_type;
+ RefPtr<SharedSerializedData> m_sharedData;
+ String m_string;
+ union {
+ double m_double;
+ JSC::EncodedJSValue m_immediate;
+ } m_data;
+ };
+
+ class SerializedScriptValue : public RefCounted<SerializedScriptValue> {
+ public:
+ static PassRefPtr<SerializedScriptValue> create(JSC::ExecState* exec, JSC::JSValue value)
+ {
+ return adoptRef(new SerializedScriptValue(SerializedScriptValueData::serialize(exec, value)));
+ }
+
+ static PassRefPtr<SerializedScriptValue> create(String string)
+ {
+ return adoptRef(new SerializedScriptValue(SerializedScriptValueData(string)));
+ }
+
+ static PassRefPtr<SerializedScriptValue> create()
+ {
+ return adoptRef(new SerializedScriptValue(SerializedScriptValueData()));
+ }
+
+ PassRefPtr<SerializedScriptValue> release()
+ {
+ PassRefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_value));
+ m_value = SerializedScriptValueData();
+ result->m_mustCopy = true;
+ return result;
+ }
+
+ String toString()
+ {
+ if (m_value.type() != SerializedScriptValueData::StringType)
+ return "";
+ return m_value.asString();
+ }
+
+ JSC::JSValue deserialize(JSC::ExecState* exec)
+ {
+ if (!m_value)
+ return JSC::jsNull();
+ return m_value.deserialize(exec, m_mustCopy);
+ }
+
+ ~SerializedScriptValue() {}
+
+ private:
+ SerializedScriptValue(SerializedScriptValueData value)
+ : m_value(value)
+ , m_mustCopy(false)
+ {
+ }
+
+ SerializedScriptValueData m_value;
+ bool m_mustCopy;
+ };
+}
+
+#endif // SerializedScriptValue_h
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp
index 3590dad5a9..b66b0e8151 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp
+++ b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp
@@ -52,6 +52,7 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext)
, m_workerContext(workerContext)
, m_executionForbidden(false)
{
+ m_globalData->clientData = new WebCoreJSClientData(m_globalData.get());
}
WorkerScriptController::~WorkerScriptController()
@@ -122,7 +123,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode,
ExecState* exec = m_workerContextWrapper->globalExec();
m_workerContextWrapper->globalData()->timeoutChecker.start();
- Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper);
+ Completion comp = evaluateInWorld(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper, currentWorld(exec));
m_workerContextWrapper->globalData()->timeoutChecker.stop();
if (comp.complType() == Normal || comp.complType() == ReturnValue)
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h
index bb33f6082c..c820cd936c 100644
--- a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h
+++ b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h
@@ -62,6 +62,9 @@ namespace WebCore {
void setException(ScriptValue);
void forbidExecution();
+
+ JSC::JSGlobalData* globalData() { return m_globalData.get(); }
+
private:
void initScriptIfNeeded()
{
diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm
index 92bd39097d..c1cb0a0347 100644
--- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm
+++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm
@@ -59,6 +59,12 @@ my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1,
"SVGAnimatedRect" => 1, "SVGAnimatedString" => 1,
"SVGAnimatedTransformList" => 1);
+my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick" => 1,
+ "onerror" => 1, "onload" => 1, "onmousedown" => 1,
+ "onmousemove" => 1, "onmouseout" => 1, "onmouseover" => 1,
+ "onmouseup" => 1, "onresize" => 1, "onscroll" => 1,
+ "onunload" => 1);
+
# Cache of IDL file pathnames.
my $idlFiles;
@@ -347,4 +353,12 @@ sub WK_lcfirst
return $ret;
}
+# Return the C++ namespace that a given attribute name string is defined in.
+sub NamespaceForAttributeName
+{
+ my ($object, $interfaceName, $attributeName) = @_;
+ return "SVGNames" if $interfaceName =~ /^SVG/ && !$svgAttributesInHTMLHash{$attributeName};
+ return "HTMLNames";
+}
+
1;
diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm
index 4d5cb96ef1..4ca441b525 100644
--- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm
+++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm
@@ -524,7 +524,7 @@ sub GenerateCPPAttributeSignature
sub GenerateCPPAttribute
{
- my ($attribute, $className, $implementationClass) = @_;
+ my ($attribute, $className, $implementationClass, $IDLType) = @_;
my $implementationClassWithoutNamespace = StripNamespace($implementationClass);
@@ -598,9 +598,10 @@ sub GenerateCPPAttribute
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $CPPImplementationWebCoreIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL);
- push(@setterImplementation, " impl${implementationClassWithoutNamespace}()->setAttribute(WebCore::HTMLNames::${contentAttributeName}Attr, " . join(", ", @setterParams) . ");\n");
+ my $namespace = $codeGenerator->NamespaceForAttributeName($IDLType, $contentAttributeName);
+ $CPPImplementationWebCoreIncludes{"${namespace}.h"} = 1;
+ push(@setterImplementation, " impl${implementationClassWithoutNamespace}()->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, " . join(", ", @setterParams) . ");\n");
} else {
push(@setterImplementation, " impl${implementationClassWithoutNamespace}()->${setterName}(" . join(", ", @setterParams) . ");\n");
}
@@ -620,10 +621,11 @@ sub GenerateCPPAttribute
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL);
+ my $namespace = $codeGenerator->NamespaceForAttributeName($IDLType, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute";
- $implementationGetter = "impl${implementationClassWithoutNamespace}()->${getAttributeFunctionName}(WebCore::HTMLNames::${contentAttributeName}Attr)";
+ $implementationGetter = "impl${implementationClassWithoutNamespace}()->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr)";
} else {
$implementationGetter = "impl${implementationClassWithoutNamespace}()->" . $codeGenerator->WK_lcfirst($attributeName) . "(" . ($hasGetterException ? "ec" : ""). ")";
}
@@ -1154,7 +1156,7 @@ sub GenerateCPPImplementation
AddIncludesForTypeInCPPImplementation($attribute->signature->type);
- my %attributes = GenerateCPPAttribute($attribute, $className, $implementationClass);
+ my %attributes = GenerateCPPAttribute($attribute, $className, $implementationClass, $IDLType);
push(@CPPImplementationContent, values(%attributes));
}
}
@@ -1182,7 +1184,7 @@ sub GenerateCPPImplementation
AddIncludesForTypeInCPPImplementation($attribute->signature->type);
- my %attributes = GenerateCPPAttribute($attribute, $className, $implementationClass);
+ my %attributes = GenerateCPPAttribute($attribute, $className, $implementationClass, $IDLType);
push(@CPPImplementationContent, values(%attributes));
}
}
diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm
index d552aa0743..d8367acb30 100644
--- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -292,7 +292,7 @@ sub GenerateGetOwnPropertySlotBody
my @getOwnPropertySlotImpl = ();
- if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection") {
+ if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
push(@getOwnPropertySlotImpl, " ${namespaceMaybe}JSValue proto = prototype();\n");
push(@getOwnPropertySlotImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n");
push(@getOwnPropertySlotImpl, " return false;\n\n");
@@ -369,7 +369,7 @@ sub GenerateGetOwnPropertyDescriptorBody
my @getOwnPropertyDescriptorImpl = ();
- if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection") {
+ if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}JSValue proto = prototype();\n");
push(@getOwnPropertyDescriptorImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n");
push(@getOwnPropertyDescriptorImpl, " return false;\n\n");
@@ -463,6 +463,7 @@ sub GenerateHeader
my $className = "JS$interfaceName";
my $implClassName = $interfaceName;
my @ancestorInterfaceNames = ();
+ my %structureFlags = ();
# We only support multiple parents with SVG (for now).
if (@{$dataNode->parents} > 1) {
@@ -574,6 +575,7 @@ sub GenerateHeader
push(@headerContent, " virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&);\n") if ($dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) && !$dataNode->extendedAttributes->{"HasOverridingNameGetter"};
push(@headerContent, " bool getOwnPropertySlotDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n") if $dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"};
push(@headerContent, " bool getOwnPropertyDescriptorDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n") if $dataNode->extendedAttributes->{"DelegatingGetOwnPropertySlot"};
+ $structureFlags{"JSC::OverridesGetOwnPropertySlot"} = 1;
}
# Check if we have any writable properties
@@ -602,21 +604,20 @@ sub GenerateHeader
# Structure ID
if ($interfaceName eq "DOMWindow") {
- push(@headerContent,
- " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
- " {\n" .
- " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance | JSC::NeedsThisConversion));\n" .
- " }\n\n");
- } elsif ($hasGetter) {
- push(@headerContent,
- " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
- " {\n" .
- " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType));\n" .
- " }\n\n");
+ $structureFlags{"JSC::ImplementsHasInstance"} = 1;
+ $structureFlags{"JSC::NeedsThisConversion"} = 1;
}
+ push(@headerContent,
+ " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
+ " {\n" .
+ " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));\n" .
+ " }\n\n");
# markChildren function
- push(@headerContent, " virtual void markChildren(JSC::MarkStack&);\n\n") if $needsMarkChildren;
+ if ($needsMarkChildren) {
+ push(@headerContent, " virtual void markChildren(JSC::MarkStack&);\n\n");
+ $structureFlags{"JSC::OverridesMarkChildren"} = 1;
+ }
# Custom pushEventHandlerScope function
push(@headerContent, " virtual void pushEventHandlerScope(JSC::ExecState*, JSC::ScopeChain&) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"};
@@ -628,13 +629,19 @@ sub GenerateHeader
push(@headerContent, " virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier&);\n") if $dataNode->extendedAttributes->{"CustomDeleteProperty"};
# Custom getPropertyNames function exists on DOMWindow
- push(@headerContent, " virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);\n") if $interfaceName eq "DOMWindow";
+ if ($interfaceName eq "DOMWindow") {
+ push(@headerContent, " virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);\n");
+ $structureFlags{"JSC::OverridesGetPropertyNames"} = 1;
+ }
# Custom defineProperty function exists on DOMWindow
push(@headerContent, " virtual bool defineOwnProperty(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interfaceName eq "DOMWindow";
# Custom getOwnPropertyNames function
- push(@headerContent, " virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);\n") if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"});
+ if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
+ push(@headerContent, " virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&);\n");
+ $structureFlags{"JSC::OverridesGetPropertyNames"} = 1;
+ }
# Custom getPropertyAttributes function
push(@headerContent, " virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier&, unsigned& attributes) const;\n") if $dataNode->extendedAttributes->{"CustomGetPropertyAttributes"};
@@ -651,6 +658,12 @@ sub GenerateHeader
# Custom lookupSetter function
push(@headerContent, " virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);\n") if $dataNode->extendedAttributes->{"CustomLookupSetter"};
+ # Override toBoolean to return false for objects that want to 'MasqueradesAsUndefined'.
+ if ($dataNode->extendedAttributes->{"MasqueradesAsUndefined"}) {
+ push(@headerContent, " virtual bool toBoolean(JSC::ExecState*) const { return false; };\n");
+ $structureFlags{"JSC::MasqueradesAsUndefined"} = 1;
+ }
+
# Constructor object getter
push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"};
@@ -712,6 +725,14 @@ sub GenerateHeader
push(@headerContent, " return static_cast<$implClassName*>(Base::impl());\n");
push(@headerContent, " }\n");
}
+
+ # structure flags
+ push(@headerContent, "protected:\n");
+ push(@headerContent, " static const unsigned StructureFlags = ");
+ foreach my $structureFlag (keys %structureFlags) {
+ push(@headerContent, $structureFlag . " | ");
+ }
+ push(@headerContent, "Base::StructureFlags;\n");
# Index getter
if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
@@ -719,6 +740,7 @@ sub GenerateHeader
}
if ($dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
push(@headerContent, " JSC::JSValue getByIndex(JSC::ExecState*, unsigned index);\n");
+
}
# Index setter
@@ -770,6 +792,7 @@ sub GenerateHeader
push(@headerContent, "\n");
# Add prototype declaration.
+ %structureFlags = ();
push(@headerContent, "class ${className}Prototype : public JSC::JSObject {\n");
push(@headerContent, " typedef JSC::JSObject Base;\n");
push(@headerContent, "public:\n");
@@ -787,19 +810,16 @@ sub GenerateHeader
push(@headerContent, " virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n");
push(@headerContent, " bool getOwnPropertySlotDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n") if $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"};
push(@headerContent, " bool getOwnPropertyDescriptorDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n") if $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"};
-
- push(@headerContent,
- " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
- " {\n" .
- " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType" . ($needsMarkChildren ? "" : ", JSC::HasDefaultMark") . "));\n" .
- " }\n");
- } elsif ($dataNode->extendedAttributes->{"CustomMarkFunction"}) {
- push(@headerContent,
- " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
- " {\n" .
- " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType));\n" .
- " }\n");
+ $structureFlags{"JSC::OverridesGetOwnPropertySlot"} = 1;
+ }
+ if ($dataNode->extendedAttributes->{"CustomMarkFunction"} or $needsMarkChildren) {
+ $structureFlags{"JSC::OverridesMarkChildren"} = 1;
}
+ push(@headerContent,
+ " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" .
+ " {\n" .
+ " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags));\n" .
+ " }\n");
if ($dataNode->extendedAttributes->{"DelegatingPrototypePutFunction"}) {
push(@headerContent, " virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);\n");
push(@headerContent, " bool putDelegate(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue, JSC::PutPropertySlot&);\n");
@@ -810,6 +830,14 @@ sub GenerateHeader
push(@headerContent, " ${className}Prototype(NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObject(structure) { }\n");
+ # structure flags
+ push(@headerContent, "protected:\n");
+ push(@headerContent, " static const unsigned StructureFlags = ");
+ foreach my $structureFlag (keys %structureFlags) {
+ push(@headerContent, $structureFlag . " | ");
+ }
+ push(@headerContent, "Base::StructureFlags;\n");
+
push(@headerContent, "};\n\n");
if ($numFunctions > 0) {
@@ -1166,19 +1194,21 @@ sub GenerateImplementation
push(@implContent, " impl()->invalidateEventListeners();\n");
}
- if ($interfaceName eq "Node") {
- push(@implContent, " forgetDOMNode(impl()->document(), impl());\n");
- } else {
- if ($podType) {
- my $animatedType = $implClassName;
- $animatedType =~ s/SVG/SVGAnimated/;
+ if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) {
+ if ($interfaceName eq "Node") {
+ push(@implContent, " forgetDOMNode(this, impl(), impl()->document());\n");
+ } else {
+ if ($podType) {
+ my $animatedType = $implClassName;
+ $animatedType =~ s/SVG/SVGAnimated/;
- # Special case for JSSVGNumber
- if ($codeGenerator->IsSVGAnimatedType($animatedType) and $podType ne "float") {
- push(@implContent, " JSSVGDynamicPODTypeWrapperCache<$podType, $animatedType>::forgetWrapper(m_impl.get());\n");
+ # Special case for JSSVGNumber
+ if ($codeGenerator->IsSVGAnimatedType($animatedType) and $podType ne "float") {
+ push(@implContent, " JSSVGDynamicPODTypeWrapperCache<$podType, $animatedType>::forgetWrapper(m_impl.get());\n");
+ }
}
+ push(@implContent, " forgetDOMObject(this, impl());\n");
}
- push(@implContent, " forgetDOMObject(*Heap::heap(this)->globalData(), impl());\n");
}
push(@implContent, "}\n\n");
@@ -1188,7 +1218,7 @@ sub GenerateImplementation
# its own special handling rather than relying on the caching that Node normally does.
if ($interfaceName eq "Document") {
push(@implContent, "${className}::~$className()\n");
- push(@implContent, "{\n forgetDOMObject(*Heap::heap(this)->globalData(), static_cast<${implClassName}*>(impl()));\n}\n\n");
+ push(@implContent, "{\n forgetDOMObject(this, static_cast<${implClassName}*>(impl()));\n}\n\n");
}
if ($needsMarkChildren && !$dataNode->extendedAttributes->{"CustomMarkFunction"}) {
@@ -1323,10 +1353,11 @@ sub GenerateImplementation
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $name : ($reflect || $reflectURL);
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute";
- $value = "imp->$getAttributeFunctionName(HTMLNames::${contentAttributeName}Attr)"
+ $value = "imp->$getAttributeFunctionName(${namespace}::${contentAttributeName}Attr)"
} else {
$value = "imp->$implGetterFunctionName()";
}
@@ -1453,7 +1484,7 @@ sub GenerateImplementation
} else {
$implIncludes{"Frame.h"} = 1;
$implIncludes{"JSDOMGlobalObject.h"} = 1;
- push(@implContent, " JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext());\n");
+ push(@implContent, " JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(imp->scriptExecutionContext(), exec);\n");
push(@implContent, " if (!globalObject)\n");
push(@implContent, " return;\n");
}
@@ -1483,9 +1514,10 @@ sub GenerateImplementation
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $name : ($reflect || $reflectURL);
- push(@implContent, " imp->setAttribute(HTMLNames::${contentAttributeName}Attr, $nativeValue");
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
+ push(@implContent, " imp->setAttribute(${namespace}::${contentAttributeName}Attr, $nativeValue");
} else {
push(@implContent, " imp->set$implSetterFunctionName($nativeValue");
}
@@ -1676,7 +1708,7 @@ sub GenerateImplementation
push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n");
}
push(@implContent, "}\n");
- if ($interfaceName eq "HTMLCollection") {
+ if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
$implIncludes{"JSNode.h"} = 1;
$implIncludes{"Node.h"} = 1;
}
@@ -1687,7 +1719,7 @@ sub GenerateImplementation
push(@implContent, "{\n");
push(@implContent, " return jsNumber(exec, static_cast<$implClassName*>(impl())->item(index));\n");
push(@implContent, "}\n");
- if ($interfaceName eq "HTMLCollection") {
+ if ($interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") {
$implIncludes{"JSNode.h"} = 1;
$implIncludes{"Node.h"} = 1;
}
@@ -1842,6 +1874,11 @@ sub JSValueToNative
return "$value.toString(exec)";
}
+ if ($type eq "SerializedScriptValue") {
+ $implIncludes{"SerializedScriptValue.h"} = 1;
+ return "SerializedScriptValue::create(exec, $value)";
+ }
+
$implIncludes{"FloatPoint.h"} = 1 if $type eq "SVGPoint";
$implIncludes{"FloatRect.h"} = 1 if $type eq "SVGRect";
$implIncludes{"HTMLOptionElement.h"} = 1 if $type eq "HTMLOptionElement";
@@ -1928,6 +1965,8 @@ sub NativeToJSValue
}
if ($codeGenerator->IsSVGAnimatedType($type)) {
+ # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++
+ $value =~ s/operator\(\)/_operator\(\)/ if ($value =~ /operator/);
$value =~ s/\(\)//;
$value .= "Animated()";
}
@@ -1947,6 +1986,9 @@ sub NativeToJSValue
$joinedName = $type;
$joinedName =~ s/Abs|Rel//;
$implIncludes{"$joinedName.h"} = 1;
+ } elsif ($type eq "SerializedScriptValue") {
+ $implIncludes{"$type.h"} = 1;
+ return "$value->deserialize(exec)";
} else {
# Default, include header with same name.
$implIncludes{"JS$type.h"} = 1;
@@ -2241,8 +2283,11 @@ public:
static PassRefPtr<Structure> createStructure(JSValue proto)
{
- return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
+ return Structure::create(proto, TypeInfo(ObjectType, StructureFlags));
}
+
+protected:
+ static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags;
EOF
if ($canConstruct) {
diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm
index 0026ba1ee6..91248c5500 100644
--- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm
+++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm
@@ -311,7 +311,7 @@ sub GetClassName
my $name = $codeGenerator->StripModule(shift);
# special cases
- return "NSString" if $codeGenerator->IsStringType($name);
+ return "NSString" if $codeGenerator->IsStringType($name) or $name eq "SerializedScriptValue";
return "NS$name" if IsNativeObjCType($name);
return "BOOL" if $name eq "boolean";
return "unsigned" if $name eq "unsigned long";
@@ -492,6 +492,11 @@ sub GetObjCTypeGetter
return "WTF::getPtr(nativeEventListener)" if $type eq "EventListener";
return "WTF::getPtr(nativeNodeFilter)" if $type eq "NodeFilter";
return "WTF::getPtr(nativeResolver)" if $type eq "XPathNSResolver";
+
+ if ($type eq "SerializedScriptValue") {
+ $implIncludes{"SerializedScriptValue.h"} = 1;
+ return "WebCore::SerializedScriptValue::create(WebCore::String($argName))";
+ }
return "core($argName)";
}
@@ -607,6 +612,11 @@ sub AddIncludesForType
return;
}
+ if ($type eq "SerializedScriptValue") {
+ $implIncludes{"SerializedScriptValue.h"} = 1;
+ return;
+ }
+
# FIXME: won't compile without these
$implIncludes{"CSSMutableStyleDeclaration.h"} = 1 if $type eq "CSSStyleDeclaration";
$implIncludes{"NameNodeList.h"} = 1 if $type eq "NodeList";
@@ -715,6 +725,8 @@ sub GenerateHeader
my $attributeIsReadonly = ($attribute->type =~ /^readonly/);
my $property = "\@property" . GetPropertyAttributes($attribute->signature->type, $attributeIsReadonly);
+ # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++
+ $attributeName =~ s/operator/_operator/ if ($attributeName =~ /operator/);
$property .= " " . $attributeType . ($attributeType =~ /\*$/ ? "" : " ") . $attributeName;
my $publicInterfaceKey = $property . ";";
@@ -1139,15 +1151,21 @@ sub GenerateImplementation
# - GETTER
my $getterSig = "- ($attributeType)$attributeInterfaceName\n";
+
+ # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++
+ $attributeName =~ s/operatorAnimated/_operatorAnimated/ if ($attributeName =~ /operatorAnimated/);
+ $getterSig =~ s/operator/_operator/ if ($getterSig =~ /operator/);
+
my $hasGetterException = @{$attribute->getterExceptions};
my $getterContentHead;
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL);
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute";
- $getterContentHead = "IMPL->${getAttributeFunctionName}(WebCore::HTMLNames::${contentAttributeName}Attr";
+ $getterContentHead = "IMPL->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr";
} else {
$getterContentHead = "IMPL->" . $codeGenerator->WK_lcfirst($attributeName) . "(";
}
@@ -1212,6 +1230,9 @@ sub GenerateImplementation
} elsif ($idlType eq "Color") {
$getterContentHead = "WebCore::nsColor($getterContentHead";
$getterContentTail .= ")";
+ } elsif ($attribute->signature->type eq "SerializedScriptValue") {
+ $getterContentHead = "$getterContentHead";
+ $getterContentTail .= "->toString()";
} elsif (ConversionNeeded($attribute->signature->type)) {
$getterContentHead = "kit(WTF::getPtr($getterContentHead";
$getterContentTail .= "))";
@@ -1278,20 +1299,20 @@ sub GenerateImplementation
} else {
push(@implContent, " IMPL->$coreSetterName($arg);\n");
}
- } elsif ($hasSetterException) {
- push(@implContent, " $exceptionInit\n");
- push(@implContent, " IMPL->$coreSetterName($arg, ec);\n");
- push(@implContent, " $exceptionRaiseOnError\n");
} else {
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
+ push(@implContent, " $exceptionInit\n") if $hasSetterException;
+ my $ec = $hasSetterException ? ", ec" : "";
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL);
- push(@implContent, " IMPL->setAttribute(WebCore::HTMLNames::${contentAttributeName}Attr, $arg);\n");
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
+ push(@implContent, " IMPL->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, $arg$ec);\n");
} else {
- push(@implContent, " IMPL->$coreSetterName($arg);\n");
+ push(@implContent, " IMPL->$coreSetterName($arg$ec);\n");
}
+ push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException;
}
push(@implContent, "}\n\n");
@@ -1446,6 +1467,8 @@ sub GenerateImplementation
push(@functionContent, " return $toReturn;\n");
push(@functionContent, " return nil;\n");
}
+ } elsif ($returnType eq "SerializedScriptValue") {
+ $content = "foo";
} else {
if (ConversionNeeded($function->signature->type)) {
if ($codeGenerator->IsPodType($function->signature->type)) {
diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 7f1508ba5b..95b2aa2fb9 100644
--- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -215,7 +215,6 @@ sub AddClassForwardIfNeeded
sub GetImplementationFileName
{
my $iface = shift;
- return "HTMLCollection.h" if $iface eq "HTMLAllCollection";
return "Event.h" if $iface eq "DOMTimeStamp";
return "NamedAttrMap.h" if $iface eq "NamedNodeMap";
return "NameNodeList.h" if $iface eq "NodeList";
@@ -307,7 +306,7 @@ sub GenerateSetDOMException
my $indent = shift;
my $result = "";
- $result .= $indent . "if (ec) {\n";
+ $result .= $indent . "if (UNLIKELY(ec)) {\n";
$result .= $indent . " V8Proxy::setDOMException(ec);\n";
$result .= $indent . " return v8::Handle<v8::Value>();\n";
$result .= $indent . "}\n";
@@ -326,10 +325,26 @@ sub IsNodeSubType
return 0;
}
-sub RequiresCustomEventListenerAccessors
+sub GetHiddenDependencyIndex
{
my $dataNode = shift;
- return !IsNodeSubType($dataNode) && $dataNode->name ne "SVGElementInstance";
+ my $attribute = shift;
+ my $name = $dataNode->name;
+ return "V8Custom::kNodeEventListenerCacheIndex" if IsNodeSubType($dataNode);
+ return "V8Custom::kSVGElementInstanceEventListenerCacheIndex" if $name eq "SVGElementInstance";
+ return "V8Custom::kAbstractWorkerRequestCacheIndex" if $name eq "AbstractWorker";
+ return "V8Custom::kWorkerRequestCacheIndex" if $name eq "Worker";
+ return "V8Custom::kDedicatedWorkerContextRequestCacheIndex" if $name eq "DedicatedWorkerContext";
+ return "V8Custom::kWorkerContextRequestCacheIndex" if $name eq "WorkerContext";
+ return "V8Custom::kWorkerContextRequestCacheIndex" if $name eq "SharedWorkerContext";
+ return "V8Custom::kMessagePortRequestCacheIndex" if $name eq "MessagePort";
+ return "V8Custom::kWebSocketCacheIndex" if $name eq "WebSocket";
+ return "V8Custom::kXMLHttpRequestCacheIndex" if $name eq "XMLHttpRequest";
+ return "V8Custom::kXMLHttpRequestCacheIndex" if $name eq "XMLHttpRequestUpload";
+ return "V8Custom::kDOMApplicationCacheCacheIndex" if $name eq "DOMApplicationCache";
+ return "V8Custom::kNotificationRequestCacheIndex" if $name eq "Notification";
+ return "V8Custom::kDOMWindowEventListenerCacheIndex" if $name eq "DOMWindow";
+ die "Unexpected name " . $name . " when generating " . $attribute;
}
sub HolderToNative
@@ -444,6 +459,7 @@ sub GenerateNormalAttrGetter
my $dataNode = shift;
my $classIndex = shift;
my $implClassName = shift;
+ my $interfaceName = shift;
my $attrExt = $attribute->signature->extendedAttributes;
@@ -500,11 +516,17 @@ END
}
} elsif ($attrExt->{"v8OnProto"} || $attrExt->{"V8DisallowShadowing"}) {
+ if ($classIndex eq "DOMWINDOW") {
+ push(@implContentDecls, <<END);
+ v8::Handle<v8::Object> holder = info.Holder();
+END
+ } else {
# perform lookup first
push(@implContentDecls, <<END);
v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::$classIndex, info.This());
if (holder.IsEmpty()) return v8::Undefined();
END
+ }
HolderToNative($dataNode, $implClassName, $classIndex);
} else {
push(@implContentDecls, <<END);
@@ -540,10 +562,11 @@ END
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL);
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute";
- $getterString = "imp->$getAttributeFunctionName(HTMLNames::${contentAttributeName}Attr";
+ $getterString = "imp->$getAttributeFunctionName(${namespace}::${contentAttributeName}Attr";
} else {
$getterString = "imp->$getterFunc(";
}
@@ -594,15 +617,21 @@ END
}
} else {
- push(@implContentDecls, " $nativeType v = ");
-
- push(@implContentDecls, "$getterString;\n");
+ if ($attribute->signature->type eq "EventListener" && $dataNode->name eq "DOMWindow") {
+ push(@implContentDecls, " if (!imp->document())\n");
+ push(@implContentDecls, " return v8::Undefined();\n");
+ }
if ($useExceptions) {
+ push(@implContentDecls, " $nativeType v = ");
+ push(@implContentDecls, "$getterString;\n");
push(@implContentDecls, GenerateSetDOMException(" "));
+ $result = "v";
+ $result .= ".release()" if (IsRefPtrType($returnType));
+ } else {
+ # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary
+ $result = $getterString;
}
-
- $result = "v";
}
if (IsSVGTypeNeedingContextParameter($attrType) && !$skipContext) {
@@ -618,7 +647,6 @@ END
my $classIndex = uc($attrType);
push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n");
} else {
- $result .= ".release()" if (IsRefPtrType($attrType));
push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n");
}
@@ -651,6 +679,7 @@ sub GenerateNormalAttrSetter
my $dataNode = shift;
my $classIndex = shift;
my $implClassName = shift;
+ my $interfaceName = shift;
my $attrExt = $attribute->signature->extendedAttributes;
@@ -672,11 +701,17 @@ sub GenerateNormalAttrSetter
push(@implContentDecls, " $implClassName* imp = &imp_instance;\n");
} elsif ($attrExt->{"v8OnProto"}) {
+ if ($classIndex eq "DOMWINDOW") {
+ push(@implContentDecls, <<END);
+ v8::Handle<v8::Object> holder = info.Holder();
+END
+ } else {
# perform lookup first
push(@implContentDecls, <<END);
v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::$classIndex, info.This());
- if (holder.IsEmpty()) return v8::Undefined();
+ if (holder.IsEmpty()) return;
END
+ }
HolderToNative($dataNode, $implClassName, $classIndex);
} else {
push(@implContentDecls, <<END);
@@ -687,7 +722,11 @@ END
my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0);
if ($attribute->signature->type eq "EventListener") {
- push(@implContentDecls, " $nativeType v = V8DOMWrapper::getEventListener(imp, value, true, false);\n");
+ if ($dataNode->name eq "DOMWindow") {
+ push(@implContentDecls, " if (!imp->document())\n");
+ push(@implContentDecls, " return;\n");
+ }
+ push(@implContentDecls, " $nativeType v = V8DOMWrapper::getEventListener(imp, value, true, ListenerFindOrCreate);\n");
} else {
push(@implContentDecls, " $nativeType v = " . JSValueToNative($attribute->signature, "value") . ";\n");
}
@@ -719,20 +758,24 @@ END
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"};
if ($reflect || $reflectURL) {
- $implIncludes{"HTMLNames.h"} = 1;
my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL);
- push(@implContentDecls, " imp->setAttribute(HTMLNames::${contentAttributeName}Attr, $result");
+ my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
+ $implIncludes{"${namespace}.h"} = 1;
+ push(@implContentDecls, " imp->setAttribute(${namespace}::${contentAttributeName}Attr, $result");
} elsif ($attribute->signature->type eq "EventListener") {
$implIncludes{"V8AbstractEventListener.h"} = 1;
$implIncludes{"V8CustomBinding.h"} = 1;
+ $cacheIndex = GetHiddenDependencyIndex($dataNode, $attrName);
push(@implContentDecls, " $nativeType old = imp->$attrName();\n");
- push(@implContentDecls, " if (old && static_cast<V8AbstractEventListener*>(old.get())->isObjectListener()) {\n");
- push(@implContentDecls, " v8::Local<v8::Object> oldListener = static_cast<V8AbstractEventListener*>(old.get())->getListenerObject();\n");
- push(@implContentDecls, " removeHiddenDependency(holder, oldListener, V8Custom::kNodeEventListenerCacheIndex);\n");
+ push(@implContentDecls, " V8AbstractEventListener* oldListener = old ? V8AbstractEventListener::cast(old.get()) : 0;\n");
+ push(@implContentDecls, " if (oldListener) {\n");
+ push(@implContentDecls, " v8::Local<v8::Object> oldListenerObject = oldListener->getExistingListenerObject();\n");
+ push(@implContentDecls, " if (!oldListenerObject.IsEmpty())\n");
+ push(@implContentDecls, " removeHiddenDependency(holder, oldListenerObject, $cacheIndex);\n");
push(@implContentDecls, " }\n");
push(@implContentDecls, " imp->set$implSetterFunctionName($result);\n");
push(@implContentDecls, " if ($result)\n");
- push(@implContentDecls, " createHiddenDependency(holder, value, V8Custom::kNodeEventListenerCacheIndex");
+ push(@implContentDecls, " createHiddenDependency(holder, value, $cacheIndex");
} else {
push(@implContentDecls, " imp->set$implSetterFunctionName(" . $result);
}
@@ -741,7 +784,8 @@ END
}
if ($useExceptions) {
- push(@implContentDecls, " V8Proxy::setDOMException(ec);\n");
+ push(@implContentDecls, " if (UNLIKELY(ec))\n");
+ push(@implContentDecls, " V8Proxy::setDOMException(ec);\n");
}
if ($isPodType) {
@@ -874,7 +918,7 @@ END
if (TypeCanFailConversion($parameter)) {
$implIncludes{"ExceptionCode.h"} = 1;
push(@implContentDecls,
-" if (!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ") {\n" .
+" if (UNLIKELY(!$parameterName" . (BasicTypeCanFailConversion($parameter) ? "Ok" : "") . ")) {\n" .
" V8Proxy::setDOMException(TYPE_MISMATCH_ERR);\n" .
" return v8::Handle<v8::Value>();\n" .
" }\n");
@@ -883,7 +927,7 @@ END
if ($parameter->extendedAttributes->{"IsIndex"}) {
$implIncludes{"ExceptionCode.h"} = 1;
push(@implContentDecls,
-" if ($parameterName < 0) {\n" .
+" if (UNLIKELY($parameterName < 0)) {\n" .
" V8Proxy::setDOMException(INDEX_SIZE_ERR);\n" .
" return v8::Handle<v8::Value>();\n" .
" }\n");
@@ -905,142 +949,134 @@ sub GenerateBatchedAttributeData
my $attributes = shift;
foreach my $attribute (@$attributes) {
- my $attrName = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
-
- my $accessControl = "v8::DEFAULT";
- if ($attrExt->{"DoNotCheckDomainSecurityOnGet"}) {
- $accessControl = "v8::ALL_CAN_READ";
- } elsif ($attrExt->{"DoNotCheckDomainSecurityOnSet"}) {
- $accessControl = "v8::ALL_CAN_WRITE";
- } elsif ($attrExt->{"DoNotCheckDomainSecurity"}) {
- $accessControl = "v8::ALL_CAN_READ";
- if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) {
- $accessControl .= "|v8::ALL_CAN_WRITE";
- }
- }
- if ($attrExt->{"V8DisallowShadowing"}) {
- $accessControl .= "|v8::PROHIBITS_OVERWRITING";
- }
- $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")";
-
- my $customAccessor =
- $attrExt->{"Custom"} ||
- $attrExt->{"CustomSetter"} ||
- $attrExt->{"CustomGetter"} ||
- $attrExt->{"V8Custom"} ||
- $attrExt->{"V8CustomSetter"} ||
- $attrExt->{"V8CustomGetter"} ||
- "";
- if ($customAccessor eq 1) {
- # use the naming convension, interface + (capitalize) attr name
- $customAccessor = $interfaceName . $codeGenerator->WK_ucfirst($attrName);
- }
+ my $conditionalString = GenerateConditionalString($attribute->signature);
+ push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString;
+ GenerateSingleBatchedAttribute($interfaceName, $attribute, ",", "");
+ push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
+ }
+}
- my $getter;
- my $setter;
- my $propAttr = "v8::None";
- my $hasCustomSetter = 0;
+sub GenerateSingleBatchedAttribute
+{
+ my $interfaceName = shift;
+ my $attribute = shift;
+ my $delimiter = shift;
+ my $indent = shift;
+ my $attrName = $attribute->signature->name;
+ my $attrExt = $attribute->signature->extendedAttributes;
- # Check attributes.
- if ($attrExt->{"DontEnum"}) {
- $propAttr .= "|v8::DontEnum";
- }
- if ($attrExt->{"V8DisallowShadowing"}) {
- $propAttr .= "|v8::DontDelete";
+ my $accessControl = "v8::DEFAULT";
+ if ($attrExt->{"DoNotCheckDomainSecurityOnGet"}) {
+ $accessControl = "v8::ALL_CAN_READ";
+ } elsif ($attrExt->{"DoNotCheckDomainSecurityOnSet"}) {
+ $accessControl = "v8::ALL_CAN_WRITE";
+ } elsif ($attrExt->{"DoNotCheckDomainSecurity"}) {
+ $accessControl = "v8::ALL_CAN_READ";
+ if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) {
+ $accessControl .= "|v8::ALL_CAN_WRITE";
}
+ }
+ if ($attrExt->{"V8DisallowShadowing"}) {
+ $accessControl .= "|v8::PROHIBITS_OVERWRITING";
+ }
+ $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")";
+
+ my $customAccessor =
+ $attrExt->{"Custom"} ||
+ $attrExt->{"CustomSetter"} ||
+ $attrExt->{"CustomGetter"} ||
+ $attrExt->{"V8Custom"} ||
+ $attrExt->{"V8CustomSetter"} ||
+ $attrExt->{"V8CustomGetter"} ||
+ "";
+ if ($customAccessor eq 1) {
+ # use the naming convension, interface + (capitalize) attr name
+ $customAccessor = $interfaceName . $codeGenerator->WK_ucfirst($attrName);
+ }
+
+ my $getter;
+ my $setter;
+ my $propAttr = "v8::None";
+ my $hasCustomSetter = 0;
+
+ # Check attributes.
+ if ($attrExt->{"DontEnum"}) {
+ $propAttr .= "|v8::DontEnum";
+ }
+ if ($attrExt->{"V8DisallowShadowing"}) {
+ $propAttr .= "|v8::DontDelete";
+ }
- my $on_proto = "0 /* on instance */";
- my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */";
+ my $on_proto = "0 /* on instance */";
+ my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */";
- # Constructor
- if ($attribute->signature->type =~ /Constructor$/) {
- my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
- $constructorType =~ s/Constructor$//;
- my $constructorIndex = uc($constructorType);
+ # Constructor
+ if ($attribute->signature->type =~ /Constructor$/) {
+ my $constructorType = $codeGenerator->StripModule($attribute->signature->type);
+ $constructorType =~ s/Constructor$//;
+ my $constructorIndex = uc($constructorType);
+ if ($customAccessor) {
+ $getter = "V8Custom::v8${customAccessor}AccessorGetter";
+ } else {
$data = "V8ClassIndex::${constructorIndex}";
$getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter";
- $setter = "0";
- $propAttr = "v8::ReadOnly";
-
- # EventListeners
- } elsif ($attribute->signature->type eq "EventListener" && RequiresCustomEventListenerAccessors($dataNode)) {
- if ($interfaceName eq "DOMWindow") {
- $getter = "V8Custom::v8DOMWindowEventHandlerAccessorGetter";
- $setter = "V8Custom::v8DOMWindowEventHandlerAccessorSetter";
- } elsif ($interfaceName eq "DOMApplicationCache") {
- $getter = "V8Custom::v8DOMApplicationCacheEventHandlerAccessorGetter";
- $setter = "V8Custom::v8DOMApplicationCacheEventHandlerAccessorSetter";
- } elsif ($interfaceName eq "Notification") {
- $getter = "V8Custom::v8NotificationEventHandlerAccessorGetter";
- $setter = "V8Custom::v8NotificationEventHandlerAccessorSetter";
- } else {
- $getter = "V8Custom::v8${customAccessor}AccessorGetter";
- if ($interfaceName eq "WorkerContext" and $attrName eq "self") {
- $setter = "0";
- $propAttr = "v8::ReadOnly";
- } else {
- $setter = "V8Custom::v8${customAccessor}AccessorSetter";
- }
- }
- } else {
- # Default Getter and Setter
- $getter = "${interfaceName}Internal::${attrName}AttrGetter";
- $setter = "${interfaceName}Internal::${attrName}AttrSetter";
-
- # Custom Setter
- if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
- $hasCustomSetter = 1;
- $setter = "V8Custom::v8${customAccessor}AccessorSetter";
- }
-
- # Custom Getter
- if ($attrExt->{"CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
- $getter = "V8Custom::v8${customAccessor}AccessorGetter";
- }
}
+ $setter = "0";
+ $propAttr = "v8::ReadOnly";
- # Replaceable
- if ($attrExt->{"Replaceable"} && !$hasCustomSetter) {
- $setter = "0";
- # Handle the special case of window.top being marked as Replaceable.
- # FIXME: Investigate whether we could treat window.top as replaceable
- # and allow shadowing without it being a security hole.
- if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) {
- $propAttr .= "|v8::ReadOnly";
- }
+ } else {
+ # Default Getter and Setter
+ $getter = "${interfaceName}Internal::${attrName}AttrGetter";
+ $setter = "${interfaceName}Internal::${attrName}AttrSetter";
+
+ # Custom Setter
+ if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
+ $hasCustomSetter = 1;
+ $setter = "V8Custom::v8${customAccessor}AccessorSetter";
}
- # Read only attributes
- if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) {
- $setter = "0";
+ # Custom Getter
+ if ($attrExt->{"CustomGetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) {
+ $getter = "V8Custom::v8${customAccessor}AccessorGetter";
}
+ }
- # An accessor can be installed on the proto
- if ($attrExt->{"v8OnProto"}) {
- $on_proto = "1 /* on proto */";
+ # Replaceable
+ if ($attrExt->{"Replaceable"} && !$hasCustomSetter) {
+ $setter = "0";
+ # Handle the special case of window.top being marked as Replaceable.
+ # FIXME: Investigate whether we could treat window.top as replaceable
+ # and allow shadowing without it being a security hole.
+ if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) {
+ $propAttr .= "|v8::ReadOnly";
}
+ }
- my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type .
- "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')";
-
- my $conditionalString = GenerateConditionalString($attribute->signature);
- push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString;
+ # Read only attributes
+ if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) {
+ $setter = "0";
+ }
- push(@implContent, <<END);
- // $commentInfo
- { "$attrName",
- $getter,
- $setter,
- $data,
- $accessControl,
- static_cast<v8::PropertyAttribute>($propAttr),
- $on_proto },
-END
- push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
+ # An accessor can be installed on the proto
+ if ($attrExt->{"v8OnProto"}) {
+ $on_proto = "1 /* on proto */";
}
-}
+ my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type .
+ "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')";
+
+ push(@implContent, $indent . " {\n");
+ push(@implContent, $indent . " \/\/ $commentInfo\n");
+ push(@implContent, $indent . " \"$attrName\",\n");
+ push(@implContent, $indent . " $getter,\n");
+ push(@implContent, $indent . " $setter,\n");
+ push(@implContent, $indent . " $data,\n");
+ push(@implContent, $indent . " $accessControl,\n");
+ push(@implContent, $indent . " static_cast<v8::PropertyAttribute>($propAttr),\n");
+ push(@implContent, $indent . " $on_proto\n");
+ push(@implContent, $indent . " }" . $delimiter . "\n");
+END
+}
sub GenerateImplementation
{
@@ -1088,20 +1124,16 @@ sub GenerateImplementation
# Generate special code for the constructor attributes.
if ($attrType =~ /Constructor$/) {
- $hasConstructors = 1;
+ if ($attribute->signature->extendedAttributes->{"CustomGetter"}) {
+ $implIncludes{"V8CustomBinding.h"} = 1;
+ } else {
+ $hasConstructors = 1;
+ }
next;
}
- # Make EventListeners custom for some types.
- # FIXME: make the perl code capable of generating the
- # event setters/getters. For now, WebKit has started removing the
- # [Custom] attribute, so just automatically insert it to avoid forking
- # other files. This should be okay because we can't generate stubs
- # for any event getter/setters anyway.
- if ($attrType eq "EventListener" && RequiresCustomEventListenerAccessors($dataNode)) {
- $attribute->signature->extendedAttributes->{"Custom"} = 1;
- $implIncludes{"V8CustomBinding.h"} = 1;
- next;
+ if ($attrType eq "EventListener" && $interfaceName eq "DOMWindow") {
+ $attribute->signature->extendedAttributes->{"v8OnProto"} = 1;
}
# Do not generate accessor if this is a custom attribute. The
@@ -1117,7 +1149,7 @@ sub GenerateImplementation
if ($attribute->signature->extendedAttributes->{"CustomGetter"}) {
$implIncludes{"V8CustomBinding.h"} = 1;
} else {
- GenerateNormalAttrGetter($attribute, $dataNode, $classIndex, $implClassName);
+ GenerateNormalAttrGetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName);
}
if ($attribute->signature->extendedAttributes->{"CustomSetter"} ||
$attribute->signature->extendedAttributes->{"V8CustomSetter"}) {
@@ -1126,7 +1158,7 @@ sub GenerateImplementation
$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"} || die "Replaceable attribute can only be used in interface that defines ExtendsDOMGlobalObject attribute!";
# GenerateReplaceableAttrSetter($implClassName);
} elsif ($attribute->type !~ /^readonly/ && !$attribute->signature->extendedAttributes->{"V8ReadOnly"}) {
- GenerateNormalAttrSetter($attribute, $dataNode, $classIndex, $implClassName);
+ GenerateNormalAttrSetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName);
}
}
@@ -1157,20 +1189,24 @@ sub GenerateImplementation
# For the DOMWindow interface we partition the attributes into the
# ones that disallows shadowing and the rest.
- my @disallows_shadowing;
+ my @disallowsShadowing;
+ # Also separate out attributes that are enabled at runtime so we can process them specially.
+ my @enabledAtRuntime;
my @normal;
- if ($interfaceName eq "DOMWindow") {
- foreach my $attribute (@$attributes) {
- if ($attribute->signature->extendedAttributes->{"V8DisallowShadowing"}) {
- push(@disallows_shadowing, $attribute);
- } else {
- push(@normal, $attribute);
- }
+ foreach my $attribute (@$attributes) {
+ if ($interfaceName eq "DOMWindow" && $attribute->signature->extendedAttributes->{"V8DisallowShadowing"}) {
+ push(@disallowsShadowing, $attribute);
+ } elsif ($attribute->signature->extendedAttributes->{"EnabledAtRuntime"}) {
+ push(@enabledAtRuntime, $attribute);
+ } else {
+ push(@normal, $attribute);
}
- # Put the attributes that disallow shadowing on the shadow object.
- $attributes = \@normal;
+ }
+ $attributes = \@normal;
+ # Put the attributes that disallow shadowing on the shadow object.
+ if (@disallowsShadowing) {
push(@implContent, "static const BatchedAttribute shadow_attrs[] = {\n");
- GenerateBatchedAttributeData($dataNode, \@disallows_shadowing);
+ GenerateBatchedAttributeData($dataNode, \@disallowsShadowing);
push(@implContent, "};\n");
}
@@ -1252,6 +1288,21 @@ END
END
}
+ # Setup the enable-at-runtime attrs if we have them
+ foreach my $runtime_attr (@enabledAtRuntime) {
+ $enable_function = $interfaceName . $codeGenerator->WK_ucfirst($runtime_attr->signature->name);
+ my $conditionalString = GenerateConditionalString($runtime_attr->signature);
+ push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString;
+ push(@implContent, " if (V8Custom::v8${enable_function}Enabled()) {\n");
+ push(@implContent, " static const BatchedAttribute attrData =\\\n");
+ GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, ";", " ");
+ push(@implContent, <<END);
+ configureAttribute(instance, proto, attrData);
+ }
+END
+ push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
+ }
+
# Define our functions with Set() or SetAccessor()
foreach my $function (@{$dataNode->functions}) {
my $attrExt = $function->signature->extendedAttributes;
@@ -1272,6 +1323,13 @@ END
$template = "instance";
}
+ my $conditional = "";
+ if ($attrExt->{"EnabledAtRuntime"}) {
+ # Only call Set()/SetAccessor() if this method should be enabled
+ $enable_function = $interfaceName . $codeGenerator->WK_ucfirst($function->signature->name);
+ $conditional = "if (V8Custom::v8${enable_function}Enabled())\n";
+ }
+
if ($attrExt->{"DoNotCheckDomainSecurity"} &&
($dataNode->extendedAttributes->{"CheckDomainSecurity"} || $interfaceName eq "DOMWindow")) {
# Mark the accessor as ReadOnly and set it on the proto object so
@@ -1292,7 +1350,7 @@ END
push(@implContent, <<END);
// $commentInfo
- $template->SetAccessor(
+ $conditional $template->SetAccessor(
v8::String::New("$name"),
${interfaceName}Internal::${name}AttrGetter,
0,
@@ -1320,7 +1378,7 @@ END
push(@implContent, <<END);
// $commentInfo
- ${template}->Set(
+ $conditional ${template}->Set(
v8::String::New("$name"),
$templateFunction,
static_cast<v8::PropertyAttribute>($property_attributes));
@@ -1338,7 +1396,7 @@ END
}
# Set the class name. This is used when printing objects.
- push(@implContent, " desc->SetClassName(v8::String::New(\"" . GetClassName(${interfaceName}) . "\"));\n");
+ push(@implContent, " desc->SetClassName(v8::String::New(\"${interfaceName}\"));\n");
if ($has_constants) {
push(@implContent, <<END);
@@ -1456,7 +1514,7 @@ sub GenerateFunctionCallString()
$paramName = "SVGPODListItem<" . GetNativeType($paramType, 1) . ">::copy($paramName)";
}
- if ($parameter->type eq "NodeFilter") {
+ if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") {
$functionString .= "$paramName.get()";
} else {
$functionString .= $paramName;
@@ -1480,6 +1538,9 @@ sub GenerateFunctionCallString()
}
$functionString .= ")";
+ my $return = "result";
+ my $returnIsRef = IsRefPtrType($returnType);
+
if ($nodeToReturn) {
# Special case for insertBefore, replaceChild, removeChild and
# appendChild functions from Node.
@@ -1500,16 +1561,18 @@ sub GenerateFunctionCallString()
$indent . "$functionString;\n";
} elsif ($returnsListItemPodType) {
$result .= $indent . "RefPtr<SVGPODListItem<$nativeReturnType> > result = $functionString;\n";
- } else {
+ } elsif (@{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) {
$result .= $indent . $nativeReturnType . " result = $functionString;\n";
+ } else {
+ # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary
+ $return = $functionString;
+ $returnIsRef = 0;
}
if (@{$function->raisesExceptions}) {
$result .= GenerateSetDOMException($indent);
}
- my $return = "result";
-
# If the return type is a POD type, separate out the wrapper generation
if ($returnsListItemPodType) {
$result .= $indent . "RefPtr<V8SVGPODTypeWrapper<" . $nativeReturnType . "> > wrapper = ";
@@ -1552,7 +1615,7 @@ sub GenerateFunctionCallString()
my $classIndex = uc($returnType);
$result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n";
} else {
- $return .= ".release()" if (IsRefPtrType($returnType));
+ $return .= ".release()" if ($returnIsRef);
$result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n";
}
@@ -1560,15 +1623,6 @@ sub GenerateFunctionCallString()
}
-# Get the class name used for printing javascript DOM-object wrappers.
-sub GetClassName
-{
- my $type = shift;
- return "HTMLCollection" if $type eq "HTMLAllCollection";
- return $type;
-}
-
-
sub GetTypeFromSignature
{
my $signature = shift;
@@ -1601,6 +1655,7 @@ sub IsRefPtrType
{
my $type = shift;
return 1 if $type eq "Attr";
+ return 1 if $type eq "CanvasActiveInfo";
return 1 if $type eq "CanvasArray";
return 1 if $type eq "CanvasArrayBuffer";
return 1 if $type eq "CanvasBooleanArray";
@@ -1645,6 +1700,7 @@ sub IsRefPtrType
return 1 if $type eq "EventListener";
return 1 if $type eq "FileList";
return 1 if $type eq "HTMLCollection";
+ return 1 if $type eq "HTMLAllCollection";
return 1 if $type eq "HTMLDocument";
return 1 if $type eq "HTMLElement";
return 1 if $type eq "HTMLOptionsCollection";
@@ -1738,6 +1794,9 @@ sub GetNativeType
# temporary hack
return "RefPtr<NodeFilter>" if $type eq "NodeFilter";
+ # necessary as resolvers could be constructed on fly.
+ return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver";
+
return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter;
# Default, assume native type is a pointer with same type name as idl type
@@ -1873,6 +1932,11 @@ sub JSValueToNative
return "toWebCoreString($value)";
}
+ if ($type eq "SerializedScriptValue") {
+ $implIncludes{"SerializedScriptValue.h"} = 1;
+ return "SerializedScriptValue::create($value)";
+ }
+
if ($type eq "NodeFilter") {
return "V8DOMWrapper::wrapNativeNodeFilter($value)";
}
@@ -1894,6 +1958,10 @@ sub JSValueToNative
return "V8Node::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast($value)) : 0";
}
+ if ($type eq "XPathNSResolver") {
+ return "V8DOMWrapper::getXPathNSResolver($value)";
+ }
+
AddIncludesForType($type);
# $implIncludes{"$type.h"} = 1 unless AvoidInclusionOfType($type);
@@ -1945,10 +2013,16 @@ sub CreateCustomSignature
if ($first) { $first = 0; }
else { $result .= ", "; }
if (IsWrapperType($parameter->type)) {
- my $type = $parameter->type;
- my $header = GetV8HeaderName($type);
- $implIncludes{$header} = 1;
- $result .= "V8${type}::GetRawTemplate()";
+ if ($parameter->type eq "XPathNSResolver") {
+ # Special case for XPathNSResolver. All other browsers accepts a callable,
+ # so, even though it's against IDL, accept objects here.
+ $result .= "v8::Handle<v8::FunctionTemplate>()";
+ } else {
+ my $type = $parameter->type;
+ my $header = GetV8HeaderName($type);
+ $implIncludes{$header} = 1;
+ $result .= "V8${type}::GetRawTemplate()";
+ }
} else {
$result .= "v8::Handle<v8::FunctionTemplate>()";
}
@@ -2053,7 +2127,9 @@ sub ReturnNativeToJSValue
# For all the types where we use 'int' as the representation type,
# we use Integer::New which has a fast Smi conversion check.
- return "return v8::Integer::New($value)" if GetNativeType($type) eq "int";
+ my $nativeType = GetNativeType($type);
+ return "return v8::Integer::New($value)" if $nativeType eq "int";
+ return "return v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned";
return "return v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType";
@@ -2076,7 +2152,11 @@ sub ReturnNativeToJSValue
# special case for non-DOM node interfaces
if (IsDOMNodeType($type)) {
- return "return V8DOMWrapper::convertNodeToV8Object($value)";
+ if ($signature->extendedAttributes->{"ReturnsNew"}) {
+ return "return V8DOMWrapper::convertNewNodeToV8Object($value)";
+ } else {
+ return "return V8DOMWrapper::convertNodeToV8Object($value)";
+ }
}
if ($type eq "EventTarget" or $type eq "SVGElementInstance") {
@@ -2088,7 +2168,12 @@ sub ReturnNativeToJSValue
}
if ($type eq "EventListener") {
- return "return V8DOMWrapper::convertEventListenerToV8Object($value)";
+ return "return V8DOMWrapper::convertEventListenerToV8Object(imp->scriptExecutionContext(), $value)";
+ }
+
+ if ($type eq "SerializedScriptValue") {
+ $implIncludes{"$type.h"} = 1;
+ return "return v8String($value->toString())";
}
if ($type eq "DedicatedWorkerContext" or $type eq "WorkerContext" or $type eq "SharedWorkerContext") {