From ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Thu, 8 Jul 2010 12:51:48 +0100 Subject: Merge WebKit at r62496: Initial merge by git Change-Id: Ie3da0770eca22a70a632e3571f31cfabc80facb2 --- WebCore/bindings/generic/BindingElement.h | 102 -------------------- WebCore/bindings/gobject/WebKitDOMObject.cpp | 36 +++++++ WebCore/bindings/js/IDBBindingUtilities.cpp | 49 ++++++++++ WebCore/bindings/js/IDBBindingUtilities.h | 44 +++++++++ WebCore/bindings/js/JSArrayBufferViewHelper.h | 9 +- WebCore/bindings/js/JSBindingsAllInOne.cpp | 12 ++- .../js/JSCanvasRenderingContext2DCustom.cpp | 1 + WebCore/bindings/js/JSDOMStringMapCustom.cpp | 102 ++++++++++++++++++++ WebCore/bindings/js/JSDOMStringMapCustom.h | 31 ++++++ WebCore/bindings/js/JSHTMLFrameElementCustom.cpp | 11 --- WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp | 59 ------------ WebCore/bindings/js/JSIDBKeyCustom.cpp | 61 ++++++++++++ .../bindings/js/JSWebGLRenderingContextCustom.cpp | 31 ++++++ WebCore/bindings/js/ScriptController.cpp | 7 +- WebCore/bindings/js/ScriptDebugServer.cpp | 8 +- WebCore/bindings/js/ScriptDebugServer.h | 2 +- WebCore/bindings/js/ScriptSourceProvider.h | 4 +- WebCore/bindings/js/StringSourceProvider.h | 4 + WebCore/bindings/objc/DOM.mm | 1 + WebCore/bindings/objc/DOMSVG.h | 1 + WebCore/bindings/scripts/CodeGeneratorGObject.pm | 36 +++++-- WebCore/bindings/scripts/CodeGeneratorJS.pm | 13 ++- WebCore/bindings/scripts/CodeGeneratorV8.pm | 11 ++- .../bindings/scripts/test/CPP/WebDOMTestObj.cpp | 10 ++ WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h | 2 + .../scripts/test/GObject/WebKitDOMTestCallback.cpp | 23 +++-- .../test/GObject/WebKitDOMTestInterface.cpp | 20 ++-- .../scripts/test/GObject/WebKitDOMTestObj.cpp | 104 +++++++++++++++++++-- .../scripts/test/GObject/WebKitDOMTestObj.h | 3 + .../bindings/scripts/test/JS/JSTestCallback.cpp | 2 +- WebCore/bindings/scripts/test/JS/JSTestObj.cpp | 20 +++- WebCore/bindings/scripts/test/JS/JSTestObj.h | 1 + WebCore/bindings/scripts/test/ObjC/DOMTestObj.h | 2 + WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm | 8 ++ WebCore/bindings/scripts/test/TestObj.idl | 1 + WebCore/bindings/scripts/test/V8/V8TestObj.cpp | 12 +++ WebCore/bindings/v8/IDBBindingUtilities.cpp | 50 ++++++++++ WebCore/bindings/v8/IDBBindingUtilities.h | 44 +++++++++ WebCore/bindings/v8/ScriptController.cpp | 43 ++++----- WebCore/bindings/v8/ScriptDebugServer.cpp | 13 ++- WebCore/bindings/v8/ScriptDebugServer.h | 2 +- WebCore/bindings/v8/SerializedScriptValue.cpp | 1 + WebCore/bindings/v8/V8AbstractEventListener.cpp | 3 +- WebCore/bindings/v8/V8Binding.h | 2 - WebCore/bindings/v8/V8HiddenPropertyName.h | 3 +- WebCore/bindings/v8/V8Proxy.cpp | 5 + WebCore/bindings/v8/V8Proxy.h | 3 + .../bindings/v8/custom/V8ArrayBufferViewCustom.h | 14 ++- WebCore/bindings/v8/custom/V8BindingMacros.h | 24 +++-- WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp | 11 ++- WebCore/bindings/v8/custom/V8DatabaseCustom.cpp | 5 +- .../bindings/v8/custom/V8DatabaseSyncCustom.cpp | 5 +- .../v8/custom/V8HTMLFrameElementCustom.cpp | 11 --- .../v8/custom/V8HTMLIFrameElementCustom.cpp | 55 ----------- WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp | 60 ++++++++++++ .../bindings/v8/custom/V8SQLTransactionCustom.cpp | 5 +- .../v8/custom/V8SQLTransactionSyncCustom.cpp | 5 +- .../v8/custom/V8WebGLRenderingContextCustom.cpp | 33 +++++++ .../bindings/v8/custom/V8WorkerContextCustom.cpp | 12 +-- 59 files changed, 904 insertions(+), 348 deletions(-) delete mode 100644 WebCore/bindings/generic/BindingElement.h create mode 100644 WebCore/bindings/js/IDBBindingUtilities.cpp create mode 100644 WebCore/bindings/js/IDBBindingUtilities.h create mode 100644 WebCore/bindings/js/JSDOMStringMapCustom.cpp create mode 100644 WebCore/bindings/js/JSDOMStringMapCustom.h delete mode 100644 WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp create mode 100644 WebCore/bindings/js/JSIDBKeyCustom.cpp create mode 100644 WebCore/bindings/v8/IDBBindingUtilities.cpp create mode 100644 WebCore/bindings/v8/IDBBindingUtilities.h delete mode 100644 WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp create mode 100644 WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp (limited to 'WebCore/bindings') diff --git a/WebCore/bindings/generic/BindingElement.h b/WebCore/bindings/generic/BindingElement.h deleted file mode 100644 index ba7856a..0000000 --- a/WebCore/bindings/generic/BindingElement.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BindingElement_h -#define BindingElement_h - -#include "Attr.h" -#include "BindingSecurity.h" -#include "Element.h" -#include "ExceptionCode.h" - -#include - -namespace WebCore { - -template -class BindingElement { -public: - static void setAttribute(State*, Element*, const AtomicString&, const AtomicString&, ExceptionCode&); - static RefPtr setAttributeNode(State*, Element*, Attr*, ExceptionCode&); - static void setAttributeNS(State*, Element*, const AtomicString&, const AtomicString&, const AtomicString&, ExceptionCode&); - static RefPtr setAttributeNodeNS(State*, Element*, Attr*, ExceptionCode&); -}; - -// Implementations of templated methods must be in this file. - -template -void BindingElement::setAttribute(State* state, Element* element, const AtomicString& name, const AtomicString& value, ExceptionCode& ec) -{ - ASSERT(element); - - if (!BindingSecurity::allowSettingSrcToJavascriptURL(state, element, name, value)) - return; - - element->setAttribute(name, value, ec); -} - -template -RefPtr BindingElement::setAttributeNode(State* state, Element* element, Attr* newAttr, ExceptionCode& ec) -{ - ASSERT(element); - ASSERT(newAttr); - - if (!BindingSecurity::allowSettingSrcToJavascriptURL(state, element, newAttr->name(), newAttr->value())) - return 0; - - return element->setAttributeNode(newAttr, ec); -} - -template -void BindingElement::setAttributeNS(State* state, Element* element, const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode& ec) -{ - ASSERT(element); - - if (!BindingSecurity::allowSettingSrcToJavascriptURL(state, element, qualifiedName, value)) - return; - - element->setAttributeNS(namespaceURI, qualifiedName, value, ec); -} - -template -RefPtr BindingElement::setAttributeNodeNS(State* state, Element* element, Attr* newAttr, ExceptionCode& ec) -{ - ASSERT(element); - ASSERT(newAttr); - - if (!BindingSecurity::allowSettingSrcToJavascriptURL(state, element, newAttr->name(), newAttr->value())) - return 0; - - return element->setAttributeNodeNS(newAttr, ec); -} - -} // namespace WebCore - -#endif // BindingElement_h diff --git a/WebCore/bindings/gobject/WebKitDOMObject.cpp b/WebCore/bindings/gobject/WebKitDOMObject.cpp index fc8a874..d8452ac 100644 --- a/WebCore/bindings/gobject/WebKitDOMObject.cpp +++ b/WebCore/bindings/gobject/WebKitDOMObject.cpp @@ -11,13 +11,49 @@ #include "glib-object.h" #include "WebKitDOMBinding.h" +enum { + PROP_0, + PROP_CORE_OBJECT +}; + G_DEFINE_TYPE(WebKitDOMObject, webkit_dom_object, G_TYPE_OBJECT); static void webkit_dom_object_init(WebKitDOMObject* object) { } +static void webkit_dom_object_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void webkit_dom_object_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + case PROP_CORE_OBJECT: + WEBKIT_DOM_OBJECT(object)->coreObject = g_value_get_pointer(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + static void webkit_dom_object_class_init(WebKitDOMObjectClass* klass) { + GObjectClass* gobjectClass = G_OBJECT_CLASS(klass); + gobjectClass->set_property = webkit_dom_object_set_property; + gobjectClass->get_property = webkit_dom_object_get_property; + + g_object_class_install_property(gobjectClass, + PROP_CORE_OBJECT, + g_param_spec_pointer("core-object", + "Core Object", + "The WebCore object the WebKitDOMObject wraps", + static_cast(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY))); } diff --git a/WebCore/bindings/js/IDBBindingUtilities.cpp b/WebCore/bindings/js/IDBBindingUtilities.cpp new file mode 100644 index 0000000..faa2370 --- /dev/null +++ b/WebCore/bindings/js/IDBBindingUtilities.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "IDBBindingUtilities.h" + +#include "IDBKey.h" + +#if ENABLE(INDEXED_DATABASE) + +namespace WebCore { + +PassRefPtr createIDBKeyFromValue(JSC::ExecState* exec, JSC::JSValue value) +{ + if (value.isNull()) + return IDBKey::create(); + if (value.isInt32()) + return IDBKey::create(value.toInt32(exec)); + if (value.isString()) + return IDBKey::create(ustringToString(value.toString(exec))); + // FIXME: Implement dates. + return 0; +} + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/js/IDBBindingUtilities.h b/WebCore/bindings/js/IDBBindingUtilities.h new file mode 100644 index 0000000..0a2fb790 --- /dev/null +++ b/WebCore/bindings/js/IDBBindingUtilities.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef IDBBindingUtilities_h +#define IDBBindingUtilities_h + +#include "ScriptValue.h" +#include + +#if ENABLE(INDEXED_DATABASE) + +namespace WebCore { + +class IDBKey; + +PassRefPtr createIDBKeyFromValue(JSC::ExecState*, JSC::JSValue); + +} + +#endif // ENABLE(INDEXED_DATABASE) + +#endif // IDBBindingUtilities_h diff --git a/WebCore/bindings/js/JSArrayBufferViewHelper.h b/WebCore/bindings/js/JSArrayBufferViewHelper.h index 331e950..27a9a98 100644 --- a/WebCore/bindings/js/JSArrayBufferViewHelper.h +++ b/WebCore/bindings/js/JSArrayBufferViewHelper.h @@ -96,9 +96,14 @@ PassRefPtr constructArrayBufferView(JSC::ExecState* exec) // RefPtr arrayObject; - // For the 0 args case, just create an object without a buffer + // For the 0 args case, just create a zero-length view. We could + // consider raising a SyntaxError for this case, but not all + // JavaScript DOM bindings can distinguish between "new + // Array()" and what occurs when a previously-constructed + // ArrayBufferView is returned to JavaScript; e.g., from + // "array.slice()". if (exec->argumentCount() < 1) - return C::create(0, 0, 0); + return C::create(0); if (exec->argument(0).isNull()) { // Invalid first argument diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp index 1d64198..c9a77fb 100644 --- a/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -25,6 +25,8 @@ // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build. +#include "DOMObjectHashTableMap.cpp" +#include "DOMWrapperWorld.cpp" #include "GCController.cpp" #include "JSAttrCustom.cpp" #include "JSAudioConstructor.cpp" @@ -39,19 +41,25 @@ #include "JSClipboardCustom.cpp" #include "JSConsoleCustom.cpp" #include "JSCoordinatesCustom.cpp" +#include "JSCustomPositionCallback.cpp" +#include "JSCustomPositionErrorCallback.cpp" #include "JSCustomSQLStatementErrorCallback.cpp" #include "JSCustomVoidCallback.cpp" #include "JSCustomXPathNSResolver.cpp" #include "JSDOMApplicationCacheCustom.cpp" #include "JSDOMBinding.cpp" +#include "JSDOMFormDataCustom.cpp" #include "JSDOMGlobalObject.cpp" +#include "JSDOMStringMapCustom.cpp" #include "JSDOMWindowBase.cpp" #include "JSDOMWindowCustom.cpp" #include "JSDOMWindowShell.cpp" +#include "JSDOMWrapper.cpp" #include "JSDataGridColumnListCustom.cpp" #include "JSDataGridDataSource.cpp" #include "JSDatabaseCustom.cpp" #include "JSDatabaseSyncCustom.cpp" +#include "JSDebugWrapperSet.cpp" #include "JSDedicatedWorkerContextCustom.cpp" #include "JSDesktopNotificationsCustom.cpp" #include "JSDocumentCustom.cpp" @@ -61,6 +69,7 @@ #include "JSEventSourceCustom.cpp" #include "JSEventTarget.cpp" #include "JSExceptionBase.cpp" +#include "JSGeolocationCustom.cpp" #include "JSHTMLAllCollectionCustom.cpp" #include "JSHTMLAppletElementCustom.cpp" #include "JSHTMLCanvasElementCustom.cpp" @@ -72,7 +81,6 @@ #include "JSHTMLFormElementCustom.cpp" #include "JSHTMLFrameElementCustom.cpp" #include "JSHTMLFrameSetElementCustom.cpp" -#include "JSHTMLIFrameElementCustom.cpp" #include "JSHTMLInputElementCustom.cpp" #include "JSHTMLObjectElementCustom.cpp" #include "JSHTMLOptionsCollectionCustom.cpp" @@ -101,6 +109,7 @@ #include "JSPluginArrayCustom.cpp" #include "JSPluginCustom.cpp" #include "JSPluginElementFunctions.cpp" +#include "JSPopStateEventCustom.cpp" #include "JSSQLResultSetRowListCustom.cpp" #include "JSSQLTransactionCustom.cpp" #include "JSSQLTransactionSyncCustom.cpp" @@ -138,6 +147,7 @@ #include "ScriptDebugServer.cpp" #include "ScriptEventListener.cpp" #include "ScriptFunctionCall.cpp" +#include "ScriptGCEvent.cpp" #include "ScriptProfiler.cpp" #include "ScriptState.cpp" #include "SerializedScriptValue.cpp" diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp index 914dea0..e88afc2 100644 --- a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp +++ b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp @@ -220,6 +220,7 @@ JSValue JSCanvasRenderingContext2D::drawImage(ExecState* exec) switch (exec->argumentCount()) { case 3: context->drawImage(canvas, exec->argument(1).toFloat(exec), exec->argument(2).toFloat(exec), ec); + setDOMException(exec, ec); break; case 5: context->drawImage(canvas, exec->argument(1).toFloat(exec), exec->argument(2).toFloat(exec), diff --git a/WebCore/bindings/js/JSDOMStringMapCustom.cpp b/WebCore/bindings/js/JSDOMStringMapCustom.cpp new file mode 100644 index 0000000..455c7b1 --- /dev/null +++ b/WebCore/bindings/js/JSDOMStringMapCustom.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 "JSDOMStringMap.h" + +#include "AtomicString.h" +#include "DOMStringMap.h" + +using namespace JSC; + +namespace WebCore { + +bool JSDOMStringMap::canGetItemsForName(ExecState*, DOMStringMap* impl, const Identifier& propertyName) +{ + return impl->contains(identifierToAtomicString(propertyName)); +} + +JSValue JSDOMStringMap::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) +{ + JSDOMStringMap* thisObj = static_cast(asObject(slotBase)); + return jsString(exec, thisObj->impl()->item(identifierToAtomicString(propertyName))); +} + +void JSDOMStringMap::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + Vector names; + m_impl->getNames(names); + size_t length = names.size(); + for (size_t i = 0; i < length; ++i) + propertyNames.add(Identifier(exec, stringToUString(names[i]))); + + Base::getOwnPropertyNames(exec, propertyNames, mode); +} + +bool JSDOMStringMap::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + // Only perform the custom delete if the object doesn't have a native property by this name. + // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check + // the native property slots manually. + PropertySlot slot; + if (getStaticValueSlot(exec, s_info.propHashTable(exec), this, propertyName, slot)) + return false; + + JSValue prototype = this->prototype(); + if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName)) + return false; + + ExceptionCode ec = 0; + m_impl->deleteItem(identifierToString(propertyName), ec); + setDOMException(exec, ec); + + return true; +} + +bool JSDOMStringMap::putDelegate(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot&) +{ + // Only perform the custom put if the object doesn't have a native property by this name. + // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check + // the native property slots manually. + PropertySlot slot; + if (getStaticValueSlot(exec, s_info.propHashTable(exec), this, propertyName, slot)) + return false; + + JSValue prototype = this->prototype(); + if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName)) + return false; + + String stringValue = ustringToString(value.toString(exec)); + if (exec->hadException()) + return true; + + ExceptionCode ec = 0; + impl()->setItem(identifierToString(propertyName), stringValue, ec); + setDOMException(exec, ec); + + return true; +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/JSDOMStringMapCustom.h b/WebCore/bindings/js/JSDOMStringMapCustom.h new file mode 100644 index 0000000..095fd21 --- /dev/null +++ b/WebCore/bindings/js/JSDOMStringMapCustom.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 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. 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 INC. 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 JSDOMStringMapCustom_h +#define JSDOMStringMapCustom_h + +#include "JSDOMStringMap.h" + +#endif // JSDOMStringMapCustom_h diff --git a/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp b/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp index 6e01513..345cffe 100644 --- a/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp @@ -51,17 +51,6 @@ static inline bool allowSettingJavascriptURL(ExecState* exec, HTMLFrameElement* return true; } -void JSHTMLFrameElement::setSrc(ExecState* exec, JSValue value) -{ - HTMLFrameElement* imp = static_cast(impl()); - String srcValue = valueToStringWithNullCheck(exec, value); - - if (!allowSettingJavascriptURL(exec, imp, srcValue)) - return; - - imp->setAttribute(srcAttr, srcValue); -} - void JSHTMLFrameElement::setLocation(ExecState* exec, JSValue value) { HTMLFrameElement* imp = static_cast(impl()); diff --git a/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp b/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp deleted file mode 100644 index 60ea45e..0000000 --- a/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp +++ /dev/null @@ -1,59 +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. - * 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 "JSHTMLIFrameElement.h" - -#include "CSSHelper.h" -#include "Document.h" -#include "HTMLIFrameElement.h" -#include "HTMLNames.h" -#include "JSDOMBinding.h" - -using namespace JSC; - -namespace WebCore { - -using namespace HTMLNames; - -void JSHTMLIFrameElement::setSrc(ExecState* exec, JSValue value) -{ - HTMLIFrameElement* imp = static_cast(impl()); - - String srcValue = valueToStringWithNullCheck(exec, value); - - if (protocolIsJavaScript(deprecatedParseURL(srcValue))) { - Document* contentDocument = imp->contentDocument(); - if (contentDocument && !checkNodeSecurity(exec, contentDocument)) - return; - } - - imp->setAttribute(srcAttr, srcValue); -} - -} // namespace WebCore diff --git a/WebCore/bindings/js/JSIDBKeyCustom.cpp b/WebCore/bindings/js/JSIDBKeyCustom.cpp new file mode 100644 index 0000000..98c9315 --- /dev/null +++ b/WebCore/bindings/js/JSIDBKeyCustom.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(INDEXED_DATABASE) +#include "JSIDBKey.h" + +#include "IDBBindingUtilities.h" +#include "IDBKey.h" + +using namespace JSC; + +namespace WebCore { + +JSValue toJS(ExecState* exec, JSDOMGlobalObject*, IDBKey* key) +{ + if (!key) + return jsNull(); + + switch (key->type()) { + case IDBKey::NullType: + return jsNull(); + case IDBKey::NumberType: + return jsNumber(exec, key->number()); + case IDBKey::StringType: + return jsString(exec, key->string()); + // FIXME: Implement dates. + } + + ASSERT_NOT_REACHED(); + return jsUndefined(); +} + +} // namespace WebCore + +#endif // ENABLE(INDEXED_DATABASE) diff --git a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp index eb4f549..0342ab6 100644 --- a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp @@ -55,6 +55,7 @@ #include "WebGLProgram.h" #include "WebGLRenderingContext.h" #include +#include #include #include @@ -72,6 +73,13 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebG switch (info.getType()) { case WebGLGetInfo::kTypeBool: return jsBoolean(info.getBool()); + case WebGLGetInfo::kTypeBoolArray: { + MarkedArgumentBuffer list; + const Vector& value = info.getBoolArray(); + for (size_t ii = 0; ii < value.size(); ++ii) + list.append(jsBoolean(value[ii])); + return constructArray(exec, list); + } case WebGLGetInfo::kTypeFloat: return jsNumber(exec, info.getFloat()); case WebGLGetInfo::kTypeLong: @@ -153,6 +161,29 @@ enum WhichProgramCall { kProgramParameter, kUniform }; +JSValue JSWebGLRenderingContext::getAttachedShaders(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return throwSyntaxError(exec); + ExceptionCode ec = 0; + WebGLRenderingContext* context = static_cast(impl()); + WebGLProgram* program = toWebGLProgram(exec->argument(0)); + if (exec->hadException()) + return jsUndefined(); + Vector shaders; + bool succeed = context->getAttachedShaders(program, shaders, ec); + if (ec) { + setDOMException(exec, ec); + return jsUndefined(); + } + if (!succeed) + return jsUndefined(); + MarkedArgumentBuffer list; + for (size_t ii = 0; ii < shaders.size(); ++ii) + list.append(toJS(exec, globalObject(), shaders[ii])); + return constructArray(exec, list); +} + JSValue JSWebGLRenderingContext::getBufferParameter(ExecState* exec) { return getObjectParameter(this, exec, kBuffer); diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 6f0457a..0aa8f52 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -21,7 +21,7 @@ #include "config.h" #include "ScriptController.h" -#include "DocumentParser.h" +#include "ScriptableDocumentParser.h" #include "Event.h" #include "EventNames.h" #include "Frame.h" @@ -238,11 +238,12 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world) int ScriptController::eventHandlerLineNumber() const { // JSC expects 1-based line numbers, so we must add one here to get it right. - if (DocumentParser* parser = m_frame->document()->parser()) + ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); + if (parser) return parser->lineNumber() + 1; return 0; } - + bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const { if (m_allowPopupsFromPlugin || isJavaScriptAnchorNavigation()) diff --git a/WebCore/bindings/js/ScriptDebugServer.cpp b/WebCore/bindings/js/ScriptDebugServer.cpp index 1fd9ae4..d1b5112 100644 --- a/WebCore/bindings/js/ScriptDebugServer.cpp +++ b/WebCore/bindings/js/ScriptDebugServer.cpp @@ -137,15 +137,17 @@ bool ScriptDebugServer::hasListenersInterestedInPage(Page* page) return m_pageListenersMap.contains(page); } -void ScriptDebugServer::setBreakpoint(const String& sourceID, unsigned lineNumber, ScriptBreakpoint breakpoint) +bool ScriptDebugServer::setBreakpoint(const String& sourceID, ScriptBreakpoint breakpoint, unsigned lineNumber, unsigned* actualLineNumber) { intptr_t sourceIDValue = sourceID.toIntPtr(); if (!sourceIDValue) - return; + return false; BreakpointsMap::iterator it = m_breakpoints.find(sourceIDValue); if (it == m_breakpoints.end()) it = m_breakpoints.set(sourceIDValue, SourceBreakpoints()).first; it->second.set(lineNumber, breakpoint); + *actualLineNumber = lineNumber; + return true; } void ScriptDebugServer::removeBreakpoint(const String& sourceID, unsigned lineNumber) @@ -255,7 +257,7 @@ JavaScriptCallFrame* ScriptDebugServer::currentCallFrame() void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener) { ASSERT(m_paused); - ScriptState* state = m_currentCallFrame->scopeChain()->globalObject->globalExec(); + ScriptState* state = m_currentCallFrame->scopeChain()->globalObject->globalExec(); listener->didPause(state); } diff --git a/WebCore/bindings/js/ScriptDebugServer.h b/WebCore/bindings/js/ScriptDebugServer.h index dcf290e..6a8209b 100644 --- a/WebCore/bindings/js/ScriptDebugServer.h +++ b/WebCore/bindings/js/ScriptDebugServer.h @@ -63,7 +63,7 @@ public: void addListener(ScriptDebugListener*, Page*); void removeListener(ScriptDebugListener*, Page*); - void setBreakpoint(const String& sourceID, unsigned lineNumber, ScriptBreakpoint breakpoint); + bool setBreakpoint(const String& sourceID, ScriptBreakpoint breakpoint, unsigned lineNumber, unsigned* actualLineNumber); void removeBreakpoint(const String& sourceID, unsigned lineNumber); void clearBreakpoints(); void setBreakpointsActivated(bool activated); diff --git a/WebCore/bindings/js/ScriptSourceProvider.h b/WebCore/bindings/js/ScriptSourceProvider.h index 3fe3584..2144169 100644 --- a/WebCore/bindings/js/ScriptSourceProvider.h +++ b/WebCore/bindings/js/ScriptSourceProvider.h @@ -35,8 +35,8 @@ namespace WebCore { class ScriptSourceProvider : public JSC::SourceProvider { public: - ScriptSourceProvider(const JSC::UString& url, JSC::SourceBOMPresence hasBOMs = JSC::SourceCouldHaveBOMs) - : SourceProvider(url, hasBOMs) + ScriptSourceProvider(const JSC::UString& url) + : SourceProvider(url) { } diff --git a/WebCore/bindings/js/StringSourceProvider.h b/WebCore/bindings/js/StringSourceProvider.h index 478c1d1..2a18006 100644 --- a/WebCore/bindings/js/StringSourceProvider.h +++ b/WebCore/bindings/js/StringSourceProvider.h @@ -49,6 +49,10 @@ namespace WebCore { : ScriptSourceProvider(stringToUString(url)) , m_source(source) { + if (m_source.length()) { + bool scratch = false; + m_source = String(source.impl()->copyStringWithoutBOMs(false, scratch)); + } } String m_source; diff --git a/WebCore/bindings/objc/DOM.mm b/WebCore/bindings/objc/DOM.mm index 378efe2..008acec 100644 --- a/WebCore/bindings/objc/DOM.mm +++ b/WebCore/bindings/objc/DOM.mm @@ -165,6 +165,7 @@ static void createElementClassMap() addElementClass(SVGNames::feColorMatrixTag, [DOMSVGFEColorMatrixElement class]); addElementClass(SVGNames::feComponentTransferTag, [DOMSVGFEComponentTransferElement class]); addElementClass(SVGNames::feCompositeTag, [DOMSVGFECompositeElement class]); + addElementClass(SVGNames::feConvolveMatrixTag, [DOMSVGFEConvolveMatrixElement class]); addElementClass(SVGNames::feDiffuseLightingTag, [DOMSVGFEDiffuseLightingElement class]); addElementClass(SVGNames::feDisplacementMapTag, [DOMSVGFEDisplacementMapElement class]); addElementClass(SVGNames::feDistantLightTag, [DOMSVGFEDistantLightElement class]); diff --git a/WebCore/bindings/objc/DOMSVG.h b/WebCore/bindings/objc/DOMSVG.h index c59532f..eda705e 100644 --- a/WebCore/bindings/objc/DOMSVG.h +++ b/WebCore/bindings/objc/DOMSVG.h @@ -63,6 +63,7 @@ #import #import #import +#import #import #import #import diff --git a/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/WebCore/bindings/scripts/CodeGeneratorGObject.pm index ef2a125..ae4ac39 100644 --- a/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -192,7 +192,7 @@ sub SkipFunction { if ($isCustomFunction && $functionName ne "webkit_dom_node_replace_child" && $functionName ne "webkit_dom_node_insert_before" && - $functionName ne "webkit_dom_node_replace_child" && + $functionName ne "webkit_dom_node_remove_child" && $functionName ne "webkit_dom_node_append_child" && $functionName ne "webkit_dom_html_collection_item" && $functionName ne "webkit_dom_html_collection_named_item") { @@ -504,7 +504,7 @@ EOF my ${listenerName} = $domSignalName . "Listener"; my $txtInstallEventListener = << "EOF"; - RefPtr ${listenerName} = WebCore::GObjectEventListener::create(reinterpret_cast(wrapper), "${gobjectSignalName}"); + RefPtr ${listenerName} = WebCore::GObjectEventListener::create(reinterpret_cast(object), "${gobjectSignalName}"); coreObject->addEventListener("${domSignalName}", ${listenerName}, false); EOF push(@txtInstallEventListeners, $txtInstallEventListener); @@ -536,6 +536,7 @@ EOF my $txtGetProp = << "EOF"; static void ${lowerCaseIfaceName}_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; EOF push(@txtGetProps, $txtGetProp); if (scalar @readableProperties > 0) { @@ -556,6 +557,7 @@ EOF my $txtSetProps = << "EOF"; static void ${lowerCaseIfaceName}_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; EOF push(@txtSetProps, $txtSetProps); @@ -625,12 +627,31 @@ static void ${lowerCaseIfaceName}_finalize(GObject* object) @txtGetProps +static void ${lowerCaseIfaceName}_constructed(GObject* object) +{ +EOF + push(@cBodyPriv, $implContent); + + if (scalar @txtInstallEventListeners > 0) { + $implContent = << "EOF"; + WebCore::${interfaceName}* coreObject = static_cast(WEBKIT_DOM_OBJECT(object)->coreObject); +EOF + push(@cBodyPriv, $implContent); + } + + $implContent = << "EOF"; +@txtInstallEventListeners + if (G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->constructed) + G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->constructed(object); +} + static void ${lowerCaseIfaceName}_class_init(${className}Class* requestClass) { GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = ${lowerCaseIfaceName}_finalize; gobjectClass->set_property = ${lowerCaseIfaceName}_set_property; gobjectClass->get_property = ${lowerCaseIfaceName}_get_property; + gobjectClass->constructed = ${lowerCaseIfaceName}_constructed; @txtInstallProps @txtInstallSignals @@ -823,6 +844,7 @@ sub GenerateFunction { push(@cBody, "#if ${conditionalString}\n") if $conditionalString; push(@cBody, "$returnType\n$functionName($functionSig)\n{\n"); + push(@cBody, " WebCore::JSMainThreadNullState state;\n"); if ($conditionalMethods{$functionName}) { push(@cBody, "#if ENABLE($conditionalMethods{$functionName})\n"); @@ -1101,20 +1123,15 @@ namespace WebKit { ${className}* wrap${interfaceName}(WebCore::${interfaceName}* coreObject) { g_return_val_if_fail(coreObject, 0); - - ${className}* wrapper = WEBKIT_DOM_${clsCaps}(g_object_new(WEBKIT_TYPE_DOM_${clsCaps}, NULL)); - g_return_val_if_fail(wrapper, 0); /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object * in a C-allocated GObject structure. See the finalize() code for the * matching deref(). */ - coreObject->ref(); - WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; -@txtInstallEventListeners - return wrapper; + return WEBKIT_DOM_${clsCaps}(g_object_new(WEBKIT_TYPE_DOM_${clsCaps}, + "core-object", coreObject, NULL)); } } // namespace WebKit EOF @@ -1264,6 +1281,7 @@ sub Generate { $implIncludes{"webkit/$className.h"} = 1; $implIncludes{"webkit/${className}Private.h"} = 1; $implIncludes{"${interfaceName}.h"} = 1; + $implIncludes{"JSMainThreadExecState.h"} = 1; $implIncludes{"ExceptionCode.h"} = 1; $hdrIncludes{"webkit/${parentClassName}.h"} = 1; diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 4e2e911..4c0cbe1 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -2179,7 +2179,11 @@ sub GenerateCallbackImplementation foreach my $param (@params) { my $paramName = $param->name; - push(@implContent, " args.append(toJS(exec, ${paramName}));\n"); + if ($param->type eq "DOMString") { + push(@implContent, " args.append(jsString(exec, ${paramName}));\n"); + } else { + push(@implContent, " args.append(toJS(exec, ${paramName}));\n"); + } } push(@implContent, "\n bool raisedException = false;\n"); @@ -2259,6 +2263,7 @@ my %nativeType = ( "DOMObject" => "ScriptValue", "NodeFilter" => "RefPtr", "SerializedScriptValue" => "RefPtr", + "IDBKey" => "RefPtr", "SVGAngle" => "SVGAngle", "SVGLength" => "SVGLength", "SVGMatrix" => "AffineTransform", @@ -2326,6 +2331,12 @@ sub JSValueToNative return "SerializedScriptValue::create(exec, $value)"; } + if ($type eq "IDBKey") { + $implIncludes{"IDBBindingUtilities.h"} = 1; + $implIncludes{"IDBKey.h"} = 1; + return "createIDBKeyFromValue(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"; diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index e249caa..1ae0f8f 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -2748,6 +2748,8 @@ sub GetNativeType return "RefPtr" if $type eq "SerializedScriptValue"; + return "RefPtr" if $type eq "IDBKey"; + # necessary as resolvers could be constructed on fly. return "RefPtr" if $type eq "XPathNSResolver"; @@ -2829,6 +2831,12 @@ sub JSValueToNative die "Unexpected SerializedScriptValue" if $type eq "SerializedScriptValue"; + if ($type eq "IDBKey") { + $implIncludes{"IDBBindingUtilities.h"} = 1; + $implIncludes{"IDBKey.h"} = 1; + return "createIDBKeyFromValue($value)"; + } + if ($type eq "DOMObject") { $implIncludes{"ScriptValue.h"} = 1; return "ScriptValue($value)"; @@ -2985,7 +2993,8 @@ my %non_wrapper_types = ( 'DOMObject' => 1, 'EventTarget' => 1, 'NodeFilter' => 1, - 'EventListener' => 1 + 'EventListener' => 1, + 'IDBKey' => 1 ); diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp index 65bc9f3..ee8afcf 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp @@ -23,9 +23,11 @@ #include "AtomicString.h" #include "HTMLNames.h" +#include "IDBKey.h" #include "KURL.h" #include "SerializedScriptValue.h" #include "TestObj.h" +#include "WebDOMIDBKey.h" #include "WebDOMString.h" #include "WebExceptionHandler.h" #include "WebNativeEventListener.h" @@ -549,6 +551,14 @@ void WebDOMTestObj::serializedValue(const WebDOMString& serializedArg) impl()->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); } +void WebDOMTestObj::idbKey(const WebDOMIDBKey& key) +{ + if (!impl()) + return; + + impl()->idbKey(toWebCore(key)); +} + void WebDOMTestObj::methodWithException() { if (!impl()) diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h index 33bc7fb..cdd47ed 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h @@ -31,6 +31,7 @@ class TestObj; }; class WebDOMEventListener; +class WebDOMIDBKey; class WebDOMString; class WebDOMTestObj; @@ -101,6 +102,7 @@ public: WebDOMTestObj methodThatRequiresAllArgs(const WebDOMString& strArg, const WebDOMTestObj& objArg); WebDOMTestObj methodThatRequiresAllArgsAndThrows(const WebDOMString& strArg, const WebDOMTestObj& objArg); void serializedValue(const WebDOMString& serializedArg); + void idbKey(const WebDOMIDBKey& key); void methodWithException(); void customMethod(); void customMethodWithArgs(int intArg, const WebDOMString& strArg, const WebDOMTestObj& objArg); diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp index 94f4ca5..6581b1f 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -26,6 +26,7 @@ #include #include #include "ExceptionCode.h" +#include "JSMainThreadExecState.h" #include "TestCallback.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" @@ -57,6 +58,7 @@ gpointer kit(WebCore::TestCallback* obj) gboolean webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestCallback * item = WebKit::core(self); g_return_val_if_fail(class1param, 0); @@ -69,6 +71,7 @@ webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, gboolean webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2param, gchar* str_arg) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestCallback * item = WebKit::core(self); g_return_val_if_fail(class2param, 0); @@ -83,6 +86,7 @@ webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, glong webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3param) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestCallback * item = WebKit::core(self); g_return_val_if_fail(class3param, 0); @@ -131,6 +135,7 @@ static void webkit_dom_test_callback_finalize(GObject* object) static void webkit_dom_test_callback_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -141,6 +146,7 @@ static void webkit_dom_test_callback_set_property(GObject* object, guint prop_id static void webkit_dom_test_callback_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -149,12 +155,20 @@ static void webkit_dom_test_callback_get_property(GObject* object, guint prop_id } +static void webkit_dom_test_callback_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->constructed(object); +} + static void webkit_dom_test_callback_class_init(WebKitDOMTestCallbackClass* requestClass) { GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_callback_finalize; gobjectClass->set_property = webkit_dom_test_callback_set_property; gobjectClass->get_property = webkit_dom_test_callback_get_property; + gobjectClass->constructed = webkit_dom_test_callback_constructed; @@ -168,20 +182,15 @@ namespace WebKit { WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback* coreObject) { g_return_val_if_fail(coreObject, 0); - - WebKitDOMTestCallback* wrapper = WEBKIT_DOM_TEST_CALLBACK(g_object_new(WEBKIT_TYPE_DOM_TEST_CALLBACK, NULL)); - g_return_val_if_fail(wrapper, 0); /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object * in a C-allocated GObject structure. See the finalize() code for the * matching deref(). */ - coreObject->ref(); - WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; - - return wrapper; + return WEBKIT_DOM_TEST_CALLBACK(g_object_new(WEBKIT_TYPE_DOM_TEST_CALLBACK, + "core-object", coreObject, NULL)); } } // namespace WebKit #endif /* ENABLE(DATABASE) */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp index af22530..a13da45 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -26,6 +26,7 @@ #include #include #include "ExceptionCode.h" +#include "JSMainThreadExecState.h" #include "TestInterface.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" @@ -87,6 +88,7 @@ static void webkit_dom_test_interface_finalize(GObject* object) static void webkit_dom_test_interface_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -97,6 +99,7 @@ static void webkit_dom_test_interface_set_property(GObject* object, guint prop_i static void webkit_dom_test_interface_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -105,12 +108,20 @@ static void webkit_dom_test_interface_get_property(GObject* object, guint prop_i } +static void webkit_dom_test_interface_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->constructed(object); +} + static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* requestClass) { GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_interface_finalize; gobjectClass->set_property = webkit_dom_test_interface_set_property; gobjectClass->get_property = webkit_dom_test_interface_get_property; + gobjectClass->constructed = webkit_dom_test_interface_constructed; @@ -124,20 +135,15 @@ namespace WebKit { WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface* coreObject) { g_return_val_if_fail(coreObject, 0); - - WebKitDOMTestInterface* wrapper = WEBKIT_DOM_TEST_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_INTERFACE, NULL)); - g_return_val_if_fail(wrapper, 0); /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object * in a C-allocated GObject structure. See the finalize() code for the * matching deref(). */ - coreObject->ref(); - WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; - - return wrapper; + return WEBKIT_DOM_TEST_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_INTERFACE, + "core-object", coreObject, NULL)); } } // namespace WebKit #endif /* ENABLE(Condition1) || ENABLE(Condition2) */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp index efb362b..3fcd3f7 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -25,9 +25,12 @@ #include #include "ExceptionCode.h" #include "HTMLNames.h" +#include "JSMainThreadExecState.h" #include "TestObj.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMIDBKey.h" +#include "webkit/WebKitDOMIDBKeyPrivate.h" #include "webkit/WebKitDOMSerializedScriptValue.h" #include "webkit/WebKitDOMSerializedScriptValuePrivate.h" #include "webkit/WebKitDOMTestObj.h" @@ -52,6 +55,7 @@ gpointer kit(WebCore::TestObj* obj) void webkit_dom_test_obj_void_method(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->voidMethod(); @@ -60,6 +64,7 @@ webkit_dom_test_obj_void_method(WebKitDOMTestObj* self) void webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(str_arg); @@ -73,6 +78,7 @@ webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, glong webkit_dom_test_obj_int_method(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->intMethod(); @@ -82,6 +88,7 @@ webkit_dom_test_obj_int_method(WebKitDOMTestObj* self) glong webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); @@ -96,6 +103,7 @@ webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebKitDOMTestObj* webkit_dom_test_obj_obj_method(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr g_res = WTF::getPtr(item->objMethod()); @@ -106,6 +114,7 @@ webkit_dom_test_obj_obj_method(WebKitDOMTestObj* self) WebKitDOMTestObj* webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); @@ -121,6 +130,7 @@ webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, WebKitDOMTestObj* webkit_dom_test_obj_method_that_requires_all_args(WebKitDOMTestObj* self, gchar* str_arg, WebKitDOMTestObj* obj_arg) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); @@ -136,6 +146,7 @@ webkit_dom_test_obj_method_that_requires_all_args(WebKitDOMTestObj* self, gchar* WebKitDOMTestObj* webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* self, gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); g_return_val_if_fail(str_arg, 0); @@ -157,6 +168,7 @@ webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* s void webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serialized_arg) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(serialized_arg); @@ -166,8 +178,20 @@ webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerialized } void +webkit_dom_test_obj_idb_key(WebKitDOMTestObj* self, WebKitDOMIDBKey* key) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(key); + WebCore::IDBKey * converted_key = WebKit::core(key); + g_return_if_fail(converted_key); + item->idbKey(converted_key); +} + +void webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; @@ -188,6 +212,7 @@ webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error void webkit_dom_test_obj_with_dynamic_frame(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrame(); @@ -196,6 +221,7 @@ webkit_dom_test_obj_with_dynamic_frame(WebKitDOMTestObj* self) void webkit_dom_test_obj_with_dynamic_frame_and_arg(WebKitDOMTestObj* self, glong int_arg) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndArg(int_arg); @@ -204,6 +230,7 @@ webkit_dom_test_obj_with_dynamic_frame_and_arg(WebKitDOMTestObj* self, glong int void webkit_dom_test_obj_with_dynamic_frame_and_optional_arg(WebKitDOMTestObj* self, glong int_arg, glong optional_arg) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndOptionalArg(int_arg, optional_arg); @@ -212,6 +239,7 @@ webkit_dom_test_obj_with_dynamic_frame_and_optional_arg(WebKitDOMTestObj* self, void webkit_dom_test_obj_with_dynamic_frame_and_user_gesture(WebKitDOMTestObj* self, glong int_arg) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndUserGesture(int_arg); @@ -220,6 +248,7 @@ webkit_dom_test_obj_with_dynamic_frame_and_user_gesture(WebKitDOMTestObj* self, void webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad(WebKitDOMTestObj* self, glong int_arg, glong optional_arg) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndUserGestureASAD(int_arg, optional_arg); @@ -228,6 +257,7 @@ webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad(WebKitDOMTestObj* s void webkit_dom_test_obj_with_script_state_void(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withScriptStateVoid(); @@ -236,6 +266,7 @@ webkit_dom_test_obj_with_script_state_void(WebKitDOMTestObj* self) WebKitDOMTestObj* webkit_dom_test_obj_with_script_state_obj(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr g_res = WTF::getPtr(item->withScriptStateObj()); @@ -246,6 +277,7 @@ webkit_dom_test_obj_with_script_state_obj(WebKitDOMTestObj* self) void webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GError **error) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; @@ -260,6 +292,7 @@ webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GEr WebKitDOMTestObj* webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GError **error) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; @@ -276,6 +309,7 @@ webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GErr void webkit_dom_test_obj_with_script_execution_context(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withScriptExecutionContext(); @@ -284,6 +318,7 @@ webkit_dom_test_obj_with_script_execution_context(WebKitDOMTestObj* self) void webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->methodWithOptionalArg(opt); @@ -292,6 +327,7 @@ webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt) void webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong non_opt, glong opt) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->methodWithNonOptionalArgAndOptionalArg(non_opt, opt); @@ -300,6 +336,7 @@ webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestO void webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong non_opt, glong opt1, glong opt2) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2); @@ -308,6 +345,7 @@ webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOM glong webkit_dom_test_obj_get_read_only_int_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->readOnlyIntAttr(); @@ -317,6 +355,7 @@ webkit_dom_test_obj_get_read_only_int_attr(WebKitDOMTestObj* self) gchar* webkit_dom_test_obj_get_read_only_string_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->readOnlyStringAttr()); @@ -326,6 +365,7 @@ webkit_dom_test_obj_get_read_only_string_attr(WebKitDOMTestObj* self) WebKitDOMTestObj* webkit_dom_test_obj_get_read_only_test_obj_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr g_res = WTF::getPtr(item->readOnlyTestObjAttr()); @@ -336,6 +376,7 @@ webkit_dom_test_obj_get_read_only_test_obj_attr(WebKitDOMTestObj* self) glong webkit_dom_test_obj_get_int_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->intAttr(); @@ -345,6 +386,7 @@ webkit_dom_test_obj_get_int_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_int_attr(WebKitDOMTestObj* self, glong value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setIntAttr(value); @@ -353,6 +395,7 @@ webkit_dom_test_obj_set_int_attr(WebKitDOMTestObj* self, glong value) gint64 webkit_dom_test_obj_get_long_long_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gint64 res = item->longLongAttr(); @@ -362,6 +405,7 @@ webkit_dom_test_obj_get_long_long_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_long_long_attr(WebKitDOMTestObj* self, gint64 value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setLongLongAttr(value); @@ -370,6 +414,7 @@ webkit_dom_test_obj_set_long_long_attr(WebKitDOMTestObj* self, gint64 value) guint64 webkit_dom_test_obj_get_unsigned_long_long_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); guint64 res = item->unsignedLongLongAttr(); @@ -379,6 +424,7 @@ webkit_dom_test_obj_get_unsigned_long_long_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_unsigned_long_long_attr(WebKitDOMTestObj* self, guint64 value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setUnsignedLongLongAttr(value); @@ -387,6 +433,7 @@ webkit_dom_test_obj_set_unsigned_long_long_attr(WebKitDOMTestObj* self, guint64 gchar* webkit_dom_test_obj_get_string_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->stringAttr()); @@ -396,6 +443,7 @@ webkit_dom_test_obj_get_string_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, gchar* value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -406,6 +454,7 @@ webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, gchar* value) WebKitDOMTestObj* webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr g_res = WTF::getPtr(item->testObjAttr()); @@ -416,6 +465,7 @@ webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -427,6 +477,7 @@ webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* gchar* webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); @@ -436,6 +487,7 @@ webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -446,6 +498,7 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* va glong webkit_dom_test_obj_get_reflected_integral_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); @@ -455,6 +508,7 @@ webkit_dom_test_obj_get_reflected_integral_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_integral_attr(WebKitDOMTestObj* self, glong value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, value); @@ -463,6 +517,7 @@ webkit_dom_test_obj_set_reflected_integral_attr(WebKitDOMTestObj* self, glong va gboolean webkit_dom_test_obj_get_reflected_boolean_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gboolean res = item->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); @@ -472,6 +527,7 @@ webkit_dom_test_obj_get_reflected_boolean_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_boolean_attr(WebKitDOMTestObj* self, gboolean value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, value); @@ -480,6 +536,7 @@ webkit_dom_test_obj_set_reflected_boolean_attr(WebKitDOMTestObj* self, gboolean gchar* webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); @@ -489,6 +546,7 @@ webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -499,6 +557,7 @@ webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value gchar* webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); @@ -508,6 +567,7 @@ webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -518,6 +578,7 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* va glong webkit_dom_test_obj_get_reflected_custom_integral_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); @@ -527,6 +588,7 @@ webkit_dom_test_obj_get_reflected_custom_integral_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_custom_integral_attr(WebKitDOMTestObj* self, glong value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, value); @@ -535,6 +597,7 @@ webkit_dom_test_obj_set_reflected_custom_integral_attr(WebKitDOMTestObj* self, g gboolean webkit_dom_test_obj_get_reflected_custom_boolean_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gboolean res = item->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); @@ -544,6 +607,7 @@ webkit_dom_test_obj_get_reflected_custom_boolean_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_custom_boolean_attr(WebKitDOMTestObj* self, gboolean value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, value); @@ -552,6 +616,7 @@ webkit_dom_test_obj_set_reflected_custom_boolean_attr(WebKitDOMTestObj* self, gb gchar* webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); @@ -561,6 +626,7 @@ webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -571,6 +637,7 @@ webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value glong webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; @@ -586,6 +653,7 @@ webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GErro void webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; @@ -600,6 +668,7 @@ webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong glong webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->attrWithSetterException(); @@ -609,6 +678,7 @@ webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError **error) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; @@ -623,6 +693,7 @@ webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong gchar* webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; @@ -633,6 +704,7 @@ webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self void webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, gchar* value, GError **error) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -649,6 +721,7 @@ webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self gchar* webkit_dom_test_obj_get_string_attr_with_setter_exception(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->stringAttrWithSetterException()); @@ -658,6 +731,7 @@ webkit_dom_test_obj_get_string_attr_with_setter_exception(WebKitDOMTestObj* self void webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, gchar* value, GError **error) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); g_return_if_fail(value); @@ -674,6 +748,7 @@ webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self gchar* webkit_dom_test_obj_get_script_string_attr(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->scriptStringAttr()); @@ -684,6 +759,7 @@ webkit_dom_test_obj_get_script_string_attr(WebKitDOMTestObj* self) glong webkit_dom_test_obj_get_conditional_attr1(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->conditionalAttr1(); @@ -695,6 +771,7 @@ webkit_dom_test_obj_get_conditional_attr1(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_conditional_attr1(WebKitDOMTestObj* self, glong value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setConditionalAttr1(value); @@ -705,6 +782,7 @@ webkit_dom_test_obj_set_conditional_attr1(WebKitDOMTestObj* self, glong value) glong webkit_dom_test_obj_get_conditional_attr2(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->conditionalAttr2(); @@ -716,6 +794,7 @@ webkit_dom_test_obj_get_conditional_attr2(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_conditional_attr2(WebKitDOMTestObj* self, glong value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setConditionalAttr2(value); @@ -726,6 +805,7 @@ webkit_dom_test_obj_set_conditional_attr2(WebKitDOMTestObj* self, glong value) glong webkit_dom_test_obj_get_conditional_attr3(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->conditionalAttr3(); @@ -737,6 +817,7 @@ webkit_dom_test_obj_get_conditional_attr3(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_conditional_attr3(WebKitDOMTestObj* self, glong value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setConditionalAttr3(value); @@ -746,6 +827,7 @@ webkit_dom_test_obj_set_conditional_attr3(WebKitDOMTestObj* self, glong value) glong webkit_dom_test_obj_get_description(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->description(); @@ -755,6 +837,7 @@ webkit_dom_test_obj_get_description(WebKitDOMTestObj* self) glong webkit_dom_test_obj_get_id(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->id(); @@ -764,6 +847,7 @@ webkit_dom_test_obj_get_id(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_id(WebKitDOMTestObj* self, glong value) { + WebCore::JSMainThreadNullState state; g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setId(value); @@ -772,6 +856,7 @@ webkit_dom_test_obj_set_id(WebKitDOMTestObj* self, glong value) gchar* webkit_dom_test_obj_get_hash(WebKitDOMTestObj* self) { + WebCore::JSMainThreadNullState state; g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->hash()); @@ -851,6 +936,7 @@ static void webkit_dom_test_obj_finalize(GObject* object) static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); WebCore::TestObj* coreSelf = WebKit::core(self); switch (prop_id) { @@ -968,6 +1054,7 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { + WebCore::JSMainThreadNullState state; WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); WebCore::TestObj* coreSelf = WebKit::core(self); switch (prop_id) { @@ -1123,12 +1210,20 @@ static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GVa } +static void webkit_dom_test_obj_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed(object); +} + static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass) { GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_obj_finalize; gobjectClass->set_property = webkit_dom_test_obj_set_property; gobjectClass->get_property = webkit_dom_test_obj_get_property; + gobjectClass->constructed = webkit_dom_test_obj_constructed; g_object_class_install_property(gobjectClass, PROP_READ_ONLY_INT_ATTR, @@ -1363,19 +1458,14 @@ namespace WebKit { WebKitDOMTestObj* wrapTestObj(WebCore::TestObj* coreObject) { g_return_val_if_fail(coreObject, 0); - - WebKitDOMTestObj* wrapper = WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, NULL)); - g_return_val_if_fail(wrapper, 0); /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object * in a C-allocated GObject structure. See the finalize() code for the * matching deref(). */ - coreObject->ref(); - WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; - - return wrapper; + return WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, + "core-object", coreObject, NULL)); } } // namespace WebKit diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h index 8dcd8c3..61c3d95 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h @@ -74,6 +74,9 @@ WEBKIT_API void webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serialized_arg); WEBKIT_API void +webkit_dom_test_obj_idb_key(WebKitDOMTestObj* self, WebKitDOMIDBKey* key); + +WEBKIT_API void webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error); diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp index df403c6..043a6ed 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -89,7 +89,7 @@ bool JSTestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Cl ExecState* exec = globalObject->globalExec(); MarkedArgumentBuffer args; args.append(toJS(exec, class2Param)); - args.append(toJS(exec, strArg)); + args.append(jsString(exec, strArg)); bool raisedException = false; m_data->invokeCallback(args, &raisedException); diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 360782d..31a3f70 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -22,6 +22,8 @@ #include "JSTestObj.h" #include "HTMLNames.h" +#include "IDBBindingUtilities.h" +#include "IDBKey.h" #include "JSEventListener.h" #include "JSTestObj.h" #include "JSlog.h" @@ -144,7 +146,7 @@ bool JSTestObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Ident #define THUNK_GENERATOR(generator) #endif -static const HashTableValue JSTestObjPrototypeTableValues[30] = +static const HashTableValue JSTestObjPrototypeTableValues[31] = { { "voidMethod", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, { "voidMethodWithArgs", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, @@ -155,6 +157,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[30] = { "methodThatRequiresAllArgs", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionMethodThatRequiresAllArgs), (intptr_t)2 THUNK_GENERATOR(0) }, { "methodThatRequiresAllArgsAndThrows", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows), (intptr_t)2 THUNK_GENERATOR(0) }, { "serializedValue", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) }, + { "idbKey", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionIdbKey), (intptr_t)1 THUNK_GENERATOR(0) }, { "methodWithException", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) }, { "customMethod", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) }, { "customMethodWithArgs", DontDelete | Function, (intptr_t)static_cast(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, @@ -179,7 +182,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[30] = }; #undef THUNK_GENERATOR -static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = { 69, 63, JSTestObjPrototypeTableValues, 0 }; +static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = { 130, 127, JSTestObjPrototypeTableValues, 0 }; const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 }; JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject) @@ -797,6 +800,19 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState return JSValue::encode(jsUndefined()); } +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = static_cast(asObject(thisValue)); + TestObj* imp = static_cast(castedThis->impl()); + RefPtr key = createIDBKeyFromValue(exec, exec->argument(0)); + + imp->idbKey(key); + return JSValue::encode(jsUndefined()); +} + EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.h b/WebCore/bindings/scripts/test/JS/JSTestObj.h index 3b21c85..4dea3d2 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.h +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -95,6 +95,7 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JS JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*); diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h index d8862da..d38dece 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h @@ -28,6 +28,7 @@ #if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST +@class DOMIDBKey; @class DOMTestObj; @class DOMlog; @class NSString; @@ -99,6 +100,7 @@ - (DOMTestObj *)methodThatRequiresAllArgs:(NSString *)strArg objArg:(DOMTestObj *)objArg; - (DOMTestObj *)methodThatRequiresAllArgsAndThrows:(NSString *)strArg objArg:(DOMTestObj *)objArg; - (void)serializedValue:(NSString *)serializedArg; +- (void)idbKey:(DOMIDBKey *)key; - (void)methodWithException; - (void)customMethod; - (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm index 9bbbf14..d71cb05 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -33,6 +33,7 @@ #import "DOMCSSRuleInternal.h" #import "DOMCSSValueInternal.h" #import "DOMEventInternal.h" +#import "DOMIDBKeyInternal.h" #import "DOMNodeInternal.h" #import "DOMStyleSheetInternal.h" #import "DOMTestObjInternal.h" @@ -40,6 +41,7 @@ #import "EventListener.h" #import "ExceptionHandlers.h" #import "HTMLNames.h" +#import "IDBKey.h" #import "JSMainThreadExecState.h" #import "KURL.h" #import "ObjCEventListener.h" @@ -451,6 +453,12 @@ IMPL->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); } +- (void)idbKey:(DOMIDBKey *)key +{ + WebCore::JSMainThreadNullState state; + IMPL->idbKey(core(key)); +} + - (void)methodWithException { WebCore::JSMainThreadNullState state; diff --git a/WebCore/bindings/scripts/test/TestObj.idl b/WebCore/bindings/scripts/test/TestObj.idl index ef4db10..3467116 100644 --- a/WebCore/bindings/scripts/test/TestObj.idl +++ b/WebCore/bindings/scripts/test/TestObj.idl @@ -63,6 +63,7 @@ module test { raises(DOMException); void serializedValue(in SerializedScriptValue serializedArg); + void idbKey(in IDBKey key); // Exceptions void methodWithException() raises(DOMException); diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 4a54ae3..1ad8a41 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -23,6 +23,8 @@ #include "ExceptionCode.h" #include "HTMLNames.h" +#include "IDBBindingUtilities.h" +#include "IDBKey.h" #include "RuntimeEnabledFeatures.h" #include "ScriptCallStack.h" #include "SerializedScriptValue.h" @@ -573,6 +575,15 @@ static v8::Handle serializedValueCallback(const v8::Arguments& args) return v8::Handle(); } +static v8::Handle idbKeyCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.idbKey"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + RefPtr key = createIDBKeyFromValue(args[0]); + imp->idbKey(key); + return v8::Handle(); +} + static v8::Handle methodWithExceptionCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.methodWithException"); @@ -947,6 +958,7 @@ static const BatchedCallback TestObjCallbacks[] = { {"intMethod", TestObjInternal::intMethodCallback}, {"objMethod", TestObjInternal::objMethodCallback}, {"serializedValue", TestObjInternal::serializedValueCallback}, + {"idbKey", TestObjInternal::idbKeyCallback}, {"methodWithException", TestObjInternal::methodWithExceptionCallback}, {"customMethod", V8TestObj::customMethodCallback}, {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback}, diff --git a/WebCore/bindings/v8/IDBBindingUtilities.cpp b/WebCore/bindings/v8/IDBBindingUtilities.cpp new file mode 100644 index 0000000..2f977e0 --- /dev/null +++ b/WebCore/bindings/v8/IDBBindingUtilities.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "IDBBindingUtilities.h" + +#include "IDBKey.h" +#include "V8Binding.h" + +#if ENABLE(INDEXED_DATABASE) + +namespace WebCore { + +PassRefPtr createIDBKeyFromValue(v8::Handle value) +{ + if (value->IsNull()) + return IDBKey::create(); + if (value->IsInt32()) + return IDBKey::create(value->Int32Value()); + if (value->IsString()) + return IDBKey::create(v8ValueToWebCoreString(value)); + // FIXME: Implement dates. + return 0; +} + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/v8/IDBBindingUtilities.h b/WebCore/bindings/v8/IDBBindingUtilities.h new file mode 100644 index 0000000..04e5c29 --- /dev/null +++ b/WebCore/bindings/v8/IDBBindingUtilities.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef IDBBindingUtilities_h +#define IDBBindingUtilities_h + +#include +#include + +#if ENABLE(INDEXED_DATABASE) + +namespace WebCore { + +class IDBKey; + +PassRefPtr createIDBKeyFromValue(v8::Handle); + +} + +#endif // ENABLE(INDEXED_DATABASE) + +#endif // IDBBindingUtilities_h diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index 6f17373..889642f 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -34,7 +34,7 @@ #include "PlatformBridge.h" #include "Document.h" -#include "DocumentParser.h" +#include "ScriptableDocumentParser.h" #include "DOMWindow.h" #include "Event.h" #include "EventListener.h" @@ -53,6 +53,7 @@ #include "V8BindingState.h" #include "V8DOMWindow.h" #include "V8Event.h" +#include "V8HiddenPropertyName.h" #include "V8HTMLEmbedElement.h" #include "V8IsolatedContext.h" #include "V8NPObject.h" @@ -160,16 +161,13 @@ void ScriptController::updatePlatformScriptObjects() bool ScriptController::processingUserGesture(DOMWrapperWorld*) const { - Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext(); // No script is running, so it is user-initiated unless the gesture stack // explicitly says it is not. - if (!activeFrame) + if (!m_proxy->executingScript()) return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture; - V8Proxy* activeProxy = activeFrame->script()->proxy(); - v8::HandleScope handleScope; - v8::Handle v8Context = V8Proxy::mainWorldContext(activeFrame); + v8::Handle v8Context = m_proxy->mainWorldContext(); // FIXME: find all cases context can be empty: // 1) JS is disabled; // 2) page is NULL; @@ -179,33 +177,24 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const v8::Context::Scope scope(v8Context); v8::Handle global = v8Context->Global(); - v8::Handle jsEvent = global->Get(v8::String::NewSymbol("event")); + v8::Handle eventSymbol = V8HiddenPropertyName::event(); + v8::Handle jsEvent = global->GetHiddenValue(eventSymbol); Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle::Cast(jsEvent)) : 0; - // Based on code from kjs_bindings.cpp. + // Based on code from JSC's ScriptController::processingUserGesture. // Note: This is more liberal than Firefox's implementation. if (event) { - if (!UserGestureIndicator::processingUserGesture()) - return false; - - const AtomicString& type = event->type(); - bool eventOk = - // mouse events - type == eventNames().clickEvent || type == eventNames().mousedownEvent || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent - // keyboard events - || type == eventNames().keydownEvent || type == eventNames().keypressEvent || type == eventNames().keyupEvent - // other accepted events - || type == eventNames().selectEvent || type == eventNames().changeEvent || type == eventNames().focusEvent || type == eventNames().blurEvent || type == eventNames().submitEvent; - - if (eventOk) - return true; - } else if (m_sourceURL && m_sourceURL->isNull() && !activeProxy->timerCallback()) { + // Event::fromUserGesture will return false when UserGestureIndicator::processingUserGesture() returns false. + return event->fromUserGesture(); + } + if (m_sourceURL && m_sourceURL->isNull() && !m_proxy->timerCallback()) { // This is the setBreakpointFunction = v8::Local::Cast(m_debuggerScript.get()->Get(v8::String::New("setBreakpoint"))); - v8::Debug::Call(setBreakpointFunction, args); + v8::Handle result = v8::Debug::Call(setBreakpointFunction, args); + if (!result->IsNumber()) + return false; + ASSERT(result->Int32Value() >= 0); + *actualLineNumber = result->Int32Value(); + return true; +#else + return false; #endif } @@ -299,7 +306,7 @@ PassRefPtr ScriptDebugServer::currentCallFrame() v8::Handle currentCallFrameFunction = v8::Local::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame"))); v8::Handle argv[] = { m_executionState.get() }; v8::Handle currentCallFrameV8 = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); - m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle::Cast(currentCallFrameV8)); + m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle::Cast(currentCallFrameV8)); } return m_currentCallFrame; } diff --git a/WebCore/bindings/v8/ScriptDebugServer.h b/WebCore/bindings/v8/ScriptDebugServer.h index b46f673..26ca785 100644 --- a/WebCore/bindings/v8/ScriptDebugServer.h +++ b/WebCore/bindings/v8/ScriptDebugServer.h @@ -55,7 +55,7 @@ public: void addListener(ScriptDebugListener*, Page*); void removeListener(ScriptDebugListener*, Page*); - void setBreakpoint(const String& sourceID, unsigned lineNumber, ScriptBreakpoint breakpoint); + bool setBreakpoint(const String& sourceID, ScriptBreakpoint breakpoint, unsigned lineNumber, unsigned* actualLineNumber); void removeBreakpoint(const String& sourceID, unsigned lineNumber); void clearBreakpoints(); void setBreakpointsActivated(bool activated); diff --git a/WebCore/bindings/v8/SerializedScriptValue.cpp b/WebCore/bindings/v8/SerializedScriptValue.cpp index 8e91920..47c4c2e 100644 --- a/WebCore/bindings/v8/SerializedScriptValue.cpp +++ b/WebCore/bindings/v8/SerializedScriptValue.cpp @@ -34,6 +34,7 @@ #include "Blob.h" #include "ByteArray.h" #include "CanvasPixelArray.h" +#include "ExceptionCode.h" #include "File.h" #include "FileList.h" #include "ImageData.h" diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp index b6c53df..bda4345 100644 --- a/WebCore/bindings/v8/V8AbstractEventListener.cpp +++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp @@ -38,6 +38,7 @@ #include "V8Binding.h" #include "V8Event.h" #include "V8EventListenerList.h" +#include "V8HiddenPropertyName.h" #include "V8Proxy.h" #include "V8Utilities.h" #include "WorkerContext.h" @@ -126,7 +127,7 @@ void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context return; // We push the event being processed into the global object, so that it can be exposed by DOMWindow's bindings. - v8::Local eventSymbol = v8::String::NewSymbol("event"); + v8::Handle eventSymbol = V8HiddenPropertyName::event(); v8::Local returnValue; // In beforeunload/unload handlers, we want to avoid sleeps which do tight loops of calling Date.getTime(). diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h index 9eebf51..a15ece1 100644 --- a/WebCore/bindings/v8/V8Binding.h +++ b/WebCore/bindings/v8/V8Binding.h @@ -32,7 +32,6 @@ #define V8Binding_h #include "AtomicString.h" -#include "BindingElement.h" #include "BindingSecurity.h" #include "MathExtras.h" #include "PlatformString.h" @@ -53,7 +52,6 @@ namespace WebCore { typedef V8BindingDOMWindow DOMWindow; }; typedef BindingSecurity V8BindingSecurity; - typedef BindingElement V8BindingElement; enum ExternalMode { Externalize, diff --git a/WebCore/bindings/v8/V8HiddenPropertyName.h b/WebCore/bindings/v8/V8HiddenPropertyName.h index 0bfadd9..2d0e8d6 100644 --- a/WebCore/bindings/v8/V8HiddenPropertyName.h +++ b/WebCore/bindings/v8/V8HiddenPropertyName.h @@ -41,7 +41,8 @@ namespace WebCore { V(attributeListener) \ V(scriptState) \ V(sleepFunction) \ - V(toStringString) + V(toStringString) \ + V(event) class V8HiddenPropertyName { public: diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp index adaea81..50e9fdc 100644 --- a/WebCore/bindings/v8/V8Proxy.cpp +++ b/WebCore/bindings/v8/V8Proxy.cpp @@ -380,6 +380,11 @@ PassOwnPtr V8Proxy::precompileScript(v8::Handle code return scriptData.release(); } +bool V8Proxy::executingScript() const +{ + return m_recursion; +} + v8::Local V8Proxy::evaluate(const ScriptSourceCode& source, Node* node) { ASSERT(v8::Context::InContext()); diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h index ec9352c..4dc28ef 100644 --- a/WebCore/bindings/v8/V8Proxy.h +++ b/WebCore/bindings/v8/V8Proxy.h @@ -210,6 +210,9 @@ namespace WebCore { // constructors. void evaluateInIsolatedWorld(int worldId, const Vector& sources, int extensionGroup); + // Returns true if the proxy is currently executing a script in V8. + bool executingScript() const; + // Evaluate a script file in the current execution environment. // The caller must hold an execution context. // If cannot evalute the script, it returns an error. diff --git a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h index 1c5d731..afaf6bf 100644 --- a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h +++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h @@ -50,12 +50,20 @@ v8::Handle constructWebGLArray(const v8::Arguments& args, WrapperType int argLen = args.Length(); if (argLen == 0) { // This happens when we return a previously constructed - // ArrayBufferView, e.g. from the call to WebGLArray.slice(). + // ArrayBufferView, e.g. from the call to Array.slice(). // The V8DOMWrapper will set the internal pointer in the // created object. Unfortunately it doesn't look like it's // possible to distinguish between this case and that where - // the user calls "new WebGLArray()" from JavaScript. - return args.Holder(); + // the user calls "new Array()" from JavaScript. We must + // construct an empty view to avoid crashes when fetching the + // length. + RefPtr array = ArrayClass::create(0); + // Transform the holder into a wrapper object for the array. + V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get()); + // Do not call SetIndexedPropertiesToExternalArrayData on this + // object. Not only is there no point from a performance + // perspective, but doing so causes errors in the slice() case. + return toV8(array.release(), args.Holder()); } // Supported constructors: diff --git a/WebCore/bindings/v8/custom/V8BindingMacros.h b/WebCore/bindings/v8/custom/V8BindingMacros.h index 16c3651..4c8ecd3 100644 --- a/WebCore/bindings/v8/custom/V8BindingMacros.h +++ b/WebCore/bindings/v8/custom/V8BindingMacros.h @@ -28,11 +28,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define EXCEPTION_BLOCK(type, var, value) \ - type var; \ - { \ - v8::TryCatch block; \ - var = value; \ - if (block.HasCaught()) \ - return throwError(block.Exception()); \ +#define EXCEPTION_BLOCK(type, var, value) \ + type var; \ + { \ + v8::TryCatch block; \ + var = (value); \ + if (block.HasCaught()) \ + return block.ReThrow(); \ + } + +#define TO_WEBCORE_STRING_EXCEPTION_BLOCK(var, value) \ + String var; \ + { \ + v8::TryCatch block; \ + v8::Handle v8String = (value)->ToString(); \ + if (block.HasCaught()) \ + return block.ReThrow(); \ + var = v8StringToWebCoreString(v8String, DoNotExternalize); \ } diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index 25564ee..210e974 100644 --- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -58,6 +58,7 @@ #include "V8Database.h" #include "V8DatabaseCallback.h" #include "V8GCForContextDispose.h" +#include "V8HiddenPropertyName.h" #include "V8HTMLAudioElementConstructor.h" #include "V8HTMLCollection.h" #include "V8HTMLImageElementConstructor.h" @@ -175,7 +176,7 @@ v8::Handle V8DOMWindow::eventAccessorGetter(v8::Local nam if (context.IsEmpty()) return v8::Undefined(); - v8::Local eventSymbol = v8::String::NewSymbol("event"); + v8::Handle eventSymbol = V8HiddenPropertyName::event(); v8::Handle jsEvent = context->Global()->GetHiddenValue(eventSymbol); if (jsEvent.IsEmpty()) return v8::Undefined(); @@ -196,7 +197,7 @@ void V8DOMWindow::eventAccessorSetter(v8::Local name, v8::Local eventSymbol = v8::String::NewSymbol("event"); + v8::Handle eventSymbol = V8HiddenPropertyName::event(); context->Global()->SetHiddenValue(eventSymbol, value); } @@ -795,9 +796,9 @@ v8::Handle V8DOMWindow::openDatabaseCallback(const v8::Arguments& arg if (args.Length() < 4) return throwError(SYNTAX_ERR); - EXCEPTION_BLOCK(String, name, toWebCoreString(args[0])); - EXCEPTION_BLOCK(String, version, toWebCoreString(args[1])); - EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2])); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]); EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value()); DOMWindow* imp = V8DOMWindow::toNative(args.Holder()); diff --git a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp index 20f7c40..44a6eeb 100644 --- a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp @@ -34,6 +34,7 @@ #include "V8Database.h" #include "Database.h" +#include "ExceptionCode.h" #include "V8Binding.h" #include "V8BindingMacros.h" #include "V8SQLTransactionCallback.h" @@ -50,8 +51,8 @@ v8::Handle V8Database::changeVersionCallback(const v8::Arguments& arg if (args.Length() < 2) return throwError(SYNTAX_ERR); - EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0])); - EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1])); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(oldVersion, args[0]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(newVersion, args[1]); Database* database = V8Database::toNative(args.Holder()); diff --git a/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp index 4fe30dc..8a317d7 100644 --- a/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp @@ -34,6 +34,7 @@ #include "V8DatabaseSync.h" #include "DatabaseSync.h" +#include "ExceptionCode.h" #include "V8Binding.h" #include "V8BindingMacros.h" #include "V8Proxy.h" @@ -48,8 +49,8 @@ v8::Handle V8DatabaseSync::changeVersionCallback(const v8::Arguments& if (args.Length() < 2) return throwError(SYNTAX_ERR); - EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0])); - EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1])); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(oldVersion, args[0]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(newVersion, args[1]); DatabaseSync* database = V8DatabaseSync::toNative(args.Holder()); diff --git a/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp index d3de1dc..35818af 100644 --- a/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLFrameElementCustom.cpp @@ -41,17 +41,6 @@ namespace WebCore { using namespace HTMLNames; -void V8HTMLFrameElement::srcAccessorSetter(v8::Local name, v8::Local value, const v8::AccessorInfo& info) -{ - HTMLFrameElement* frame = V8HTMLFrameElement::toNative(info.Holder()); - String srcValue = toWebCoreStringWithNullCheck(value); - - if (!V8BindingSecurity::allowSettingFrameSrcToJavascriptUrl(V8BindingState::Only(), frame, srcValue)) - return; - - frame->setAttribute(srcAttr, srcValue); -} - void V8HTMLFrameElement::locationAccessorSetter(v8::Local name, v8::Local value, const v8::AccessorInfo& info) { HTMLFrameElement* frame = V8HTMLFrameElement::toNative(info.Holder()); diff --git a/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp deleted file mode 100644 index 5f22400..0000000 --- a/WebCore/bindings/v8/custom/V8HTMLIFrameElementCustom.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2007-2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "V8HTMLIFrameElement.h" - -#include "HTMLIFrameElement.h" -#include "HTMLNames.h" -#include "V8Binding.h" -#include "V8BindingState.h" -#include "V8Proxy.h" - -namespace WebCore { - -using namespace HTMLNames; - -void V8HTMLIFrameElement::srcAccessorSetter(v8::Local name, v8::Local value, const v8::AccessorInfo& info) -{ - HTMLIFrameElement* iframe = V8HTMLIFrameElement::toNative(info.Holder()); - String v = toWebCoreStringWithNullCheck(value); - - if (!V8BindingSecurity::allowSettingFrameSrcToJavascriptUrl(V8BindingState::Only(), iframe, v)) - return; - - iframe->setAttribute(srcAttr, v); -} - -} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp b/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp new file mode 100644 index 0000000..2afa55f --- /dev/null +++ b/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(INDEXED_DATABASE) +#include "V8IDBAny.h" + +#include "IDBBindingUtilities.h" +#include "IDBKey.h" +#include "V8Binding.h" + +namespace WebCore { + +v8::Handle toV8(IDBKey* key) +{ + if (!key) + return v8::Null(); + + switch (key->type()) { + case IDBKey::NullType: + return v8::Null(); + case IDBKey::NumberType: + return v8::Integer::New(key->number()); + case IDBKey::StringType: + return v8String(key->string()); + // FIXME: Implement dates. + } + + ASSERT_NOT_REACHED(); + return v8::Undefined(); +} + +#endif // ENABLE(INDEXED_DATABASE) + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp index f1b708a..e2a5070 100644 --- a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp @@ -35,6 +35,7 @@ #include "V8SQLTransaction.h" #include "Database.h" +#include "ExceptionCode.h" #include "SQLValue.h" #include "V8Binding.h" #include "V8BindingMacros.h" @@ -54,7 +55,7 @@ v8::Handle V8SQLTransaction::executeSqlCallback(const v8::Arguments& if (args.Length() == 0) return throwError(SYNTAX_ERR); - EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0])); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(statement, args[0]); Vector sqlValues; @@ -81,7 +82,7 @@ v8::Handle V8SQLTransaction::executeSqlCallback(const v8::Arguments& EXCEPTION_BLOCK(double, sqlValue, value->NumberValue()); sqlValues.append(SQLValue(sqlValue)); } else { - EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value)); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(sqlValue, value); sqlValues.append(SQLValue(sqlValue)); } } diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp index 651c79b..8ef11ce 100644 --- a/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp @@ -35,6 +35,7 @@ #include "V8SQLTransactionSync.h" #include "DatabaseSync.h" +#include "ExceptionCode.h" #include "SQLResultSet.h" #include "SQLValue.h" #include "V8Binding.h" @@ -53,7 +54,7 @@ v8::Handle V8SQLTransactionSync::executeSqlCallback(const v8::Argumen if (!args.Length()) return throwError(SYNTAX_ERR); - EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0])); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(statement, args[0]); Vector sqlValues; @@ -80,7 +81,7 @@ v8::Handle V8SQLTransactionSync::executeSqlCallback(const v8::Argumen EXCEPTION_BLOCK(double, sqlValue, value->NumberValue()); sqlValues.append(SQLValue(sqlValue)); } else { - EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value)); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(sqlValue, value); sqlValues.append(SQLValue(sqlValue)); } } diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 5da4b3e..e1a9c0e 100644 --- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -110,6 +110,13 @@ static v8::Handle toV8Object(const WebGLGetInfo& info) switch (info.getType()) { case WebGLGetInfo::kTypeBool: return v8::Boolean::New(info.getBool()); + case WebGLGetInfo::kTypeBoolArray: { + const Vector& value = info.getBoolArray(); + v8::Local array = v8::Array::New(value.size()); + for (size_t ii = 0; ii < value.size(); ++ii) + array->Set(v8::Integer::New(ii), v8::Boolean::New(value[ii])); + return array; + } case WebGLGetInfo::kTypeFloat: return v8::Number::New(info.getFloat()); case WebGLGetInfo::kTypeLong: @@ -209,6 +216,32 @@ enum WhichProgramCall { kProgramParameter, kUniform }; +v8::Handle V8WebGLRenderingContext::getAttachedShadersCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.WebGLRenderingContext.getAttachedShaders()"); + + if (args.Length() < 1) { + V8Proxy::setDOMException(SYNTAX_ERR); + return notHandledByInterceptor(); + } + + ExceptionCode ec = 0; + WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); + WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle::Cast(args[0])) : 0; + Vector shaders; + bool succeed = context->getAttachedShaders(program, shaders, ec); + if (ec) { + V8Proxy::setDOMException(ec); + return v8::Undefined(); + } + if (!succeed) + return v8::Undefined(); + v8::Local array = v8::Array::New(shaders.size()); + for (size_t ii = 0; ii < shaders.size(); ++ii) + array->Set(v8::Integer::New(ii), toV8(shaders[ii])); + return array; +} + v8::Handle V8WebGLRenderingContext::getBufferParameterCallback(const v8::Arguments& args) { INC_STATS("DOM.WebGLRenderingContext.getBufferParameter()"); diff --git a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp index acf10b7..f66ff3d 100755 --- a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp @@ -150,9 +150,9 @@ v8::Handle V8WorkerContext::openDatabaseCallback(const v8::Arguments& if (args.Length() < 4) return throwError(SYNTAX_ERR); - EXCEPTION_BLOCK(String, name, toWebCoreString(args[0])); - EXCEPTION_BLOCK(String, version, toWebCoreString(args[1])); - EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2])); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]); EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value()); WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder()); @@ -178,9 +178,9 @@ v8::Handle V8WorkerContext::openDatabaseSyncCallback(const v8::Argume if (args.Length() < 4) return throwError(SYNTAX_ERR); - EXCEPTION_BLOCK(String, name, toWebCoreString(args[0])); - EXCEPTION_BLOCK(String, version, toWebCoreString(args[1])); - EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2])); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(name, args[0]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(version, args[1]); + TO_WEBCORE_STRING_EXCEPTION_BLOCK(displayName, args[2]); EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value()); WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder()); -- cgit v1.1