diff options
author | Kristian Monsen <kristianm@google.com> | 2010-06-28 16:42:48 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-07-02 10:29:56 +0100 |
commit | 06ea8e899e48f1f2f396b70e63fae369f2f23232 (patch) | |
tree | 20c1428cd05c76f32394ab354ea35ed99acd86d8 /WebCore/bindings | |
parent | 72aad67af14193199e29cdd5c4ddc095a8b9a8a8 (diff) | |
download | external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.zip external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.gz external_webkit-06ea8e899e48f1f2f396b70e63fae369f2f23232.tar.bz2 |
Merge WebKit at r61871: Initial merge by git.
Change-Id: I6cff43abca9cc4782e088a469ad4f03f166a65d5
Diffstat (limited to 'WebCore/bindings')
118 files changed, 2985 insertions, 2703 deletions
diff --git a/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp b/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp new file mode 100644 index 0000000..5dd9ec4 --- /dev/null +++ b/WebCore/bindings/cpp/WebDOMDOMWindowCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebDOMDOMWindow.h" + +#include "DOMWindow.h" +#include "WebDOMEventListener.h" +#include "WebNativeEventListener.h" + +void WebDOMDOMWindow::addEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture) +{ + if (!impl()) + return; + + if (toWebCore(listener)) + impl()->addEventListener(type, toWebCore(listener), useCapture); +} + +void WebDOMDOMWindow::removeEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture) +{ + if (!impl()) + return; + + if (toWebCore(listener)) + impl()->removeEventListener(type, toWebCore(listener), useCapture); +} diff --git a/WebCore/bindings/cpp/WebDOMEventTarget.cpp b/WebCore/bindings/cpp/WebDOMEventTarget.cpp index 2eaef00..b24bc84 100644 --- a/WebCore/bindings/cpp/WebDOMEventTarget.cpp +++ b/WebCore/bindings/cpp/WebDOMEventTarget.cpp @@ -22,6 +22,7 @@ #include "WebDOMEventTarget.h" #include "DOMApplicationCache.h" +#include "DOMWindow.h" #include "DedicatedWorkerContext.h" #include "EventSource.h" #include "MessagePort.h" @@ -31,6 +32,7 @@ #include "SharedWorkerContext.h" #include "ThreadCheck.h" #include "WebDOMDOMApplicationCache.h" +#include "WebDOMDOMWindow.h" #include "WebDOMDedicatedWorkerContext.h" #include "WebDOMEventSource.h" #include "WebDOMMessagePort.h" @@ -88,6 +90,45 @@ WebCore::EventTarget* WebDOMEventTarget::impl() const return m_impl ? m_impl->impl.get() : 0; } +#define ConvertTo(type) \ +WebDOM##type WebDOMEventTarget::to##type() \ +{ \ + WebCore::EventTarget* target = impl(); \ + return WebDOM##type(target ? target->to##type() : 0); \ +} + +ConvertTo(Node) +ConvertTo(DOMWindow) +ConvertTo(XMLHttpRequest) +ConvertTo(XMLHttpRequestUpload) +ConvertTo(MessagePort) + +#if ENABLE(EVENTSOURCE) +ConvertTo(EventSource) +#endif + +#if ENABLE(OFFLINE_WEB_APPLICATIONS) +ConvertTo(DOMApplicationCache) +#endif + +#if ENABLE(WORKERS) +ConvertTo(Worker) +ConvertTo(DedicatedWorkerContext) +#endif + +#if ENABLE(SHARED_WORKERS) +ConvertTo(SharedWorker) +ConvertTo(SharedWorkerContext) +#endif + +#if ENABLE(NOTIFICATIONS) +ConvertTo(Notification) +#endif + +#if ENABLE(WEB_SOCKETS) +ConvertTo(WebSocket) +#endif + WebCore::EventTarget* toWebCore(const WebDOMEventTarget& wrapper) { return wrapper.impl(); @@ -95,6 +136,21 @@ WebCore::EventTarget* toWebCore(const WebDOMEventTarget& wrapper) WebDOMEventTarget toWebKit(WebCore::EventTarget* value) { + if (WebCore::Node* node = value->toNode()) + return toWebKit(node); + + if (WebCore::DOMWindow* window = value->toDOMWindow()) + return toWebKit(window); + + if (WebCore::XMLHttpRequest* xhr = value->toXMLHttpRequest()) + return toWebKit(xhr); + + if (WebCore::XMLHttpRequestUpload* upload = value->toXMLHttpRequestUpload()) + return toWebKit(upload); + + if (WebCore::MessagePort* messagePort = value->toMessagePort()) + return toWebKit(messagePort); + #if ENABLE(EVENTSOURCE) if (WebCore::EventSource* eventSource = value->toEventSource()) return toWebKit(eventSource); @@ -107,23 +163,11 @@ WebDOMEventTarget toWebKit(WebCore::EventTarget* value) return toWebKit(instance); #endif - if (WebCore::Node* node = value->toNode()) - return toWebKit(node); - - if (WebCore::XMLHttpRequest* xhr = value->toXMLHttpRequest()) - return toWebKit(xhr); - - if (WebCore::XMLHttpRequestUpload* upload = value->toXMLHttpRequestUpload()) - return toWebKit(upload); - #if ENABLE(OFFLINE_WEB_APPLICATIONS) if (WebCore::DOMApplicationCache* cache = value->toDOMApplicationCache()) return toWebKit(cache); #endif - if (WebCore::MessagePort* messagePort = value->toMessagePort()) - return toWebKit(messagePort); - #if ENABLE(WORKERS) if (WebCore::Worker* worker = value->toWorker()) return toWebKit(worker); diff --git a/WebCore/bindings/cpp/WebDOMEventTarget.h b/WebCore/bindings/cpp/WebDOMEventTarget.h index f5360ca..d514372 100644 --- a/WebCore/bindings/cpp/WebDOMEventTarget.h +++ b/WebCore/bindings/cpp/WebDOMEventTarget.h @@ -26,6 +26,20 @@ namespace WebCore { class EventTarget; }; +class WebDOMDedicatedWorkerContext; +class WebDOMDOMApplicationCache; +class WebDOMDOMWindow; +class WebDOMEventSource; +class WebDOMMessagePort; +class WebDOMNode; +class WebDOMNotification; +class WebDOMSharedWorker; +class WebDOMSharedWorkerContext; +class WebDOMWebSocket; +class WebDOMWorker; +class WebDOMXMLHttpRequest; +class WebDOMXMLHttpRequestUpload; + class WebDOMEventTarget : public WebDOMObject { public: WebDOMEventTarget(); @@ -35,8 +49,20 @@ public: WebCore::EventTarget* impl() const; - // FIXME: Add a possibility to check what kind of EventTarget we have, - // to be able to cast eg. a WebDOMEventTarget to a WebDOMNode + WebDOMNode toNode(); + WebDOMDOMWindow toDOMWindow(); + WebDOMXMLHttpRequest toXMLHttpRequest(); + WebDOMXMLHttpRequestUpload toXMLHttpRequestUpload(); + WebDOMMessagePort toMessagePort(); + + WebDOMEventSource toEventSource(); + WebDOMDOMApplicationCache toDOMApplicationCache(); + WebDOMWorker toWorker(); + WebDOMDedicatedWorkerContext toDedicatedWorkerContext(); + WebDOMSharedWorker toSharedWorker(); + WebDOMSharedWorkerContext toSharedWorkerContext(); + WebDOMNotification toNotification(); + WebDOMWebSocket toWebSocket(); protected: struct WebDOMEventTargetPrivate; diff --git a/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp b/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp new file mode 100644 index 0000000..3f3378c --- /dev/null +++ b/WebCore/bindings/cpp/WebDOMHTMLCollectionCustom.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebDOMHTMLCollection.h" + +#include "AtomicString.h" +#include "HTMLCollection.h" +#include "WebDOMNode.h" +#include <wtf/GetPtr.h> + +WebDOMNode WebDOMHTMLCollection::item(unsigned index) +{ + if (!impl()) + return WebDOMNode(); + + return toWebKit(WTF::getPtr(impl()->item(index))); +} + +WebDOMNode WebDOMHTMLCollection::namedItem(const WebDOMString& name) +{ + if (!impl()) + return WebDOMNode(); + + return toWebKit(WTF::getPtr(impl()->namedItem(name))); +} diff --git a/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp b/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp new file mode 100644 index 0000000..7e2eb25 --- /dev/null +++ b/WebCore/bindings/cpp/WebDOMHTMLOptionsCollectionCustom.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebDOMHTMLOptionsCollection.h" + +#include "HTMLOptionsCollection.h" +#include "WebExceptionHandler.h" + +unsigned WebDOMHTMLOptionsCollection::length() const +{ + if (!impl()) + return 0; + + return impl()->length(); +} + +void WebDOMHTMLOptionsCollection::setLength(unsigned length) +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->setLength(length, ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} diff --git a/WebCore/bindings/js/JSWebKitPointConstructor.h b/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp index 44c253d..565fa61 100644 --- a/WebCore/bindings/js/JSWebKitPointConstructor.h +++ b/WebCore/bindings/cpp/WebDOMNodeFilterCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) Research In Motion Limited 2010. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,24 +23,22 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWebKitPointConstructor_h -#define JSWebKitPointConstructor_h +#include "config.h" +#include "WebDOMNodeFilter.h" -#include "JSDOMBinding.h" -#include "JSDocument.h" +#include "WebDOMNode.h" +#include "WebNativeNodeFilterCondition.h" -namespace WebCore { - -class JSWebKitPointConstructor : public DOMConstructorObject { -public: - JSWebKitPointConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - -private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } -}; +short WebDOMNodeFilter::acceptNode(const WebDOMNode& n) +{ + if (!impl()) + return 0; + return impl()->acceptNode(0, toWebCore(n)); } -#endif // JSWebKitPointConstructor_h +WebDOMNodeFilter toWebKit(WebUserNodeFilter* value) +{ + RefPtr<WebCore::NodeFilter> listener = WebCore::NodeFilter::create(WebNativeNodeFilterCondition::create(value)); + return WebDOMNodeFilter(listener.get()); +} diff --git a/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp b/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp new file mode 100644 index 0000000..3d30810 --- /dev/null +++ b/WebCore/bindings/cpp/WebNativeNodeFilterCondition.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "WebNativeNodeFilterCondition.h" + +#include "WebDOMNode.h" + +WebNativeNodeFilterCondition::WebNativeNodeFilterCondition(WebUserNodeFilter* filter) + : WebCore::NodeFilterCondition() + , m_filter(filter) +{ + ASSERT(m_filter); + m_filter->ref(); +} + +WebNativeNodeFilterCondition::~WebNativeNodeFilterCondition() +{ + m_filter->deref(); +} + +short WebNativeNodeFilterCondition::acceptNode(WebCore::ScriptState*, WebCore::Node* node) const +{ + return m_filter->acceptNode(toWebKit(node)); +} diff --git a/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h b/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h new file mode 100644 index 0000000..33d2786 --- /dev/null +++ b/WebCore/bindings/cpp/WebNativeNodeFilterCondition.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * Copyright (C) 2001 Peter Kelly (pmk@post.com) + * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef WebNativeNodeFilterCondition_h +#define WebNativeNodeFilterCondition_h + +#include "NodeFilter.h" +#include "WebDOMNodeFilter.h" + +class WebNativeNodeFilterCondition : public WebCore::NodeFilterCondition { +public: + static PassRefPtr<WebNativeNodeFilterCondition> create(WebUserNodeFilter* filter) + { + return adoptRef(new WebNativeNodeFilterCondition(filter)); + } + + virtual ~WebNativeNodeFilterCondition(); + + virtual short acceptNode(WebCore::ScriptState*, WebCore::Node*) const; + +protected: + WebNativeNodeFilterCondition(WebUserNodeFilter*); + WebUserNodeFilter* m_filter; +}; + +#endif diff --git a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp index a3e488e..93ce1ee 100644 --- a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp +++ b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp @@ -31,8 +31,7 @@ #include "config.h" #include "RuntimeEnabledFeatures.h" -#include "Database.h" -#include "DatabaseSync.h" +#include "AbstractDatabase.h" #include "MediaPlayer.h" #include "SharedWorkerRepository.h" #include "WebSocket.h" @@ -95,12 +94,12 @@ bool RuntimeEnabledFeatures::webSocketEnabled() #if ENABLE(DATABASE) bool RuntimeEnabledFeatures::openDatabaseEnabled() { - return Database::isAvailable(); + return AbstractDatabase::isAvailable(); } bool RuntimeEnabledFeatures::openDatabaseSyncEnabled() { - return DatabaseSync::isAvailable(); + return AbstractDatabase::isAvailable(); } #endif diff --git a/WebCore/bindings/js/JSArrayBufferConstructor.h b/WebCore/bindings/js/JSArrayBufferConstructor.h deleted file mode 100644 index fa07a55..0000000 --- a/WebCore/bindings/js/JSArrayBufferConstructor.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSArrayBufferConstructor_h -#define JSArrayBufferConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" -#include "JSArrayBuffer.h" -#include <runtime/Error.h> -#include "ArrayBuffer.h" - -namespace WebCore { - - class ArrayBufferView; - - // Template function used by CanvasXXXArrayConstructors - template<class C, typename T> - PassRefPtr<ArrayBufferView> construct(JSC::ExecState* exec, const JSC::ArgList& args) - { - // There are 3 constructors: - // - // 1) (in int size) - // 2) (in ArrayBuffer buffer, [Optional] in int offset, [Optional] in unsigned int length) - // 3) (in sequence<T>) - This ends up being a JS "array-like" object - // - RefPtr<C> arrayObject; - - // For the 0 args case, just create an object without a buffer - if (args.size() < 1) - return C::create(0, 0, 0); - - if (args.size() > 1 && !args.at(0).isObject()) - // Invalid first argument - return 0; - - if (args.at(0).isObject()) { - RefPtr<ArrayBuffer> buffer = toArrayBuffer(args.at(0)); - if (buffer) { - unsigned offset = (args.size() > 1) ? args.at(1).toUInt32(exec) : 0; - unsigned int length = (buffer->byteLength() - offset) / sizeof(T); - if (args.size() > 2) - length = args.at(2).toUInt32(exec); - return C::create(buffer, offset, length); - } - - JSC::JSObject* array = asObject(args.at(0)); - unsigned length = array->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); - void* tempValues; - if (!tryFastCalloc(length, sizeof(T)).getValue(tempValues)) { - throwError(exec, createError(exec, "Error")); - return 0; - } - - OwnFastMallocPtr<T> values(static_cast<T*>(tempValues)); - for (unsigned i = 0; i < length; ++i) { - JSC::JSValue v = array->get(exec, i); - if (exec->hadException()) - return 0; - values.get()[i] = static_cast<T>(v.toNumber(exec)); - } - - return C::create(values.get(), length); - } - - unsigned size = args.at(0).toUInt32(exec); - return C::create(size); - } - - class JSArrayBufferConstructor : public DOMConstructorObject { - public: - JSArrayBufferConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} - -#endif // JSArrayBufferConstructor_h diff --git a/WebCore/bindings/js/JSArrayBufferConstructor.cpp b/WebCore/bindings/js/JSArrayBufferCustom.cpp index 683f9d1..3555a60 100644 --- a/WebCore/bindings/js/JSArrayBufferConstructor.cpp +++ b/WebCore/bindings/js/JSArrayBufferCustom.cpp @@ -27,49 +27,31 @@ #if ENABLE(3D_CANVAS) -#include "JSArrayBufferConstructor.h" +#include "JSArrayBuffer.h" -#include "Document.h" +#include "ArrayBuffer.h" #include "ExceptionCode.h" -#include "JSArrayBuffer.h" +#include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSArrayBufferConstructor::s_info = { "ArrayBufferConstructor", 0, 0, 0 }; - -JSArrayBufferConstructor::JSArrayBufferConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSArrayBufferConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSArrayBufferPrototype::self(exec, globalObject), None); - putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasArrayBuffer(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(ExecState* exec) { JSArrayBufferConstructor* jsConstructor = static_cast<JSArrayBufferConstructor*>(exec->callee()); - unsigned int size = 0; - if (exec->argumentCount() == 1) { - size = (unsigned int)exec->argument(0).toInt32(exec); - if (isnan(size)) - size = 0; - } - RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(size, 1); - if (!buffer.get()){ - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } + int length = 0; + if (exec->argumentCount() > 0) + length = exec->argument(0).toInt32(exec); // NaN/+inf/-inf returns 0, this is intended by WebIDL + RefPtr<ArrayBuffer> buffer; + if (length >= 0) + buffer = ArrayBuffer::create(static_cast<unsigned>(length), 1); + if (!buffer.get()) + return throwVMError(exec, createRangeError(exec, "ArrayBuffer size is not a small enough positive integer.")); return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), buffer.get()))); } -JSC::ConstructType JSArrayBufferConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasArrayBuffer; - return ConstructTypeHost; -} - } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSArrayBufferViewHelper.h b/WebCore/bindings/js/JSArrayBufferViewHelper.h index f632f38..331e950 100644 --- a/WebCore/bindings/js/JSArrayBufferViewHelper.h +++ b/WebCore/bindings/js/JSArrayBufferViewHelper.h @@ -27,7 +27,9 @@ #ifndef JSArrayBufferViewHelper_h #define JSArrayBufferViewHelper_h +#include "ArrayBufferView.h" #include "ExceptionCode.h" +#include "JSArrayBuffer.h" #include "JSDOMBinding.h" #include <interpreter/CallFrame.h> #include <runtime/ArgList.h> @@ -81,6 +83,73 @@ JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionF return JSC::throwSyntaxError(exec); } +// Template function used by XXXArrayConstructors. +// If this returns 0, it will already have thrown a JavaScript exception. +template<class C, typename T> +PassRefPtr<ArrayBufferView> constructArrayBufferView(JSC::ExecState* exec) +{ + // There are 3 constructors: + // + // 1) (in int size) + // 2) (in ArrayBuffer buffer, [Optional] in int offset, [Optional] in unsigned int length) + // 3) (in sequence<T>) - This ends up being a JS "array-like" object + // + RefPtr<C> arrayObject; + + // For the 0 args case, just create an object without a buffer + if (exec->argumentCount() < 1) + return C::create(0, 0, 0); + + if (exec->argument(0).isNull()) { + // Invalid first argument + throwTypeError(exec); + return 0; + } + + if (exec->argument(0).isObject()) { + RefPtr<ArrayBuffer> buffer = toArrayBuffer(exec->argument(0)); + if (buffer) { + unsigned offset = (exec->argumentCount() > 1) ? exec->argument(1).toUInt32(exec) : 0; + unsigned int length = (buffer->byteLength() - offset) / sizeof(T); + if (exec->argumentCount() > 2) + length = exec->argument(2).toUInt32(exec); + PassRefPtr<ArrayBufferView> array = C::create(buffer, offset, length); + if (!array) + setDOMException(exec, INDEX_SIZE_ERR); + return array; + } + + JSC::JSObject* array = asObject(exec->argument(0)); + unsigned length = array->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); + void* tempValues; + if (!tryFastCalloc(length, sizeof(T)).getValue(tempValues)) { + JSC::throwError(exec, createError(exec, "Error")); + return 0; + } + + OwnFastMallocPtr<T> values(static_cast<T*>(tempValues)); + for (unsigned i = 0; i < length; ++i) { + JSC::JSValue v = array->get(exec, i); + if (exec->hadException()) + return 0; + values.get()[i] = static_cast<T>(v.toNumber(exec)); + } + + PassRefPtr<ArrayBufferView> result = C::create(values.get(), length); + if (!result) + setDOMException(exec, INDEX_SIZE_ERR); + return result; + } + + int length = exec->argument(0).toInt32(exec); + PassRefPtr<ArrayBufferView> result; + if (length >= 0) + result = C::create(static_cast<unsigned>(length)); + if (!result) + throwError(exec, createRangeError(exec, "ArrayBufferView size is not a small enough positive integer.")); + return result; } +} // namespace WebCore + #endif // JSArrayBufferViewHelper_h diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp index ae31608..1d64198 100644 --- a/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2009, 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 @@ -58,7 +58,7 @@ #include "JSElementCustom.cpp" #include "JSEventCustom.cpp" #include "JSEventListener.cpp" -#include "JSEventSourceConstructor.cpp" +#include "JSEventSourceCustom.cpp" #include "JSEventTarget.cpp" #include "JSExceptionBase.cpp" #include "JSHTMLAllCollectionCustom.cpp" @@ -86,7 +86,6 @@ #include "JSLazyEventListener.cpp" #include "JSLocationCustom.cpp" #include "JSMainThreadExecState.cpp" -#include "JSMessageChannelConstructor.cpp" #include "JSMessageChannelCustom.cpp" #include "JSMessageEventCustom.cpp" #include "JSMessagePortCustom.cpp" @@ -111,25 +110,21 @@ #include "JSSVGPathSegCustom.cpp" #include "JSSVGPathSegListCustom.cpp" #include "JSScriptProfileNodeCustom.cpp" -#include "JSSharedWorkerConstructor.cpp" #include "JSSharedWorkerCustom.cpp" #include "JSStorageCustom.cpp" #include "JSStyleSheetCustom.cpp" #include "JSStyleSheetListCustom.cpp" #include "JSTextCustom.cpp" #include "JSTreeWalkerCustom.cpp" -#include "JSWebKitCSSMatrixConstructor.cpp" -#include "JSWebKitPointConstructor.cpp" -#include "JSWebSocketConstructor.cpp" +#include "JSWebKitCSSMatrixCustom.cpp" +#include "JSWebKitPointCustom.cpp" #include "JSWebSocketCustom.cpp" -#include "JSWorkerConstructor.cpp" #include "JSWorkerContextBase.cpp" #include "JSWorkerContextCustom.cpp" #include "JSWorkerContextErrorHandler.cpp" #include "JSWorkerCustom.cpp" #include "JSXMLHttpRequestCustom.cpp" #include "JSXMLHttpRequestUploadCustom.cpp" -#include "JSXSLTProcessorConstructor.cpp" #include "JSXSLTProcessorCustom.cpp" #include "JavaScriptCallFrame.cpp" #include "MemoryInfo.cpp" diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp index 27ac9e4..8220f51 100644 --- a/WebCore/bindings/js/JSDOMBinding.cpp +++ b/WebCore/bindings/js/JSDOMBinding.cpp @@ -71,6 +71,11 @@ #include "XPathException.h" #endif +#if ENABLE(DATABASE) +#include "JSSQLException.h" +#include "SQLException.h" +#endif + using namespace JSC; namespace WebCore { @@ -600,6 +605,11 @@ void setDOMException(ExecState* exec, ExceptionCode ec) errorObject = toJS(exec, globalObject, XPathException::create(description)); break; #endif +#if ENABLE(DATABASE) + case SQLExceptionType: + errorObject = toJS(exec, globalObject, SQLException::create(description)); + break; +#endif } ASSERT(errorObject); diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 7e0a785..30d79b3 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -43,38 +43,38 @@ #include "JSDOMWindowShell.h" #include "JSEvent.h" #include "JSEventListener.h" -#include "JSEventSourceConstructor.h" +#include "JSEventSource.h" #include "JSHTMLCollection.h" #include "JSHistory.h" #include "JSImageConstructor.h" #include "JSLocation.h" -#include "JSMessageChannelConstructor.h" +#include "JSMessageChannel.h" #include "JSMessagePort.h" #include "JSMessagePortCustom.h" #include "JSOptionConstructor.h" #if ENABLE(SHARED_WORKERS) -#include "JSSharedWorkerConstructor.h" +#include "JSSharedWorker.h" #endif #if ENABLE(3D_CANVAS) -#include "JSArrayBufferConstructor.h" -#include "JSInt8ArrayConstructor.h" -#include "JSUint8ArrayConstructor.h" -#include "JSInt32ArrayConstructor.h" -#include "JSUint32ArrayConstructor.h" -#include "JSInt16ArrayConstructor.h" -#include "JSUint16ArrayConstructor.h" -#include "JSFloat32ArrayConstructor.h" +#include "JSArrayBuffer.h" +#include "JSInt8Array.h" +#include "JSUint8Array.h" +#include "JSInt32Array.h" +#include "JSUint32Array.h" +#include "JSInt16Array.h" +#include "JSUint16Array.h" +#include "JSFloat32Array.h" #endif -#include "JSWebKitCSSMatrixConstructor.h" -#include "JSWebKitPointConstructor.h" +#include "JSWebKitCSSMatrix.h" +#include "JSWebKitPoint.h" #if ENABLE(WEB_SOCKETS) -#include "JSWebSocketConstructor.h" +#include "JSWebSocket.h" #endif -#include "JSWorkerConstructor.h" +#include "JSWorker.h" #include "JSXMLHttpRequest.h" -#include "JSXSLTProcessorConstructor.h" +#include "JSXSLTProcessor.h" #include "Location.h" #include "MediaPlayer.h" #include "MessagePort.h" diff --git a/WebCore/bindings/js/JSEventSourceConstructor.h b/WebCore/bindings/js/JSEventSourceConstructor.h deleted file mode 100644 index b2f3cb5..0000000 --- a/WebCore/bindings/js/JSEventSourceConstructor.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2009 Ericsson AB - * 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 Ericsson 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 JSEventSourceConstructor_h -#define JSEventSourceConstructor_h - -#if ENABLE(EVENTSOURCE) - -#include "JSDOMBinding.h" - -namespace WebCore { - - class JSEventSourceConstructor : public DOMConstructorObject { - public: - JSEventSourceConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} // namespace WebCore - -#endif // ENABLE(EVENTSOURCE) - -#endif // JSEventSourceConstructor_h diff --git a/WebCore/bindings/js/JSEventSourceConstructor.cpp b/WebCore/bindings/js/JSEventSourceCustom.cpp index 4524f70..aa991dd 100644 --- a/WebCore/bindings/js/JSEventSourceConstructor.cpp +++ b/WebCore/bindings/js/JSEventSourceCustom.cpp @@ -1,6 +1,6 @@ /* - * Copyright (C) 2009 Ericsson AB - * All rights reserved. + * Copyright (C) 2009 Ericsson AB. All rights reserved. + * 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 @@ -33,11 +33,10 @@ #if ENABLE(EVENTSOURCE) -#include "JSEventSourceConstructor.h" +#include "JSEventSource.h" #include "EventSource.h" #include "ExceptionCode.h" -#include "JSEventSource.h" #include "ScriptExecutionContext.h" #include <runtime/Error.h> @@ -45,18 +44,7 @@ using namespace JSC; namespace WebCore { -ASSERT_CLASS_FITS_IN_CELL(JSEventSourceConstructor); - -const ClassInfo JSEventSourceConstructor::s_info = { "EventSourceContructor", 0, 0, 0 }; - -JSEventSourceConstructor::JSEventSourceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSEventSourceConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSEventSourcePrototype::self(exec, globalObject), None); - putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); -} - -static EncodedJSValue JSC_HOST_CALL constructEventSource(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSEventSourceConstructor::constructJSEventSource(ExecState* exec) { if (exec->argumentCount() < 1) return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); @@ -80,12 +68,6 @@ static EncodedJSValue JSC_HOST_CALL constructEventSource(ExecState* exec) return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), eventSource.release()))); } -ConstructType JSEventSourceConstructor::getConstructData(ConstructData& constructData) -{ - constructData.native.function = constructEventSource; - return ConstructTypeHost; -} - } // namespace WebCore #endif // ENABLE(EVENTSOURCE) diff --git a/WebCore/bindings/js/JSExceptionBase.cpp b/WebCore/bindings/js/JSExceptionBase.cpp index 3749eed..44b38ec 100644 --- a/WebCore/bindings/js/JSExceptionBase.cpp +++ b/WebCore/bindings/js/JSExceptionBase.cpp @@ -1,64 +1,72 @@ -/*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "JSExceptionBase.h"
-
-#include "JSDOMCoreException.h"
-#include "JSEventException.h"
-#include "JSRangeException.h"
-#include "JSXMLHttpRequestException.h"
-#if ENABLE(SVG)
-#include "JSSVGException.h"
-#endif
-#if ENABLE(XPATH)
-#include "JSXPathException.h"
-#endif
-
-namespace WebCore {
-
-ExceptionBase* toExceptionBase(JSC::JSValue value)
-{
- if (DOMCoreException* domException = toDOMCoreException(value))
- return reinterpret_cast<ExceptionBase*>(domException);
- if (RangeException* rangeException = toRangeException(value))
- return reinterpret_cast<ExceptionBase*>(rangeException);
- if (EventException* eventException = toEventException(value))
- return reinterpret_cast<ExceptionBase*>(eventException);
- if (XMLHttpRequestException* xmlHttpException = toXMLHttpRequestException(value))
- return reinterpret_cast<ExceptionBase*>(xmlHttpException);
-#if ENABLE(SVG)
- if (SVGException* svgException = toSVGException(value))
- return reinterpret_cast<ExceptionBase*>(svgException);
-#endif
-#if ENABLE(XPATH)
- if (XPathException* pathException = toXPathException(value))
- return reinterpret_cast<ExceptionBase*>(pathException);
-#endif
-
- return 0;
-}
-
-} // namespace WebCore
+/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSExceptionBase.h" + +#include "JSDOMCoreException.h" +#include "JSEventException.h" +#include "JSRangeException.h" +#include "JSXMLHttpRequestException.h" +#if ENABLE(DATABASE) +#include "SQLException.h" +#include "JSSQLException.h" +#endif +#if ENABLE(SVG) +#include "JSSVGException.h" +#endif +#if ENABLE(XPATH) +#include "JSXPathException.h" +#endif + +namespace WebCore { + +ExceptionBase* toExceptionBase(JSC::JSValue value) +{ + if (DOMCoreException* domException = toDOMCoreException(value)) + return reinterpret_cast<ExceptionBase*>(domException); + if (RangeException* rangeException = toRangeException(value)) + return reinterpret_cast<ExceptionBase*>(rangeException); + if (EventException* eventException = toEventException(value)) + return reinterpret_cast<ExceptionBase*>(eventException); + if (XMLHttpRequestException* xmlHttpException = toXMLHttpRequestException(value)) + return reinterpret_cast<ExceptionBase*>(xmlHttpException); +#if ENABLE(SVG) + if (SVGException* svgException = toSVGException(value)) + return reinterpret_cast<ExceptionBase*>(svgException); +#endif +#if ENABLE(XPATH) + if (XPathException* pathException = toXPathException(value)) + return reinterpret_cast<ExceptionBase*>(pathException); +#endif +#if ENABLE(DATABASE) + if (SQLException* pathException = toSQLException(value)) + return reinterpret_cast<ExceptionBase*>(pathException); +#endif + + return 0; +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/JSFloat32ArrayConstructor.cpp b/WebCore/bindings/js/JSFloat32ArrayConstructor.cpp deleted file mode 100644 index 08cffb5..0000000 --- a/WebCore/bindings/js/JSFloat32ArrayConstructor.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) - -#include "JSFloat32ArrayConstructor.h" - -#include "Document.h" -#include "Float32Array.h" -#include "JSArrayBuffer.h" -#include "JSArrayBufferConstructor.h" -#include "JSFloat32Array.h" -#include <runtime/Error.h> - -namespace WebCore { - -using namespace JSC; - -const ClassInfo JSFloat32ArrayConstructor::s_info = { "Float32ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; - -JSFloat32ArrayConstructor::JSFloat32ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSFloat32ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSFloat32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); -} - -JSObject* JSFloat32ArrayConstructor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSFloat32ArrayPrototype(globalObject, JSFloat32ArrayPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSFloat32ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSFloat32ArrayConstructor, DOMObject>(exec, JSFloat32ArrayPrototype::s_info.staticPropHashTable, this, propertyName, slot); -} - -bool JSFloat32ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor<JSFloat32ArrayConstructor, DOMObject>(exec, JSFloat32ArrayPrototype::s_info.staticPropHashTable, this, propertyName, descriptor); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasFloatArray(ExecState* exec) -{ - ArgList args(exec); - JSFloat32ArrayConstructor* jsConstructor = static_cast<JSFloat32ArrayConstructor*>(exec->callee()); - RefPtr<Float32Array> array = static_cast<Float32Array*>(construct<Float32Array, float>(exec, args).get()); - if (!array.get()) { - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); -} - -JSC::ConstructType JSFloat32ArrayConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasFloatArray; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSFloat32ArrayConstructor.h b/WebCore/bindings/js/JSFloat32ArrayConstructor.h deleted file mode 100644 index c2f8b7e..0000000 --- a/WebCore/bindings/js/JSFloat32ArrayConstructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSFloat32ArrayConstructor_h -#define JSFloat32ArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSFloat32ArrayConstructor : public DOMConstructorObject { - typedef DOMConstructorObject Base; - public: - JSFloat32ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - static const JSC::ClassInfo s_info; - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - }; - -} - -#endif // JSFloat32ArrayConstructor_h diff --git a/WebCore/bindings/js/JSFloat32ArrayCustom.cpp b/WebCore/bindings/js/JSFloat32ArrayCustom.cpp index 7965274..3be7458 100644 --- a/WebCore/bindings/js/JSFloat32ArrayCustom.cpp +++ b/WebCore/bindings/js/JSFloat32ArrayCustom.cpp @@ -51,6 +51,16 @@ JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec) return setWebGLArrayHelper(exec, impl(), toFloat32Array); } +EncodedJSValue JSC_HOST_CALL JSFloat32ArrayConstructor::constructJSFloat32Array(ExecState* exec) +{ + JSFloat32ArrayConstructor* jsConstructor = static_cast<JSFloat32ArrayConstructor*>(exec->callee()); + RefPtr<Float32Array> array = static_cast<Float32Array*>(constructArrayBufferView<Float32Array, float>(exec).get()); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSInt16ArrayConstructor.cpp b/WebCore/bindings/js/JSInt16ArrayConstructor.cpp deleted file mode 100644 index aaed578..0000000 --- a/WebCore/bindings/js/JSInt16ArrayConstructor.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) - -#include "JSInt16ArrayConstructor.h" - -#include "Document.h" -#include "Int16Array.h" -#include "JSArrayBufferView.h" -#include "JSArrayBuffer.h" -#include "JSArrayBufferConstructor.h" -#include "JSInt16Array.h" -#include <runtime/Error.h> - -namespace WebCore { - -using namespace JSC; - -const ClassInfo JSInt16ArrayConstructor::s_info = { "Int16ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; - -JSInt16ArrayConstructor::JSInt16ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSInt16ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSInt16ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); -} - -JSObject* JSInt16ArrayConstructor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSInt16ArrayPrototype(globalObject, JSInt16ArrayPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSInt16ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSInt16ArrayConstructor, DOMObject>(exec, JSInt16ArrayPrototype::s_info.staticPropHashTable, this, propertyName, slot); -} - -bool JSInt16ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor<JSInt16ArrayConstructor, DOMObject>(exec, JSInt16ArrayPrototype::s_info.staticPropHashTable, this, propertyName, descriptor); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasShortArray(ExecState* exec) -{ - ArgList args(exec); - JSInt16ArrayConstructor* jsConstructor = static_cast<JSInt16ArrayConstructor*>(exec->callee()); - RefPtr<Int16Array> array = static_cast<Int16Array*>(construct<Int16Array, short>(exec, args).get()); - if (!array.get()) { - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); -} - -JSC::ConstructType JSInt16ArrayConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasShortArray; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSInt16ArrayConstructor.h b/WebCore/bindings/js/JSInt16ArrayConstructor.h deleted file mode 100644 index 87908a0..0000000 --- a/WebCore/bindings/js/JSInt16ArrayConstructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSInt16ArrayConstructor_h -#define JSInt16ArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSInt16ArrayConstructor : public DOMConstructorObject { - typedef DOMConstructorObject Base; - public: - JSInt16ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - static const JSC::ClassInfo s_info; - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - }; - -} - -#endif // JSInt16ArrayConstructor_h diff --git a/WebCore/bindings/js/JSInt16ArrayCustom.cpp b/WebCore/bindings/js/JSInt16ArrayCustom.cpp index 2888a1b..e8be4d1 100644 --- a/WebCore/bindings/js/JSInt16ArrayCustom.cpp +++ b/WebCore/bindings/js/JSInt16ArrayCustom.cpp @@ -51,6 +51,16 @@ JSC::JSValue JSInt16Array::set(JSC::ExecState* exec) return setWebGLArrayHelper(exec, impl(), toInt16Array); } +EncodedJSValue JSC_HOST_CALL JSInt16ArrayConstructor::constructJSInt16Array(ExecState* exec) +{ + JSInt16ArrayConstructor* jsConstructor = static_cast<JSInt16ArrayConstructor*>(exec->callee()); + RefPtr<Int16Array> array = static_cast<Int16Array*>(constructArrayBufferView<Int16Array, short>(exec).get()); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSInt32ArrayConstructor.cpp b/WebCore/bindings/js/JSInt32ArrayConstructor.cpp deleted file mode 100644 index b44c9ca..0000000 --- a/WebCore/bindings/js/JSInt32ArrayConstructor.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) - -#include "JSInt32ArrayConstructor.h" - -#include "Document.h" -#include "Int32Array.h" -#include "JSArrayBuffer.h" -#include "JSArrayBufferConstructor.h" -#include "JSInt32Array.h" -#include <runtime/Error.h> - -namespace WebCore { - -using namespace JSC; - -const ClassInfo JSInt32ArrayConstructor::s_info = { "Int32ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; - -JSInt32ArrayConstructor::JSInt32ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSInt32ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSInt32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); -} - -JSObject* JSInt32ArrayConstructor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSInt32ArrayPrototype(globalObject, JSInt32ArrayPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSInt32ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSInt32ArrayConstructor, DOMObject>(exec, JSInt32ArrayPrototype::s_info.staticPropHashTable, this, propertyName, slot); -} - -bool JSInt32ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor<JSInt32ArrayConstructor, DOMObject>(exec, JSInt32ArrayPrototype::s_info.staticPropHashTable, this, propertyName, descriptor); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasIntArray(ExecState* exec) -{ - ArgList args(exec); - JSInt32ArrayConstructor* jsConstructor = static_cast<JSInt32ArrayConstructor*>(exec->callee()); - RefPtr<Int32Array> array = static_cast<Int32Array*>(construct<Int32Array, int>(exec, args).get()); - if (!array.get()) { - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); -} - -JSC::ConstructType JSInt32ArrayConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasIntArray; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSInt32ArrayConstructor.h b/WebCore/bindings/js/JSInt32ArrayConstructor.h deleted file mode 100644 index 6bed3c4..0000000 --- a/WebCore/bindings/js/JSInt32ArrayConstructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSInt32ArrayConstructor_h -#define JSInt32ArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSInt32ArrayConstructor : public DOMConstructorObject { - typedef DOMConstructorObject Base; - public: - JSInt32ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - static const JSC::ClassInfo s_info; - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - }; - -} - -#endif // JSInt32ArrayConstructor_h diff --git a/WebCore/bindings/js/JSInt32ArrayCustom.cpp b/WebCore/bindings/js/JSInt32ArrayCustom.cpp index cfdab63..ee5712b 100644 --- a/WebCore/bindings/js/JSInt32ArrayCustom.cpp +++ b/WebCore/bindings/js/JSInt32ArrayCustom.cpp @@ -51,6 +51,16 @@ JSC::JSValue JSInt32Array::set(JSC::ExecState* exec) return setWebGLArrayHelper(exec, impl(), toInt32Array); } +EncodedJSValue JSC_HOST_CALL JSInt32ArrayConstructor::constructJSInt32Array(ExecState* exec) +{ + JSInt32ArrayConstructor* jsConstructor = static_cast<JSInt32ArrayConstructor*>(exec->callee()); + RefPtr<Int32Array> array = static_cast<Int32Array*>(constructArrayBufferView<Int32Array, int>(exec).get()); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSInt8ArrayConstructor.cpp b/WebCore/bindings/js/JSInt8ArrayConstructor.cpp deleted file mode 100644 index e4c5688..0000000 --- a/WebCore/bindings/js/JSInt8ArrayConstructor.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) - -#include "JSInt8ArrayConstructor.h" - -#include "Document.h" -#include "Int8Array.h" -#include "JSArrayBuffer.h" -#include "JSArrayBufferConstructor.h" -#include "JSInt8Array.h" -#include <runtime/Error.h> - -namespace WebCore { - -using namespace JSC; - -const ClassInfo JSInt8ArrayConstructor::s_info = { "Int8ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; - -JSInt8ArrayConstructor::JSInt8ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSInt8ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSInt8ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); -} - -JSObject* JSInt8ArrayConstructor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSInt8ArrayPrototype(globalObject, JSInt8ArrayPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSInt8ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSInt8ArrayConstructor, DOMObject>(exec, JSInt8ArrayPrototype::s_info.staticPropHashTable, this, propertyName, slot); -} - -bool JSInt8ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor<JSInt8ArrayConstructor, DOMObject>(exec, JSInt8ArrayPrototype::s_info.staticPropHashTable, this, propertyName, descriptor); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasByteArray(ExecState* exec) -{ - ArgList args(exec); - JSInt8ArrayConstructor* jsConstructor = static_cast<JSInt8ArrayConstructor*>(exec->callee()); - RefPtr<Int8Array> array = static_cast<Int8Array*>(construct<Int8Array, signed char>(exec, args).get()); - if (!array.get()) { - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); -} - -JSC::ConstructType JSInt8ArrayConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasByteArray; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSInt8ArrayConstructor.h b/WebCore/bindings/js/JSInt8ArrayConstructor.h deleted file mode 100644 index 96482fc..0000000 --- a/WebCore/bindings/js/JSInt8ArrayConstructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSInt8ArrayConstructor_h -#define JSInt8ArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSInt8ArrayConstructor : public DOMConstructorObject { - typedef DOMConstructorObject Base; - public: - JSInt8ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - static const JSC::ClassInfo s_info; - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - }; - -} - -#endif // JSInt8ArrayConstructor_h diff --git a/WebCore/bindings/js/JSInt8ArrayCustom.cpp b/WebCore/bindings/js/JSInt8ArrayCustom.cpp index 9d41694..70f18a5 100644 --- a/WebCore/bindings/js/JSInt8ArrayCustom.cpp +++ b/WebCore/bindings/js/JSInt8ArrayCustom.cpp @@ -31,7 +31,6 @@ #include "JSInt8Array.h" #include "Int8Array.h" - #include <runtime/Error.h> using namespace JSC; @@ -53,6 +52,16 @@ JSC::JSValue JSInt8Array::set(JSC::ExecState* exec) return setWebGLArrayHelper(exec, impl(), toInt8Array); } +EncodedJSValue JSC_HOST_CALL JSInt8ArrayConstructor::constructJSInt8Array(ExecState* exec) +{ + JSInt8ArrayConstructor* jsConstructor = static_cast<JSInt8ArrayConstructor*>(exec->callee()); + RefPtr<Int8Array> array = static_cast<Int8Array*>(constructArrayBufferView<Int8Array, signed char>(exec).get()); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSMessageChannelConstructor.cpp b/WebCore/bindings/js/JSMessageChannelConstructor.cpp deleted file mode 100644 index b188ed5..0000000 --- a/WebCore/bindings/js/JSMessageChannelConstructor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSMessageChannelConstructor.h" - -#include "Document.h" -#include "JSDocument.h" -#include "JSMessageChannel.h" -#include "MessageChannel.h" -#include <runtime/Error.h> - -using namespace JSC; - -namespace WebCore { - -const ClassInfo JSMessageChannelConstructor::s_info = { "MessageChannelConstructor", 0, 0, 0 }; - -JSMessageChannelConstructor::JSMessageChannelConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSMessageChannelConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSMessageChannelPrototype::self(exec, globalObject), None); -} - -JSMessageChannelConstructor::~JSMessageChannelConstructor() -{ -} - -ConstructType JSMessageChannelConstructor::getConstructData(ConstructData& constructData) -{ - constructData.native.function = construct; - return ConstructTypeHost; -} - -EncodedJSValue JSC_HOST_CALL JSMessageChannelConstructor::construct(ExecState* exec) -{ - JSMessageChannelConstructor* jsConstructor = static_cast<JSMessageChannelConstructor*>(exec->callee()); - ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); - if (!context) - return throwVMError(exec, createReferenceError(exec, "MessageChannel constructor associated document is unavailable")); - - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), MessageChannel::create(context)))); -} - -} // namespace WebCore diff --git a/WebCore/bindings/js/JSMessageChannelConstructor.h b/WebCore/bindings/js/JSMessageChannelConstructor.h deleted file mode 100644 index decf05b..0000000 --- a/WebCore/bindings/js/JSMessageChannelConstructor.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSMessageChannelConstructor_h -#define JSMessageChannelConstructor_h - -#include "JSDOMBinding.h" - -namespace WebCore { - - class JSMessageChannelConstructor : public DOMConstructorObject { - public: - JSMessageChannelConstructor(JSC::ExecState*, JSDOMGlobalObject*); - virtual ~JSMessageChannelConstructor(); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - static const JSC::ClassInfo s_info; - - virtual bool implementsHasInstance() const { return true; } - static JSC::EncodedJSValue JSC_HOST_CALL construct(JSC::ExecState*); - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - }; - -} // namespace WebCore - -#endif // JSMessageChannelConstructor_h diff --git a/WebCore/bindings/js/JSMessageChannelCustom.cpp b/WebCore/bindings/js/JSMessageChannelCustom.cpp index d28d494..c2f5779 100644 --- a/WebCore/bindings/js/JSMessageChannelCustom.cpp +++ b/WebCore/bindings/js/JSMessageChannelCustom.cpp @@ -27,6 +27,7 @@ #include "JSMessageChannel.h" #include "MessageChannel.h" +#include <runtime/Error.h> using namespace JSC; @@ -43,4 +44,14 @@ void JSMessageChannel::markChildren(MarkStack& markStack) markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), port); } +EncodedJSValue JSC_HOST_CALL JSMessageChannelConstructor::constructJSMessageChannel(ExecState* exec) +{ + JSMessageChannelConstructor* jsConstructor = static_cast<JSMessageChannelConstructor*>(exec->callee()); + ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); + if (!context) + return throwVMError(exec, createReferenceError(exec, "MessageChannel constructor associated document is unavailable")); + + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), MessageChannel::create(context)))); +} + } // namespace WebCore diff --git a/WebCore/bindings/js/JSSharedWorkerConstructor.cpp b/WebCore/bindings/js/JSSharedWorkerConstructor.cpp deleted file mode 100644 index f2bf6de..0000000 --- a/WebCore/bindings/js/JSSharedWorkerConstructor.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 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" - -#if ENABLE(SHARED_WORKERS) - -#include "JSSharedWorkerConstructor.h" - -#include "JSDOMWindowCustom.h" -#include "JSSharedWorker.h" -#include "SharedWorker.h" -#include <runtime/Error.h> - -using namespace JSC; - -namespace WebCore { - -const ClassInfo JSSharedWorkerConstructor::s_info = { "SharedWorkerConstructor", 0, 0, 0 }; - -JSSharedWorkerConstructor::JSSharedWorkerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSSharedWorkerConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSSharedWorkerPrototype::self(exec, globalObject), None); - // Host functions have a length property describing the number of expected arguments. - putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); -} - -static EncodedJSValue JSC_HOST_CALL constructSharedWorker(ExecState* exec) -{ - JSSharedWorkerConstructor* jsConstructor = static_cast<JSSharedWorkerConstructor*>(exec->callee()); - - if (exec->argumentCount() < 1) - return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); - - UString scriptURL = exec->argument(0).toString(exec); - UString name; - if (exec->argumentCount() > 1) - name = exec->argument(1).toString(exec); - - if (exec->hadException()) - return JSValue::encode(JSValue()); - - // FIXME: We need to use both the dynamic scope and the lexical scope (dynamic scope for resolving the worker URL) - DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); - ExceptionCode ec = 0; - RefPtr<SharedWorker> worker = SharedWorker::create(ustringToString(scriptURL), ustringToString(name), window->document(), ec); - setDOMException(exec, ec); - - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), worker.release()))); -} - -ConstructType JSSharedWorkerConstructor::getConstructData(ConstructData& constructData) -{ - constructData.native.function = constructSharedWorker; - return ConstructTypeHost; -} - - -} // namespace WebCore - -#endif // ENABLE(SHARED_WORKERS) diff --git a/WebCore/bindings/js/JSSharedWorkerConstructor.h b/WebCore/bindings/js/JSSharedWorkerConstructor.h deleted file mode 100644 index 87baa38..0000000 --- a/WebCore/bindings/js/JSSharedWorkerConstructor.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 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. - */ - -#ifndef JSSharedWorkerConstructor_h -#define JSSharedWorkerConstructor_h - -#if ENABLE(SHARED_WORKERS) - -#include "JSDOMBinding.h" - -namespace WebCore { - - class JSSharedWorkerConstructor : public DOMConstructorObject { - public: - JSSharedWorkerConstructor(JSC::ExecState*, JSDOMGlobalObject*); - - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} // namespace WebCore - -#endif // ENABLE(SHARED_WORKERS) - -#endif // JSSharedWorkerConstructor_h diff --git a/WebCore/bindings/js/JSSharedWorkerCustom.cpp b/WebCore/bindings/js/JSSharedWorkerCustom.cpp index 4617087..261ae2b 100644 --- a/WebCore/bindings/js/JSSharedWorkerCustom.cpp +++ b/WebCore/bindings/js/JSSharedWorkerCustom.cpp @@ -35,7 +35,9 @@ #include "JSSharedWorker.h" #include "JSDOMGlobalObject.h" +#include "JSDOMWindowCustom.h" #include "SharedWorker.h" +#include <runtime/Error.h> using namespace JSC; @@ -49,6 +51,30 @@ void JSSharedWorker::markChildren(MarkStack& markStack) markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), port); } +EncodedJSValue JSC_HOST_CALL JSSharedWorkerConstructor::constructJSSharedWorker(ExecState* exec) +{ + JSSharedWorkerConstructor* jsConstructor = static_cast<JSSharedWorkerConstructor*>(exec->callee()); + + if (exec->argumentCount() < 1) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + + UString scriptURL = exec->argument(0).toString(exec); + UString name; + if (exec->argumentCount() > 1) + name = exec->argument(1).toString(exec); + + if (exec->hadException()) + return JSValue::encode(JSValue()); + + // FIXME: We need to use both the dynamic scope and the lexical scope (dynamic scope for resolving the worker URL) + DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); + ExceptionCode ec = 0; + RefPtr<SharedWorker> worker = SharedWorker::create(ustringToString(scriptURL), ustringToString(name), window->document(), ec); + setDOMException(exec, ec); + + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), worker.release()))); +} + } // namespace WebCore #endif // ENABLE(SHARED_WORKERS) diff --git a/WebCore/bindings/js/JSUint16ArrayConstructor.cpp b/WebCore/bindings/js/JSUint16ArrayConstructor.cpp deleted file mode 100644 index b1770c5..0000000 --- a/WebCore/bindings/js/JSUint16ArrayConstructor.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) - -#include "JSUint16ArrayConstructor.h" - -#include "Document.h" -#include "Uint16Array.h" -#include "JSArrayBuffer.h" -#include "JSArrayBufferConstructor.h" -#include "JSUint16Array.h" -#include <runtime/Error.h> - -namespace WebCore { - -using namespace JSC; - -const ClassInfo JSUint16ArrayConstructor::s_info = { "Uint16ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; - -JSUint16ArrayConstructor::JSUint16ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSUint16ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSUint16ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); -} - -JSObject* JSUint16ArrayConstructor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSUint16ArrayPrototype(globalObject, JSUint16ArrayPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSUint16ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSUint16ArrayConstructor, DOMObject>(exec, JSUint16ArrayPrototype::s_info.staticPropHashTable, this, propertyName, slot); -} - -bool JSUint16ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor<JSUint16ArrayConstructor, DOMObject>(exec, JSUint16ArrayPrototype::s_info.staticPropHashTable, this, propertyName, descriptor); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasUnsignedShortArray(ExecState* exec) -{ - ArgList args(exec); - JSUint16ArrayConstructor* jsConstructor = static_cast<JSUint16ArrayConstructor*>(exec->callee()); - RefPtr<Uint16Array> array = static_cast<Uint16Array*>(construct<Uint16Array, unsigned short>(exec, args).get()); - if (!array.get()) { - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); -} - -JSC::ConstructType JSUint16ArrayConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasUnsignedShortArray; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSUint16ArrayConstructor.h b/WebCore/bindings/js/JSUint16ArrayConstructor.h deleted file mode 100644 index b950791..0000000 --- a/WebCore/bindings/js/JSUint16ArrayConstructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSUint16ArrayConstructor_h -#define JSUint16ArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSUint16ArrayConstructor : public DOMConstructorObject { - typedef DOMConstructorObject Base; - public: - JSUint16ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - static const JSC::ClassInfo s_info; - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - }; - -} - -#endif // JSUint16ArrayConstructor_h diff --git a/WebCore/bindings/js/JSUint16ArrayCustom.cpp b/WebCore/bindings/js/JSUint16ArrayCustom.cpp index 4eb254f..ccea62f 100644 --- a/WebCore/bindings/js/JSUint16ArrayCustom.cpp +++ b/WebCore/bindings/js/JSUint16ArrayCustom.cpp @@ -51,6 +51,16 @@ JSC::JSValue JSUint16Array::set(JSC::ExecState* exec) return setWebGLArrayHelper(exec, impl(), toUint16Array); } +EncodedJSValue JSC_HOST_CALL JSUint16ArrayConstructor::constructJSUint16Array(ExecState* exec) +{ + JSUint16ArrayConstructor* jsConstructor = static_cast<JSUint16ArrayConstructor*>(exec->callee()); + RefPtr<Uint16Array> array = static_cast<Uint16Array*>(constructArrayBufferView<Uint16Array, unsigned short>(exec).get()); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSUint32ArrayConstructor.cpp b/WebCore/bindings/js/JSUint32ArrayConstructor.cpp deleted file mode 100644 index 46ec9da..0000000 --- a/WebCore/bindings/js/JSUint32ArrayConstructor.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) - -#include "JSUint32ArrayConstructor.h" - -#include "Document.h" -#include "Uint32Array.h" -#include "JSArrayBuffer.h" -#include "JSArrayBufferConstructor.h" -#include "JSUint32Array.h" -#include <runtime/Error.h> - -namespace WebCore { - -using namespace JSC; - -const ClassInfo JSUint32ArrayConstructor::s_info = { "Uint32ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; - -JSUint32ArrayConstructor::JSUint32ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSUint32ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSUint32ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); -} - -JSObject* JSUint32ArrayConstructor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSUint32ArrayPrototype(globalObject, JSUint32ArrayPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSUint32ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSUint32ArrayConstructor, DOMObject>(exec, JSUint32ArrayPrototype::s_info.staticPropHashTable, this, propertyName, slot); -} - -bool JSUint32ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor<JSUint32ArrayConstructor, DOMObject>(exec, JSUint32ArrayPrototype::s_info.staticPropHashTable, this, propertyName, descriptor); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasUnsignedIntArray(ExecState* exec) -{ - ArgList args(exec); - JSUint32ArrayConstructor* jsConstructor = static_cast<JSUint32ArrayConstructor*>(exec->callee()); - RefPtr<Uint32Array> array = static_cast<Uint32Array*>(construct<Uint32Array, unsigned int>(exec, args).get()); - if (!array.get()) { - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); -} - -JSC::ConstructType JSUint32ArrayConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasUnsignedIntArray; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSUint32ArrayConstructor.h b/WebCore/bindings/js/JSUint32ArrayConstructor.h deleted file mode 100644 index 7cad849..0000000 --- a/WebCore/bindings/js/JSUint32ArrayConstructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSUint32ArrayConstructor_h -#define JSUint32ArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSUint32ArrayConstructor : public DOMConstructorObject { - typedef DOMConstructorObject Base; - public: - JSUint32ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - static const JSC::ClassInfo s_info; - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - }; - -} - -#endif // JSUint32ArrayConstructor_h diff --git a/WebCore/bindings/js/JSUint32ArrayCustom.cpp b/WebCore/bindings/js/JSUint32ArrayCustom.cpp index 2826b6a..31ec8cb 100644 --- a/WebCore/bindings/js/JSUint32ArrayCustom.cpp +++ b/WebCore/bindings/js/JSUint32ArrayCustom.cpp @@ -51,6 +51,16 @@ JSC::JSValue JSUint32Array::set(JSC::ExecState* exec) return setWebGLArrayHelper(exec, impl(), toUint32Array); } +EncodedJSValue JSC_HOST_CALL JSUint32ArrayConstructor::constructJSUint32Array(ExecState* exec) +{ + JSUint32ArrayConstructor* jsConstructor = static_cast<JSUint32ArrayConstructor*>(exec->callee()); + RefPtr<Uint32Array> array = static_cast<Uint32Array*>(constructArrayBufferView<Uint32Array, unsigned int>(exec).get()); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSUint8ArrayConstructor.cpp b/WebCore/bindings/js/JSUint8ArrayConstructor.cpp deleted file mode 100644 index 0d47b51..0000000 --- a/WebCore/bindings/js/JSUint8ArrayConstructor.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) - -#include "JSUint8ArrayConstructor.h" - -#include "Document.h" -#include "ExceptionCode.h" -#include "Uint8Array.h" -#include "JSArrayBuffer.h" -#include "JSArrayBufferConstructor.h" -#include "JSUint8Array.h" -#include <runtime/Error.h> - -namespace WebCore { - -using namespace JSC; - -const ClassInfo JSUint8ArrayConstructor::s_info = { "Uint8ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; - -JSUint8ArrayConstructor::JSUint8ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSUint8ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSUint8ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); -} - -JSObject* JSUint8ArrayConstructor::createPrototype(ExecState* exec, JSGlobalObject* globalObject) -{ - return new (exec) JSUint8ArrayPrototype(globalObject, JSUint8ArrayPrototype::createStructure(globalObject->objectPrototype())); -} - -bool JSUint8ArrayConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSUint8ArrayConstructor, DOMObject>(exec, JSUint8ArrayPrototype::s_info.staticPropHashTable, this, propertyName, slot); -} - -bool JSUint8ArrayConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) -{ - return getStaticValueDescriptor<JSUint8ArrayConstructor, DOMObject>(exec, JSUint8ArrayPrototype::s_info.staticPropHashTable, this, propertyName, descriptor); -} - -static EncodedJSValue JSC_HOST_CALL constructCanvasUnsignedByteArray(ExecState* exec) -{ - ArgList args(exec); - JSUint8ArrayConstructor* jsConstructor = static_cast<JSUint8ArrayConstructor*>(exec->callee()); - RefPtr<Uint8Array> array = static_cast<Uint8Array*>(construct<Uint8Array, unsigned char>(exec, args).get()); - if (!array.get()) { - setDOMException(exec, INDEX_SIZE_ERR); - return JSValue::encode(JSValue()); - } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); -} - -JSC::ConstructType JSUint8ArrayConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructCanvasUnsignedByteArray; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSUint8ArrayConstructor.h b/WebCore/bindings/js/JSUint8ArrayConstructor.h deleted file mode 100644 index 644cf86..0000000 --- a/WebCore/bindings/js/JSUint8ArrayConstructor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSUint8ArrayConstructor_h -#define JSUint8ArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSUint8ArrayConstructor : public DOMConstructorObject { - typedef DOMConstructorObject Base; - public: - JSUint8ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - static const JSC::ClassInfo s_info; - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); - } - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; - }; - -} - -#endif // JSUint8ArrayConstructor_h diff --git a/WebCore/bindings/js/JSUint8ArrayCustom.cpp b/WebCore/bindings/js/JSUint8ArrayCustom.cpp index 45c80c0..7361b08 100644 --- a/WebCore/bindings/js/JSUint8ArrayCustom.cpp +++ b/WebCore/bindings/js/JSUint8ArrayCustom.cpp @@ -51,6 +51,16 @@ JSC::JSValue JSUint8Array::set(JSC::ExecState* exec) return setWebGLArrayHelper(exec, impl(), toUint8Array); } +EncodedJSValue JSC_HOST_CALL JSUint8ArrayConstructor::constructJSUint8Array(ExecState* exec) +{ + JSUint8ArrayConstructor* jsConstructor = static_cast<JSUint8ArrayConstructor*>(exec->callee()); + RefPtr<Uint8Array> array = static_cast<Uint8Array*>(constructArrayBufferView<Uint8Array, unsigned char>(exec).get()); + if (!array.get()) + // Exception has already been thrown. + return JSValue::encode(JSValue()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h b/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h deleted file mode 100644 index 65b9050..0000000 --- a/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSWebKitCSSMatrixConstructor_h -#define JSWebKitCSSMatrixConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - -class JSWebKitCSSMatrixConstructor : public DOMConstructorObject { -public: - JSWebKitCSSMatrixConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - -private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } -}; - -} - -#endif // JSWebKitCSSMatrixConstructor_h diff --git a/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp b/WebCore/bindings/js/JSWebKitCSSMatrixCustom.cpp index 5013a6d..0889dcf 100644 --- a/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp +++ b/WebCore/bindings/js/JSWebKitCSSMatrixCustom.cpp @@ -24,25 +24,15 @@ */ #include "config.h" -#include "JSWebKitCSSMatrixConstructor.h" +#include "JSWebKitCSSMatrix.h" #include "WebKitCSSMatrix.h" -#include "JSWebKitCSSMatrix.h" using namespace JSC; namespace WebCore { -const ClassInfo JSWebKitCSSMatrixConstructor::s_info = { "WebKitCSSMatrixConstructor", 0, 0, 0 }; - -JSWebKitCSSMatrixConstructor::JSWebKitCSSMatrixConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebKitCSSMatrixConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSWebKitCSSMatrixPrototype::self(exec, globalObject), None); - putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); -} - -static EncodedJSValue JSC_HOST_CALL constructWebKitCSSMatrix(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSWebKitCSSMatrixConstructor::constructJSWebKitCSSMatrix(ExecState* exec) { JSWebKitCSSMatrixConstructor* jsConstructor = static_cast<JSWebKitCSSMatrixConstructor*>(exec->callee()); String s; @@ -55,10 +45,4 @@ static EncodedJSValue JSC_HOST_CALL constructWebKitCSSMatrix(ExecState* exec) return JSValue::encode(CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), WebKitCSSMatrix, matrix.get())); } -ConstructType JSWebKitCSSMatrixConstructor::getConstructData(ConstructData& constructData) -{ - constructData.native.function = constructWebKitCSSMatrix; - return ConstructTypeHost; -} - } // namespace WebCore diff --git a/WebCore/bindings/js/JSWebKitPointConstructor.cpp b/WebCore/bindings/js/JSWebKitPointCustom.cpp index c62f5b6..e1b20ce 100644 --- a/WebCore/bindings/js/JSWebKitPointConstructor.cpp +++ b/WebCore/bindings/js/JSWebKitPointCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 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 @@ -24,34 +24,23 @@ */ #include "config.h" -#include "JSWebKitPointConstructor.h" - -#include "Document.h" -#include "WebKitPoint.h" #include "JSWebKitPoint.h" -namespace WebCore { +#include "WebKitPoint.h" using namespace JSC; -const ClassInfo JSWebKitPointConstructor::s_info = { "WebKitPointConstructor", 0, 0, 0 }; - -JSWebKitPointConstructor::JSWebKitPointConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebKitPointConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSWebKitPointPrototype::self(exec, globalObject), None); - putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); -} +namespace WebCore { -static EncodedJSValue JSC_HOST_CALL constructWebKitPoint(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSWebKitPointConstructor::constructJSWebKitPoint(ExecState* exec) { JSWebKitPointConstructor* jsConstructor = static_cast<JSWebKitPointConstructor*>(exec->callee()); float x = 0; float y = 0; if (exec->argumentCount() >= 2) { - x = (float)exec->argument(0).toNumber(exec); - y = (float)exec->argument(1).toNumber(exec); + x = static_cast<float>(exec->argument(0).toNumber(exec)); + y = static_cast<float>(exec->argument(1).toNumber(exec)); if (isnan(x)) x = 0; if (isnan(y)) @@ -60,11 +49,4 @@ static EncodedJSValue JSC_HOST_CALL constructWebKitPoint(ExecState* exec) return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), WebKitPoint::create(x, y)))); } -JSC::ConstructType JSWebKitPointConstructor::getConstructData(JSC::ConstructData& constructData) -{ - constructData.native.function = constructWebKitPoint; - return ConstructTypeHost; -} - - } // namespace WebCore diff --git a/WebCore/bindings/js/JSWebSocketConstructor.cpp b/WebCore/bindings/js/JSWebSocketConstructor.cpp deleted file mode 100644 index 2384c7b..0000000 --- a/WebCore/bindings/js/JSWebSocketConstructor.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 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" - -#if ENABLE(WEB_SOCKETS) - -#include "JSWebSocketConstructor.h" - -#include "JSWebSocket.h" -#include "ScriptExecutionContext.h" -#include "WebSocket.h" -#include <runtime/Error.h> - -using namespace JSC; - -namespace WebCore { - -ASSERT_CLASS_FITS_IN_CELL(JSWebSocketConstructor); - -const ClassInfo JSWebSocketConstructor::s_info = { "WebSocketConstructor", 0, 0, 0 }; - -JSWebSocketConstructor::JSWebSocketConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebSocketConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSWebSocketPrototype::self(exec, globalObject), None); - putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum); -} - -static EncodedJSValue JSC_HOST_CALL constructWebSocket(ExecState* exec) -{ - JSWebSocketConstructor* jsConstructor = static_cast<JSWebSocketConstructor*>(exec->callee()); - ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); - if (!context) - return throwVMError(exec, createReferenceError(exec, "WebSocket constructor associated document is unavailable")); - - if (!exec->argumentCount()) - return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); - - const String& urlString = ustringToString(exec->argument(0).toString(exec)); - if (exec->hadException()) - return throwVMError(exec, createSyntaxError(exec, "wrong URL")); - const KURL& url = context->completeURL(urlString); - RefPtr<WebSocket> webSocket = WebSocket::create(context); - ExceptionCode ec = 0; - if (exec->argumentCount() < 2) - webSocket->connect(url, ec); - else { - const String& protocol = ustringToString(exec->argument(1).toString(exec)); - if (exec->hadException()) - return JSValue::encode(JSValue()); - webSocket->connect(url, protocol, ec); - } - setDOMException(exec, ec); - return JSValue::encode(CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), WebSocket, webSocket.get())); -} - -ConstructType JSWebSocketConstructor::getConstructData(ConstructData& constructData) -{ - constructData.native.function = constructWebSocket; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif diff --git a/WebCore/bindings/js/JSWebSocketConstructor.h b/WebCore/bindings/js/JSWebSocketConstructor.h deleted file mode 100644 index 633e612..0000000 --- a/WebCore/bindings/js/JSWebSocketConstructor.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 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. - */ - -#ifndef JSWebSocketConstructor_h -#define JSWebSocketConstructor_h - -#if ENABLE(WEB_SOCKETS) - -#include "JSDOMBinding.h" - -namespace WebCore { - -class JSWebSocketConstructor : public DOMConstructorObject { - public: - JSWebSocketConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } -}; - -} // namespace WebCore - -#endif // ENABLE(WEB_SOCKETS) - -#endif // JSWebSocketConstructor_h diff --git a/WebCore/bindings/js/JSWebSocketCustom.cpp b/WebCore/bindings/js/JSWebSocketCustom.cpp index eb0fda0..3567206 100644 --- a/WebCore/bindings/js/JSWebSocketCustom.cpp +++ b/WebCore/bindings/js/JSWebSocketCustom.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2009 Apple, Inc. All rights reserved. + * Copyright (C) 2009, 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 @@ -44,21 +44,34 @@ using namespace JSC; namespace WebCore { -// Custom functions -JSValue JSWebSocket::send(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecState* exec) { - if (exec->argumentCount() < 1) - return throwError(exec, createSyntaxError(exec, "Not enough arguments")); + JSWebSocketConstructor* jsConstructor = static_cast<JSWebSocketConstructor*>(exec->callee()); + ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); + if (!context) + return throwVMError(exec, createReferenceError(exec, "WebSocket constructor associated document is unavailable")); - const String& msg = ustringToString(exec->argument(0).toString(exec)); + if (!exec->argumentCount()) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + + const String& urlString = ustringToString(exec->argument(0).toString(exec)); if (exec->hadException()) - return throwError(exec, createSyntaxError(exec, "bad message data.")); + return throwVMError(exec, createSyntaxError(exec, "wrong URL")); + const KURL& url = context->completeURL(urlString); + RefPtr<WebSocket> webSocket = WebSocket::create(context); ExceptionCode ec = 0; - JSValue ret = jsBoolean(impl()->send(msg, ec)); + if (exec->argumentCount() < 2) + webSocket->connect(url, ec); + else { + const String& protocol = ustringToString(exec->argument(1).toString(exec)); + if (exec->hadException()) + return JSValue::encode(JSValue()); + webSocket->connect(url, protocol, ec); + } setDOMException(exec, ec); - return ret; + return JSValue::encode(CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), WebSocket, webSocket.get())); } -} // namespace WebCore +} // namespace WebCore #endif diff --git a/WebCore/bindings/js/JSWorkerConstructor.cpp b/WebCore/bindings/js/JSWorkerConstructor.cpp deleted file mode 100644 index 13d8ddc..0000000 --- a/WebCore/bindings/js/JSWorkerConstructor.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(WORKERS) - -#include "JSWorkerConstructor.h" - -#include "Document.h" -#include "ExceptionCode.h" -#include "JSDOMWindowCustom.h" -#include "JSWorker.h" -#include "Worker.h" -#include <runtime/Error.h> - -using namespace JSC; - -namespace WebCore { - -const ClassInfo JSWorkerConstructor::s_info = { "WorkerConstructor", 0, 0, 0 }; - -JSWorkerConstructor::JSWorkerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWorkerConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSWorkerPrototype::self(exec, globalObject), None); - putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); -} - -static EncodedJSValue JSC_HOST_CALL constructWorker(ExecState* exec) -{ - JSWorkerConstructor* jsConstructor = static_cast<JSWorkerConstructor*>(exec->callee()); - - if (!exec->argumentCount()) - return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); - - UString scriptURL = exec->argument(0).toString(exec); - if (exec->hadException()) - return JSValue::encode(JSValue()); - - // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject. - DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); - - ExceptionCode ec = 0; - RefPtr<Worker> worker = Worker::create(ustringToString(scriptURL), window->document(), ec); - if (ec) { - setDOMException(exec, ec); - return JSValue::encode(JSValue()); - } - - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), worker.release()))); -} - -ConstructType JSWorkerConstructor::getConstructData(ConstructData& constructData) -{ - constructData.native.function = constructWorker; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSWorkerConstructor.h b/WebCore/bindings/js/JSWorkerConstructor.h deleted file mode 100644 index c845fa6..0000000 --- a/WebCore/bindings/js/JSWorkerConstructor.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSWorkerConstructor_h -#define JSWorkerConstructor_h - -#if ENABLE(WORKERS) - -#include "JSDOMBinding.h" - -namespace WebCore { - - class JSWorkerConstructor : public DOMConstructorObject { - public: - JSWorkerConstructor(JSC::ExecState*, JSDOMGlobalObject*); - - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} // namespace WebCore - -#endif // ENABLE(WORKERS) - -#endif // JSWorkerConstructor_h diff --git a/WebCore/bindings/js/JSWorkerContextCustom.cpp b/WebCore/bindings/js/JSWorkerContextCustom.cpp index 2bde58b..b443f90 100644 --- a/WebCore/bindings/js/JSWorkerContextCustom.cpp +++ b/WebCore/bindings/js/JSWorkerContextCustom.cpp @@ -31,6 +31,7 @@ #if ENABLE(DATABASE) #include "Database.h" +#include "DatabaseSync.h" #include "JSDatabase.h" #include "JSDatabaseCallback.h" #include "JSDatabaseSync.h" @@ -39,10 +40,9 @@ #include "JSDOMBinding.h" #include "JSDOMGlobalObject.h" #include "JSEventListener.h" -#include "JSEventSourceConstructor.h" -#include "JSMessageChannelConstructor.h" +#include "JSEventSource.h" +#include "JSMessageChannel.h" #include "JSMessagePort.h" -#include "JSWebSocketConstructor.h" #include "JSWorkerLocation.h" #include "JSWorkerNavigator.h" #include "JSXMLHttpRequest.h" @@ -52,6 +52,10 @@ #include "WorkerNavigator.h" #include <interpreter/Interpreter.h> +#if ENABLE(WEB_SOCKETS) +#include "JSWebSocket.h" +#endif + using namespace JSC; namespace WebCore { diff --git a/WebCore/bindings/js/JSWorkerCustom.cpp b/WebCore/bindings/js/JSWorkerCustom.cpp index 64d9d41..27580ae 100644 --- a/WebCore/bindings/js/JSWorkerCustom.cpp +++ b/WebCore/bindings/js/JSWorkerCustom.cpp @@ -32,6 +32,8 @@ #include "JSDOMGlobalObject.h" #include "JSMessagePortCustom.h" #include "Worker.h" +#include "JSDOMWindowCustom.h" +#include <runtime/Error.h> using namespace JSC; @@ -42,6 +44,30 @@ JSC::JSValue JSWorker::postMessage(JSC::ExecState* exec) return handlePostMessage(exec, impl()); } +EncodedJSValue JSC_HOST_CALL JSWorkerConstructor::constructJSWorker(ExecState* exec) +{ + JSWorkerConstructor* jsConstructor = static_cast<JSWorkerConstructor*>(exec->callee()); + + if (!exec->argumentCount()) + return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + + UString scriptURL = exec->argument(0).toString(exec); + if (exec->hadException()) + return JSValue::encode(JSValue()); + + // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject. + DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); + + ExceptionCode ec = 0; + RefPtr<Worker> worker = Worker::create(ustringToString(scriptURL), window->document(), ec); + if (ec) { + setDOMException(exec, ec); + return JSValue::encode(JSValue()); + } + + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), worker.release()))); +} + } // namespace WebCore #endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp b/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp deleted file mode 100644 index b2ebef3..0000000 --- a/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(XSLT) - -#include "JSXSLTProcessorConstructor.h" - -#include "JSXSLTProcessor.h" -#include "XSLTProcessor.h" -#include <wtf/RefPtr.h> - -using namespace JSC; - -namespace WebCore { - -ASSERT_CLASS_FITS_IN_CELL(JSXSLTProcessorConstructor); - -const ClassInfo JSXSLTProcessorConstructor::s_info = { "XSLTProcessorConsructor", 0, 0, 0 }; - -JSXSLTProcessorConstructor::JSXSLTProcessorConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSXSLTProcessorConstructor::createStructure(globalObject->objectPrototype()), globalObject) -{ - putDirect(exec->propertyNames().prototype, JSXSLTProcessorPrototype::self(exec, globalObject), None); -} - -static EncodedJSValue JSC_HOST_CALL constructXSLTProcessor(ExecState* exec) -{ - JSXSLTProcessorConstructor* jsConstructor = static_cast<JSXSLTProcessorConstructor*>(exec->callee()); - return JSValue::encode(CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), XSLTProcessor, XSLTProcessor::create().get())); -} - -ConstructType JSXSLTProcessorConstructor::getConstructData(ConstructData& constructData) -{ - constructData.native.function = constructXSLTProcessor; - return ConstructTypeHost; -} - -} // namespace WebCore - -#endif // ENABLE(XSLT) diff --git a/WebCore/bindings/js/JSXSLTProcessorConstructor.h b/WebCore/bindings/js/JSXSLTProcessorConstructor.h deleted file mode 100644 index 96fa607..0000000 --- a/WebCore/bindings/js/JSXSLTProcessorConstructor.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSXSLTProcessorConstructor_h -#define JSXSLTProcessorConstructor_h - -#if ENABLE(XSLT) - -#include "JSDOMBinding.h" - -namespace WebCore { - - class JSXSLTProcessorConstructor : public DOMConstructorObject { - public: - JSXSLTProcessorConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} // namespace WebCore - -#endif // ENABLE(XSLT) - -#endif // JSXSLTProcessorConstructor_h diff --git a/WebCore/bindings/js/JSXSLTProcessorCustom.cpp b/WebCore/bindings/js/JSXSLTProcessorCustom.cpp index 63aa2b5..3423272 100644 --- a/WebCore/bindings/js/JSXSLTProcessorCustom.cpp +++ b/WebCore/bindings/js/JSXSLTProcessorCustom.cpp @@ -116,6 +116,12 @@ JSValue JSXSLTProcessor::removeParameter(ExecState* exec) return jsUndefined(); } +EncodedJSValue JSC_HOST_CALL JSXSLTProcessorConstructor::constructJSXSLTProcessor(ExecState* exec) +{ + JSXSLTProcessorConstructor* jsConstructor = static_cast<JSXSLTProcessorConstructor*>(exec->callee()); + return JSValue::encode(CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), XSLTProcessor, XSLTProcessor::create().get())); +} + } // namespace WebCore #endif // ENABLE(XSLT) diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 5c4bd4c..6f0457a 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -21,6 +21,7 @@ #include "config.h" #include "ScriptController.h" +#include "DocumentParser.h" #include "Event.h" #include "EventNames.h" #include "Frame.h" @@ -60,7 +61,6 @@ void ScriptController::initializeThreading() ScriptController::ScriptController(Frame* frame) : m_frame(frame) - , m_handlerLineNumber(0) , m_sourceURL(0) , m_inExecuteScript(false) , m_processingTimerCallback(false) @@ -235,6 +235,14 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world) return windowShell; } +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()) + return parser->lineNumber() + 1; + return 0; +} + bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const { if (m_allowPopupsFromPlugin || isJavaScriptAnchorNavigation()) diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index ee7cc7d..0debf39 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -117,9 +117,8 @@ public: ScriptValue evaluate(const ScriptSourceCode&, ShouldAllowXSS shouldAllowXSS = DoNotAllowXSS); ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*, ShouldAllowXSS shouldAllowXSS = DoNotAllowXSS); - void setEventHandlerLineNumber(int lineno) { m_handlerLineNumber = lineno; } - int eventHandlerLineNumber() { return m_handlerLineNumber; } - + int eventHandlerLineNumber() const; + void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; } bool processingUserGesture(DOMWrapperWorld*) const; bool anyPageIsProcessingUserGesture() const; @@ -187,7 +186,6 @@ private: ShellMap m_windowShells; Frame* m_frame; - int m_handlerLineNumber; const String* m_sourceURL; bool m_inExecuteScript; diff --git a/WebCore/bindings/js/ScriptDebugServer.cpp b/WebCore/bindings/js/ScriptDebugServer.cpp index eb0923b..1fd9ae4 100644 --- a/WebCore/bindings/js/ScriptDebugServer.cpp +++ b/WebCore/bindings/js/ScriptDebugServer.cpp @@ -69,6 +69,7 @@ ScriptDebugServer::ScriptDebugServer() , m_pauseOnExceptionsState(DontPauseOnExceptions) , m_pauseOnNextStatement(false) , m_paused(false) + , m_pausedPage(0) , m_doneProcessingDebuggerEvents(true) , m_breakpointsActivated(true) , m_pauseOnCallFrame(0) @@ -113,8 +114,6 @@ void ScriptDebugServer::removeListener(ScriptDebugListener* listener, Page* page } didRemoveListener(page); - if (!hasListeners()) - didRemoveLastListener(); } void ScriptDebugServer::pageCreated(Page* page) @@ -324,7 +323,7 @@ void ScriptDebugServer::sourceParsed(ExecState* exec, const SourceCode& source, if (m_callingListeners) return; - Page* page = toPage(exec->dynamicGlobalObject()); + Page* page = toPage(exec->lexicalGlobalObject()); if (!page) return; @@ -360,8 +359,6 @@ void ScriptDebugServer::dispatchFunctionToListeners(JavaScriptExecutionCallback m_callingListeners = true; - ASSERT(hasListeners()); - if (ListenerSet* pageListeners = m_pageListenersMap.get(page)) { ASSERT(!pageListeners->isEmpty()); dispatchFunctionToListeners(*pageListeners, callback); @@ -443,6 +440,7 @@ void ScriptDebugServer::pauseIfNeeded(Page* page) m_pauseOnCallFrame = 0; m_pauseOnNextStatement = false; m_paused = true; + m_pausedPage = page; dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidPause, page); @@ -458,6 +456,7 @@ void ScriptDebugServer::pauseIfNeeded(Page* page) setJavaScriptPaused(page->group(), false); m_paused = false; + m_pausedPage = 0; dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue, page); } @@ -573,29 +572,19 @@ void ScriptDebugServer::recompileAllJSFunctions(Timer<ScriptDebugServer>*) void ScriptDebugServer::didAddListener(Page* page) { recompileAllJSFunctionsSoon(); - - if (page) - page->setDebugger(this); - else - Page::setDebuggerForAllPages(this); + page->setDebugger(this); } void ScriptDebugServer::didRemoveListener(Page* page) { - if (page && hasListenersInterestedInPage(page)) + if (hasListenersInterestedInPage(page)) return; - recompileAllJSFunctionsSoon(); + if (m_pausedPage == page) + m_doneProcessingDebuggerEvents = true; - if (page) - page->setDebugger(0); - else - Page::setDebuggerForAllPages(0); -} - -void ScriptDebugServer::didRemoveLastListener() -{ - m_doneProcessingDebuggerEvents = true; + recompileAllJSFunctionsSoon(); + page->setDebugger(0); } } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptDebugServer.h b/WebCore/bindings/js/ScriptDebugServer.h index a45fae4..dcf290e 100644 --- a/WebCore/bindings/js/ScriptDebugServer.h +++ b/WebCore/bindings/js/ScriptDebugServer.h @@ -101,7 +101,6 @@ private: ~ScriptDebugServer(); bool hasBreakpoint(intptr_t sourceID, unsigned lineNumber) const; - bool hasListeners() const { return !m_pageListenersMap.isEmpty(); } bool hasListenersInterestedInPage(Page*); void setJavaScriptPaused(const PageGroup&, bool paused); @@ -131,7 +130,6 @@ private: void didAddListener(Page*); void didRemoveListener(Page*); - void didRemoveLastListener(); typedef HashMap<Page*, ListenerSet*> PageListenersMap; typedef HashMap<intptr_t, SourceBreakpoints> BreakpointsMap; @@ -141,6 +139,7 @@ private: PauseOnExceptionsState m_pauseOnExceptionsState; bool m_pauseOnNextStatement; bool m_paused; + Page* m_pausedPage; bool m_doneProcessingDebuggerEvents; bool m_breakpointsActivated; JavaScriptCallFrame* m_pauseOnCallFrame; diff --git a/WebCore/bindings/js/ScriptProfiler.h b/WebCore/bindings/js/ScriptProfiler.h index a86bcfb..16195a3 100644 --- a/WebCore/bindings/js/ScriptProfiler.h +++ b/WebCore/bindings/js/ScriptProfiler.h @@ -39,6 +39,7 @@ class ScriptProfiler : public Noncopyable { public: static void start(ScriptState* state, const String& title); static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); + static void takeHeapSnapshot() { } }; } // namespace WebCore diff --git a/WebCore/bindings/scripts/CodeGenerator.pm b/WebCore/bindings/scripts/CodeGenerator.pm index 7c0f427..fbcee02 100644 --- a/WebCore/bindings/scripts/CodeGenerator.pm +++ b/WebCore/bindings/scripts/CodeGenerator.pm @@ -381,5 +381,86 @@ sub LinkOverloadedFunctions } } +sub AttributeNameForGetterAndSetter +{ + my ($generator, $attribute) = @_; + + my $attributeName = $attribute->signature->name; + + # Avoid clash with C++ keyword. + $attributeName = "_operator" if $attributeName eq "operator"; + + # SVG animated types need to use a special attribute name. + # The rest of the special casing for SVG animated types is handled in the language-specific code generators. + $attributeName .= "Animated" if $generator->IsSVGAnimatedType($generator->StripModule($attribute->signature->type)); + + return $attributeName; +} + +sub ContentAttributeName +{ + my ($generator, $implIncludes, $interfaceName, $attribute) = @_; + + my $contentAttributeName = $attribute->signature->extendedAttributes->{"Reflect"} + || $attribute->signature->extendedAttributes->{"ReflectURL"}; + return undef if !$contentAttributeName; + + $contentAttributeName = lc $generator->AttributeNameForGetterAndSetter($attribute) if $contentAttributeName eq "1"; + + my $namespace = $generator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + + $implIncludes->{"${namespace}.h"} = 1; + return "WebCore::${namespace}::${contentAttributeName}Attr"; +} + +sub GetterExpressionPrefix +{ + my ($generator, $implIncludes, $interfaceName, $attribute) = @_; + + my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute); + + if (!$contentAttributeName) { + return $generator->WK_lcfirst($generator->AttributeNameForGetterAndSetter($attribute)) . "("; + } + + my $functionName; + if ($attribute->signature->extendedAttributes->{"ReflectURL"}) { + $functionName = "getURLAttribute"; + } elsif ($attribute->signature->type eq "boolean") { + $functionName = "hasAttribute"; + } elsif ($attribute->signature->type eq "long") { + $functionName = "getIntegralAttribute"; + } elsif ($attribute->signature->type eq "unsigned long") { + $functionName = "getUnsignedIntegralAttribute"; + } else { + $functionName = "getAttribute"; + } + + return "$functionName($contentAttributeName" +} + +sub SetterExpressionPrefix +{ + my ($generator, $implIncludes, $interfaceName, $attribute) = @_; + + my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute); + + if (!$contentAttributeName) { + return "set" . $generator->WK_ucfirst($generator->AttributeNameForGetterAndSetter($attribute)) . "("; + } + + my $functionName; + if ($attribute->signature->type eq "boolean") { + $functionName = "setBooleanAttribute"; + } elsif ($attribute->signature->type eq "long") { + $functionName = "setIntegralAttribute"; + } elsif ($attribute->signature->type eq "unsigned long") { + $functionName = "setUnsignedIntegralAttribute"; + } else { + $functionName = "setAttribute"; + } + + return "$functionName($contentAttributeName, " +} 1; diff --git a/WebCore/bindings/scripts/CodeGeneratorCPP.pm b/WebCore/bindings/scripts/CodeGeneratorCPP.pm index f441b0e..7df91ca 100644 --- a/WebCore/bindings/scripts/CodeGeneratorCPP.pm +++ b/WebCore/bindings/scripts/CodeGeneratorCPP.pm @@ -145,7 +145,6 @@ sub GetClassName # special cases return "WebDOMString" if $codeGenerator->IsStringType($name) or $name eq "SerializedScriptValue"; - return "WebDOMAbstractView" if $name eq "DOMWindow"; return "WebDOMObject" if $name eq "DOMObject"; return "bool" if $name eq "boolean"; return $name if $codeGenerator->IsPrimitiveType($name); @@ -155,10 +154,7 @@ sub GetClassName sub GetImplClassName { - my $name = $codeGenerator->StripModule(shift); - - return "DOMWindow" if $name eq "AbstractView"; - return $name; + return $codeGenerator->StripModule(shift); } sub GetParentImplClassName @@ -203,7 +199,8 @@ sub ShouldSkipTypeInImplementation return 1 if $typeInfo->signature->extendedAttributes->{"CustomArgumentHandling"} or $typeInfo->signature->extendedAttributes->{"CustomGetter"} - or $typeInfo->signature->extendedAttributes->{"NeedsUserGestureCheck"}; + or $typeInfo->signature->extendedAttributes->{"NeedsUserGestureCheck"} + or $typeInfo->signature->extendedAttributes->{"CPPCustom"}; # FIXME: We don't generate bindings for SVG related interfaces yet return 1 if $typeInfo->signature->name =~ /getSVGDocument/; @@ -297,12 +294,6 @@ sub AddIncludesForType return; } - if ($type eq "DOMWindow") { - $implIncludes{"DOMWindow.h"} = 1; - $implIncludes{"WebDOMAbstractView.h"} = 1; - return; - } - if ($type eq "EventListener") { $implIncludes{"WebNativeEventListener.h"} = 1; return; @@ -388,12 +379,12 @@ sub GenerateHeader push(@headerContent, " explicit $className($implClassNameWithNamespace*);\n"); # Copy constructor on classes which have the d-ptr - if (@{$dataNode->parents} eq 0) { + if ($parentName eq "WebDOMObject") { push(@headerContent, " $className(const $className&);\n"); } # Destructor - if (@{$dataNode->parents} eq 0) { + if ($parentName eq "WebDOMObject") { push(@headerContent, " ~$className();\n"); } @@ -505,7 +496,7 @@ sub GenerateHeader push(@headerContent, "\n"); push(@headerContent, " $implClassNameWithNamespace* impl() const;\n"); - if (@{$dataNode->parents} eq 0) { + if ($parentName eq "WebDOMObject") { push(@headerContent, "\nprotected:\n"); push(@headerContent, " struct ${className}Private;\n"); push(@headerContent, " ${className}Private* m_impl;\n"); @@ -607,7 +598,7 @@ sub GenerateImplementation push(@implContent, "#include <wtf/RefPtr.h>\n\n"); # Private datastructure, encapsulating WebCore types - if (@{$dataNode->parents} eq 0) { + if ($baseClass eq "WebDOMObject") { push(@implContent, "struct ${className}::${className}Private {\n"); push(@implContent, " ${className}Private($implClassNameWithNamespace* object = 0)\n"); push(@implContent, " : impl(object)\n"); @@ -620,12 +611,12 @@ sub GenerateImplementation # Constructor push(@implContent, "${className}::$className()\n"); push(@implContent, " : ${baseClass}()\n"); - push(@implContent, " , m_impl(0)\n") if (@{$dataNode->parents} eq 0); + push(@implContent, " , m_impl(0)\n") if ($baseClass eq "WebDOMObject"); push(@implContent, "{\n"); push(@implContent, "}\n\n"); push(@implContent, "${className}::$className($implClassNameWithNamespace* impl)\n"); - if (@{$dataNode->parents} eq 0) { + if ($baseClass eq "WebDOMObject") { push(@implContent, " : ${baseClass}()\n"); push(@implContent, " , m_impl(new ${className}Private(impl))\n"); push(@implContent, "{\n"); @@ -679,18 +670,7 @@ sub GenerateImplementation # - GETTER my $getterSig = "$attributeType $className\:\:$attributeName() const\n"; my $hasGetterException = @{$attribute->getterExceptions}; - my $getterContentHead; - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; - $getterContentHead = "impl()->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr"; - } else { - $getterContentHead = "impl()->" . $codeGenerator->WK_lcfirst($attributeName) . "("; - } + my $getterContentHead = "impl()->" . $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); my $getterContentTail = ")"; # Special cases @@ -698,8 +678,6 @@ sub GenerateImplementation if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { $getterContentHead = "WebCore::String::number(" . $getterContentHead; $getterContentTail .= ")"; - } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $getterContentTail .= ".toInt()"; } elsif ($attribute->signature->type eq "SerializedScriptValue") { $getterContentHead = "$getterContentHead"; $getterContentTail .= "->toString()"; @@ -750,10 +728,8 @@ sub GenerateImplementation my $argName = "new" . ucfirst($attributeName); my $arg = GetCPPTypeGetter($argName, $idlType); - # The definition of ConvertFromString and ConvertToString is flipped for the setter - if ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $arg = "WebCore::String::number($arg)"; - } elsif ($attribute->signature->extendedAttributes->{"ConvertToString"}) { + # The definition of ConvertToString is flipped for the setter + if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { $arg = "WebCore::String($arg).toInt()"; } @@ -762,18 +738,10 @@ sub GenerateImplementation push(@implContent, "{\n"); push(@implContent, AddEarlyReturnStatement()); - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; push(@implContent, " $exceptionInit\n") if $hasSetterException; my $ec = $hasSetterException ? ", ec" : ""; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - push(@implContent, " impl()->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, $arg$ec);\n"); - } else { - push(@implContent, " impl()->$coreSetterName($arg$ec);\n"); - } + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + push(@implContent, " impl()->$setterExpressionPrefix$arg$ec);\n"); push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException; push(@implContent, "}\n\n"); } diff --git a/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/WebCore/bindings/scripts/CodeGeneratorGObject.pm index e98c661..ef2a125 100644 --- a/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -301,11 +301,29 @@ sub GetWriteableProperties { return @result; } +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } + } else { + return ""; + } +} + sub GenerateProperty { my $attribute = shift; my $interfaceName = shift; my @writeableProperties = @{shift @_}; + my $conditionalString = GenerateConditionalString($attribute->signature); my $camelPropName = $attribute->signature->name; my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName); my $getPropNameFunction = $codeGenerator->WK_lcfirst($camelPropName); @@ -314,7 +332,9 @@ sub GenerateProperty { my $propNameCaps = uc($propName); $propName =~ s/_/-/g; my ${propEnum} = "PROP_${propNameCaps}"; + push(@cBodyPriv, "#if ${conditionalString}\n") if $conditionalString; push(@cBodyPriv, " ${propEnum},\n"); + push(@cBodyPriv, "#endif /* ${conditionalString} */\n") if $conditionalString; my $propType = $attribute->signature->type; my ${propGType} = decamelize($propType); @@ -341,35 +361,26 @@ sub GenerateProperty { my $convertFunction = ""; if ($gtype eq "string") { $convertFunction = "WebCore::String::fromUTF8"; - } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $convertFunction = "WebCore::String::number"; } - my $setterContentHead; - my $getterContentHead; - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $camelPropName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; - $setterContentHead = "coreSelf->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${convertFunction}(g_value_get_$gtype(value))"; - $getterContentHead = "coreSelf->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr"; - } else { - $setterContentHead = "coreSelf->set${setPropNameFunction}(${convertFunction}(g_value_get_$gtype(value))"; - $getterContentHead = "coreSelf->${getPropNameFunction}("; - } + my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + + my $getterContentHead = "coreSelf->$getterExpressionPrefix"; + my $setterContentHead = "coreSelf->$setterExpressionPrefix${convertFunction}(g_value_get_$gtype(value))"; if (grep {$_ eq $attribute} @writeableProperties) { + push(@txtSetProps, "#if ${conditionalString}\n") if $conditionalString; push(@txtSetProps, " case ${propEnum}:\n {\n"); push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; push(@txtSetProps, " ${setterContentHead}"); push(@txtSetProps, ", ec") if @{$attribute->setterExceptions}; push(@txtSetProps, ");\n"); push(@txtSetProps, " break;\n }\n"); + push(@txtSetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; } + push(@txtGetProps, "#if ${conditionalString}\n") if $conditionalString; push(@txtGetProps, " case ${propEnum}:\n {\n"); my $exception = ""; @@ -392,17 +403,6 @@ EOF $done = 1; } - if($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - # TODO: Add other conversion functions for different types. Current - # IDLs only list longs. - if($gtype eq "long") { - $convertFunction = ""; - $postConvertFunction = ".toInt()"; - } else { - die "Can't convert to type ${gtype}."; - } - } - # FIXME: get rid of this glitch? my $_gtype = $gtype; if ($gtype eq "ushort") { @@ -410,10 +410,11 @@ EOF } if (!$done) { - push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getPropNameFunction}(${exception})${postConvertFunction});\n"); + push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getterExpressionPrefix}${exception})${postConvertFunction});\n"); } push(@txtGetProps, " break;\n }\n"); + push(@txtGetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; my %param_spec_options = ("int", "G_MININT, /* min */\nG_MAXINT, /* max */\n0, /* default */", "boolean", "FALSE, /* default */", @@ -439,7 +440,9 @@ EOF $param_spec_options{$gtype} ${gparamflag})); EOF + push(@txtInstallProps, "#if ${conditionalString}\n") if $conditionalString; push(@txtInstallProps, $txtInstallProp); + push(@txtInstallProps, "#endif /* ${conditionalString} */\n") if $conditionalString; } my %breakWords = ("before" => 1, "can" => 1, "context" => 1, "dbl" => 1, "drag" => 1, @@ -755,10 +758,11 @@ sub GenerateFunction { } my $functionSigName = $function->signature->name; - my $functionSigType = $function->signature->type; + my $functionSigType = $prefix eq "set_" ? "void" : $function->signature->type; my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($functionSigName); my $returnType = GetGlibTypeName($functionSigType); my $returnValueIsGDOMType = IsGDOMClassType($functionSigType); + my $conditionalString = GenerateConditionalString($function->signature); my $functionSig = "${className}* self"; @@ -788,7 +792,7 @@ sub GenerateFunction { } } if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) { - $paramName = "_g_" . $paramName; + $paramName = "converted_" . $paramName; } if ($callImplParams) { $callImplParams .= ", $paramName"; @@ -812,7 +816,12 @@ sub GenerateFunction { $functionSig .= ", GError **error"; } - push(@hBody, "WEBKIT_API $returnType\n$functionName($functionSig);\n\n"); + push(@hBody, "#if ${conditionalString}\n") if $conditionalString; + push(@hBody, "WEBKIT_API $returnType\n$functionName($functionSig);\n"); + push(@hBody, "#endif /* ${conditionalString} */\n") if $conditionalString; + push(@hBody, "\n"); + + push(@cBody, "#if ${conditionalString}\n") if $conditionalString; push(@cBody, "$returnType\n$functionName($functionSig)\n{\n"); if ($conditionalMethods{$functionName}) { @@ -821,9 +830,9 @@ sub GenerateFunction { if ($returnType ne "void") { # TODO: return proper default result - push(@cBody, " g_return_val_if_fail (self, 0);\n"); + push(@cBody, " g_return_val_if_fail(self, 0);\n"); } else { - push(@cBody, " g_return_if_fail (self);\n"); + push(@cBody, " g_return_if_fail(self);\n"); } # The WebKit::core implementations check for NULL already; no need to @@ -838,9 +847,9 @@ sub GenerateFunction { if (!$paramTypeIsPrimitive) { if ($returnType ne "void") { # TODO: return proper default result - push(@cBody, " g_return_val_if_fail ($paramName, 0);\n"); + push(@cBody, " g_return_val_if_fail($paramName, 0);\n"); } else { - push(@cBody, " g_return_if_fail ($paramName);\n"); + push(@cBody, " g_return_if_fail($paramName);\n"); } } } @@ -852,19 +861,19 @@ sub GenerateFunction { my $paramIsGDOMType = IsGDOMClassType($paramIDLType); if ($paramIDLType eq "DOMString") { - push(@cBody, " WebCore::String _g_${paramName} = WebCore::String::fromUTF8($paramName);\n"); + push(@cBody, " WebCore::String converted_${paramName} = WebCore::String::fromUTF8($paramName);\n"); } elsif ($paramIDLType eq "CompareHow") { - push(@cBody, " WebCore::Range::CompareHow _g_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); + push(@cBody, " WebCore::Range::CompareHow converted_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); } elsif ($paramIsGDOMType) { - push(@cBody, " WebCore::${paramIDLType} * _g_${paramName} = WebKit::core($paramName);\n"); + push(@cBody, " WebCore::${paramIDLType} * converted_${paramName} = WebKit::core($paramName);\n"); if ($returnType ne "void") { # TODO: return proper default result - push(@cBody, " g_return_val_if_fail (_g_${paramName}, 0);\n"); + push(@cBody, " g_return_val_if_fail(converted_${paramName}, 0);\n"); } else { - push(@cBody, " g_return_if_fail (_g_${paramName});\n"); + push(@cBody, " g_return_if_fail(converted_${paramName});\n"); } } - $returnParamName = "_g_".$paramName if $param->extendedAttributes->{"Return"}; + $returnParamName = "converted_".$paramName if $param->extendedAttributes->{"Return"}; } my $assign = ""; @@ -923,35 +932,25 @@ EOF return; } elsif ($functionSigType eq "DOMString") { my $getterContentHead; - my $reflect = $function->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; - $getterContentHead = "${assign}convertToUTF8String(item->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr));\n"; + if ($prefix) { + my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $function); + $getterContentHead = "${assign}convertToUTF8String(item->$getterExpressionPrefix${exceptions}));\n"; } else { $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n"; } - push(@cBody, " ${getterContentHead}"); } else { - my $setterContentHead; - my $reflect = $function->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL); - $contentAttributeName =~ s/set//; - $contentAttributeName = $codeGenerator->WK_lcfirst($contentAttributeName); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - $setterContentHead = "${assign}${assignPre}item->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${callImplParams}${exceptions}${assignPost});\n"; + my $contentHead; + if ($prefix eq "get_") { + my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $function); + $contentHead = "${assign}${assignPre}item->$getterExpressionPrefix${callImplParams}${exceptions}${assignPost});\n"; + } elsif ($prefix eq "set_") { + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $function); + $contentHead = "${assign}${assignPre}item->$setterExpressionPrefix${callImplParams}${exceptions}${assignPost});\n"; } else { - $setterContentHead = "${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n"; + $contentHead = "${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n"; } - - push(@cBody, " ${setterContentHead}"); + push(@cBody, " ${contentHead}"); if(@{$function->raisesExceptions}) { my $exceptionHandling = << "EOF"; @@ -982,7 +981,9 @@ EOF push(@cBody, "#endif\n"); } - push(@cBody, "}\n\n"); + push(@cBody, "}\n"); + push(@cBody, "#endif /* ${conditionalString} */\n") if $conditionalString; + push(@cBody, "\n"); } sub ClassHasFunction { @@ -1014,7 +1015,6 @@ sub GenerateFunctions { # This will conflict with the get_type() function we define to return a GType # according to GObject conventions. Skip this for now. || $attribute->signature->name eq "URL" # TODO: handle this - || $attribute->signature->extendedAttributes->{"ConvertFromString"} # TODO: handle this ) { next TOP; } @@ -1044,8 +1044,8 @@ sub GenerateFunctions { $function = new domFunction(); $function->signature(new domSignature()); - $function->signature->name($setname); - $function->signature->type("void"); + $function->signature->name($attribute->signature->name); + $function->signature->type($attribute->signature->type); $function->signature->extendedAttributes($attribute->signature->extendedAttributes); my $param = new domSignature(); @@ -1058,7 +1058,7 @@ sub GenerateFunctions { $function->raisesExceptions($attribute->setterExceptions); - $object->GenerateFunction($interfaceName, $function, ""); + $object->GenerateFunction($interfaceName, $function, "set_"); } } @@ -1128,7 +1128,7 @@ sub GenerateEndHeader { my $guard = $className . "_h"; push(@hBody, "G_END_DECLS\n\n"); - push(@hBody, "#endif /* $guard */\n"); + push(@hPrefixGuardEnd, "#endif /* $guard */\n"); } sub GeneratePrivateHeader { @@ -1189,7 +1189,7 @@ EOF #endif /* ${guard} */ EOF print PRIVHEADER $text; - + close(PRIVHEADER); } @@ -1248,6 +1248,11 @@ sub Generate { my $parentGObjType = GetParentGObjType($dataNode); my $interfaceName = $dataNode->name; + # Add the guard if the 'Conditional' extended attribute exists + my $conditionalString = GenerateConditionalString($dataNode); + push(@conditionGuardStart, "#if ${conditionalString}\n\n") if $conditionalString; + push(@conditionGuardEnd, "#endif /* ${conditionalString} */\n") if $conditionalString; + # Add the default impl header template @cPrefix = split("\r", $licenceTemplate); push(@cPrefix, "\n"); @@ -1308,6 +1313,7 @@ sub WriteData { print HEADER "\n"; print HEADER @hBodyPre; print HEADER @hBody; + print HEADER @hPrefixGuardEnd; close(HEADER); @@ -1318,6 +1324,7 @@ sub WriteData { print IMPL @cPrefix; print IMPL "#include <glib-object.h>\n"; print IMPL "#include \"config.h\"\n\n"; + print IMPL @conditionGuardStart; print IMPL "#include <wtf/GetPtr.h>\n"; print IMPL "#include <wtf/RefPtr.h>\n"; print IMPL map { "#include \"$_\"\n" } sort keys(%implIncludes); @@ -1326,6 +1333,7 @@ sub WriteData { print IMPL "\n"; print IMPL @cBodyPriv; + print IMPL @conditionGuardEnd; close(IMPL); diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index c3521bf..4e2e911 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -3,7 +3,7 @@ # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> # Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> -# Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +# Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> # Copyright (C) Research In Motion Limited 2010. All rights reserved. # @@ -1170,7 +1170,7 @@ END push(@implContent, " return ${functionName}$overload->{overloadIndex}(exec);\n"); } push(@implContent, <<END); - return JSValue::encode(throwTypeError(exec)); + return throwVMTypeError(exec); } END @@ -1570,20 +1570,9 @@ sub GenerateImplementation push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "castedThis") . ";\n"); } } else { + my $getterExpression = "imp->" . $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute) . ")"; + my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, $getterExpression, "castedThis"); push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); - my $value; - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $name : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; - $value = "imp->$getAttributeFunctionName(${namespace}::${contentAttributeName}Attr)" - } else { - $value = "imp->$implGetterFunctionName()"; - } - my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, $value, "castedThis"); if ($codeGenerator->IsSVGAnimatedType($type)) { push(@implContent, " RefPtr<$type> obj = $jsType;\n"); push(@implContent, " JSValue result = toJS(exec, castedThis->globalObject(), obj.get(), imp);\n"); @@ -1734,17 +1723,10 @@ sub GenerateImplementation push(@implContent, " imp->commitChange(podImp, castedThis);\n"); } else { my $nativeValue = JSValueToNative($attribute->signature, "value"); + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $name : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - push(@implContent, " imp->setAttribute(${namespace}::${contentAttributeName}Attr, $nativeValue"); - } else { - push(@implContent, " imp->set$implSetterFunctionName($nativeValue"); - } + push(@implContent, " imp->$setterExpressionPrefix$nativeValue"); push(@implContent, ", ec") if @{$attribute->setterExceptions}; push(@implContent, ");\n"); push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions}; @@ -2330,7 +2312,7 @@ sub JSValueToNative return "static_cast<SVGPaint::SVGPaintType>($value.toInt32(exec))" if $type eq "SVGPaintType"; if ($type eq "DOMString") { - return "valueToStringWithNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertNullToNullString"}; + return "valueToStringWithNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertNullToNullString"} || $signature->extendedAttributes->{"Reflect"} || $signature->extendedAttributes->{"ReflectURL"}; return "valueToStringWithUndefinedOrNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertUndefinedOrNullToNullString"}; return "ustringToString($value.toString(exec))"; } @@ -2424,13 +2406,6 @@ sub NativeToJSValue } } - if ($codeGenerator->IsSVGAnimatedType($type)) { - # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++ - $value =~ s/operator\(\)/_operator\(\)/ if ($value =~ /operator/); - $value =~ s/\(\)//; - $value .= "Animated()"; - } - if ($type eq "CSSStyleDeclaration") { $implIncludes{"CSSMutableStyleDeclaration.h"} = 1; } @@ -2766,6 +2741,7 @@ sub GenerateConstructorDefinition my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"}; my $customConstructFunction = $dataNode->extendedAttributes->{"CustomConstructFunction"}; my $callWith = $dataNode->extendedAttributes->{"CallWith"}; + my $numberOfconstructParameters = $dataNode->extendedAttributes->{"ConstructorParameters"}; push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleClassName}Constructor\", 0, &${constructorClassName}Table, 0 };\n\n"); @@ -2773,6 +2749,7 @@ sub GenerateConstructorDefinition push(@$outputArray, " : DOMConstructorObject(${constructorClassName}::createStructure(globalObject->objectPrototype()), globalObject)\n"); push(@$outputArray, "{\n"); push(@$outputArray, " putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), DontDelete | ReadOnly);\n"); + push(@$outputArray, " putDirect(exec->propertyNames().length, jsNumber(exec, ${numberOfconstructParameters}), ReadOnly | DontDelete | DontEnum);\n") if $numberOfconstructParameters; push(@$outputArray, "}\n\n"); push(@$outputArray, "bool ${constructorClassName}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n"); diff --git a/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/WebCore/bindings/scripts/CodeGeneratorObjC.pm index daead72..7d66979 100644 --- a/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -3,7 +3,7 @@ # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> # Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org> # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> -# Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +# Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> # Copyright (C) 2010 Google Inc. # @@ -793,6 +793,12 @@ sub GenerateHeader push(@headerAttributes, $property) if $public; push(@privateHeaderAttributes, $property) unless $public; } else { + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + if ($attributeConditionalString) { + push(@headerAttributes, "#if ${attributeConditionalString}\n") if $public; + push(@privateHeaderAttributes, "#if ${attributeConditionalString}\n") unless $public; + } + # - GETTER my $getter = "- (" . $attributeType . ")" . $attributeName . $declarationSuffix; push(@headerAttributes, $getter) if $public; @@ -804,6 +810,11 @@ sub GenerateHeader push(@headerAttributes, $setter) if $public; push(@privateHeaderAttributes, $setter) unless $public; } + + if ($attributeConditionalString) { + push(@headerAttributes, "#endif\n") if $public; + push(@privateHeaderAttributes, "#endif\n") unless $public; + } } } @@ -1164,13 +1175,9 @@ sub GenerateImplementation } elsif ($attributeName eq "frame") { # Special case attribute frame to be frameBorders. $attributeInterfaceName .= "Borders"; - } elsif ($attributeName eq "ownerDocument") { - # FIXME: for now special case attribute ownerDocument to call document, this is incorrect - # legacy behavior. (see http://bugs.webkit.org/show_bug.cgi?id=10889) - $attributeName = "document"; - } elsif ($codeGenerator->IsSVGAnimatedType($idlType)) { - # Special case for animated types. - $attributeName .= "Animated"; + } elsif ($attributeName eq "operator") { + # Avoid clash with C++ keyword. + $attributeInterfaceName = "_operator"; } $attributeNames{$attributeInterfaceName} = 1; @@ -1178,23 +1185,14 @@ sub GenerateImplementation # - GETTER my $getterSig = "- ($attributeType)$attributeInterfaceName\n"; - # Some SVGFE*Element.idl use 'operator' as attribute name, rewrite as '_operator' to avoid clashes with C/C++ - $attributeName =~ s/operatorAnimated/_operatorAnimated/ if ($attributeName =~ /operatorAnimated/); - $getterSig =~ s/operator/_operator/ if ($getterSig =~ /operator/); + my $getterExpressionPrefix = $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + + # FIXME: Special case attribute ownerDocument to call document. This makes it return the + # document when called on the document itself. Legacy behavior, see <https://bugs.webkit.org/show_bug.cgi?id=10889>. + $getterExpressionPrefix =~ s/\bownerDocument\b/document/; my $hasGetterException = @{$attribute->getterExceptions}; - my $getterContentHead; - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; - $getterContentHead = "IMPL->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr"; - } else { - $getterContentHead = "IMPL->" . $codeGenerator->WK_lcfirst($attributeName) . "("; - } + my $getterContentHead = "IMPL->$getterExpressionPrefix"; my $getterContentTail = ")"; # Special case for DOMSVGNumber @@ -1245,8 +1243,6 @@ sub GenerateImplementation } elsif ($attribute->signature->extendedAttributes->{"ConvertToString"}) { $getterContentHead = "WebCore::String::number(" . $getterContentHead; $getterContentTail .= ")"; - } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $getterContentTail .= ".toInt()"; } elsif ($codeGenerator->IsPodType($idlType) or $idlType eq "Date") { $getterContentHead = "kit($getterContentHead"; $getterContentTail .= ")"; @@ -1271,6 +1267,8 @@ sub GenerateImplementation $getterContent = $getterContentHead . $getterContentTail; } + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, $getterSig); push(@implContent, "{\n"); push(@implContent, " $jsContextSetter\n"); @@ -1291,7 +1289,7 @@ sub GenerateImplementation } else { push(@implContent, " return $getterContent;\n"); } - push(@implContent, "}\n\n"); + push(@implContent, "}\n"); # - SETTER if (!$attributeIsReadonly) { @@ -1303,15 +1301,14 @@ sub GenerateImplementation my $argName = "new" . ucfirst($attributeInterfaceName); my $arg = GetObjCTypeGetter($argName, $idlType); - # The definition of ConvertFromString and ConvertToString is flipped for the setter - if ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $arg = "WebCore::String::number($arg)"; - } elsif ($attribute->signature->extendedAttributes->{"ConvertToString"}) { + # The definition of ConvertToString is flipped for the setter + if ($attribute->signature->extendedAttributes->{"ConvertToString"}) { $arg = "WebCore::String($arg).toInt()"; } my $setterSig = "- (void)$setterName:($attributeType)$argName\n"; + push(@implContent, "\n"); push(@implContent, $setterSig); push(@implContent, "{\n"); push(@implContent, " $jsContextSetter\n"); @@ -1332,23 +1329,18 @@ sub GenerateImplementation push(@implContent, " IMPL->$coreSetterName($arg);\n"); } } else { - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - push(@implContent, " $exceptionInit\n") if $hasSetterException; + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); my $ec = $hasSetterException ? ", ec" : ""; - if ($reflect || $reflectURL) { - my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - push(@implContent, " IMPL->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, $arg$ec);\n"); - } else { - push(@implContent, " IMPL->$coreSetterName($arg$ec);\n"); - } + push(@implContent, " $exceptionInit\n") if $hasSetterException; + push(@implContent, " IMPL->$setterExpressionPrefix$arg$ec);\n"); push(@implContent, " $exceptionRaiseOnError\n") if $hasSetterException; } - push(@implContent, "}\n\n"); + push(@implContent, "}\n"); } + + push(@implContent, "#endif\n") if $attributeConditionalString; + push(@implContent, "\n"); } } diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index e471500..e249caa 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -677,7 +677,7 @@ END my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; if ($getterStringUsesImp && $reflect && IsNodeSubType($dataNode) && $codeGenerator->IsStringType($attrType)) { # Generate super-compact call for regular attribute getter: - my $contentAttributeName = $reflect eq "1" ? $attrName : $reflect; + my $contentAttributeName = $reflect eq "1" ? lc $attrName : $reflect; my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); $implIncludes{"${namespace}.h"} = 1; push(@implContentDecls, " return getElementStringAttr(info, ${namespace}::${contentAttributeName}Attr);\n"); @@ -708,34 +708,13 @@ END $attrName = $attribute->signature->extendedAttributes->{"v8referenceattr"}; } - my $getterFunc = $codeGenerator->WK_lcfirst($attrName); - - if ($codeGenerator->IsSVGAnimatedType($attribute->signature->type)) { - # Some SVGFE*Element.idl use 'operator' as attribute name; rewrite as '_operator' to avoid clashes with C/C++ - $getterFunc = "_" . $getterFunc if ($attrName =~ /operator/); - $getterFunc .= "Animated"; - } - my $returnType = GetTypeFromSignature($attribute->signature); my $getterString; if ($getterStringUsesImp) { - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; - $getterString = "imp->$getAttributeFunctionName(${namespace}::${contentAttributeName}Attr"; - } else { - $getterString = "imp->$getterFunc("; - } + $getterString = "imp->" . $codeGenerator->GetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); $getterString .= "ec" if $useExceptions; $getterString .= ")"; - if ($nativeType eq "int" and $attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $getterString .= ".toInt()"; - } } else { $getterString = "impInstance"; } @@ -887,7 +866,7 @@ END my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; if (($reflect || $reflectURL) && IsNodeSubType($dataNode) && $codeGenerator->IsStringType($attrType)) { # Generate super-compact call for regular attribute setter: - my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL); + my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? lc $attrName : ($reflect || $reflectURL); my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); $implIncludes{"${namespace}.h"} = 1; push(@implContentDecls, " setElementStringAttr(info, ${namespace}::${contentAttributeName}Attr, value);\n"); @@ -912,14 +891,7 @@ END push(@implContentDecls, " $nativeType v = " . JSValueToNative($attribute->signature, "value") . ";\n"); } - my $result = ""; - if ($nativeType eq "int" and $attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $result .= "WebCore::String::number("; - } - $result .= "v"; - if ($nativeType eq "int" and $attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $result .= ")"; - } + my $result = "v"; my $returnType = GetTypeFromSignature($attribute->signature); if (IsRefPtrType($returnType)) { $result = "WTF::getPtr(" . $result . ")"; @@ -935,15 +907,8 @@ END if ($implClassName eq "float") { push(@implContentDecls, " *imp = $result;\n"); } else { - my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); - my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; - my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; - if ($reflect || $reflectURL) { - my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL); - my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); - $implIncludes{"${namespace}.h"} = 1; - push(@implContentDecls, " imp->setAttribute(${namespace}::${contentAttributeName}Attr, $result"); - } elsif ($attribute->signature->type eq "EventListener") { + if ($attribute->signature->type eq "EventListener") { + my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); $implIncludes{"V8AbstractEventListener.h"} = 1; push(@implContentDecls, " transferHiddenDependency(info.Holder(), imp->$attrName(), value, V8${interfaceName}::eventListenerCacheIndex);\n"); if ($interfaceName eq "WorkerContext" and $attribute->signature->name eq "onerror") { @@ -954,7 +919,8 @@ END push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)"); } } else { - push(@implContentDecls, " imp->set$implSetterFunctionName($result"); + my $setterExpressionPrefix = $codeGenerator->SetterExpressionPrefix(\%implIncludes, $interfaceName, $attribute); + push(@implContentDecls, " imp->$setterExpressionPrefix$result"); } push(@implContentDecls, ", ec") if $useExceptions; push(@implContentDecls, ");\n"); @@ -1104,7 +1070,7 @@ END push(@implContentDecls, " return ${name}$overload->{overloadIndex}Callback(args);\n"); } push(@implContentDecls, <<END); - V8Proxy::setDOMException(SYNTAX_ERR); + V8Proxy::throwTypeError(); return notHandledByInterceptor(); END push(@implContentDecls, "}\n\n"); @@ -1283,9 +1249,9 @@ sub GenerateBatchedAttributeData foreach my $attribute (@$attributes) { my $conditionalString = GenerateConditionalString($attribute->signature); - push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; + push(@implContent, "#if ${conditionalString}\n") if $conditionalString; GenerateSingleBatchedAttribute($interfaceName, $attribute, ",", ""); - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; + push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; } } @@ -2712,7 +2678,7 @@ sub GetNativeTypeFromSignature my $mode = ""; if ($signature->extendedAttributes->{"ConvertUndefinedOrNullToNullString"}) { $mode = "WithUndefinedOrNullCheck"; - } elsif ($signature->extendedAttributes->{"ConvertNullToNullString"}) { + } elsif ($signature->extendedAttributes->{"ConvertNullToNullString"} || $signature->extendedAttributes->{"Reflect"} || $signature->extendedAttributes->{"ReflectURL"}) { $mode = "WithNullCheck"; } $type .= "<$mode>"; diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp b/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp index 0b20841..0436e13 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.cpp @@ -19,6 +19,9 @@ */ #include "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + #include "WebDOMTestInterface.h" #include "TestInterface.h" @@ -73,3 +76,5 @@ WebDOMTestInterface toWebKit(WebCore::TestInterface* value) { return WebDOMTestInterface(value); } + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h b/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h index d0cee5b..4e7af6d 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestInterface.h @@ -23,6 +23,8 @@ #ifndef WebDOMTestInterface_h #define WebDOMTestInterface_h +#if ENABLE(Condition1) || ENABLE(Condition2) + #include <WebDOMObject.h> #include <WebDOMString.h> @@ -50,3 +52,5 @@ WebCore::TestInterface* toWebCore(const WebDOMTestInterface&); WebDOMTestInterface toWebKit(WebCore::TestInterface*); #endif +#endif // ENABLE(Condition1) || ENABLE(Condition2) + diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp index e540a57..65bc9f3 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp @@ -22,6 +22,7 @@ #include "WebDOMTestObj.h" #include "AtomicString.h" +#include "HTMLNames.h" #include "KURL.h" #include "SerializedScriptValue.h" #include "TestObj.h" @@ -173,33 +174,163 @@ void WebDOMTestObj::setTestObjAttr(const WebDOMTestObj& newTestObjAttr) impl()->setTestObjAttr(toWebCore(newTestObjAttr)); } -int WebDOMTestObj::attrWithException() const +WebDOMString WebDOMTestObj::reflectedStringAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WebCore::String&>(impl()->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); +} + +void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, newReflectedStringAttr); +} + +int WebDOMTestObj::reflectedIntegralAttr() const { if (!impl()) return 0; - return impl()->attrWithException(); + return impl()->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); } -void WebDOMTestObj::setAttrWithException(int newAttrWithException) +void WebDOMTestObj::setReflectedIntegralAttr(int newReflectedIntegralAttr) { if (!impl()) return; - impl()->setAttrWithException(newAttrWithException); + impl()->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, newReflectedIntegralAttr); } -int WebDOMTestObj::attrWithSetterException() const +bool WebDOMTestObj::reflectedBooleanAttr() const +{ + if (!impl()) + return false; + + return impl()->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); +} + +void WebDOMTestObj::setReflectedBooleanAttr(bool newReflectedBooleanAttr) +{ + if (!impl()) + return; + + impl()->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, newReflectedBooleanAttr); +} + +WebDOMString WebDOMTestObj::reflectedURLAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WebCore::String&>(impl()->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); +} + +void WebDOMTestObj::setReflectedURLAttr(const WebDOMString& newReflectedURLAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, newReflectedURLAttr); +} + +WebDOMString WebDOMTestObj::reflectedStringAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WebCore::String&>(impl()->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); +} + +void WebDOMTestObj::setReflectedStringAttr(const WebDOMString& newReflectedStringAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, newReflectedStringAttr); +} + +int WebDOMTestObj::reflectedCustomIntegralAttr() const +{ + if (!impl()) + return 0; + + return impl()->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); +} + +void WebDOMTestObj::setReflectedCustomIntegralAttr(int newReflectedCustomIntegralAttr) +{ + if (!impl()) + return; + + impl()->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, newReflectedCustomIntegralAttr); +} + +bool WebDOMTestObj::reflectedCustomBooleanAttr() const +{ + if (!impl()) + return false; + + return impl()->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); +} + +void WebDOMTestObj::setReflectedCustomBooleanAttr(bool newReflectedCustomBooleanAttr) +{ + if (!impl()) + return; + + impl()->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, newReflectedCustomBooleanAttr); +} + +WebDOMString WebDOMTestObj::reflectedURLAttr() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WebCore::String&>(impl()->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); +} + +void WebDOMTestObj::setReflectedURLAttr(const WebDOMString& newReflectedURLAttr) +{ + if (!impl()) + return; + + impl()->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, newReflectedURLAttr); +} + +int WebDOMTestObj::attrWithGetterException() const { if (!impl()) return 0; WebCore::ExceptionCode ec = 0; - int result = impl()->attrWithSetterException(ec); + int result = impl()->attrWithGetterException(ec); webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); return result; } +void WebDOMTestObj::setAttrWithGetterException(int newAttrWithGetterException) +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->setAttrWithGetterException(newAttrWithGetterException, ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +int WebDOMTestObj::attrWithSetterException() const +{ + if (!impl()) + return 0; + + return impl()->attrWithSetterException(); +} + void WebDOMTestObj::setAttrWithSetterException(int newAttrWithSetterException) { if (!impl()) @@ -210,21 +341,42 @@ void WebDOMTestObj::setAttrWithSetterException(int newAttrWithSetterException) webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); } -int WebDOMTestObj::attrWithGetterException() const +WebDOMString WebDOMTestObj::stringAttrWithGetterException() const { if (!impl()) - return 0; + return WebDOMString(); - return impl()->attrWithGetterException(); + WebCore::ExceptionCode ec = 0; + WebDOMString result = impl()->stringAttrWithGetterException(ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); + return static_cast<const WebCore::String&>(result); } -void WebDOMTestObj::setAttrWithGetterException(int newAttrWithGetterException) +void WebDOMTestObj::setStringAttrWithGetterException(const WebDOMString& newStringAttrWithGetterException) { if (!impl()) return; WebCore::ExceptionCode ec = 0; - impl()->setAttrWithGetterException(newAttrWithGetterException, ec); + impl()->setStringAttrWithGetterException(newStringAttrWithGetterException, ec); + webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); +} + +WebDOMString WebDOMTestObj::stringAttrWithSetterException() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WebCore::String&>(impl()->stringAttrWithSetterException()); +} + +void WebDOMTestObj::setStringAttrWithSetterException(const WebDOMString& newStringAttrWithSetterException) +{ + if (!impl()) + return; + + WebCore::ExceptionCode ec = 0; + impl()->setStringAttrWithSetterException(newStringAttrWithSetterException, ec); webDOMRaiseError(static_cast<WebDOMExceptionCode>(ec)); } @@ -236,6 +388,92 @@ WebDOMString WebDOMTestObj::scriptStringAttr() const return static_cast<const WebCore::String&>(impl()->scriptStringAttr()); } +#if ENABLE(Condition1) +int WebDOMTestObj::conditionalAttr1() const +{ + if (!impl()) + return 0; + + return impl()->conditionalAttr1(); +} + +void WebDOMTestObj::setConditionalAttr1(int newConditionalAttr1) +{ + if (!impl()) + return; + + impl()->setConditionalAttr1(newConditionalAttr1); +} + +#endif +#if ENABLE(Condition1) && ENABLE(Condition2) +int WebDOMTestObj::conditionalAttr2() const +{ + if (!impl()) + return 0; + + return impl()->conditionalAttr2(); +} + +void WebDOMTestObj::setConditionalAttr2(int newConditionalAttr2) +{ + if (!impl()) + return; + + impl()->setConditionalAttr2(newConditionalAttr2); +} + +#endif +#if ENABLE(Condition1) || ENABLE(Condition2) +int WebDOMTestObj::conditionalAttr3() const +{ + if (!impl()) + return 0; + + return impl()->conditionalAttr3(); +} + +void WebDOMTestObj::setConditionalAttr3(int newConditionalAttr3) +{ + if (!impl()) + return; + + impl()->setConditionalAttr3(newConditionalAttr3); +} + +#endif +int WebDOMTestObj::description() const +{ + if (!impl()) + return 0; + + return impl()->description(); +} + +int WebDOMTestObj::id() const +{ + if (!impl()) + return 0; + + return impl()->id(); +} + +void WebDOMTestObj::setId(int newId) +{ + if (!impl()) + return; + + impl()->setId(newId); +} + +WebDOMString WebDOMTestObj::hash() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WebCore::String&>(impl()->hash()); +} + void WebDOMTestObj::voidMethod() { if (!impl()) diff --git a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h index 7bcd988..33bc7fb 100644 --- a/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h +++ b/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h @@ -54,15 +54,43 @@ public: void setStringAttr(const WebDOMString&); WebDOMTestObj testObjAttr() const; void setTestObjAttr(const WebDOMTestObj&); - int attrWithException() const; - void setAttrWithException(int); - int attrWithSetterException() const; - void setAttrWithSetterException(int); + WebDOMString reflectedStringAttr() const; + void setReflectedStringAttr(const WebDOMString&); + int reflectedIntegralAttr() const; + void setReflectedIntegralAttr(int); + bool reflectedBooleanAttr() const; + void setReflectedBooleanAttr(bool); + WebDOMString reflectedURLAttr() const; + void setReflectedURLAttr(const WebDOMString&); + WebDOMString reflectedStringAttr() const; + void setReflectedStringAttr(const WebDOMString&); + int reflectedCustomIntegralAttr() const; + void setReflectedCustomIntegralAttr(int); + bool reflectedCustomBooleanAttr() const; + void setReflectedCustomBooleanAttr(bool); + WebDOMString reflectedURLAttr() const; + void setReflectedURLAttr(const WebDOMString&); int attrWithGetterException() const; void setAttrWithGetterException(int); + int attrWithSetterException() const; + void setAttrWithSetterException(int); + WebDOMString stringAttrWithGetterException() const; + void setStringAttrWithGetterException(const WebDOMString&); + WebDOMString stringAttrWithSetterException() const; + void setStringAttrWithSetterException(const WebDOMString&); int customAttr() const; void setCustomAttr(int); WebDOMString scriptStringAttr() const; + int conditionalAttr1() const; + void setConditionalAttr1(int); + int conditionalAttr2() const; + void setConditionalAttr2(int); + int conditionalAttr3() const; + void setConditionalAttr3(int); + int description() const; + int id() const; + void setId(int); + WebDOMString hash() const; void voidMethod(); void voidMethodWithArgs(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 a67b6ac..94f4ca5 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -21,6 +21,8 @@ #include <glib-object.h> #include "config.h" +#if ENABLE(DATABASE) + #include <wtf/GetPtr.h> #include <wtf/RefPtr.h> #include "ExceptionCode.h" @@ -55,38 +57,38 @@ gpointer kit(WebCore::TestCallback* obj) gboolean webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestCallback * item = WebKit::core(self); - g_return_val_if_fail (class1param, 0); - WebCore::Class1 * _g_class1param = WebKit::core(class1param); - g_return_val_if_fail (_g_class1param, 0); - gboolean res = item->callbackWithClass1Param(_g_class1param); + g_return_val_if_fail(class1param, 0); + WebCore::Class1 * converted_class1param = WebKit::core(class1param); + g_return_val_if_fail(converted_class1param, 0); + gboolean res = item->callbackWithClass1Param(converted_class1param); return res; } gboolean webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2param, gchar* str_arg) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestCallback * item = WebKit::core(self); - g_return_val_if_fail (class2param, 0); - g_return_val_if_fail (str_arg, 0); - WebCore::Class2 * _g_class2param = WebKit::core(class2param); - g_return_val_if_fail (_g_class2param, 0); - WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); - gboolean res = item->callbackWithClass2Param(_g_class2param, _g_str_arg); + g_return_val_if_fail(class2param, 0); + g_return_val_if_fail(str_arg, 0); + WebCore::Class2 * converted_class2param = WebKit::core(class2param); + g_return_val_if_fail(converted_class2param, 0); + WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + gboolean res = item->callbackWithClass2Param(converted_class2param, converted_str_arg); return res; } glong webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3param) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestCallback * item = WebKit::core(self); - g_return_val_if_fail (class3param, 0); - WebCore::Class3 * _g_class3param = WebKit::core(class3param); - g_return_val_if_fail (_g_class3param, 0); - glong res = item->callbackWithNonBoolReturnType(_g_class3param); + g_return_val_if_fail(class3param, 0); + WebCore::Class3 * converted_class3param = WebKit::core(class3param); + g_return_val_if_fail(converted_class3param, 0); + glong res = item->callbackWithNonBoolReturnType(converted_class3param); return res; } @@ -182,3 +184,4 @@ WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback* coreObject) return wrapper; } } // namespace WebKit +#endif /* ENABLE(DATABASE) */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp index 0d0021d..af22530 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -21,6 +21,8 @@ #include <glib-object.h> #include "config.h" +#if ENABLE(Condition1) || ENABLE(Condition2) + #include <wtf/GetPtr.h> #include <wtf/RefPtr.h> #include "ExceptionCode.h" @@ -138,3 +140,4 @@ WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface* coreObject) return wrapper; } } // 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 5dfb255..efb362b 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -24,6 +24,7 @@ #include <wtf/GetPtr.h> #include <wtf/RefPtr.h> #include "ExceptionCode.h" +#include "HTMLNames.h" #include "TestObj.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" @@ -51,7 +52,7 @@ gpointer kit(WebCore::TestObj* obj) void webkit_dom_test_obj_void_method(WebKitDOMTestObj* self) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->voidMethod(); } @@ -59,20 +60,20 @@ 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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); - g_return_if_fail (str_arg); - g_return_if_fail (obj_arg); - WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); - WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); - g_return_if_fail (_g_obj_arg); - item->voidMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg); + g_return_if_fail(str_arg); + g_return_if_fail(obj_arg); + WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); + g_return_if_fail(converted_obj_arg); + item->voidMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); } glong webkit_dom_test_obj_int_method(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->intMethod(); return res; @@ -81,21 +82,21 @@ 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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); - g_return_val_if_fail (str_arg, 0); - g_return_val_if_fail (obj_arg, 0); - WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); - WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); - g_return_val_if_fail (_g_obj_arg, 0); - glong res = item->intMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); + glong res = item->intMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); return res; } WebKitDOMTestObj* webkit_dom_test_obj_obj_method(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethod()); WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); @@ -105,14 +106,14 @@ 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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); - g_return_val_if_fail (str_arg, 0); - g_return_val_if_fail (obj_arg, 0); - WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); - WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); - g_return_val_if_fail (_g_obj_arg, 0); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg)); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg)); WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); return res; } @@ -120,14 +121,14 @@ 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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); - g_return_val_if_fail (str_arg, 0); - g_return_val_if_fail (obj_arg, 0); - WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); - WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); - g_return_val_if_fail (_g_obj_arg, 0); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgs(_g_str_arg, _g_obj_arg)); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgs(converted_str_arg, converted_obj_arg)); WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); return res; } @@ -135,15 +136,15 @@ 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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); - g_return_val_if_fail (str_arg, 0); - g_return_val_if_fail (obj_arg, 0); - WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); - WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); - g_return_val_if_fail (_g_obj_arg, 0); + g_return_val_if_fail(str_arg, 0); + g_return_val_if_fail(obj_arg, 0); + WebCore::String converted_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * converted_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail(converted_obj_arg, 0); WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgsAndThrows(_g_str_arg, _g_obj_arg, ec)); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgsAndThrows(converted_str_arg, converted_obj_arg, ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc; WebCore::getExceptionCodeDescription(ec, ecdesc); @@ -156,18 +157,18 @@ 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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); - g_return_if_fail (serialized_arg); - WebCore::SerializedScriptValue * _g_serialized_arg = WebKit::core(serialized_arg); - g_return_if_fail (_g_serialized_arg); - item->serializedValue(_g_serialized_arg); + g_return_if_fail(serialized_arg); + WebCore::SerializedScriptValue * converted_serialized_arg = WebKit::core(serialized_arg); + g_return_if_fail(converted_serialized_arg); + item->serializedValue(converted_serialized_arg); } void webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; item->methodWithException(ec); @@ -187,7 +188,7 @@ webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error void webkit_dom_test_obj_with_dynamic_frame(WebKitDOMTestObj* self) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrame(); } @@ -195,7 +196,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndArg(int_arg); } @@ -203,7 +204,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndOptionalArg(int_arg, optional_arg); } @@ -211,7 +212,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndUserGesture(int_arg); } @@ -219,7 +220,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withDynamicFrameAndUserGestureASAD(int_arg, optional_arg); } @@ -227,7 +228,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withScriptStateVoid(); } @@ -235,7 +236,7 @@ webkit_dom_test_obj_with_script_state_void(WebKitDOMTestObj* self) WebKitDOMTestObj* webkit_dom_test_obj_with_script_state_obj(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj()); WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); @@ -245,7 +246,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; item->withScriptStateVoidException(ec); @@ -259,7 +260,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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObjException(ec)); @@ -275,7 +276,7 @@ webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GErr void webkit_dom_test_obj_with_script_execution_context(WebKitDOMTestObj* self) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->withScriptExecutionContext(); } @@ -283,7 +284,7 @@ webkit_dom_test_obj_with_script_execution_context(WebKitDOMTestObj* self) void webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->methodWithOptionalArg(opt); } @@ -291,7 +292,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->methodWithNonOptionalArgAndOptionalArg(non_opt, opt); } @@ -299,7 +300,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2); } @@ -307,7 +308,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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->readOnlyIntAttr(); return res; @@ -316,7 +317,7 @@ webkit_dom_test_obj_get_read_only_int_attr(WebKitDOMTestObj* self) gchar* webkit_dom_test_obj_get_read_only_string_attr(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->readOnlyStringAttr()); return res; @@ -325,7 +326,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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->readOnlyTestObjAttr()); WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); @@ -335,7 +336,7 @@ webkit_dom_test_obj_get_read_only_test_obj_attr(WebKitDOMTestObj* self) glong webkit_dom_test_obj_get_int_attr(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->intAttr(); return res; @@ -344,7 +345,7 @@ webkit_dom_test_obj_get_int_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_int_attr(WebKitDOMTestObj* self, glong value) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setIntAttr(value); } @@ -352,7 +353,7 @@ webkit_dom_test_obj_set_int_attr(WebKitDOMTestObj* self, glong value) gint64 webkit_dom_test_obj_get_long_long_attr(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gint64 res = item->longLongAttr(); return res; @@ -361,7 +362,7 @@ webkit_dom_test_obj_get_long_long_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_long_long_attr(WebKitDOMTestObj* self, gint64 value) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setLongLongAttr(value); } @@ -369,7 +370,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) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); guint64 res = item->unsignedLongLongAttr(); return res; @@ -378,7 +379,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) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setUnsignedLongLongAttr(value); } @@ -386,7 +387,7 @@ webkit_dom_test_obj_set_unsigned_long_long_attr(WebKitDOMTestObj* self, guint64 gchar* webkit_dom_test_obj_get_string_attr(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->stringAttr()); return res; @@ -395,17 +396,17 @@ webkit_dom_test_obj_get_string_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, gchar* value) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); - g_return_if_fail (value); - WebCore::String _g_value = WebCore::String::fromUTF8(value); - item->setStringAttr(_g_value); + g_return_if_fail(value); + WebCore::String converted_value = WebCore::String::fromUTF8(value); + item->setStringAttr(converted_value); } WebKitDOMTestObj* webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->testObjAttr()); WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); @@ -415,38 +416,165 @@ webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); - g_return_if_fail (value); - WebCore::TestObj * _g_value = WebKit::core(value); - g_return_if_fail (_g_value); - item->setTestObjAttr(_g_value); + g_return_if_fail(value); + WebCore::TestObj * converted_value = WebKit::core(value); + g_return_if_fail(converted_value); + item->setTestObjAttr(converted_value); +} + +gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WebCore::String converted_value = WebCore::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, converted_value); } glong -webkit_dom_test_obj_get_attr_with_exception(WebKitDOMTestObj* self) +webkit_dom_test_obj_get_reflected_integral_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_integral_attr(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + item->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, value); +} + +gboolean +webkit_dom_test_obj_get_reflected_boolean_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + gboolean res = item->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_boolean_attr(WebKitDOMTestObj* self, gboolean value) { - g_return_val_if_fail (self, 0); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); - glong res = item->attrWithException(); + item->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, value); +} + +gchar* +webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); return res; } void -webkit_dom_test_obj_set_attr_with_exception(WebKitDOMTestObj* self, glong value) +webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); - item->setAttrWithException(value); + g_return_if_fail(value); + WebCore::String converted_value = WebCore::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, converted_value); +} + +gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WebCore::String converted_value = WebCore::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, converted_value); } glong -webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_get_reflected_custom_integral_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_custom_integral_attr(WebKitDOMTestObj* self, glong value) { - g_return_val_if_fail (self, 0); + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + item->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, value); +} + +gboolean +webkit_dom_test_obj_get_reflected_custom_boolean_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + gboolean res = item->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); + return res; +} + +void +webkit_dom_test_obj_set_reflected_custom_boolean_attr(WebKitDOMTestObj* self, gboolean value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + item->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, value); +} + +gchar* +webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return res; +} + +void +webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WebCore::String converted_value = WebCore::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, converted_value); +} + +glong +webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) +{ + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - glong res = item->attrWithSetterException(ec); + glong res = item->attrWithGetterException(ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc; WebCore::getExceptionCodeDescription(ec, ecdesc); @@ -456,9 +584,32 @@ webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self, GErro } void +webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->setAttrWithGetterException(value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + +glong +webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithSetterException(); + return res; +} + +void webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError **error) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); WebCore::ExceptionCode ec = 0; item->setAttrWithSetterException(value, ec); @@ -469,22 +620,50 @@ webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong } } -glong -webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self) +gchar* +webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); - glong res = item->attrWithGetterException(); + WebCore::ExceptionCode ec = 0; + gchar* res = convertToUTF8String(item->stringAttrWithGetterException(ec)); return res; } void -webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error) +webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, gchar* value, GError **error) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WebCore::String converted_value = WebCore::String::fromUTF8(value); WebCore::ExceptionCode ec = 0; - item->setAttrWithGetterException(value, ec); + item->setStringAttrWithGetterException(converted_value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } +} + +gchar* +webkit_dom_test_obj_get_string_attr_with_setter_exception(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->stringAttrWithSetterException()); + return res; +} + +void +webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, gchar* value, GError **error) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail(value); + WebCore::String converted_value = WebCore::String::fromUTF8(value); + WebCore::ExceptionCode ec = 0; + item->setStringAttrWithSetterException(converted_value, ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc; WebCore::getExceptionCodeDescription(ec, ecdesc); @@ -495,16 +674,79 @@ webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong gchar* webkit_dom_test_obj_get_script_string_attr(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->scriptStringAttr()); return res; } +#if ENABLE(Condition1) +glong +webkit_dom_test_obj_get_conditional_attr1(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->conditionalAttr1(); + return res; +} +#endif /* ENABLE(Condition1) */ + +#if ENABLE(Condition1) +void +webkit_dom_test_obj_set_conditional_attr1(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + item->setConditionalAttr1(value); +} +#endif /* ENABLE(Condition1) */ + +#if ENABLE(Condition1) && ENABLE(Condition2) +glong +webkit_dom_test_obj_get_conditional_attr2(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->conditionalAttr2(); + return res; +} +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ + +#if ENABLE(Condition1) && ENABLE(Condition2) +void +webkit_dom_test_obj_set_conditional_attr2(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + item->setConditionalAttr2(value); +} +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ + +#if ENABLE(Condition1) || ENABLE(Condition2) +glong +webkit_dom_test_obj_get_conditional_attr3(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->conditionalAttr3(); + return res; +} +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + +#if ENABLE(Condition1) || ENABLE(Condition2) +void +webkit_dom_test_obj_set_conditional_attr3(WebKitDOMTestObj* self, glong value) +{ + g_return_if_fail(self); + WebCore::TestObj * item = WebKit::core(self); + item->setConditionalAttr3(value); +} +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + glong webkit_dom_test_obj_get_description(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->description(); return res; @@ -513,7 +755,7 @@ webkit_dom_test_obj_get_description(WebKitDOMTestObj* self) glong webkit_dom_test_obj_get_id(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); glong res = item->id(); return res; @@ -522,7 +764,7 @@ webkit_dom_test_obj_get_id(WebKitDOMTestObj* self) void webkit_dom_test_obj_set_id(WebKitDOMTestObj* self, glong value) { - g_return_if_fail (self); + g_return_if_fail(self); WebCore::TestObj * item = WebKit::core(self); item->setId(value); } @@ -530,7 +772,7 @@ webkit_dom_test_obj_set_id(WebKitDOMTestObj* self, glong value) gchar* webkit_dom_test_obj_get_hash(WebKitDOMTestObj* self) { - g_return_val_if_fail (self, 0); + g_return_val_if_fail(self, 0); WebCore::TestObj * item = WebKit::core(self); gchar* res = convertToUTF8String(item->hash()); return res; @@ -562,11 +804,29 @@ enum { PROP_UNSIGNED_LONG_LONG_ATTR, PROP_STRING_ATTR, PROP_TEST_OBJ_ATTR, - PROP_ATTR_WITH_EXCEPTION, - PROP_ATTR_WITH_SETTER_EXCEPTION, + PROP_REFLECTED_STRING_ATTR, + PROP_REFLECTED_INTEGRAL_ATTR, + PROP_REFLECTED_BOOLEAN_ATTR, + PROP_REFLECTED_URL_ATTR, + PROP_REFLECTED_STRING_ATTR, + PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR, + PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR, + PROP_REFLECTED_URL_ATTR, PROP_ATTR_WITH_GETTER_EXCEPTION, + PROP_ATTR_WITH_SETTER_EXCEPTION, + PROP_STRING_ATTR_WITH_GETTER_EXCEPTION, + PROP_STRING_ATTR_WITH_SETTER_EXCEPTION, PROP_CUSTOM_ATTR, PROP_SCRIPT_STRING_ATTR, +#if ENABLE(Condition1) + PROP_CONDITIONAL_ATTR1, +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + PROP_CONDITIONAL_ATTR2, +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + PROP_CONDITIONAL_ATTR3, +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ PROP_DESCRIPTION, PROP_ID, PROP_HASH, @@ -609,9 +869,50 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con coreSelf->setStringAttr(WebCore::String::fromUTF8(g_value_get_string(value))); break; } - case PROP_ATTR_WITH_EXCEPTION: + case PROP_REFLECTED_STRING_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_INTEGRAL_ATTR: + { + coreSelf->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, (g_value_get_long(value))); + break; + } + case PROP_REFLECTED_BOOLEAN_ATTR: + { + coreSelf->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, (g_value_get_boolean(value))); + break; + } + case PROP_REFLECTED_URL_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_STRING_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR: + { + coreSelf->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, (g_value_get_long(value))); + break; + } + case PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR: { - coreSelf->setAttrWithException((g_value_get_long(value))); + coreSelf->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, (g_value_get_boolean(value))); + break; + } + case PROP_REFLECTED_URL_ATTR: + { + coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WebCore::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + coreSelf->setAttrWithGetterException((g_value_get_long(value)), ec); break; } case PROP_ATTR_WITH_SETTER_EXCEPTION: @@ -620,12 +921,39 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con coreSelf->setAttrWithSetterException((g_value_get_long(value)), ec); break; } - case PROP_ATTR_WITH_GETTER_EXCEPTION: + case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: { WebCore::ExceptionCode ec = 0; - coreSelf->setAttrWithGetterException((g_value_get_long(value)), ec); + coreSelf->setStringAttrWithGetterException(WebCore::String::fromUTF8(g_value_get_string(value)), ec); + break; + } + case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + coreSelf->setStringAttrWithSetterException(WebCore::String::fromUTF8(g_value_get_string(value)), ec); + break; + } +#if ENABLE(Condition1) + case PROP_CONDITIONAL_ATTR1: + { + coreSelf->setConditionalAttr1((g_value_get_long(value))); break; } +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR2: + { + coreSelf->setConditionalAttr2((g_value_get_long(value))); + break; + } +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR3: + { + coreSelf->setConditionalAttr3((g_value_get_long(value))); + break; + } +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ case PROP_ID: { coreSelf->setId((g_value_get_long(value))); @@ -685,20 +1013,66 @@ static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GVa g_value_set_object(value, WebKit::kit(ptr.get())); break; } - case PROP_ATTR_WITH_EXCEPTION: + case PROP_REFLECTED_STRING_ATTR: { - g_value_set_long(value, coreSelf->attrWithException()); + g_value_take_string(value, convertToUTF8String(coreSelf->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr))); + break; + } + case PROP_REFLECTED_INTEGRAL_ATTR: + { + g_value_set_long(value, coreSelf->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); + break; + } + case PROP_REFLECTED_BOOLEAN_ATTR: + { + g_value_set_boolean(value, coreSelf->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr)); + break; + } + case PROP_REFLECTED_URL_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr))); + break; + } + case PROP_REFLECTED_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr))); + break; + } + case PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR: + { + g_value_set_long(value, coreSelf->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); + break; + } + case PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR: + { + g_value_set_boolean(value, coreSelf->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr)); + break; + } + case PROP_REFLECTED_URL_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr))); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + WebCore::ExceptionCode ec = 0; + g_value_set_long(value, coreSelf->attrWithGetterException(ec)); break; } case PROP_ATTR_WITH_SETTER_EXCEPTION: { + g_value_set_long(value, coreSelf->attrWithSetterException()); + break; + } + case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: + { WebCore::ExceptionCode ec = 0; - g_value_set_long(value, coreSelf->attrWithSetterException(ec)); + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttrWithGetterException(ec))); break; } - case PROP_ATTR_WITH_GETTER_EXCEPTION: + case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: { - g_value_set_long(value, coreSelf->attrWithGetterException()); + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttrWithSetterException())); break; } case PROP_SCRIPT_STRING_ATTR: @@ -706,6 +1080,27 @@ static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GVa g_value_take_string(value, convertToUTF8String(coreSelf->scriptStringAttr())); break; } +#if ENABLE(Condition1) + case PROP_CONDITIONAL_ATTR1: + { + g_value_set_long(value, coreSelf->conditionalAttr1()); + break; + } +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR2: + { + g_value_set_long(value, coreSelf->conditionalAttr2()); + break; + } +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + case PROP_CONDITIONAL_ATTR3: + { + g_value_set_long(value, coreSelf->conditionalAttr3()); + break; + } +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ case PROP_DESCRIPTION: { g_value_set_long(value, coreSelf->description()); @@ -800,24 +1195,66 @@ G_MAXUINT64, /* min */ WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ WEBKIT_PARAM_READWRITE)); g_object_class_install_property(gobjectClass, - PROP_ATTR_WITH_EXCEPTION, - g_param_spec_long("attr-with-exception", /* name */ - "test_obj_attr-with-exception", /* short description */ - "read-write glong TestObj.attr-with-exception", /* longer - could do with some extra doc stuff here */ + PROP_REFLECTED_STRING_ATTR, + g_param_spec_string("reflected-string-attr", /* name */ + "test_obj_reflected-string-attr", /* short description */ + "read-write gchar* TestObj.reflected-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_INTEGRAL_ATTR, + g_param_spec_long("reflected-integral-attr", /* name */ + "test_obj_reflected-integral-attr", /* short description */ + "read-write glong TestObj.reflected-integral-attr", /* longer - could do with some extra doc stuff here */ G_MINLONG, /* min */ G_MAXLONG, /* max */ 0, /* default */ WEBKIT_PARAM_READWRITE)); g_object_class_install_property(gobjectClass, - PROP_ATTR_WITH_SETTER_EXCEPTION, - g_param_spec_long("attr-with-setter-exception", /* name */ - "test_obj_attr-with-setter-exception", /* short description */ - "read-write glong TestObj.attr-with-setter-exception", /* longer - could do with some extra doc stuff here */ + PROP_REFLECTED_BOOLEAN_ATTR, + g_param_spec_boolean("reflected-boolean-attr", /* name */ + "test_obj_reflected-boolean-attr", /* short description */ + "read-write gboolean TestObj.reflected-boolean-attr", /* longer - could do with some extra doc stuff here */ + FALSE, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_URL_ATTR, + g_param_spec_string("reflected-url-attr", /* name */ + "test_obj_reflected-url-attr", /* short description */ + "read-write gchar* TestObj.reflected-url-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_STRING_ATTR, + g_param_spec_string("reflected-string-attr", /* name */ + "test_obj_reflected-string-attr", /* short description */ + "read-write gchar* TestObj.reflected-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_CUSTOM_INTEGRAL_ATTR, + g_param_spec_long("reflected-custom-integral-attr", /* name */ + "test_obj_reflected-custom-integral-attr", /* short description */ + "read-write glong TestObj.reflected-custom-integral-attr", /* longer - could do with some extra doc stuff here */ G_MINLONG, /* min */ G_MAXLONG, /* max */ 0, /* default */ WEBKIT_PARAM_READWRITE)); g_object_class_install_property(gobjectClass, + PROP_REFLECTED_CUSTOM_BOOLEAN_ATTR, + g_param_spec_boolean("reflected-custom-boolean-attr", /* name */ + "test_obj_reflected-custom-boolean-attr", /* short description */ + "read-write gboolean TestObj.reflected-custom-boolean-attr", /* longer - could do with some extra doc stuff here */ + FALSE, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_REFLECTED_URL_ATTR, + g_param_spec_string("reflected-url-attr", /* name */ + "test_obj_reflected-url-attr", /* short description */ + "read-write gchar* TestObj.reflected-url-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, PROP_ATTR_WITH_GETTER_EXCEPTION, g_param_spec_long("attr-with-getter-exception", /* name */ "test_obj_attr-with-getter-exception", /* short description */ @@ -827,12 +1264,68 @@ G_MAXLONG, /* max */ 0, /* default */ WEBKIT_PARAM_READWRITE)); g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_SETTER_EXCEPTION, + g_param_spec_long("attr-with-setter-exception", /* name */ + "test_obj_attr-with-setter-exception", /* short description */ + "read-write glong TestObj.attr-with-setter-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR_WITH_GETTER_EXCEPTION, + g_param_spec_string("string-attr-with-getter-exception", /* name */ + "test_obj_string-attr-with-getter-exception", /* short description */ + "read-write gchar* TestObj.string-attr-with-getter-exception", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR_WITH_SETTER_EXCEPTION, + g_param_spec_string("string-attr-with-setter-exception", /* name */ + "test_obj_string-attr-with-setter-exception", /* short description */ + "read-write gchar* TestObj.string-attr-with-setter-exception", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, PROP_SCRIPT_STRING_ATTR, g_param_spec_string("script-string-attr", /* name */ "test_obj_script-string-attr", /* short description */ "read-only gchar* TestObj.script-string-attr", /* longer - could do with some extra doc stuff here */ "", /* default */ WEBKIT_PARAM_READABLE)); +#if ENABLE(Condition1) + g_object_class_install_property(gobjectClass, + PROP_CONDITIONAL_ATTR1, + g_param_spec_long("conditional-attr1", /* name */ + "test_obj_conditional-attr1", /* short description */ + "read-write glong TestObj.conditional-attr1", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); +#endif /* ENABLE(Condition1) */ +#if ENABLE(Condition1) && ENABLE(Condition2) + g_object_class_install_property(gobjectClass, + PROP_CONDITIONAL_ATTR2, + g_param_spec_long("conditional-attr2", /* name */ + "test_obj_conditional-attr2", /* short description */ + "read-write glong TestObj.conditional-attr2", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_object_class_install_property(gobjectClass, + PROP_CONDITIONAL_ATTR3, + g_param_spec_long("conditional-attr3", /* name */ + "test_obj_conditional-attr3", /* short description */ + "read-write glong TestObj.conditional-attr3", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ g_object_class_install_property(gobjectClass, PROP_DESCRIPTION, g_param_spec_long("description", /* name */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h index ef5ccb8..8dcd8c3 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h @@ -160,27 +160,111 @@ webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self); WEBKIT_API void webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value); +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* value); + WEBKIT_API glong -webkit_dom_test_obj_get_attr_with_exception(WebKitDOMTestObj* self); +webkit_dom_test_obj_get_reflected_integral_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_integral_attr(WebKitDOMTestObj* self, glong value); + +WEBKIT_API gboolean +webkit_dom_test_obj_get_reflected_boolean_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_boolean_attr(WebKitDOMTestObj* self, gboolean value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self); WEBKIT_API void -webkit_dom_test_obj_set_attr_with_exception(WebKitDOMTestObj* self, glong value); +webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, gchar* value); WEBKIT_API glong -webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_get_reflected_custom_integral_attr(WebKitDOMTestObj* self); WEBKIT_API void -webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError **error); +webkit_dom_test_obj_set_reflected_custom_integral_attr(WebKitDOMTestObj* self, glong value); + +WEBKIT_API gboolean +webkit_dom_test_obj_get_reflected_custom_boolean_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_custom_boolean_attr(WebKitDOMTestObj* self, gboolean value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, gchar* value); WEBKIT_API glong -webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self); +webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error); WEBKIT_API void webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error); +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError **error); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error); + +WEBKIT_API void +webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, gchar* value, GError **error); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_string_attr_with_setter_exception(WebKitDOMTestObj* self); + +WEBKIT_API void +webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, gchar* value, GError **error); + WEBKIT_API gchar* webkit_dom_test_obj_get_script_string_attr(WebKitDOMTestObj* self); +#if ENABLE(Condition1) +WEBKIT_API glong +webkit_dom_test_obj_get_conditional_attr1(WebKitDOMTestObj* self); +#endif /* ENABLE(Condition1) */ + +#if ENABLE(Condition1) +WEBKIT_API void +webkit_dom_test_obj_set_conditional_attr1(WebKitDOMTestObj* self, glong value); +#endif /* ENABLE(Condition1) */ + +#if ENABLE(Condition1) && ENABLE(Condition2) +WEBKIT_API glong +webkit_dom_test_obj_get_conditional_attr2(WebKitDOMTestObj* self); +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ + +#if ENABLE(Condition1) && ENABLE(Condition2) +WEBKIT_API void +webkit_dom_test_obj_set_conditional_attr2(WebKitDOMTestObj* self, glong value); +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ + +#if ENABLE(Condition1) || ENABLE(Condition2) +WEBKIT_API glong +webkit_dom_test_obj_get_conditional_attr3(WebKitDOMTestObj* self); +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + +#if ENABLE(Condition1) || ENABLE(Condition2) +WEBKIT_API void +webkit_dom_test_obj_set_conditional_attr3(WebKitDOMTestObj* self, glong value); +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + WEBKIT_API glong webkit_dom_test_obj_get_description(WebKitDOMTestObj* self); diff --git a/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp index 693a48b..8e71df1 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -19,6 +19,9 @@ */ #include "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + #include "JSTestInterface.h" #include "TestInterface.h" @@ -61,39 +64,30 @@ static const HashTableValue JSTestInterfaceConstructorTableValues[1] = static JSC_CONST_HASHTABLE HashTable JSTestInterfaceConstructorTable = { 1, 0, JSTestInterfaceConstructorTableValues, 0 }; class JSTestInterfaceConstructor : public DOMConstructorObject { public: - JSTestInterfaceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSTestInterfaceConstructor::createStructure(globalObject->objectPrototype()), globalObject) + JSTestInterfaceConstructor(JSC::ExecState*, JSDOMGlobalObject*); + + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - putDirect(exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); } - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); - virtual const ClassInfo* classInfo() const { return &s_info; } - static const ClassInfo s_info; - - static PassRefPtr<Structure> createStructure(JSValue proto) - { - return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); - } - protected: - static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; - static EncodedJSValue JSC_HOST_CALL constructTestInterface(ExecState* exec) - { - ScriptExecutionContext* context = static_cast<JSTestInterfaceConstructor*>(exec->callee())->scriptExecutionContext(); - if (!context) - return throwVMError(exec, createReferenceError(exec, "Reference error")); - return JSValue::encode(asObject(toJS(exec, static_cast<JSTestInterfaceConstructor*>(exec->callee())->globalObject(), TestInterface::create(context)))); - } - virtual ConstructType getConstructData(ConstructData& constructData) - { - constructData.native.function = constructTestInterface; - return ConstructTypeHost; - } + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestInterface(JSC::ExecState*); + virtual JSC::ConstructType getConstructData(JSC::ConstructData&); }; const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", 0, &JSTestInterfaceConstructorTable, 0 }; +JSTestInterfaceConstructor::JSTestInterfaceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestInterfaceConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + putDirect(exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + bool JSTestInterfaceConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { return getStaticValueSlot<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, slot); @@ -104,6 +98,20 @@ bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(ExecState* exec, const return getStaticValueDescriptor<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, descriptor); } +EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterface(ExecState* exec) +{ + ScriptExecutionContext* context = static_cast<JSTestInterfaceConstructor*>(exec->callee())->scriptExecutionContext(); + if (!context) + return throwVMError(exec, createReferenceError(exec, "Reference error")); + return JSValue::encode(asObject(toJS(exec, static_cast<JSTestInterfaceConstructor*>(exec->callee())->globalObject(), TestInterface::create(context)))); +} + +ConstructType JSTestInterfaceConstructor::getConstructData(ConstructData& constructData) +{ + constructData.native.function = constructJSTestInterface; + return ConstructTypeHost; +} + /* Hash table for prototype */ #if ENABLE(JIT) #define THUNK_GENERATOR(generator) , generator @@ -173,3 +181,5 @@ TestInterface* toTestInterface(JSC::JSValue value) } } + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/WebCore/bindings/scripts/test/JS/JSTestInterface.h b/WebCore/bindings/scripts/test/JS/JSTestInterface.h index 23b183b..09d7d7c 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestInterface.h +++ b/WebCore/bindings/scripts/test/JS/JSTestInterface.h @@ -21,6 +21,8 @@ #ifndef JSTestInterface_h #define JSTestInterface_h +#if ENABLE(Condition1) || ENABLE(Condition2) + #include "JSDOMBinding.h" #include <runtime/JSGlobalObject.h> #include <runtime/JSObjectWithGlobalObject.h> @@ -79,4 +81,6 @@ JSC::JSValue jsTestInterfaceConstructor(JSC::ExecState*, JSC::JSValue, const JSC } // namespace WebCore +#endif // ENABLE(Condition1) || ENABLE(Condition2) + #endif diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 09b69cd..360782d 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -21,6 +21,7 @@ #include "config.h" #include "JSTestObj.h" +#include "HTMLNames.h" #include "JSEventListener.h" #include "JSTestObj.h" #include "JSlog.h" @@ -46,7 +47,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSTestObj); #define THUNK_GENERATOR(generator) #endif -static const HashTableValue JSTestObjTableValues[18] = +static const HashTableValue JSTestObjTableValues[30] = { { "readOnlyIntAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) }, { "readOnlyStringAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, @@ -56,11 +57,29 @@ static const HashTableValue JSTestObjTableValues[18] = { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t)setJSTestObjUnsignedLongLongAttr THUNK_GENERATOR(0) }, { "stringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttr), (intptr_t)setJSTestObjStringAttr THUNK_GENERATOR(0) }, { "testObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestObjAttr), (intptr_t)setJSTestObjTestObjAttr THUNK_GENERATOR(0) }, - { "attrWithException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithException), (intptr_t)setJSTestObjAttrWithException THUNK_GENERATOR(0) }, - { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) }, + { "reflectedStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedStringAttr), (intptr_t)setJSTestObjReflectedStringAttr THUNK_GENERATOR(0) }, + { "reflectedIntegralAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedIntegralAttr), (intptr_t)setJSTestObjReflectedIntegralAttr THUNK_GENERATOR(0) }, + { "reflectedBooleanAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedBooleanAttr), (intptr_t)setJSTestObjReflectedBooleanAttr THUNK_GENERATOR(0) }, + { "reflectedURLAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedURLAttr), (intptr_t)setJSTestObjReflectedURLAttr THUNK_GENERATOR(0) }, + { "reflectedStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedStringAttr), (intptr_t)setJSTestObjReflectedStringAttr THUNK_GENERATOR(0) }, + { "reflectedCustomIntegralAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedCustomIntegralAttr), (intptr_t)setJSTestObjReflectedCustomIntegralAttr THUNK_GENERATOR(0) }, + { "reflectedCustomBooleanAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedCustomBooleanAttr), (intptr_t)setJSTestObjReflectedCustomBooleanAttr THUNK_GENERATOR(0) }, + { "reflectedURLAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedURLAttr), (intptr_t)setJSTestObjReflectedURLAttr THUNK_GENERATOR(0) }, { "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t)setJSTestObjAttrWithGetterException THUNK_GENERATOR(0) }, + { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) }, + { "stringAttrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithGetterException), (intptr_t)setJSTestObjStringAttrWithGetterException THUNK_GENERATOR(0) }, + { "stringAttrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttrWithSetterException), (intptr_t)setJSTestObjStringAttrWithSetterException THUNK_GENERATOR(0) }, { "customAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomAttr), (intptr_t)setJSTestObjCustomAttr THUNK_GENERATOR(0) }, { "scriptStringAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, +#if ENABLE(Condition1) + { "conditionalAttr1", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConditionalAttr1), (intptr_t)setJSTestObjConditionalAttr1 THUNK_GENERATOR(0) }, +#endif +#if ENABLE(Condition1) && ENABLE(Condition2) + { "conditionalAttr2", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConditionalAttr2), (intptr_t)setJSTestObjConditionalAttr2 THUNK_GENERATOR(0) }, +#endif +#if ENABLE(Condition1) || ENABLE(Condition2) + { "conditionalAttr3", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConditionalAttr3), (intptr_t)setJSTestObjConditionalAttr3 THUNK_GENERATOR(0) }, +#endif { "description", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjDescription), (intptr_t)0 THUNK_GENERATOR(0) }, { "id", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjId), (intptr_t)setJSTestObjId THUNK_GENERATOR(0) }, { "hash", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjHash), (intptr_t)0 THUNK_GENERATOR(0) }, @@ -69,7 +88,7 @@ static const HashTableValue JSTestObjTableValues[18] = }; #undef THUNK_GENERATOR -static JSC_CONST_HASHTABLE HashTable JSTestObjTable = { 65, 63, JSTestObjTableValues, 0 }; +static JSC_CONST_HASHTABLE HashTable JSTestObjTable = { 69, 63, JSTestObjTableValues, 0 }; /* Hash table for constructor */ #if ENABLE(JIT) #define THUNK_GENERATOR(generator) , generator @@ -86,27 +105,28 @@ static const HashTableValue JSTestObjConstructorTableValues[1] = static JSC_CONST_HASHTABLE HashTable JSTestObjConstructorTable = { 1, 0, JSTestObjConstructorTableValues, 0 }; class JSTestObjConstructor : public DOMConstructorObject { public: - JSTestObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSTestObjConstructor::createStructure(globalObject->objectPrototype()), globalObject) + JSTestObjConstructor(JSC::ExecState*, JSDOMGlobalObject*); + + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - putDirect(exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), DontDelete | ReadOnly); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); } - virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); - virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); - virtual const ClassInfo* classInfo() const { return &s_info; } - static const ClassInfo s_info; - - static PassRefPtr<Structure> createStructure(JSValue proto) - { - return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); - } - protected: - static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; }; const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", 0, &JSTestObjConstructorTable, 0 }; +JSTestObjConstructor::JSTestObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestObjConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + putDirect(exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + bool JSTestObjConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { return getStaticValueSlot<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, slot); @@ -277,31 +297,113 @@ JSValue jsTestObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier return result; } -JSValue jsTestObjAttrWithException(ExecState* exec, JSValue slotBase, const Identifier&) +JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return result; +} + +JSValue jsTestObjReflectedIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); + return result; +} + +JSValue jsTestObjReflectedBooleanAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsBoolean(imp->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr)); + return result; +} + +JSValue jsTestObjReflectedURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); + return result; +} + +JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return result; +} + +JSValue jsTestObjReflectedCustomIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); + return result; +} + +JSValue jsTestObjReflectedCustomBooleanAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsBoolean(imp->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr)); + return result; +} + +JSValue jsTestObjReflectedURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) { JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - JSValue result = jsNumber(exec, imp->attrWithException()); + JSValue result = jsString(exec, imp->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return result; +} + +JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + ExceptionCode ec = 0; + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSC::JSValue result = jsNumber(exec, imp->attrWithGetterException(ec)); + setDOMException(exec, ec); return result; } JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) { JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->attrWithSetterException()); + return result; +} + +JSValue jsTestObjStringAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); ExceptionCode ec = 0; TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - JSC::JSValue result = jsNumber(exec, imp->attrWithSetterException(ec)); + JSC::JSValue result = jsString(exec, imp->stringAttrWithGetterException(ec)); setDOMException(exec, ec); return result; } -JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) +JSValue jsTestObjStringAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) { JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - JSValue result = jsNumber(exec, imp->attrWithGetterException()); + JSValue result = jsString(exec, imp->stringAttrWithSetterException()); return result; } @@ -320,6 +422,39 @@ JSValue jsTestObjScriptStringAttr(ExecState* exec, JSValue slotBase, const Ident return result; } +#if ENABLE(Condition1) +JSValue jsTestObjConditionalAttr1(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->conditionalAttr1()); + return result; +} +#endif + +#if ENABLE(Condition1) && ENABLE(Condition2) +JSValue jsTestObjConditionalAttr2(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->conditionalAttr2()); + return result; +} +#endif + +#if ENABLE(Condition1) || ENABLE(Condition2) +JSValue jsTestObjConditionalAttr3(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->conditionalAttr3()); + return result; +} +#endif + JSValue jsTestObjDescription(ExecState* exec, JSValue slotBase, const Identifier&) { JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); @@ -392,11 +527,69 @@ void setJSTestObjTestObjAttr(ExecState* exec, JSObject* thisObject, JSValue valu imp->setTestObjAttr(toTestObj(value)); } -void setJSTestObjAttrWithException(ExecState* exec, JSObject* thisObject, JSValue value) +void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) { JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - imp->setAttrWithException(value.toInt32(exec)); + imp->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, value.toInt32(exec)); +} + +void setJSTestObjReflectedBooleanAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, value.toBoolean(exec)); +} + +void setJSTestObjReflectedURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjReflectedCustomIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, value.toInt32(exec)); +} + +void setJSTestObjReflectedCustomBooleanAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, value.toBoolean(exec)); +} + +void setJSTestObjReflectedURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, valueToStringWithNullCheck(exec, value)); +} + +void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + imp->setAttrWithGetterException(value.toInt32(exec), ec); + setDOMException(exec, ec); } void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) @@ -408,12 +601,21 @@ void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, setDOMException(exec, ec); } -void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) +void setJSTestObjStringAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) { JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; - imp->setAttrWithGetterException(value.toInt32(exec), ec); + imp->setStringAttrWithGetterException(ustringToString(value.toString(exec)), ec); + setDOMException(exec, ec); +} + +void setJSTestObjStringAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + imp->setStringAttrWithSetterException(ustringToString(value.toString(exec)), ec); setDOMException(exec, ec); } @@ -422,6 +624,33 @@ void setJSTestObjCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value static_cast<JSTestObj*>(thisObject)->setCustomAttr(exec, value); } +#if ENABLE(Condition1) +void setJSTestObjConditionalAttr1(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setConditionalAttr1(value.toInt32(exec)); +} +#endif + +#if ENABLE(Condition1) && ENABLE(Condition2) +void setJSTestObjConditionalAttr2(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setConditionalAttr2(value.toInt32(exec)); +} +#endif + +#if ENABLE(Condition1) || ENABLE(Condition2) +void setJSTestObjConditionalAttr3(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setConditionalAttr3(value.toInt32(exec)); +} +#endif + void setJSTestObjId(ExecState* exec, JSObject* thisObject, JSValue value) { JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); @@ -875,7 +1104,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA return JSValue::encode(jsUndefined()); } -EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec) +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) @@ -889,7 +1118,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecSta return JSValue::encode(jsUndefined()); } -EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecState* exec) +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) @@ -910,7 +1139,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecSta return JSValue::encode(jsUndefined()); } -EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3(ExecState* exec) +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) @@ -923,7 +1152,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3(ExecSta return JSValue::encode(jsUndefined()); } -EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(ExecState* exec) +static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) @@ -938,15 +1167,15 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(ExecSta EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecState* exec) { - if ((exec->argumentCount() == 2 && (exec->argument(0).isNull() || asObject(exec->argument(0))->inherits(&JSTestObj::s_info)) && (exec->argument(1).isNull() || exec->argument(1).isUndefined() || exec->argument(1).isString() || exec->argument(1).isObject()))) + if ((exec->argumentCount() == 2 && (exec->argument(0).isNull() || exec->argument(0).isObject() && asObject(exec->argument(0))->inherits(&JSTestObj::s_info)) && (exec->argument(1).isNull() || exec->argument(1).isUndefined() || exec->argument(1).isString() || exec->argument(1).isObject()))) return jsTestObjPrototypeFunctionOverloadedMethod1(exec); - if ((exec->argumentCount() == 1 && (exec->argument(0).isNull() || asObject(exec->argument(0))->inherits(&JSTestObj::s_info))) || (exec->argumentCount() == 2 && (exec->argument(0).isNull() || asObject(exec->argument(0))->inherits(&JSTestObj::s_info)))) + if ((exec->argumentCount() == 1 && (exec->argument(0).isNull() || exec->argument(0).isObject() && asObject(exec->argument(0))->inherits(&JSTestObj::s_info))) || (exec->argumentCount() == 2 && (exec->argument(0).isNull() || exec->argument(0).isObject() && asObject(exec->argument(0))->inherits(&JSTestObj::s_info)))) return jsTestObjPrototypeFunctionOverloadedMethod2(exec); if ((exec->argumentCount() == 1 && (exec->argument(0).isNull() || exec->argument(0).isUndefined() || exec->argument(0).isString() || exec->argument(0).isObject()))) return jsTestObjPrototypeFunctionOverloadedMethod3(exec); if (exec->argumentCount() == 1) return jsTestObjPrototypeFunctionOverloadedMethod4(exec); - return throwTypeError(exec); + return throwVMTypeError(exec); } JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* object) diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.h b/WebCore/bindings/scripts/test/JS/JSTestObj.h index dd84005..3b21c85 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.h +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -130,15 +130,39 @@ JSC::JSValue jsTestObjStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Ident void setJSTestObjStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestObjTestObjAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); -JSC::JSValue jsTestObjAttrWithException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); -void setJSTestObjAttrWithException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); -JSC::JSValue jsTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); -void setJSTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedIntegralAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedIntegralAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedBooleanAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedBooleanAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedURLAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedURLAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedCustomIntegralAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedCustomIntegralAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedCustomBooleanAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedCustomBooleanAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjReflectedURLAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjReflectedURLAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStringAttrWithGetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStringAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStringAttrWithSetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStringAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjCustomAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestObjCustomAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjScriptStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjConditionalAttr1(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjConditionalAttr1(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjConditionalAttr2(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjConditionalAttr2(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjConditionalAttr3(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjConditionalAttr3(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjDescription(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); JSC::JSValue jsTestObjId(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestObjId(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm index 8fd7791..ab59333 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm @@ -25,6 +25,9 @@ */ #import "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + #import "DOMInternal.h" #import "DOMTestInterface.h" @@ -85,3 +88,5 @@ DOMTestInterface *kit(WebCore::TestInterface* value) addDOMWrapper(wrapper, value); return [wrapper autorelease]; } + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h index 6b50246..d8862da 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h @@ -47,15 +47,45 @@ - (void)setStringAttr:(NSString *)newStringAttr; - (DOMTestObj *)testObjAttr; - (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr; -- (int)attrWithException; -- (void)setAttrWithException:(int)newAttrWithException; -- (int)attrWithSetterException; -- (void)setAttrWithSetterException:(int)newAttrWithSetterException; +- (NSString *)reflectedStringAttr; +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr; +- (int)reflectedIntegralAttr; +- (void)setReflectedIntegralAttr:(int)newReflectedIntegralAttr; +- (BOOL)reflectedBooleanAttr; +- (void)setReflectedBooleanAttr:(BOOL)newReflectedBooleanAttr; +- (NSString *)reflectedURLAttr; +- (void)setReflectedURLAttr:(NSString *)newReflectedURLAttr; +- (NSString *)reflectedStringAttr; +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr; +- (int)reflectedCustomIntegralAttr; +- (void)setReflectedCustomIntegralAttr:(int)newReflectedCustomIntegralAttr; +- (BOOL)reflectedCustomBooleanAttr; +- (void)setReflectedCustomBooleanAttr:(BOOL)newReflectedCustomBooleanAttr; +- (NSString *)reflectedURLAttr; +- (void)setReflectedURLAttr:(NSString *)newReflectedURLAttr; - (int)attrWithGetterException; - (void)setAttrWithGetterException:(int)newAttrWithGetterException; +- (int)attrWithSetterException; +- (void)setAttrWithSetterException:(int)newAttrWithSetterException; +- (NSString *)stringAttrWithGetterException; +- (void)setStringAttrWithGetterException:(NSString *)newStringAttrWithGetterException; +- (NSString *)stringAttrWithSetterException; +- (void)setStringAttrWithSetterException:(NSString *)newStringAttrWithSetterException; - (int)customAttr; - (void)setCustomAttr:(int)newCustomAttr; - (NSString *)scriptStringAttr; +#if ENABLE(Condition1) +- (int)conditionalAttr1; +- (void)setConditionalAttr1:(int)newConditionalAttr1; +#endif +#if ENABLE(Condition1) && ENABLE(Condition2) +- (int)conditionalAttr2; +- (void)setConditionalAttr2:(int)newConditionalAttr2; +#endif +#if ENABLE(Condition1) || ENABLE(Condition2) +- (int)conditionalAttr3; +- (void)setConditionalAttr3:(int)newConditionalAttr3; +#endif - (int)descriptionName; - (int)idName; - (void)setIdName:(int)newIdName; diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm index e57ed87..9bbbf14 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -39,6 +39,7 @@ #import "DOMlogInternal.h" #import "EventListener.h" #import "ExceptionHandlers.h" +#import "HTMLNames.h" #import "JSMainThreadExecState.h" #import "KURL.h" #import "ObjCEventListener.h" @@ -151,27 +152,125 @@ IMPL->setTestObjAttr(core(newTestObjAttr)); } -- (int)attrWithException +- (NSString *)reflectedStringAttr { WebCore::JSMainThreadNullState state; - return IMPL->attrWithException(); + return IMPL->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr); } -- (void)setAttrWithException:(int)newAttrWithException +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr { WebCore::JSMainThreadNullState state; - IMPL->setAttrWithException(newAttrWithException); + IMPL->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, newReflectedStringAttr); } -- (int)attrWithSetterException +- (int)reflectedIntegralAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); +} + +- (void)setReflectedIntegralAttr:(int)newReflectedIntegralAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, newReflectedIntegralAttr); +} + +- (BOOL)reflectedBooleanAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); +} + +- (void)setReflectedBooleanAttr:(BOOL)newReflectedBooleanAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, newReflectedBooleanAttr); +} + +- (NSString *)reflectedURLAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr); +} + +- (void)setReflectedURLAttr:(NSString *)newReflectedURLAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, newReflectedURLAttr); +} + +- (NSString *)reflectedStringAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr); +} + +- (void)setReflectedStringAttr:(NSString *)newReflectedStringAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, newReflectedStringAttr); +} + +- (int)reflectedCustomIntegralAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); +} + +- (void)setReflectedCustomIntegralAttr:(int)newReflectedCustomIntegralAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, newReflectedCustomIntegralAttr); +} + +- (BOOL)reflectedCustomBooleanAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); +} + +- (void)setReflectedCustomBooleanAttr:(BOOL)newReflectedCustomBooleanAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, newReflectedCustomBooleanAttr); +} + +- (NSString *)reflectedURLAttr +{ + WebCore::JSMainThreadNullState state; + return IMPL->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr); +} + +- (void)setReflectedURLAttr:(NSString *)newReflectedURLAttr +{ + WebCore::JSMainThreadNullState state; + IMPL->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, newReflectedURLAttr); +} + +- (int)attrWithGetterException { WebCore::JSMainThreadNullState state; WebCore::ExceptionCode ec = 0; - int result = IMPL->attrWithSetterException(ec); + int result = IMPL->attrWithGetterException(ec); WebCore::raiseOnDOMError(ec); return result; } +- (void)setAttrWithGetterException:(int)newAttrWithGetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->setAttrWithGetterException(newAttrWithGetterException, ec); + WebCore::raiseOnDOMError(ec); +} + +- (int)attrWithSetterException +{ + WebCore::JSMainThreadNullState state; + return IMPL->attrWithSetterException(); +} + - (void)setAttrWithSetterException:(int)newAttrWithSetterException { WebCore::JSMainThreadNullState state; @@ -180,17 +279,34 @@ WebCore::raiseOnDOMError(ec); } -- (int)attrWithGetterException +- (NSString *)stringAttrWithGetterException { WebCore::JSMainThreadNullState state; - return IMPL->attrWithGetterException(); + WebCore::ExceptionCode ec = 0; + NSString *result = IMPL->stringAttrWithGetterException(ec); + WebCore::raiseOnDOMError(ec); + return result; } -- (void)setAttrWithGetterException:(int)newAttrWithGetterException +- (void)setStringAttrWithGetterException:(NSString *)newStringAttrWithGetterException { WebCore::JSMainThreadNullState state; WebCore::ExceptionCode ec = 0; - IMPL->setAttrWithGetterException(newAttrWithGetterException, ec); + IMPL->setStringAttrWithGetterException(newStringAttrWithGetterException, ec); + WebCore::raiseOnDOMError(ec); +} + +- (NSString *)stringAttrWithSetterException +{ + WebCore::JSMainThreadNullState state; + return IMPL->stringAttrWithSetterException(); +} + +- (void)setStringAttrWithSetterException:(NSString *)newStringAttrWithSetterException +{ + WebCore::JSMainThreadNullState state; + WebCore::ExceptionCode ec = 0; + IMPL->setStringAttrWithSetterException(newStringAttrWithSetterException, ec); WebCore::raiseOnDOMError(ec); } @@ -212,6 +328,48 @@ return IMPL->scriptStringAttr(); } +#if ENABLE(Condition1) +- (int)conditionalAttr1 +{ + WebCore::JSMainThreadNullState state; + return IMPL->conditionalAttr1(); +} + +- (void)setConditionalAttr1:(int)newConditionalAttr1 +{ + WebCore::JSMainThreadNullState state; + IMPL->setConditionalAttr1(newConditionalAttr1); +} +#endif + +#if ENABLE(Condition1) && ENABLE(Condition2) +- (int)conditionalAttr2 +{ + WebCore::JSMainThreadNullState state; + return IMPL->conditionalAttr2(); +} + +- (void)setConditionalAttr2:(int)newConditionalAttr2 +{ + WebCore::JSMainThreadNullState state; + IMPL->setConditionalAttr2(newConditionalAttr2); +} +#endif + +#if ENABLE(Condition1) || ENABLE(Condition2) +- (int)conditionalAttr3 +{ + WebCore::JSMainThreadNullState state; + return IMPL->conditionalAttr3(); +} + +- (void)setConditionalAttr3:(int)newConditionalAttr3 +{ + WebCore::JSMainThreadNullState state; + IMPL->setConditionalAttr3(newConditionalAttr3); +} +#endif + - (int)descriptionName { WebCore::JSMainThreadNullState state; diff --git a/WebCore/bindings/scripts/test/TestInterface.idl b/WebCore/bindings/scripts/test/TestInterface.idl index 5a8b008..1f0aa18 100644 --- a/WebCore/bindings/scripts/test/TestInterface.idl +++ b/WebCore/bindings/scripts/test/TestInterface.idl @@ -30,6 +30,7 @@ // changes in its ouput. module test { interface [ + Conditional=Condition1|Condition2, CanBeConstructed, CallWith=ScriptExecutionContext ] TestInterface { diff --git a/WebCore/bindings/scripts/test/TestObj.idl b/WebCore/bindings/scripts/test/TestObj.idl index 1cb004c..ef4db10 100644 --- a/WebCore/bindings/scripts/test/TestObj.idl +++ b/WebCore/bindings/scripts/test/TestObj.idl @@ -40,6 +40,16 @@ module test { attribute DOMString stringAttr; attribute TestObj testObjAttr; + // Reflected DOM attributes + attribute [Reflect] DOMString reflectedStringAttr; + attribute [Reflect] long reflectedIntegralAttr; + attribute [Reflect] boolean reflectedBooleanAttr; + attribute [ReflectURL] DOMString reflectedURLAttr; + attribute [Reflect=customContentStringAttr] DOMString reflectedStringAttr; + attribute [Reflect=customContentIntegralAttr] long reflectedCustomIntegralAttr; + attribute [Reflect=customContentBooleanAttr] boolean reflectedCustomBooleanAttr; + attribute [ReflectURL=customContentURLAttr] DOMString reflectedURLAttr; + // Methods void voidMethod(); void voidMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); @@ -55,10 +65,11 @@ module test { void serializedValue(in SerializedScriptValue serializedArg); // Exceptions - void methodWithException() raises(DOMException); - attribute long attrWithException raises(DOMException); - attribute long attrWithSetterException getter raises(DOMException); - attribute long attrWithGetterException setter raises(DOMException); + void methodWithException() raises(DOMException); + attribute long attrWithGetterException getter raises(DOMException); + attribute long attrWithSetterException setter raises(DOMException); + attribute DOMString stringAttrWithGetterException getter raises(DOMException); + attribute DOMString stringAttrWithSetterException setter raises(DOMException); // 'Custom' extended attribute attribute [Custom] long customAttr; @@ -97,6 +108,11 @@ module test { // 'ConvertScriptString' extended attribute readonly attribute [ConvertScriptString] DOMString scriptStringAttr; + // 'Conditional' extended attribute + attribute [Conditional=Condition1] long conditionalAttr1; + attribute [Conditional=Condition1&Condition2] long conditionalAttr2; + attribute [Conditional=Condition1|Condition2] long conditionalAttr3; + #if defined(TESTING_V8) || defined(TESTING_JS) // Overloads void overloadedMethod(in TestObj objArg, in DOMString strArg); diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp index fef199a..eff4ebd 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -28,6 +28,7 @@ #include "V8Class2.h" #include "V8CustomVoidCallback.h" #include "V8DOMString.h" +#include "V8Proxy.h" #include <wtf/Assertions.h> diff --git a/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp b/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp index f0bfb86..340dca7 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp @@ -21,6 +21,8 @@ #include "config.h" #include "V8TestInterface.h" +#if ENABLE(Condition1) || ENABLE(Condition2) + #include "RuntimeEnabledFeatures.h" #include "V8Binding.h" #include "V8BindingState.h" @@ -113,3 +115,5 @@ void V8TestInterface::derefObject(void* object) } } // namespace WebCore + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/WebCore/bindings/scripts/test/V8/V8TestInterface.h b/WebCore/bindings/scripts/test/V8/V8TestInterface.h index ce1310e..d2192ca 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestInterface.h +++ b/WebCore/bindings/scripts/test/V8/V8TestInterface.h @@ -18,6 +18,8 @@ Boston, MA 02111-1307, USA. */ +#if ENABLE(Condition1) || ENABLE(Condition2) + #ifndef V8TestInterface_h #define V8TestInterface_h @@ -48,3 +50,5 @@ v8::Handle<v8::Value> toV8(PassRefPtr<TestInterface >); } #endif // V8TestInterface_h +#endif // ENABLE(Condition1) || ENABLE(Condition2) + diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 69c57bb..4a54ae3 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -22,6 +22,7 @@ #include "V8TestObj.h" #include "ExceptionCode.h" +#include "HTMLNames.h" #include "RuntimeEnabledFeatures.h" #include "ScriptCallStack.h" #include "SerializedScriptValue.h" @@ -151,28 +152,140 @@ static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Valu return; } -static v8::Handle<v8::Value> attrWithExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { - INC_STATS("DOM.TestObj.attrWithException._get"); + INC_STATS("DOM.TestObj.reflectedStringAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8::Integer::New(imp->attrWithException()); + return v8String(imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); } -static void attrWithExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - INC_STATS("DOM.TestObj.attrWithException._set"); + INC_STATS("DOM.TestObj.reflectedStringAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + V8Parameter<WithNullCheck> v = value; + imp->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedIntegralAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedIntegralAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); +} + +static void reflectedIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedIntegralAttr._set"); TestObj* imp = V8TestObj::toNative(info.Holder()); int v = toInt32(value); - imp->setAttrWithException(v); + imp->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, v); return; } -static v8::Handle<v8::Value> attrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +static v8::Handle<v8::Value> reflectedBooleanAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { - INC_STATS("DOM.TestObj.attrWithSetterException._get"); + INC_STATS("DOM.TestObj.reflectedBooleanAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr)); +} + +static void reflectedBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedBooleanAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + bool v = value->BooleanValue(); + imp->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedURLAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); +} + +static void reflectedURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedURLAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + V8Parameter<WithNullCheck> v = value; + imp->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); +} + +static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedStringAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + V8Parameter<WithNullCheck> v = value; + imp->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedCustomIntegralAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomIntegralAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); +} + +static void reflectedCustomIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomIntegralAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedCustomBooleanAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomBooleanAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr)); +} + +static void reflectedCustomBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedCustomBooleanAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + bool v = value->BooleanValue(); + imp->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> reflectedURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedURLAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); +} + +static void reflectedURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.reflectedURLAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + V8Parameter<WithNullCheck> v = value; + imp->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, v); + return; +} + +static v8::Handle<v8::Value> attrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithGetterException._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); ExceptionCode ec = 0; - int v = imp->attrWithSetterException(ec); + int v = imp->attrWithGetterException(ec); if (UNLIKELY(ec)) { V8Proxy::setDOMException(ec); return v8::Handle<v8::Value>(); @@ -180,6 +293,25 @@ static v8::Handle<v8::Value> attrWithSetterExceptionAttrGetter(v8::Local<v8::Str return v8::Integer::New(v); } +static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithGetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + ExceptionCode ec = 0; + imp->setAttrWithGetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); + return; +} + +static v8::Handle<v8::Value> attrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithSetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->attrWithSetterException()); +} + static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.TestObj.attrWithSetterException._set"); @@ -192,20 +324,45 @@ static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Lo return; } -static v8::Handle<v8::Value> attrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +static v8::Handle<v8::Value> stringAttrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { - INC_STATS("DOM.TestObj.attrWithGetterException._get"); + INC_STATS("DOM.TestObj.stringAttrWithGetterException._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8::Integer::New(imp->attrWithGetterException()); + ExceptionCode ec = 0; + String v = imp->stringAttrWithGetterException(ec); + if (UNLIKELY(ec)) { + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); + } + return v8String(v); } -static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +static void stringAttrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - INC_STATS("DOM.TestObj.attrWithGetterException._set"); + INC_STATS("DOM.TestObj.stringAttrWithGetterException._set"); TestObj* imp = V8TestObj::toNative(info.Holder()); - int v = toInt32(value); + V8Parameter<> v = value; ExceptionCode ec = 0; - imp->setAttrWithGetterException(v, ec); + imp->setStringAttrWithGetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); + return; +} + +static v8::Handle<v8::Value> stringAttrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttrWithSetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->stringAttrWithSetterException()); +} + +static void stringAttrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttrWithSetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + V8Parameter<> v = value; + ExceptionCode ec = 0; + imp->setStringAttrWithSetterException(v, ec); if (UNLIKELY(ec)) V8Proxy::setDOMException(ec); return; @@ -218,6 +375,78 @@ static v8::Handle<v8::Value> scriptStringAttrAttrGetter(v8::Local<v8::String> na return v8StringOrNull(imp->scriptStringAttr()); } +#if ENABLE(Condition1) + +static v8::Handle<v8::Value> conditionalAttr1AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr1._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->conditionalAttr1()); +} + +#endif // ENABLE(Condition1) + +#if ENABLE(Condition1) + +static void conditionalAttr1AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr1._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setConditionalAttr1(v); + return; +} + +#endif // ENABLE(Condition1) + +#if ENABLE(Condition1) && ENABLE(Condition2) + +static v8::Handle<v8::Value> conditionalAttr2AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr2._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->conditionalAttr2()); +} + +#endif // ENABLE(Condition1) && ENABLE(Condition2) + +#if ENABLE(Condition1) && ENABLE(Condition2) + +static void conditionalAttr2AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr2._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setConditionalAttr2(v); + return; +} + +#endif // ENABLE(Condition1) && ENABLE(Condition2) + +#if ENABLE(Condition1) || ENABLE(Condition2) + +static v8::Handle<v8::Value> conditionalAttr3AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr3._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->conditionalAttr3()); +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) + +#if ENABLE(Condition1) || ENABLE(Condition2) + +static void conditionalAttr3AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.conditionalAttr3._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setConditionalAttr3(v); + return; +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) + static v8::Handle<v8::Value> descriptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestObj.description._get"); @@ -643,7 +872,7 @@ static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args) return overloadedMethod3Callback(args); if (args.Length() == 1) return overloadedMethod4Callback(args); - V8Proxy::setDOMException(SYNTAX_ERR); + V8Proxy::throwTypeError(); return notHandledByInterceptor(); } @@ -666,16 +895,46 @@ static const BatchedAttribute TestObjAttrs[] = { {"stringAttr", TestObjInternal::stringAttrAttrGetter, TestObjInternal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: '') {"testObjAttr", TestObjInternal::testObjAttrAttrGetter, TestObjInternal::testObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, - // Attribute 'attrWithException' (Type: 'attribute' ExtAttr: '') - {"attrWithException", TestObjInternal::attrWithExceptionAttrGetter, TestObjInternal::attrWithExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, - // Attribute 'attrWithSetterException' (Type: 'attribute' ExtAttr: '') - {"attrWithSetterException", TestObjInternal::attrWithSetterExceptionAttrGetter, TestObjInternal::attrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedStringAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedStringAttr", TestObjInternal::reflectedStringAttrAttrGetter, TestObjInternal::reflectedStringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedIntegralAttr", TestObjInternal::reflectedIntegralAttrAttrGetter, TestObjInternal::reflectedIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedBooleanAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedBooleanAttr", TestObjInternal::reflectedBooleanAttrAttrGetter, TestObjInternal::reflectedBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedURLAttr' (Type: 'attribute' ExtAttr: 'ReflectURL') + {"reflectedURLAttr", TestObjInternal::reflectedURLAttrAttrGetter, TestObjInternal::reflectedURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedStringAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedStringAttr", TestObjInternal::reflectedStringAttrAttrGetter, TestObjInternal::reflectedStringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedCustomIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedCustomIntegralAttr", TestObjInternal::reflectedCustomIntegralAttrAttrGetter, TestObjInternal::reflectedCustomIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedCustomBooleanAttr' (Type: 'attribute' ExtAttr: 'Reflect') + {"reflectedCustomBooleanAttr", TestObjInternal::reflectedCustomBooleanAttrAttrGetter, TestObjInternal::reflectedCustomBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'reflectedURLAttr' (Type: 'attribute' ExtAttr: 'ReflectURL') + {"reflectedURLAttr", TestObjInternal::reflectedURLAttrAttrGetter, TestObjInternal::reflectedURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'attrWithGetterException' (Type: 'attribute' ExtAttr: '') {"attrWithGetterException", TestObjInternal::attrWithGetterExceptionAttrGetter, TestObjInternal::attrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'attrWithSetterException' (Type: 'attribute' ExtAttr: '') + {"attrWithSetterException", TestObjInternal::attrWithSetterExceptionAttrGetter, TestObjInternal::attrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'stringAttrWithGetterException' (Type: 'attribute' ExtAttr: '') + {"stringAttrWithGetterException", TestObjInternal::stringAttrWithGetterExceptionAttrGetter, TestObjInternal::stringAttrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'stringAttrWithSetterException' (Type: 'attribute' ExtAttr: '') + {"stringAttrWithSetterException", TestObjInternal::stringAttrWithSetterExceptionAttrGetter, TestObjInternal::stringAttrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'customAttr' (Type: 'attribute' ExtAttr: 'Custom') {"customAttr", V8TestObj::customAttrAccessorGetter, V8TestObj::customAttrAccessorSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'scriptStringAttr' (Type: 'readonly attribute' ExtAttr: 'ConvertScriptString') {"scriptStringAttr", TestObjInternal::scriptStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#if ENABLE(Condition1) + // Attribute 'conditionalAttr1' (Type: 'attribute' ExtAttr: 'Conditional') + {"conditionalAttr1", TestObjInternal::conditionalAttr1AttrGetter, TestObjInternal::conditionalAttr1AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#endif // ENABLE(Condition1) +#if ENABLE(Condition1) && ENABLE(Condition2) + // Attribute 'conditionalAttr2' (Type: 'attribute' ExtAttr: 'Conditional') + {"conditionalAttr2", TestObjInternal::conditionalAttr2AttrGetter, TestObjInternal::conditionalAttr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#endif // ENABLE(Condition1) && ENABLE(Condition2) +#if ENABLE(Condition1) || ENABLE(Condition2) + // Attribute 'conditionalAttr3' (Type: 'attribute' ExtAttr: 'Conditional') + {"conditionalAttr3", TestObjInternal::conditionalAttr3AttrGetter, TestObjInternal::conditionalAttr3AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +#endif // ENABLE(Condition1) || ENABLE(Condition2) // Attribute 'description' (Type: 'readonly attribute' ExtAttr: '') {"description", TestObjInternal::descriptionAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'id' (Type: 'attribute' ExtAttr: '') diff --git a/WebCore/bindings/v8/JavaScriptCallFrame.cpp b/WebCore/bindings/v8/JavaScriptCallFrame.cpp index 049321b..20bf378 100644 --- a/WebCore/bindings/v8/JavaScriptCallFrame.cpp +++ b/WebCore/bindings/v8/JavaScriptCallFrame.cpp @@ -85,7 +85,7 @@ String JavaScriptCallFrame::functionName() const v8::HandleScope handleScope; v8::Context::Scope contextScope(m_debuggerContext.get()); v8::Handle<v8::Value> result = m_callFrame.get()->Get(v8String("functionName")); - return toWebCoreString(result); + return toWebCoreStringWithNullOrUndefinedCheck(result); } v8::Handle<v8::Value> JavaScriptCallFrame::scopeChain() const diff --git a/WebCore/bindings/v8/NPV8Object.cpp b/WebCore/bindings/v8/NPV8Object.cpp index af0933f..15382ad 100644 --- a/WebCore/bindings/v8/NPV8Object.cpp +++ b/WebCore/bindings/v8/NPV8Object.cpp @@ -57,7 +57,7 @@ namespace WebCore { WrapperTypeInfo* npObjectTypeInfo() { - static WrapperTypeInfo typeInfo = { 0, 0, false }; + static WrapperTypeInfo typeInfo = { 0, 0, 0 }; return &typeInfo; } diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index d3ec33f..6f17373 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -34,6 +34,7 @@ #include "PlatformBridge.h" #include "Document.h" +#include "DocumentParser.h" #include "DOMWindow.h" #include "Event.h" #include "EventListener.h" @@ -258,9 +259,18 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode, Shoul return ScriptValue(object); } -void ScriptController::setEventHandlerLineNumber(int lineNumber) +int ScriptController::eventHandlerLineNumber() const { - m_proxy->setEventHandlerLineNumber(lineNumber); + if (DocumentParser* parser = m_frame->document()->parser()) + return parser->lineNumber(); + return 0; +} + +int ScriptController::eventHandlerColumnNumber() const +{ + if (DocumentParser* parser = m_frame->document()->parser()) + return parser->columnNumber(); + return 0; } void ScriptController::finishedWithEvent(Event* event) diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h index 5d4b83e..3187180 100644 --- a/WebCore/bindings/v8/ScriptController.h +++ b/WebCore/bindings/v8/ScriptController.h @@ -153,7 +153,9 @@ public: static void gcUnprotectJSWrapper(void*); void finishedWithEvent(Event*); - void setEventHandlerLineNumber(int lineNumber); + + int eventHandlerLineNumber() const; + int eventHandlerColumnNumber() const; void setProcessingTimerCallback(bool processingTimerCallback) { m_processingTimerCallback = processingTimerCallback; } // FIXME: Currently we don't use the parameter world at all. diff --git a/WebCore/bindings/v8/ScriptDebugServer.cpp b/WebCore/bindings/v8/ScriptDebugServer.cpp index 39e409e..38fcd8a 100644 --- a/WebCore/bindings/v8/ScriptDebugServer.cpp +++ b/WebCore/bindings/v8/ScriptDebugServer.cpp @@ -72,6 +72,7 @@ ScriptDebugServer& ScriptDebugServer::shared() ScriptDebugServer::ScriptDebugServer() : m_pauseOnExceptionsState(DontPauseOnExceptions) , m_pausedPage(0) + , m_enabled(true) { } @@ -83,6 +84,8 @@ void ScriptDebugServer::setDebuggerScriptSource(const String& scriptSource) void ScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page) { #if ENABLE(V8_SCRIPT_DEBUG_SERVER) + if (!m_enabled) + return; v8::HandleScope scope; v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); v8::Context::Scope contextScope(debuggerContext); @@ -301,9 +304,14 @@ PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::currentCallFrame() return m_currentCallFrame; } +void ScriptDebugServer::setEnabled(bool value) +{ + m_enabled = value; +} + bool ScriptDebugServer::isDebuggerAlwaysEnabled() { - return true; + return m_enabled; } #if ENABLE(V8_SCRIPT_DEBUG_SERVER) @@ -335,6 +343,12 @@ void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); dispatchDidParseSource(listener, object); } else if (event == v8::Break || event == v8::Exception) { + if (event == v8::Exception) { + v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(1); + // Stack trace is empty in case of syntax error. Silently continue execution in such cases. + if (!stackTrace->GetFrameCount()) + return; + } m_executionState.set(eventDetails.GetExecutionState()); m_pausedPage = frame->page(); ScriptState* currentCallFrameState = mainWorldScriptState(frame); diff --git a/WebCore/bindings/v8/ScriptDebugServer.h b/WebCore/bindings/v8/ScriptDebugServer.h index 9439c16..b46f673 100644 --- a/WebCore/bindings/v8/ScriptDebugServer.h +++ b/WebCore/bindings/v8/ScriptDebugServer.h @@ -94,6 +94,7 @@ public: PassRefPtr<JavaScriptCallFrame> currentCallFrame(); + void setEnabled(bool); bool isDebuggerAlwaysEnabled(); private: @@ -119,6 +120,7 @@ private: OwnHandle<v8::Object> m_executionState; OwnPtr<ClientMessageLoop> m_clientMessageLoop; Page* m_pausedPage; + bool m_enabled; }; } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptEventListener.cpp b/WebCore/bindings/v8/ScriptEventListener.cpp index 57a2824..63e7dff 100644 --- a/WebCore/bindings/v8/ScriptEventListener.cpp +++ b/WebCore/bindings/v8/ScriptEventListener.cpp @@ -64,11 +64,8 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node* node, Attribu return 0; } - if (frame->document()->parser()) { - // FIXME: Change to use script->eventHandlerLineNumber() when implemented. - lineNumber = frame->document()->parser()->lineNumber(); - columnNumber = frame->document()->parser()->columnNumber(); - } + lineNumber = scriptController->eventHandlerLineNumber(); + columnNumber = scriptController->eventHandlerColumnNumber(); sourceURL = node->document()->url().string(); } @@ -97,11 +94,8 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, Attri return 0; } - if (frame->document()->parser()) { - // FIXME: Change to use script->eventHandlerLineNumber() when implemented. - lineNumber = frame->document()->parser()->lineNumber(); - columnNumber = frame->document()->parser()->columnNumber(); - } + lineNumber = scriptController->eventHandlerLineNumber(); + columnNumber = scriptController->eventHandlerColumnNumber(); sourceURL = frame->document()->url().string(); return V8LazyEventListener::create(attr->localName().string(), frame->document()->isSVGDocument(), attr->value(), sourceURL, lineNumber, columnNumber, WorldContextHandle(UseMainWorld)); } diff --git a/WebCore/bindings/v8/ScriptProfiler.cpp b/WebCore/bindings/v8/ScriptProfiler.cpp index ab0b9fe..4891892 100644 --- a/WebCore/bindings/v8/ScriptProfiler.cpp +++ b/WebCore/bindings/v8/ScriptProfiler.cpp @@ -52,4 +52,11 @@ PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& return profile ? ScriptProfile::create(profile) : 0; } +void ScriptProfiler::takeHeapSnapshot() +{ + v8::V8::ResumeProfilerEx(v8::PROFILER_MODULE_HEAP_SNAPSHOT + | v8::PROFILER_MODULE_HEAP_STATS + | v8::PROFILER_MODULE_JS_CONSTRUCTORS); +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptProfiler.h b/WebCore/bindings/v8/ScriptProfiler.h index c02cc32..aff3ce7 100644 --- a/WebCore/bindings/v8/ScriptProfiler.h +++ b/WebCore/bindings/v8/ScriptProfiler.h @@ -43,6 +43,7 @@ class ScriptProfiler : public Noncopyable { public: static void start(ScriptState* state, const String& title); static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); + static void takeHeapSnapshot(); }; } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptSourceCode.h b/WebCore/bindings/v8/ScriptSourceCode.h index 5c16168..dbc9d5e 100644 --- a/WebCore/bindings/v8/ScriptSourceCode.h +++ b/WebCore/bindings/v8/ScriptSourceCode.h @@ -31,6 +31,7 @@ #ifndef ScriptSourceCode_h #define ScriptSourceCode_h +#include "CachedResourceHandle.h" #include "CachedScript.h" #include "KURL.h" #include "PlatformString.h" @@ -41,6 +42,7 @@ class ScriptSourceCode { public: ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1) : m_source(source) + , m_cachedScript(0) , m_url(url) , m_startLine(startLine) { @@ -50,6 +52,7 @@ public: // Not sure if that matters. ScriptSourceCode(CachedScript* cs) : m_source(cs->script()) + , m_cachedScript(cs) , m_url(ParsedURLString, cs->url()) , m_startLine(1) { @@ -58,11 +61,13 @@ public: bool isEmpty() const { return m_source.isEmpty(); } const String& source() const { return m_source; } + CachedScript* cachedScript() const { return m_cachedScript.get(); } const KURL& url() const { return m_url; } int startLine() const { return m_startLine; } private: String m_source; + CachedResourceHandle<CachedScript> m_cachedScript; KURL m_url; int m_startLine; }; diff --git a/WebCore/bindings/v8/ScriptValue.cpp b/WebCore/bindings/v8/ScriptValue.cpp index 02d62db..3aca3c1 100755 --- a/WebCore/bindings/v8/ScriptValue.cpp +++ b/WebCore/bindings/v8/ScriptValue.cpp @@ -63,7 +63,7 @@ bool ScriptValue::getString(String& result) const String ScriptValue::toString(ScriptState*) const { - return toWebCoreStringWithNullCheck(m_value); + return toWebCoreString(m_value); } } // namespace WebCore diff --git a/WebCore/bindings/v8/V8Binding.cpp b/WebCore/bindings/v8/V8Binding.cpp index 97805c0..1272fd4 100644 --- a/WebCore/bindings/v8/V8Binding.cpp +++ b/WebCore/bindings/v8/V8Binding.cpp @@ -442,25 +442,29 @@ static void cachedStringCallback(v8::Persistent<v8::Value> wrapper, void* parame stringImpl->deref(); } -v8::Local<v8::String> v8ExternalString(const String& string) +RefPtr<StringImpl> lastStringImpl = 0; +v8::Persistent<v8::String> lastV8String; + +v8::Local<v8::String> v8ExternalStringSlow(StringImpl* stringImpl) { - StringImpl* stringImpl = string.impl(); - if (!stringImpl || !stringImpl->length()) + if (!stringImpl->length()) return v8::String::Empty(); if (!stringImplCacheEnabled) - return makeExternalString(string); + return makeExternalString(String(stringImpl)); StringCache& stringCache = getStringCache(); v8::String* cachedV8String = stringCache.get(stringImpl); - if (cachedV8String) - { + if (cachedV8String) { v8::Persistent<v8::String> handle(cachedV8String); - if (!handle.IsNearDeath() && !handle.IsEmpty()) + if (!handle.IsNearDeath() && !handle.IsEmpty()) { + lastStringImpl = stringImpl; + lastV8String = handle; return v8::Local<v8::String>::New(handle); + } } - v8::Local<v8::String> newString = makeExternalString(string); + v8::Local<v8::String> newString = makeExternalString(String(stringImpl)); if (newString.IsEmpty()) return newString; @@ -472,6 +476,9 @@ v8::Local<v8::String> v8ExternalString(const String& string) wrapper.MakeWeak(stringImpl, cachedStringCallback); stringCache.set(stringImpl, *wrapper); + lastStringImpl = stringImpl; + lastV8String = wrapper; + return newString; } diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h index 696cd1a..9eebf51 100644 --- a/WebCore/bindings/v8/V8Binding.h +++ b/WebCore/bindings/v8/V8Binding.h @@ -81,10 +81,30 @@ namespace WebCore { AtomicString v8NonStringValueToAtomicWebCoreString(v8::Handle<v8::Value>); AtomicString v8ValueToAtomicWebCoreString(v8::Handle<v8::Value> value); + // Note: RefPtr is a must as we cache by StringImpl* equality, not identity + // hence lastStringImpl might be not a key of the cache (in sense of identity) + // and hence it's not refed on addition. + extern RefPtr<StringImpl> lastStringImpl; + extern v8::Persistent<v8::String> lastV8String; + v8::Local<v8::String> v8ExternalStringSlow(StringImpl* stringImpl); + // Return a V8 external string that shares the underlying buffer with the given // WebCore string. The reference counting mechanism is used to keep the // underlying buffer alive while the string is still live in the V8 engine. - v8::Local<v8::String> v8ExternalString(const String&); + inline v8::Local<v8::String> v8ExternalString(const String& string) + { + StringImpl* stringImpl = string.impl(); + if (!stringImpl) + return v8::String::Empty(); + + if (lastStringImpl.get() == stringImpl) { + ASSERT(!lastV8String.IsNearDeath()); + ASSERT(!lastV8String.IsEmpty()); + return v8::Local<v8::String>::New(lastV8String); + } + + return v8ExternalStringSlow(stringImpl); + } // Convert a string to a V8 string. inline v8::Handle<v8::String> v8String(const String& string) diff --git a/WebCore/bindings/v8/V8GCController.cpp b/WebCore/bindings/v8/V8GCController.cpp index 5611199..c27e1d5 100644 --- a/WebCore/bindings/v8/V8GCController.cpp +++ b/WebCore/bindings/v8/V8GCController.cpp @@ -39,6 +39,7 @@ #include "HTMLNames.h" #include "MessagePort.h" #include "SVGElement.h" +#include "V8Binding.h" #include "V8DOMMap.h" #include "V8MessagePort.h" #include "V8Proxy.h" @@ -359,6 +360,10 @@ void V8GCController::gcPrologue() ObjectGrouperVisitor objectGrouperVisitor; visitDOMNodesInCurrentThread(&objectGrouperVisitor); objectGrouperVisitor.applyGrouping(); + + // Clean single element cache for string conversions. + lastStringImpl = 0; + lastV8String.Clear(); } class GCEpilogueVisitor : public DOMWrapperMap<void>::Visitor { diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp index 7a5df96..a8473be 100644 --- a/WebCore/bindings/v8/V8Proxy.cpp +++ b/WebCore/bindings/v8/V8Proxy.cpp @@ -32,6 +32,7 @@ #include "V8Proxy.h" #include "CSSMutableStyleDeclaration.h" +#include "CachedMetadata.h" #include "DateExtension.h" #include "DocumentLoader.h" #include "Frame.h" @@ -55,6 +56,7 @@ #include "V8HiddenPropertyName.h" #include "V8IsolatedContext.h" #include "V8RangeException.h" +#include "V8SQLException.h" #include "V8XMLHttpRequestException.h" #include "V8XPathException.h" #include "WorkerContext.h" @@ -69,6 +71,7 @@ #include <utility> #include <wtf/Assertions.h> #include <wtf/OwnArrayPtr.h> +#include <wtf/OwnPtr.h> #include <wtf/StdLibExtras.h> #include <wtf/StringExtras.h> #include <wtf/UnusedParam.h> @@ -240,6 +243,7 @@ V8Proxy::~V8Proxy() windowShell()->destroyGlobal(); } +<<<<<<< HEAD v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine) #ifdef ANDROID_INSTRUMENT { @@ -251,12 +255,15 @@ v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const v8::Handle<v8::Script> V8Proxy::compileScriptInternal(v8::Handle<v8::String> code, const String& fileName, int baseLine) #endif +======= +v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData) +>>>>>>> webkit.org at r61871 { const uint16_t* fileNameString = fromWebCoreString(fileName); v8::Handle<v8::String> name = v8::String::New(fileNameString, fileName.length()); v8::Handle<v8::Integer> line = v8::Integer::New(baseLine); v8::ScriptOrigin origin(name, line); - v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin); + v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin, scriptData); return script; } @@ -355,6 +362,28 @@ bool V8Proxy::setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetCont return true; } +PassOwnPtr<v8::ScriptData> V8Proxy::precompileScript(v8::Handle<v8::String> code, CachedScript* cachedScript) +{ + // A pseudo-randomly chosen ID used to store and retrieve V8 ScriptData from + // the CachedScript. If the format changes, this ID should be changed too. + static const unsigned dataTypeID = 0xECC13BD7; + + // Very small scripts are not worth the effort to preparse. + static const int minPreparseLength = 1024; + + if (!cachedScript || code->Length() < minPreparseLength) + return 0; + + CachedMetadata* cachedMetadata = cachedScript->cachedMetadata(dataTypeID); + if (cachedMetadata) + return v8::ScriptData::New(cachedMetadata->data(), cachedMetadata->size()); + + OwnPtr<v8::ScriptData> scriptData(v8::ScriptData::PreCompile(code)); + cachedScript->setCachedMetadata(dataTypeID, scriptData->Data(), scriptData->Length()); + + return scriptData.release(); +} + v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* node) { ASSERT(v8::Context::InContext()); @@ -380,10 +409,11 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod #if PLATFORM(CHROMIUM) PlatformBridge::traceEventBegin("v8.compile", node, ""); #endif + OwnPtr<v8::ScriptData> scriptData = precompileScript(code, source.cachedScript()); // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at // 1, whereas v8 starts at 0. - v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1); + v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1, scriptData.get()); #if PLATFORM(CHROMIUM) PlatformBridge::traceEventEnd("v8.compile", node, ""); @@ -711,6 +741,11 @@ void V8Proxy::setDOMException(int exceptionCode) exception = toV8(XPathException::create(description)); break; #endif +#if ENABLE(DATABASE) + case SQLExceptionType: + exception = toV8(SQLException::create(description)); + break; +#endif default: ASSERT_NOT_REACHED(); } @@ -738,6 +773,16 @@ v8::Handle<v8::Value> V8Proxy::throwError(ErrorType type, const char* message) } } +v8::Handle<v8::Value> V8Proxy::throwTypeError() +{ + return throwError(TypeError, "Type error"); +} + +v8::Handle<v8::Value> V8Proxy::throwSyntaxError() +{ + return throwError(SyntaxError, "Syntax error"); +} + v8::Local<v8::Context> V8Proxy::context(Frame* frame) { v8::Local<v8::Context> context = V8Proxy::mainWorldContext(frame); diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h index cd2ddad..ec9352c 100644 --- a/WebCore/bindings/v8/V8Proxy.h +++ b/WebCore/bindings/v8/V8Proxy.h @@ -53,6 +53,7 @@ namespace WebCore { + class CachedScript; class DOMWindow; class Frame; class Node; @@ -201,7 +202,6 @@ namespace WebCore { } #endif - void setEventHandlerLineNumber(int lineNumber) { m_handlerLineNumber = lineNumber; } void finishedWithEvent(Event*) { } // Evaluate JavaScript in a new isolated world. The script gets its own @@ -289,7 +289,7 @@ namespace WebCore { static v8::Handle<v8::Value> checkNewLegal(const v8::Arguments&); - static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine); + static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* = 0); #ifdef ANDROID_INSTRUMENT static v8::Handle<v8::Script> compileScriptInternal(v8::Handle<v8::String> code, const String& fileName, int baseLine); @@ -302,6 +302,10 @@ namespace WebCore { // Schedule an error object to be thrown. static v8::Handle<v8::Value> throwError(ErrorType, const char* message); + // Helpers for throwing syntax and type errors with predefined messages. + static v8::Handle<v8::Value> throwTypeError(); + static v8::Handle<v8::Value> throwSyntaxError(); + template <typename T> static v8::Handle<v8::Value> constructDOMObject(const v8::Arguments&, WrapperTypeInfo*); @@ -345,6 +349,8 @@ namespace WebCore { void resetIsolatedWorlds(); + PassOwnPtr<v8::ScriptData> precompileScript(v8::Handle<v8::String>, CachedScript*); + // Returns false when we're out of memory in V8. bool setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext); @@ -361,13 +367,15 @@ namespace WebCore { static const char* svgExceptionName(int exceptionCode); #endif +#if ENABLE(DATABASE) + static const char* sqlExceptionName(int exceptionCode); +#endif + Frame* m_frame; // For the moment, we have one of these. Soon we will have one per DOMWrapperWorld. RefPtr<V8DOMWindowShell> m_windowShell; - int m_handlerLineNumber; - // True for <a href="javascript:foo()"> and false for <script>foo()</script>. // Only valid during execution. bool m_inlineCode; diff --git a/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp b/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp index 3e48f4b..501e5a2 100644 --- a/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp @@ -45,7 +45,7 @@ v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& ar INC_STATS("DOM.ArrayBuffer.Constructor"); if (!args.IsConstructCall()) - return throwError("DOM object constructor cannot be called as a function."); + return throwError("DOM object constructor cannot be called as a function.", V8Proxy::SyntaxError); // If we return a previously constructed ArrayBuffer, // e.g. from the call to ArrayBufferView.buffer, this code is called @@ -61,22 +61,15 @@ v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& ar // ArrayBuffer(n) where n is an integer: // -- create an empty buffer of n bytes - int argLen = args.Length(); - if (argLen > 1) - return throwError("Wrong number of arguments specified to constructor (requires 1)"); - - int len = 0; - if (argLen > 0) { - if (!args[0]->IsInt32()) - return throwError("Argument to ArrayBuffer constructor was not an integer"); - len = toInt32(args[0]); - } - - RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(len, 1); - if (!buffer.get()) { - V8Proxy::setDOMException(INDEX_SIZE_ERR); - return v8::Undefined(); - } + int argLength = args.Length(); + int length = 0; + if (argLength > 0) + length = toInt32(args[0]); // NaN/+inf/-inf returns 0, this is intended by WebIDL + RefPtr<ArrayBuffer> buffer; + if (length >= 0) + buffer = ArrayBuffer::create(static_cast<unsigned>(length), 1); + if (!buffer.get()) + return throwError("ArrayBuffer size is not a small enough positive integer.", V8Proxy::RangeError); // Transform the holder into a wrapper object for the array. V8DOMWrapper::setDOMWrapper(args.Holder(), &info, buffer.get()); return toV8(buffer.release(), args.Holder()); diff --git a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h index cc34778..1c5d731 100644 --- a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h +++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h @@ -68,6 +68,12 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType // "buf", starting at the specified offset, for the given // length + if (args[0]->IsNull()) { + // Invalid first argument + // FIXME: use forthcoming V8Proxy::throwTypeError(). + return V8Proxy::throwError(V8Proxy::TypeError, "Type error"); + } + // See whether the first argument is a ArrayBuffer. if (V8ArrayBuffer::HasInstance(args[0])) { ArrayBuffer* buf = V8ArrayBuffer::toNative(args[0]->ToObject()); @@ -88,8 +94,10 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType } RefPtr<ArrayClass> array = ArrayClass::create(buf, offset, length); - if (!array) - return throwError("Out-of-range offset and/or length"); + if (!array) { + V8Proxy::setDOMException(INDEX_SIZE_ERR); + return notHandledByInterceptor(); + } // Transform the holder into a wrapper object for the array. V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get()); args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length()); @@ -98,22 +106,29 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType uint32_t len = 0; v8::Handle<v8::Object> srcArray; + bool doInstantiation = false; - if (args[0]->IsInt32()) { - len = toUInt32(args[0]); - } else if (args[0]->IsObject()) { + if (args[0]->IsObject()) { srcArray = args[0]->ToObject(); if (srcArray.IsEmpty()) return throwError("Could not convert argument 0 to an array"); len = toUInt32(srcArray->Get(v8::String::New("length"))); - } else - return throwError("Could not convert argument 0 to either a number or an array"); - - RefPtr<ArrayClass> array = ArrayClass::create(len); - if (!array.get()) { - V8Proxy::setDOMException(INDEX_SIZE_ERR); - return v8::Undefined(); + doInstantiation = true; + } else { + bool ok = false; + int32_t tempLength = toInt32(args[0], ok); // NaN/+inf/-inf returns 0, this is intended by WebIDL + if (ok && tempLength >= 0) { + len = static_cast<uint32_t>(tempLength); + doInstantiation = true; + } } + + RefPtr<ArrayClass> array; + if (doInstantiation) + array = ArrayClass::create(len); + if (!array.get()) + return throwError("ArrayBufferView size is not a small enough positive integer.", V8Proxy::RangeError); + if (!srcArray.IsEmpty()) { // Need to copy the incoming array into the newly created ArrayBufferView. for (unsigned i = 0; i < len; i++) { diff --git a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp index df16501..7a0a545 100644 --- a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp @@ -44,7 +44,7 @@ namespace WebCore { -WrapperTypeInfo V8HTMLAudioElementConstructor::info = { V8HTMLAudioElementConstructor::GetTemplate, 0, false }; +WrapperTypeInfo V8HTMLAudioElementConstructor::info = { V8HTMLAudioElementConstructor::GetTemplate, 0, 0 }; static v8::Handle<v8::Value> v8HTMLAudioElementConstructorCallback(const v8::Arguments& args) { diff --git a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.h b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.h index 8bc5f2c..8bc5f2c 100755..100644 --- a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.h +++ b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.h diff --git a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp index 4751224..24b1709 100644 --- a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp @@ -44,7 +44,7 @@ namespace WebCore { -WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, 0, false }; +WrapperTypeInfo V8HTMLImageElementConstructor::info = { V8HTMLImageElementConstructor::GetTemplate, 0, 0 }; static v8::Handle<v8::Value> v8HTMLImageElementConstructorCallback(const v8::Arguments& args) { diff --git a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.h b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.h index 5db4946..5db4946 100755..100644 --- a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.h +++ b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.h diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp index 6b84856..14c80b9 100644 --- a/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.cpp @@ -44,7 +44,7 @@ namespace WebCore { -WrapperTypeInfo V8HTMLOptionElementConstructor::info = { V8HTMLOptionElementConstructor::GetTemplate, 0, false }; +WrapperTypeInfo V8HTMLOptionElementConstructor::info = { V8HTMLOptionElementConstructor::GetTemplate, 0, 0 }; static v8::Handle<v8::Value> v8HTMLOptionElementConstructorCallback(const v8::Arguments& args) { diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.h b/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.h index 2adf0fe..2adf0fe 100755..100644 --- a/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.h +++ b/WebCore/bindings/v8/custom/V8HTMLOptionElementConstructor.h diff --git a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp index bf81ae9..2ce4780 100644 --- a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp @@ -58,6 +58,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createHTMLNotificationCallback(const if (ec) return throwError(ec); + notification->ref(); return toV8(notification.get()); } @@ -72,6 +73,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8: if (ec) return throwError(ec); + notification->ref(); return toV8(notification.get()); } diff --git a/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp b/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp index 7c24ac8..63d0a97 100644 --- a/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SQLResultSetRowListCustom.cpp @@ -56,7 +56,7 @@ v8::Handle<v8::Value> V8SQLResultSetRowList::itemCallback(const v8::Arguments& a SQLResultSetRowList* rowList = V8SQLResultSetRowList::toNative(args.Holder()); unsigned long index = args[0]->IntegerValue(); - if (index < 0 || index >= rowList->length()) { + if (index >= rowList->length()) { V8Proxy::throwError(V8Proxy::RangeError, "Item index is out of range."); return v8::Undefined(); } @@ -91,4 +91,3 @@ v8::Handle<v8::Value> V8SQLResultSetRowList::itemCallback(const v8::Arguments& a } // namespace WebCore #endif - diff --git a/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp b/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp index b931053..5e15dab 100644 --- a/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp @@ -93,24 +93,6 @@ v8::Handle<v8::Value> V8WebSocket::constructorCallback(const v8::Arguments& args return args.Holder(); } -v8::Handle<v8::Value> V8WebSocket::sendCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebSocket.send()"); - WebSocket* webSocket = V8WebSocket::toNative(args.Holder()); - - ExceptionCode ec = 0; - bool ret = false; - if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SyntaxError); - else { - String msg = toWebCoreString(args[0]); - ret = webSocket->send(msg, ec); - } - if (ec) - return throwError(ec); - return v8Boolean(ret); -} - } // namespace WebCore #endif // ENABLE(WEB_SOCKETS) diff --git a/WebCore/bindings/v8/npruntime.cpp b/WebCore/bindings/v8/npruntime.cpp index 12500a7..836456a 100644 --- a/WebCore/bindings/v8/npruntime.cpp +++ b/WebCore/bindings/v8/npruntime.cpp @@ -296,7 +296,6 @@ NPObject* _NPN_RetainObject(NPObject* npObject) void _NPN_DeallocateObject(NPObject* npObject) { ASSERT(npObject); - ASSERT(npObject->referenceCount >= 0); if (npObject) { // NPObjects that remain in pure C++ may never have wrappers. |