diff options
Diffstat (limited to 'Source/WebCore/bindings')
398 files changed, 10457 insertions, 5286 deletions
diff --git a/Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp b/Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp index f0c60985b..ae40d5146 100644 --- a/Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp +++ b/Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp @@ -56,7 +56,7 @@ #include "WebDOMSharedWorkerContext.h" #endif -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) #include "WebDOMNotification.h" #endif @@ -112,7 +112,7 @@ WebDOM##type WebDOMEventTarget::to##type() \ ConvertTo(Node) ConvertTo(DOMWindow) -#if ENABLE(WORKERS) +#if ENABLE(WORKERS) && 0 ConvertTo(Worker) ConvertTo(DedicatedWorkerContext) #endif @@ -122,7 +122,7 @@ ConvertTo(SharedWorker) ConvertTo(SharedWorkerContext) #endif -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) ConvertTo(Notification) #endif @@ -150,7 +150,7 @@ WebDOMEventTarget toWebKit(WebCore::EventTarget* value) return toWebKit(instance); #endif -#if ENABLE(WORKERS) +#if ENABLE(WORKERS) && 0 if (WebCore::Worker* worker = value->toWorker()) return toWebKit(worker); @@ -166,7 +166,7 @@ WebDOMEventTarget toWebKit(WebCore::EventTarget* value) return toWebKit(workerContext); #endif -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) if (WebCore::Notification* notification = value->toNotification()) return toWebKit(notification); #endif diff --git a/Source/WebCore/bindings/generic/BindingSecurity.h b/Source/WebCore/bindings/generic/BindingSecurity.h index 02b97ea70..7e5ff7de5 100644 --- a/Source/WebCore/bindings/generic/BindingSecurity.h +++ b/Source/WebCore/bindings/generic/BindingSecurity.h @@ -32,6 +32,8 @@ #define BindingSecurity_h #include "BindingSecurityBase.h" +#include "DOMWindow.h" +#include "Document.h" #include "Element.h" #include "Frame.h" #include "GenericBinding.h" @@ -61,8 +63,6 @@ public: static bool allowSettingFrameSrcToJavascriptUrl(State<Binding>*, HTMLFrameElementBase*, const String& value); static bool allowSettingSrcToJavascriptURL(State<Binding>*, Element*, const String& name, const String& value); - static bool shouldAllowNavigation(State<Binding>*, Frame*); - private: explicit BindingSecurity() {} ~BindingSecurity(); @@ -145,13 +145,6 @@ bool BindingSecurity<Binding>::allowSettingSrcToJavascriptURL(State<Binding>* st return true; } -template <class Binding> -bool BindingSecurity<Binding>::shouldAllowNavigation(State<Binding>* state, Frame* frame) -{ - Frame* activeFrame = state->activeFrame(); - return activeFrame && activeFrame->loader()->shouldAllowNavigation(frame); -} - } #endif // BindingSecurity_h diff --git a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp index 15f94d4d9..b7c31e6a9 100644 --- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp +++ b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp @@ -55,13 +55,15 @@ bool RuntimeEnabledFeatures::isTouchEnabled = true; bool RuntimeEnabledFeatures::isDeviceMotionEnabled = true; bool RuntimeEnabledFeatures::isDeviceOrientationEnabled = true; bool RuntimeEnabledFeatures::isSpeechInputEnabled = true; +bool RuntimeEnabledFeatures::isCSSExclusionsEnabled = false; #if ENABLE(SCRIPTED_SPEECH) bool RuntimeEnabledFeatures::isScriptedSpeechEnabled = false; #endif #if ENABLE(MEDIA_STREAM) -bool RuntimeEnabledFeatures::isMediaStreamEnabled = true; +bool RuntimeEnabledFeatures::isMediaStreamEnabled = false; +bool RuntimeEnabledFeatures::isPeerConnectionEnabled = true; #endif #if ENABLE(GAMEPAD) @@ -177,24 +179,27 @@ bool RuntimeEnabledFeatures::isMediaSourceEnabled = false; #endif #if ENABLE(VIDEO_TRACK) -#if PLATFORM(MAC) +#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(EFL) bool RuntimeEnabledFeatures::isVideoTrackEnabled = true; #else bool RuntimeEnabledFeatures::isVideoTrackEnabled = false; #endif #endif -#if ENABLE(SHADOW_DOM) -void RuntimeEnabledFeatures::setMultipleShadowSubtreesEnabled(bool isEnabled) -{ - isMultipleShadowSubtreesEnabled = isEnabled; -} +#if ENABLE(ENCRYPTED_MEDIA) +bool RuntimeEnabledFeatures::isEncryptedMediaEnabled = false; +#endif +#if ENABLE(SHADOW_DOM) bool RuntimeEnabledFeatures::isShadowDOMEnabled = false; -bool RuntimeEnabledFeatures::isMultipleShadowSubtreesEnabled = false; #endif #if ENABLE(STYLE_SCOPED) bool RuntimeEnabledFeatures::isStyleScopedEnabled = false; #endif + +#if ENABLE(INPUT_TYPE_DATE) +bool RuntimeEnabledFeatures::isInputTypeDateEnabled = true; +#endif + } // namespace WebCore diff --git a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h index ee38d04e2..8b47009c8 100644 --- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h +++ b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h @@ -70,7 +70,11 @@ public: static bool webkitIDBRequestEnabled() { return isIndexedDBEnabled; } static bool webkitIDBTransactionEnabled() { return isIndexedDBEnabled; } + static void setCSSExclusionsEnabled(bool isEnabled) { isCSSExclusionsEnabled = isEnabled; } + static bool cssExclusionsEnabled() { return isCSSExclusionsEnabled; } + #if ENABLE(FULLSCREEN_API) + // Mozilla version static bool webkitFullScreenAPIEnabled() { return isFullScreenAPIEnabled; } static void setWebkitFullScreenAPIEnabled(bool isEnabled) { isFullScreenAPIEnabled = isEnabled; } static bool webkitRequestFullScreenEnabled() { return isFullScreenAPIEnabled; } @@ -78,6 +82,12 @@ public: static bool webkitFullScreenKeyboardInputAllowedEnabled() { return isFullScreenAPIEnabled; } static bool webkitCurrentFullScreenElementEnabled() { return isFullScreenAPIEnabled; } static bool webkitCancelFullScreenEnabled() { return isFullScreenAPIEnabled; } + + // W3C version + static bool webkitFullscreenEnabledEnabled() { return isFullScreenAPIEnabled; } + static bool webkitFullscreenElementEnabled() { return isFullScreenAPIEnabled; } + static bool webkitExitFullscreenEnabled() { return isFullScreenAPIEnabled; } + static bool webkitRequestFullscreenEnabled() { return isFullScreenAPIEnabled; } #endif #if ENABLE(POINTER_LOCK) @@ -178,7 +188,12 @@ public: static bool mediaStreamEnabled() { return isMediaStreamEnabled; } static void setMediaStreamEnabled(bool isEnabled) { isMediaStreamEnabled = isEnabled; } static bool webkitGetUserMediaEnabled() { return isMediaStreamEnabled; } - static bool webkitPeerConnectionEnabled() { return isMediaStreamEnabled; } + static bool webkitMediaStreamEnabled() { return isMediaStreamEnabled; } + + static bool peerConnectionEnabled() { return isMediaStreamEnabled && isPeerConnectionEnabled; } + static void setPeerConnectionEnabled(bool isEnabled) { isPeerConnectionEnabled = isEnabled; } + static bool webkitDeprecatedPeerConnectionEnabled() { return peerConnectionEnabled(); } + static bool webkitPeerConnection00Enabled() { return peerConnectionEnabled(); } #endif #if ENABLE(GAMEPAD) @@ -192,8 +207,13 @@ public: #endif #if ENABLE(MEDIA_SOURCE) - static bool webkitMediaSourceEnabled() { return isMediaSourceEnabled; } - static void setWebkitMediaSourceEnabled(bool isEnabled) { isMediaSourceEnabled = isEnabled; } + static bool mediaSourceEnabled() { return isMediaSourceEnabled; } + static void setMediaSourceEnabled(bool isEnabled) { isMediaSourceEnabled = isEnabled; } +#endif + +#if ENABLE(ENCRYPTED_MEDIA) + static bool encryptedMediaEnabled() { return isEncryptedMediaEnabled; } + static void setEncryptedMediaEnabled(bool isEnabled) { isEncryptedMediaEnabled = isEnabled; } #endif #if ENABLE(VIDEO_TRACK) @@ -204,9 +224,6 @@ public: #if ENABLE(SHADOW_DOM) static bool shadowDOMEnabled() { return isShadowDOMEnabled; } static void setShadowDOMEnabled(bool isEnabled) { isShadowDOMEnabled = isEnabled; } - - static bool multipleShadowSubtreesEnabled() { return isMultipleShadowSubtreesEnabled; } - static void setMultipleShadowSubtreesEnabled(bool isEnabled); #endif #if ENABLE(STYLE_SCOPED) @@ -214,6 +231,11 @@ public: static void setStyleScopedEnabled(bool isEnabled) { isStyleScopedEnabled = isEnabled; } #endif +#if ENABLE(INPUT_TYPE_DATE) + static bool inputTypeDateEnabled() { return isInputTypeDateEnabled; } + static void setInputTypeDateEnabled(bool isEnabled) { isInputTypeDateEnabled = isEnabled; } +#endif + private: // Never instantiate. RuntimeEnabledFeatures() { } @@ -231,6 +253,7 @@ private: static bool isDeviceMotionEnabled; static bool isDeviceOrientationEnabled; static bool isSpeechInputEnabled; + static bool isCSSExclusionsEnabled; #if ENABLE(SCRIPTED_SPEECH) static bool isScriptedSpeechEnabled; #endif @@ -248,6 +271,7 @@ private: #if ENABLE(MEDIA_STREAM) static bool isMediaStreamEnabled; + static bool isPeerConnectionEnabled; #endif #if ENABLE(GAMEPAD) @@ -270,18 +294,25 @@ private: static bool isMediaSourceEnabled; #endif +#if ENABLE(ENCRYPTED_MEDIA) + static bool isEncryptedMediaEnabled; +#endif + #if ENABLE(VIDEO_TRACK) static bool isVideoTrackEnabled; #endif #if ENABLE(SHADOW_DOM) static bool isShadowDOMEnabled; - static bool isMultipleShadowSubtreesEnabled; #endif #if ENABLE(STYLE_SCOPED) static bool isStyleScopedEnabled; #endif + +#if ENABLE(INPUT_TYPE_DATE) + static bool isInputTypeDateEnabled; +#endif }; } // namespace WebCore diff --git a/Source/WebCore/bindings/gobject/GNUmakefile.am b/Source/WebCore/bindings/gobject/GNUmakefile.am index a51280f95..a806be67b 100644 --- a/Source/WebCore/bindings/gobject/GNUmakefile.am +++ b/Source/WebCore/bindings/gobject/GNUmakefile.am @@ -66,6 +66,8 @@ webkitgtk_gdom_built_sources += \ DerivedSources/webkit/WebKitDOMFileList.cpp \ DerivedSources/webkit/WebKitDOMFileListPrivate.h \ DerivedSources/webkit/WebKitDOMFilePrivate.h \ + DerivedSources/webkit/WebKitDOMGeolocation.cpp \ + DerivedSources/webkit/WebKitDOMGeolocationPrivate.h \ DerivedSources/webkit/WebKitDOMHistory.cpp \ DerivedSources/webkit/WebKitDOMHistoryPrivate.h \ DerivedSources/webkit/WebKitDOMHTMLAnchorElement.cpp \ @@ -293,6 +295,7 @@ webkitgtk_built_h_api += \ DerivedSources/webkit/WebKitDOMBlob.h \ DerivedSources/webkit/WebKitDOMFile.h \ DerivedSources/webkit/WebKitDOMFileList.h \ + DerivedSources/webkit/WebKitDOMGeolocation.h \ DerivedSources/webkit/WebKitDOMHTMLAnchorElement.h \ DerivedSources/webkit/WebKitDOMHTMLAppletElement.h \ DerivedSources/webkit/WebKitDOMHTMLAreaElement.h \ @@ -386,14 +389,6 @@ webkitgtk_built_h_api += \ DerivedSources/webkit/webkitdom.h \ DerivedSources/webkit/webkitdomdefines.h -if ENABLE_GEOLOCATION -webkitgtk_built_h_api += \ - $(top_builddir)/DerivedSources/webkit/WebKitDOMGeolocation.h -webkitgtk_gdom_built_sources += \ - DerivedSources/webkit/WebKitDOMGeolocation.cpp \ - DerivedSources/webkit/WebKitDOMGeolocationPrivate.h -endif - if ENABLE_VIDEO webkitgtk_built_h_api += \ $(top_builddir)/DerivedSources/webkit/WebKitDOMHTMLAudioElement.h \ @@ -433,6 +428,21 @@ webkitgtk_gdom_built_sources += \ DerivedSources/webkit/WebKitDOMHTMLPropertiesCollectionPrivate.h endif + +if ENABLE_WEB_TIMING +webkitgtk_built_h_api += \ + $(top_builddir)/DerivedSources/webkit/WebKitDOMPerformance.h \ + $(top_builddir)/DerivedSources/webkit/WebKitDOMPerformanceNavigation.h \ + $(top_builddir)/DerivedSources/webkit/WebKitDOMPerformanceTiming.h +webkitgtk_gdom_built_sources += \ + DerivedSources/webkit/WebKitDOMPerformance.cpp \ + DerivedSources/webkit/WebKitDOMPerformancePrivate.h \ + DerivedSources/webkit/WebKitDOMPerformanceNavigation.cpp \ + DerivedSources/webkit/WebKitDOMPerformanceNavigationPrivate.h \ + DerivedSources/webkit/WebKitDOMPerformanceTiming.cpp \ + DerivedSources/webkit/WebKitDOMPerformanceTimingPrivate.h +endif + gdom_class_list := $(subst WebKitDOM,, $(filter-out %Private, $(basename $(notdir $(webkitgtk_gdom_built_sources))))) gdom_class_list += Custom EventTarget Object DerivedSources/webkit/webkitdom.h: $(WebCore)/bindings/scripts/gobject-generate-headers.pl $(WebCore)/bindings/gobject/GNUmakefile.am diff --git a/Source/WebCore/bindings/js/CachedScriptSourceProvider.h b/Source/WebCore/bindings/js/CachedScriptSourceProvider.h index b0b6ac932..8efb48175 100644 --- a/Source/WebCore/bindings/js/CachedScriptSourceProvider.h +++ b/Source/WebCore/bindings/js/CachedScriptSourceProvider.h @@ -45,7 +45,16 @@ namespace WebCore { m_cachedScript->removeClient(this); } - JSC::UString getRange(int start, int end) const { return JSC::UString(m_cachedScript->script().characters() + start, end - start); } + virtual JSC::UString getRange(int start, int end) const OVERRIDE + { + int length = end - start; + ASSERT(length >= 0); + ASSERT(start + length <= this->length()); + + String script = m_cachedScript->script(); + return JSC::UString(StringImpl::create(script.impl(), start, length)); + } + const StringImpl* data() const { return m_cachedScript->script().impl(); } int length() const { return m_cachedScript->script().length(); } const String& source() const { return m_cachedScript->script(); } diff --git a/Source/WebCore/bindings/js/DOMObjectHashTableMap.h b/Source/WebCore/bindings/js/DOMObjectHashTableMap.h index 2c0e94836..216b945c4 100644 --- a/Source/WebCore/bindings/js/DOMObjectHashTableMap.h +++ b/Source/WebCore/bindings/js/DOMObjectHashTableMap.h @@ -47,7 +47,7 @@ public: HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.find(staticTable); if (iter != m_map.end()) return &iter->second; - return &m_map.set(staticTable, JSC::HashTable(*staticTable)).first->second; + return &m_map.set(staticTable, JSC::HashTable(*staticTable)).iterator->second; } private: diff --git a/Source/WebCore/bindings/js/DOMWrapperWorld.cpp b/Source/WebCore/bindings/js/DOMWrapperWorld.cpp index 812549bc3..a1f86d423 100644 --- a/Source/WebCore/bindings/js/DOMWrapperWorld.cpp +++ b/Source/WebCore/bindings/js/DOMWrapperWorld.cpp @@ -32,9 +32,9 @@ namespace WebCore { void JSStringOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSString* jsString = static_cast<JSString*>(handle.get().asCell()); + JSString* jsString = jsCast<JSString*>(handle.get().asCell()); StringImpl* stringImpl = static_cast<StringImpl*>(context); - ASSERT_UNUSED(jsString, m_world->m_stringCache.find(stringImpl)->second.get() == jsString); + ASSERT_UNUSED(jsString, m_world->m_stringCache.find(stringImpl)->second.was(jsString)); m_world->m_stringCache.remove(stringImpl); } diff --git a/Source/WebCore/bindings/js/DOMWrapperWorld.h b/Source/WebCore/bindings/js/DOMWrapperWorld.h index 010be0497..755375d65 100644 --- a/Source/WebCore/bindings/js/DOMWrapperWorld.h +++ b/Source/WebCore/bindings/js/DOMWrapperWorld.h @@ -91,7 +91,7 @@ inline DOMWrapperWorld* pluginWorld() { return mainThreadNormalWorld(); } inline DOMWrapperWorld* currentWorld(JSC::ExecState* exec) { - return static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->world(); + return JSC::jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->world(); } } // namespace WebCore diff --git a/Source/WebCore/bindings/js/Dictionary.cpp b/Source/WebCore/bindings/js/Dictionary.cpp new file mode 100644 index 000000000..2c1b785fe --- /dev/null +++ b/Source/WebCore/bindings/js/Dictionary.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2012 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Dictionary.h" + +#if ENABLE(NOTIFICATIONS) +#include "JSNotification.h" +#include "Notification.h" +#endif + +using namespace JSC; + +namespace WebCore { + +Dictionary::Dictionary(JSC::ExecState* exec, JSC::JSValue value) + : m_dictionary(exec, value.isObject() ? value.getObject() : 0) +{ +} + + +#if ENABLE(NOTIFICATIONS) +template<> +JSObject* Dictionary::asJSObject<Notification>(Notification* object) const +{ + return asObject(toJS(m_dictionary.execState(), jsCast<JSDOMGlobalObject*>(m_dictionary.execState()->lexicalGlobalObject()), object)); +} +#endif + +}; + diff --git a/Source/WebCore/bindings/js/Dictionary.h b/Source/WebCore/bindings/js/Dictionary.h new file mode 100644 index 000000000..d41cb1705 --- /dev/null +++ b/Source/WebCore/bindings/js/Dictionary.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2012 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 AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef Dictionary_h +#define Dictionary_h + +#include "JSDictionary.h" +#include "JSEventListener.h" +#include "NotImplemented.h" +#include "ScriptValue.h" +#include <wtf/text/CString.h> +#include <wtf/text/WTFString.h> + +namespace JSC { +class JSValue; +} + +namespace WebCore { +class EventListener; + +class Dictionary { +public: + Dictionary(JSC::ExecState*, JSC::JSValue); + + // Returns true if a value was found for the provided property. + template <typename Result> + bool get(const char* propertyName, Result&) const; + template <typename Result> + bool get(const String& propertyName, Result&) const; + + template <typename T> + PassRefPtr<EventListener> getEventListener(const char* propertyName, T* target) const; + template <typename T> + PassRefPtr<EventListener> getEventListener(const String& propertyName, T* target) const; + + bool isObject() const { return m_dictionary.isValid(); } + bool isUndefinedOrNull() const { return !m_dictionary.isValid(); } + bool getWithUndefinedOrNullCheck(const String&, String&) const { notImplemented(); return false; } + +private: + template <typename T> + JSC::JSObject* asJSObject(T*) const; + + JSDictionary m_dictionary; +}; + +template <typename Result> +bool Dictionary::get(const char* propertyName, Result& result) const +{ + if (!m_dictionary.isValid()) + return false; + + return m_dictionary.get(propertyName, result); +} + +template <typename Result> +bool Dictionary::get(const String& propertyName, Result& result) const +{ + return get(propertyName.utf8().data(), result); +} + +template <typename T> +PassRefPtr<EventListener> Dictionary::getEventListener(const char* propertyName, T* target) const +{ + if (!m_dictionary.isValid()) + return 0; + + ScriptValue eventListener; + if (!m_dictionary.tryGetProperty(propertyName, eventListener)) + return 0; + if (eventListener.hasNoValue()) + return 0; + + return JSEventListener::create(asObject(eventListener.jsValue()), asJSObject(target), true, currentWorld(m_dictionary.execState())); +} + +template <typename T> +PassRefPtr<EventListener> Dictionary::getEventListener(const String& propertyName, T* target) const +{ + return getEventListener(propertyName.utf8().data(), target); +} + +} + +#endif // Dictionary_h diff --git a/Source/WebCore/bindings/js/GCController.cpp b/Source/WebCore/bindings/js/GCController.cpp index cf70f18c3..a137c3a03 100644 --- a/Source/WebCore/bindings/js/GCController.cpp +++ b/Source/WebCore/bindings/js/GCController.cpp @@ -49,26 +49,40 @@ GCController& gcController() } GCController::GCController() +#if !USE(CF) : m_GCTimer(this, &GCController::gcTimerFired) +#endif { } void GCController::garbageCollectSoon() { + // We only use reportAbandonedObjectGraph on systems with CoreFoundation + // since it uses a runloop-based timer that is currently only available on + // systems with CoreFoundation. If and when the notion of a run loop is pushed + // down into WTF so that more platforms can take advantage of it, we will be + // able to use reportAbandonedObjectGraph on more platforms. +#if USE(CF) + JSLock lock(SilenceAssertionsOnly); + JSDOMWindow::commonJSGlobalData()->heap.reportAbandonedObjectGraph(); +#else if (!m_GCTimer.isActive()) m_GCTimer.startOneShot(0); +#endif } +#if !USE(CF) void GCController::gcTimerFired(Timer<GCController>*) { collect(0); } +#endif void GCController::garbageCollectNow() { JSLock lock(SilenceAssertionsOnly); if (!JSDOMWindow::commonJSGlobalData()->heap.isBusy()) - collect(0); + JSDOMWindow::commonJSGlobalData()->heap.collectAllGarbage(); } void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone) @@ -83,4 +97,10 @@ void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDon detachThread(threadID); } +void GCController::discardAllCompiledCode() +{ + JSLock lock(SilenceAssertionsOnly); + JSDOMWindow::commonJSGlobalData()->heap.discardAllCompiledCode(); +} + } // namespace WebCore diff --git a/Source/WebCore/bindings/js/GCController.h b/Source/WebCore/bindings/js/GCController.h index 91f1e4c53..a36737880 100644 --- a/Source/WebCore/bindings/js/GCController.h +++ b/Source/WebCore/bindings/js/GCController.h @@ -26,7 +26,12 @@ #ifndef GCController_h #define GCController_h +#if USE(CF) +#include <wtf/FastAllocBase.h> +#include <wtf/Noncopyable.h> +#else #include "Timer.h" +#endif namespace WebCore { @@ -40,11 +45,15 @@ namespace WebCore { void garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone); // Used for stress testing. + void discardAllCompiledCode(); + private: GCController(); // Use gcController() instead + +#if !USE(CF) void gcTimerFired(Timer<GCController>*); - Timer<GCController> m_GCTimer; +#endif }; // Function to obtain the global GC controller. diff --git a/Source/WebCore/bindings/js/IDBBindingUtilities.cpp b/Source/WebCore/bindings/js/IDBBindingUtilities.cpp index 67623f85c..cdc0c4884 100644 --- a/Source/WebCore/bindings/js/IDBBindingUtilities.cpp +++ b/Source/WebCore/bindings/js/IDBBindingUtilities.cpp @@ -26,7 +26,6 @@ #include "config.h" #if ENABLE(INDEXED_DATABASE) - #include "IDBBindingUtilities.h" #include "IDBKey.h" @@ -36,11 +35,11 @@ namespace WebCore { PassRefPtr<IDBKey> createIDBKeyFromValue(JSC::ExecState* exec, JSC::JSValue value) { if (value.isNull()) - return IDBKey::create(); + return IDBKey::createInvalid(); if (value.isInt32()) - return IDBKey::create(value.toInt32(exec)); + return IDBKey::createNumber(value.toNumber(exec)); if (value.isString()) - return IDBKey::create(ustringToString(value.toString(exec)->value(exec))); + return IDBKey::createString(ustringToString(value.toString(exec)->value(exec))); // FIXME: Implement dates. return 0; } diff --git a/Source/WebCore/bindings/js/IDBBindingUtilities.h b/Source/WebCore/bindings/js/IDBBindingUtilities.h index 7e7215269..8e0c9c5cd 100644 --- a/Source/WebCore/bindings/js/IDBBindingUtilities.h +++ b/Source/WebCore/bindings/js/IDBBindingUtilities.h @@ -28,6 +28,7 @@ #if ENABLE(INDEXED_DATABASE) +#include "Dictionary.h" #include "ScriptValue.h" #include <wtf/Forward.h> diff --git a/Source/WebCore/bindings/js/JSArrayBufferCustom.cpp b/Source/WebCore/bindings/js/JSArrayBufferCustom.cpp index 3ddcf9a48..2fa306a9d 100644 --- a/Source/WebCore/bindings/js/JSArrayBufferCustom.cpp +++ b/Source/WebCore/bindings/js/JSArrayBufferCustom.cpp @@ -36,7 +36,7 @@ using namespace JSC; EncodedJSValue JSC_HOST_CALL JSArrayBufferConstructor::constructJSArrayBuffer(ExecState* exec) { - JSArrayBufferConstructor* jsConstructor = static_cast<JSArrayBufferConstructor*>(exec->callee()); + JSArrayBufferConstructor* jsConstructor = jsCast<JSArrayBufferConstructor*>(exec->callee()); int length = 0; if (exec->argumentCount() > 0) diff --git a/Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp b/Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp index 2d917eb0d..d7441df2f 100644 --- a/Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp +++ b/Source/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010, Google Inc. All rights reserved. + * Copyright (C) 2012 Samsung Electronics * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,12 +43,12 @@ void JSAudioBufferSourceNode::setBuffer(ExecState* exec, JSValue value) AudioBufferSourceNode* imp = static_cast<AudioBufferSourceNode*>(impl()); AudioBuffer* buffer = toAudioBuffer(value); if (!buffer) { - throwError(exec, createSyntaxError(exec, "Value is not of type AudioBuffer")); + throwError(exec, createTypeError(exec, "Value is not of type AudioBuffer")); return; } if (!imp->setBuffer(buffer)) - throwError(exec, createSyntaxError(exec, "AudioBuffer unsupported number of channels")); + throwError(exec, createTypeError(exec, "AudioBuffer unsupported number of channels")); } } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSAudioContextCustom.cpp b/Source/WebCore/bindings/js/JSAudioContextCustom.cpp index 64e44e63f..120fc57db 100644 --- a/Source/WebCore/bindings/js/JSAudioContextCustom.cpp +++ b/Source/WebCore/bindings/js/JSAudioContextCustom.cpp @@ -51,7 +51,7 @@ void JSAudioContext::visitChildren(JSCell* cell, SlotVisitor& visitor) EncodedJSValue JSC_HOST_CALL JSAudioContextConstructor::constructJSAudioContext(ExecState* exec) { - JSAudioContextConstructor* jsConstructor = static_cast<JSAudioContextConstructor*>(exec->callee()); + JSAudioContextConstructor* jsConstructor = jsCast<JSAudioContextConstructor*>(exec->callee()); if (!jsConstructor) return throwVMError(exec, createReferenceError(exec, "AudioContext constructor callee is unavailable")); @@ -68,14 +68,19 @@ EncodedJSValue JSC_HOST_CALL JSAudioContextConstructor::constructJSAudioContext( if (!exec->argumentCount()) { // Constructor for default AudioContext which talks to audio hardware. - audioContext = AudioContext::create(document); + ExceptionCode ec = 0; + audioContext = AudioContext::create(document, ec); + if (ec) { + setDOMException(exec, ec); + return JSValue::encode(JSValue()); + } if (!audioContext.get()) return throwVMError(exec, createSyntaxError(exec, "audio resources unavailable for AudioContext construction")); } else { // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer. // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate); if (exec->argumentCount() < 3) - return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int32_t numberOfChannels = exec->argument(0).toInt32(exec); int32_t numberOfFrames = exec->argument(1).toInt32(exec); diff --git a/Source/WebCore/bindings/js/JSBlobCustom.cpp b/Source/WebCore/bindings/js/JSBlobCustom.cpp index 049456043..3392f3ce6 100644 --- a/Source/WebCore/bindings/js/JSBlobCustom.cpp +++ b/Source/WebCore/bindings/js/JSBlobCustom.cpp @@ -32,8 +32,15 @@ #include "JSBlob.h" #include "Blob.h" +#include "ExceptionCode.h" +#include "ExceptionCodePlaceholder.h" +#include "JSArrayBuffer.h" #include "JSDOMBinding.h" +#include "JSDictionary.h" #include "JSFile.h" +#include "WebKitBlobBuilder.h" +#include <runtime/Error.h> +#include <runtime/JSArray.h> #include <wtf/Assertions.h> using namespace JSC; @@ -51,4 +58,80 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Blob* blob) return CREATE_DOM_WRAPPER(exec, globalObject, Blob, blob); } +EncodedJSValue JSC_HOST_CALL JSBlobConstructor::constructJSBlob(ExecState* exec) +{ + JSBlobConstructor* jsConstructor = jsCast<JSBlobConstructor*>(exec->callee()); + ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); + if (!context) + return throwVMError(exec, createReferenceError(exec, "Blob constructor associated document is unavailable")); + + if (!exec->argumentCount()) { + RefPtr<Blob> blob = Blob::create(); + return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), Blob, blob.get())); + } + + JSValue firstArg = exec->argument(0); + if (!isJSArray(firstArg)) + return throwVMError(exec, createTypeError(exec, "First argument of the constructor is not of type Array")); + + String type; + String endings = "transparent"; + + if (exec->argumentCount() > 1) { + JSValue blobPropertyBagValue = exec->argument(1); + + if (!blobPropertyBagValue.isObject()) + return throwVMError(exec, createTypeError(exec, "Second argument of the constructor is not of type Object")); + + // Given the above test, this will always yield an object. + JSObject* blobPropertyBagObject = blobPropertyBagValue.toObject(exec); + + // Create the dictionary wrapper from the initializer object. + JSDictionary dictionary(exec, blobPropertyBagObject); + + // Attempt to get the endings property and validate it. + bool containsEndings = dictionary.get("endings", endings); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + if (containsEndings) { + if (endings != "transparent" && endings != "native") + return throwVMError(exec, createTypeError(exec, "The endings property must be either \"transparent\" or \"native\"")); + } + + // Attempt to get the type property. + dictionary.get("type", type); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + } + + ASSERT(endings == "transparent" || endings == "native"); + + // FIXME: this would be better if the WebKitBlobBuilder were a stack object to avoid the allocation. + RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create(); + + JSArray* array = asArray(firstArg); + unsigned length = array->length(); + + for (unsigned i = 0; i < length; ++i) { + JSValue item = array->getIndex(i); +#if ENABLE(BLOB) + if (item.inherits(&JSArrayBuffer::s_info)) + blobBuilder->append(toArrayBuffer(item)); + else +#endif + if (item.inherits(&JSBlob::s_info)) + blobBuilder->append(toBlob(item)); + else { + String string = ustringToString(item.toString(exec)->value(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + blobBuilder->append(string, endings, ASSERT_NO_EXCEPTION); + } + } + + RefPtr<Blob> blob = blobBuilder->getBlob(type); + return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), Blob, blob.get())); +} + } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSCSSRuleListCustom.cpp b/Source/WebCore/bindings/js/JSCSSRuleListCustom.cpp index 28ccb1fde..87b69a635 100644 --- a/Source/WebCore/bindings/js/JSCSSRuleListCustom.cpp +++ b/Source/WebCore/bindings/js/JSCSSRuleListCustom.cpp @@ -37,7 +37,7 @@ namespace WebCore { bool JSCSSRuleListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSCSSRuleList* jsCSSRuleList = static_cast<JSCSSRuleList*>(handle.get().asCell()); + JSCSSRuleList* jsCSSRuleList = jsCast<JSCSSRuleList*>(handle.get().asCell()); if (!jsCSSRuleList->hasCustomProperties()) return false; if (CSSStyleSheet* styleSheet = jsCSSRuleList->impl()->styleSheet()) diff --git a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp index aaa117170..2c72fec41 100644 --- a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp +++ b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp @@ -34,6 +34,7 @@ #include "JSCSSValue.h" #include "JSNode.h" #include "PlatformString.h" +#include "Settings.h" #include "StylePropertySet.h" #include <runtime/StringPrototype.h> #include <wtf/ASCIICType.h> @@ -60,7 +61,7 @@ void JSCSSStyleDeclaration::visitChildren(JSCell* cell, SlotVisitor& visitor) class CSSPropertyInfo { public: - int propertyID; + CSSPropertyID propertyID; bool hadPixelOrPosPrefix; }; @@ -70,9 +71,13 @@ enum PropertyNamePrefix PropertyNamePrefixCSS, PropertyNamePrefixPixel, PropertyNamePrefixPos, +#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES) PropertyNamePrefixApple, +#endif PropertyNamePrefixEpub, +#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES) PropertyNamePrefixKHTML, +#endif PropertyNamePrefixWebKit }; @@ -113,18 +118,22 @@ static PropertyNamePrefix getCSSPropertyNamePrefix(const StringImpl& propertyNam // First character of the prefix within the property name may be upper or lowercase. UChar firstChar = toASCIILower(propertyName[0]); switch (firstChar) { +#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES) case 'a': if (matchesCSSPropertyNamePrefix(propertyName, "apple")) return PropertyNamePrefixApple; break; +#endif case 'c': if (matchesCSSPropertyNamePrefix(propertyName, "css")) return PropertyNamePrefixCSS; break; +#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES) case 'k': if (matchesCSSPropertyNamePrefix(propertyName, "khtml")) return PropertyNamePrefixKHTML; break; +#endif case 'e': if (matchesCSSPropertyNamePrefix(propertyName, "epub")) return PropertyNamePrefixEpub; @@ -169,7 +178,7 @@ static inline void writeEpubPrefix(char*& buffer) static CSSPropertyInfo cssPropertyIDForJSCSSPropertyName(const Identifier& propertyName) { - CSSPropertyInfo propertyInfo = {0, false}; + CSSPropertyInfo propertyInfo = {CSSPropertyInvalid, false}; bool hadPixelOrPosPrefix = false; unsigned length = propertyName.length(); @@ -209,11 +218,13 @@ static CSSPropertyInfo cssPropertyIDForJSCSSPropertyName(const Identifier& prope i += 3; hadPixelOrPosPrefix = true; break; +#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES) case PropertyNamePrefixApple: case PropertyNamePrefixKHTML: writeWebKitPrefix(bufferPtr); i += 5; break; +#endif case PropertyNamePrefixEpub: writeEpubPrefix(bufferPtr); i += 4; @@ -260,7 +271,7 @@ static CSSPropertyInfo cssPropertyIDForJSCSSPropertyName(const Identifier& prope int propertyID = hashTableEntry ? hashTableEntry->id : 0; if (propertyID) { propertyInfo.hadPixelOrPosPrefix = hadPixelOrPosPrefix; - propertyInfo.propertyID = propertyID; + propertyInfo.propertyID = static_cast<CSSPropertyID>(propertyID); propertyInfoCache.add(stringForCache, propertyInfo); } return propertyInfo; @@ -292,7 +303,7 @@ static inline JSValue cssPropertyGetterPixelOrPosPrefix(ExecState* exec, JSCSSSt static JSValue cssPropertyGetterPixelOrPosPrefixCallback(ExecState* exec, JSValue slotBase, unsigned propertyID) { - return cssPropertyGetterPixelOrPosPrefix(exec, static_cast<JSCSSStyleDeclaration*>(asObject(slotBase)), propertyID); + return cssPropertyGetterPixelOrPosPrefix(exec, jsCast<JSCSSStyleDeclaration*>(asObject(slotBase)), propertyID); } static inline JSValue cssPropertyGetter(ExecState* exec, JSCSSStyleDeclaration* thisObj, unsigned propertyID) @@ -306,7 +317,7 @@ static inline JSValue cssPropertyGetter(ExecState* exec, JSCSSStyleDeclaration* static JSValue cssPropertyGetterCallback(ExecState* exec, JSValue slotBase, unsigned propertyID) { - return cssPropertyGetter(exec, static_cast<JSCSSStyleDeclaration*>(asObject(slotBase)), propertyID); + return cssPropertyGetter(exec, jsCast<JSCSSStyleDeclaration*>(asObject(slotBase)), propertyID); } bool JSCSSStyleDeclaration::getOwnPropertySlotDelegate(ExecState*, const Identifier& propertyIdentifier, PropertySlot& slot) @@ -346,8 +357,18 @@ bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, const Identifier& prope String propValue = valueToStringWithNullCheck(exec, value); if (propertyInfo.hadPixelOrPosPrefix) propValue += "px"; + + bool important = false; + if (Settings::shouldRespectPriorityInCSSAttributeSetters()) { + size_t importantIndex = propValue.find("!important", 0, false); + if (importantIndex != notFound) { + important = true; + propValue = propValue.left(importantIndex - 1); + } + } + ExceptionCode ec = 0; - impl()->setPropertyInternal(static_cast<CSSPropertyID>(propertyInfo.propertyID), propValue, false, ec); + impl()->setPropertyInternal(static_cast<CSSPropertyID>(propertyInfo.propertyID), propValue, important, ec); setDOMException(exec, ec); return true; } diff --git a/Source/WebCore/bindings/js/JSCSSValueCustom.cpp b/Source/WebCore/bindings/js/JSCSSValueCustom.cpp index 0efb4bb4b..7ce457faf 100644 --- a/Source/WebCore/bindings/js/JSCSSValueCustom.cpp +++ b/Source/WebCore/bindings/js/JSCSSValueCustom.cpp @@ -52,7 +52,7 @@ namespace WebCore { bool JSCSSValueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, SlotVisitor& visitor) { - JSCSSValue* jsCSSValue = static_cast<JSCSSValue*>(handle.get().asCell()); + JSCSSValue* jsCSSValue = jsCast<JSCSSValue*>(handle.get().asCell()); if (!jsCSSValue->hasCustomProperties()) return false; DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); @@ -64,7 +64,7 @@ bool JSCSSValueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handl void JSCSSValueOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSCSSValue* jsCSSValue = static_cast<JSCSSValue*>(handle.get().asCell()); + JSCSSValue* jsCSSValue = jsCast<JSCSSValue*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); world->m_cssValueRoots.remove(jsCSSValue->impl()); uncacheWrapper(world, jsCSSValue->impl(), jsCSSValue); @@ -76,6 +76,13 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CSSValue* value) if (!value) return jsNull(); + // Scripts should only ever see cloned CSSValues, never the internal ones. + ASSERT(value->isCSSOMSafe()); + + // If we're here under erroneous circumstances, prefer returning null over a potentially insecure value. + if (!value->isCSSOMSafe()) + return jsNull(); + JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), value); if (wrapper) diff --git a/Source/WebCore/bindings/js/JSCallbackData.cpp b/Source/WebCore/bindings/js/JSCallbackData.cpp index 1c0c452d9..aa30de730 100644 --- a/Source/WebCore/bindings/js/JSCallbackData.cpp +++ b/Source/WebCore/bindings/js/JSCallbackData.cpp @@ -45,6 +45,12 @@ void JSCallbackData::deleteData(void* context) JSValue JSCallbackData::invokeCallback(MarkedArgumentBuffer& args, bool* raisedException) { ASSERT(callback()); + return invokeCallback(callback(), args, raisedException); +} + +JSValue JSCallbackData::invokeCallback(JSValue thisValue, MarkedArgumentBuffer& args, bool* raisedException) +{ + ASSERT(callback()); ASSERT(globalObject()); ExecState* exec = globalObject()->globalExec(); @@ -58,7 +64,7 @@ JSValue JSCallbackData::invokeCallback(MarkedArgumentBuffer& args, bool* raisedE if (callType == CallTypeNone) return JSValue(); } - + ScriptExecutionContext* context = globalObject()->scriptExecutionContext(); // We will fail to get the context if the frame has been detached. if (!context) @@ -69,8 +75,8 @@ JSValue JSCallbackData::invokeCallback(MarkedArgumentBuffer& args, bool* raisedE bool contextIsDocument = context->isDocument(); JSValue result = contextIsDocument - ? JSMainThreadExecState::call(exec, function, callType, callData, callback(), args) - : JSC::call(exec, function, callType, callData, callback(), args); + ? JSMainThreadExecState::call(exec, function, callType, callData, thisValue, args) + : JSC::call(exec, function, callType, callData, thisValue, args); InspectorInstrumentation::didCallFunction(cookie); globalObject()->globalData().timeoutChecker.stop(); @@ -84,8 +90,8 @@ JSValue JSCallbackData::invokeCallback(MarkedArgumentBuffer& args, bool* raisedE *raisedException = true; return result; } - + return result; } - + } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSCallbackData.h b/Source/WebCore/bindings/js/JSCallbackData.h index 77a26b54b..738d0eab3 100644 --- a/Source/WebCore/bindings/js/JSCallbackData.h +++ b/Source/WebCore/bindings/js/JSCallbackData.h @@ -65,6 +65,7 @@ public: JSDOMGlobalObject* globalObject() { return m_globalObject.get(); } JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer&, bool* raisedException = 0); + JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer&, bool* raisedException = 0); private: JSC::Strong<JSC::JSObject> m_callback; diff --git a/Source/WebCore/bindings/js/JSConsoleCustom.cpp b/Source/WebCore/bindings/js/JSConsoleCustom.cpp index f1d1fe990..b049f83e2 100644 --- a/Source/WebCore/bindings/js/JSConsoleCustom.cpp +++ b/Source/WebCore/bindings/js/JSConsoleCustom.cpp @@ -30,31 +30,14 @@ #include "JSConsole.h" #include "Console.h" -#include "JSScriptProfile.h" #include "ScriptCallStack.h" #include "ScriptCallStackFactory.h" -#include "ScriptProfile.h" -#include <runtime/JSArray.h> #include <wtf/OwnPtr.h> using namespace JSC; namespace WebCore { -typedef Vector<RefPtr<ScriptProfile> > ProfilesArray; - -JSValue JSConsole::profiles(ExecState* exec) const -{ - const ProfilesArray& profiles = impl()->profiles(); - MarkedArgumentBuffer list; - - ProfilesArray::const_iterator end = profiles.end(); - for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter) - list.append(toJS(exec, globalObject(), iter->get())); - - return constructArray(exec, globalObject(), list); -} - JSValue JSConsole::profile(ExecState* exec) { RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1)); diff --git a/Source/WebCore/bindings/js/JSDOMBinding.cpp b/Source/WebCore/bindings/js/JSDOMBinding.cpp index 0050a7315..5deacb74f 100644 --- a/Source/WebCore/bindings/js/JSDOMBinding.cpp +++ b/Source/WebCore/bindings/js/JSDOMBinding.cpp @@ -49,7 +49,7 @@ const JSC::HashTable* getHashTableForGlobalData(JSGlobalData& globalData, const JSValue jsStringSlowCase(ExecState* exec, JSStringCache& stringCache, StringImpl* stringImpl) { JSString* wrapper = jsString(exec, UString(stringImpl)); - stringCache.add(stringImpl, PassWeak<JSString>(exec->globalData(), wrapper, currentWorld(exec)->stringWrapperOwner(), stringImpl)); + stringCache.add(stringImpl, PassWeak<JSString>(wrapper, currentWorld(exec)->stringWrapperOwner(), stringImpl)); return wrapper; } @@ -160,7 +160,7 @@ void reportException(ExecState* exec, JSValue exception) if (ExceptionBase* exceptionBase = toExceptionBase(exception)) errorMessage = stringToUString(exceptionBase->message() + ": " + exceptionBase->description()); - ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptExecutionContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); // scriptExecutionContext can be null when the relevant global object is a stale inner window object. // It's harmless to return here without reporting the exception to the log and the debugger in this case. @@ -258,7 +258,7 @@ Structure* cacheDOMStructure(JSDOMGlobalObject* globalObject, Structure* structu { JSDOMStructureMap& structures = globalObject->structures(); ASSERT(!structures.contains(classInfo)); - return structures.set(classInfo, WriteBarrier<Structure>(globalObject->globalData(), globalObject, structure)).first->second.get(); + return structures.set(classInfo, WriteBarrier<Structure>(globalObject->globalData(), globalObject, structure)).iterator->second.get(); } JSC::JSObject* toJSSequence(ExecState* exec, JSValue value, unsigned& length) diff --git a/Source/WebCore/bindings/js/JSDOMBinding.h b/Source/WebCore/bindings/js/JSDOMBinding.h index 0eb3d9cf5..96f03f1db 100644 --- a/Source/WebCore/bindings/js/JSDOMBinding.h +++ b/Source/WebCore/bindings/js/JSDOMBinding.h @@ -35,6 +35,7 @@ #include "StyledElement.h" #include <heap/Weak.h> #include <runtime/FunctionPrototype.h> +#include <runtime/JSArray.h> #include <runtime/Lookup.h> #include <runtime/ObjectPrototype.h> #include <wtf/Forward.h> @@ -103,7 +104,7 @@ enum ParameterDefaultPolicy { // FIXME: Callers to this function should be using the global object // from which the object is being created, instead of assuming the lexical one. // e.g. subframe.document.body should use the subframe's global object, not the lexical one. - return static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); + return JSC::jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); } template<class WrapperClass> inline JSC::Structure* getDOMStructure(JSC::ExecState* exec, JSDOMGlobalObject* globalObject) @@ -121,7 +122,7 @@ enum ParameterDefaultPolicy { template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) { - return static_cast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec, static_cast<JSDOMGlobalObject*>(globalObject))->storedPrototype())); + return JSC::jsCast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec, JSC::jsCast<JSDOMGlobalObject*>(globalObject))->storedPrototype())); } // Overload these functions to provide a fast path for wrapper access. @@ -140,16 +141,16 @@ enum ParameterDefaultPolicy { { if (setInlineCachedWrapper(world, domObject, wrapper)) return; - JSC::PassWeak<JSDOMWrapper> passWeak(*world->globalData(), wrapper, wrapperOwner(world, domObject), wrapperContext(world, domObject)); - pair<DOMObjectWrapperMap::iterator, bool> result = world->m_wrappers.add(domObject, passWeak); - ASSERT_UNUSED(result, result.second); + JSC::PassWeak<JSDOMWrapper> passWeak(wrapper, wrapperOwner(world, domObject), wrapperContext(world, domObject)); + DOMObjectWrapperMap::AddResult result = world->m_wrappers.add(domObject, passWeak); + ASSERT_UNUSED(result, result.isNewEntry); } template <typename DOMClass> inline void uncacheWrapper(DOMWrapperWorld* world, DOMClass* domObject, JSDOMWrapper* wrapper) { if (clearInlineCachedWrapper(world, domObject, wrapper)) return; - ASSERT(world->m_wrappers.find(domObject)->second.get() == wrapper); + ASSERT(world->m_wrappers.find(domObject)->second.was(wrapper)); world->m_wrappers.remove(domObject); } @@ -215,6 +216,8 @@ enum ParameterDefaultPolicy { inline void* root(MediaList* mediaList) { + if (CSSRule* parentRule = mediaList->parentRule()) + return root(parentRule); if (CSSStyleSheet* parentStyleSheet = mediaList->parentStyleSheet()) return root(parentStyleSheet); return mediaList; @@ -278,6 +281,46 @@ enum ParameterDefaultPolicy { return toJS(exec, globalObject, ptr.get()); } + template <typename T> + JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<T>& iterator) + { + JSC::MarkedArgumentBuffer list; + typename Vector<T>::const_iterator end = iterator.end(); + + for (typename Vector<T>::const_iterator iter = iterator.begin(); iter != end; ++iter) + list.append(toJS(exec, globalObject, WTF::getPtr(*iter))); + + return JSC::constructArray(exec, globalObject, list); + } + + template<> + inline JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<String>& iterator) + { + JSC::MarkedArgumentBuffer array; + Vector<String>::const_iterator end = iterator.end(); + + for (Vector<String>::const_iterator it = iterator.begin(); it != end; ++it) + array.append(jsString(exec, stringToUString(*it))); + + return JSC::constructArray(exec, globalObject, array); + } + + template <class T> + Vector<T> toNativeArray(JSC::ExecState* exec, JSC::JSValue value) + { + if (!isJSArray(value)) + return Vector<T>(); + + Vector<T> result; + JSC::JSArray* array = asArray(value); + + for (unsigned i = 0; i < array->length(); ++i) { + String indexedValue = ustringToString(array->getIndex(i).toString(exec)->value(exec)); + result.append(indexedValue); + } + return result; + } + // Validates that the passed object is a sequence type per section 4.1.13 of the WebIDL spec. JSC::JSObject* toJSSequence(JSC::ExecState*, JSC::JSValue, unsigned&); diff --git a/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp b/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp index 65c1cf43f..7be93328c 100644 --- a/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp @@ -43,12 +43,12 @@ namespace WebCore { static HTMLFormElement* toHTMLFormElement(JSC::JSValue value) { - return value.inherits(&JSHTMLFormElement::s_info) ? static_cast<HTMLFormElement*>(static_cast<JSHTMLFormElement*>(asObject(value))->impl()) : 0; + return value.inherits(&JSHTMLFormElement::s_info) ? static_cast<HTMLFormElement*>(jsCast<JSHTMLFormElement*>(asObject(value))->impl()) : 0; } EncodedJSValue JSC_HOST_CALL JSDOMFormDataConstructor::constructJSDOMFormData(ExecState* exec) { - JSDOMFormDataConstructor* jsConstructor = static_cast<JSDOMFormDataConstructor*>(exec->callee()); + JSDOMFormDataConstructor* jsConstructor = jsCast<JSDOMFormDataConstructor*>(exec->callee()); HTMLFormElement* form = 0; if (exec->argumentCount() > 0) diff --git a/Source/WebCore/bindings/js/JSDOMGlobalObject.h b/Source/WebCore/bindings/js/JSDOMGlobalObject.h index adcd3889f..74f35b0b7 100644 --- a/Source/WebCore/bindings/js/JSDOMGlobalObject.h +++ b/Source/WebCore/bindings/js/JSDOMGlobalObject.h @@ -95,7 +95,7 @@ namespace WebCore { JSC::JSObject* constructor = ConstructorClass::create(exec, ConstructorClass::createStructure(exec->globalData(), const_cast<JSDOMGlobalObject*>(globalObject), globalObject->objectPrototype()), const_cast<JSDOMGlobalObject*>(globalObject)); ASSERT(!const_cast<JSDOMGlobalObject*>(globalObject)->constructors().contains(&ConstructorClass::s_info)); JSC::WriteBarrier<JSC::JSObject> temp; - const_cast<JSDOMGlobalObject*>(globalObject)->constructors().add(&ConstructorClass::s_info, temp).first->second.set(exec->globalData(), globalObject, constructor); + const_cast<JSDOMGlobalObject*>(globalObject)->constructors().add(&ConstructorClass::s_info, temp).iterator->second.set(exec->globalData(), globalObject, constructor); return constructor; } diff --git a/Source/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp b/Source/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp index dcd4c5ad5..bd8a3428a 100644 --- a/Source/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMMimeTypeArrayCustom.cpp @@ -35,7 +35,7 @@ bool JSDOMMimeTypeArray::canGetItemsForName(ExecState*, DOMMimeTypeArray* mimeTy JSValue JSDOMMimeTypeArray::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSDOMMimeTypeArray* thisObj = static_cast<JSDOMMimeTypeArray*>(asObject(slotBase)); + JSDOMMimeTypeArray* thisObj = jsCast<JSDOMMimeTypeArray*>(asObject(slotBase)); return toJS(exec, thisObj->globalObject(), thisObj->impl()->namedItem(identifierToAtomicString(propertyName))); } diff --git a/Source/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp b/Source/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp index 036a5a328..12a2d7a7f 100644 --- a/Source/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMPluginArrayCustom.cpp @@ -35,7 +35,7 @@ bool JSDOMPluginArray::canGetItemsForName(ExecState*, DOMPluginArray* pluginArra JSValue JSDOMPluginArray::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSDOMPluginArray* thisObj = static_cast<JSDOMPluginArray*>(asObject(slotBase)); + JSDOMPluginArray* thisObj = jsCast<JSDOMPluginArray*>(asObject(slotBase)); return toJS(exec, thisObj->globalObject(), thisObj->impl()->namedItem(identifierToAtomicString(propertyName))); } diff --git a/Source/WebCore/bindings/js/JSDOMPluginCustom.cpp b/Source/WebCore/bindings/js/JSDOMPluginCustom.cpp index 32b76edf8..061da3ab6 100644 --- a/Source/WebCore/bindings/js/JSDOMPluginCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMPluginCustom.cpp @@ -34,7 +34,7 @@ bool JSDOMPlugin::canGetItemsForName(ExecState*, DOMPlugin* plugin, const Identi JSValue JSDOMPlugin::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSDOMPlugin* thisObj = static_cast<JSDOMPlugin*>(asObject(slotBase)); + JSDOMPlugin* thisObj = jsCast<JSDOMPlugin*>(asObject(slotBase)); return toJS(exec, thisObj->globalObject(), thisObj->impl()->namedItem(identifierToAtomicString(propertyName))); } diff --git a/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp b/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp index 7c599c5db..56871c2cc 100644 --- a/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp @@ -42,7 +42,7 @@ bool JSDOMStringMap::canGetItemsForName(ExecState*, DOMStringMap* impl, const Id JSValue JSDOMStringMap::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSDOMStringMap* thisObj = static_cast<JSDOMStringMap*>(asObject(slotBase)); + JSDOMStringMap* thisObj = jsCast<JSDOMStringMap*>(asObject(slotBase)); return jsString(exec, thisObj->impl()->item(identifierToAtomicString(propertyName))); } diff --git a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp index 160465f4b..39e0ec14c 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp +++ b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp @@ -237,9 +237,9 @@ JSDOMWindow* toJSDOMWindow(JSValue value) return 0; const ClassInfo* classInfo = asObject(value)->classInfo(); if (classInfo == &JSDOMWindow::s_info) - return static_cast<JSDOMWindow*>(asObject(value)); + return jsCast<JSDOMWindow*>(asObject(value)); if (classInfo == &JSDOMWindowShell::s_info) - return static_cast<JSDOMWindowShell*>(asObject(value))->window(); + return jsCast<JSDOMWindowShell*>(asObject(value))->window(); return 0; } diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp index be551bf96..758a88a99 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -99,17 +99,17 @@ JSValue nonCachingStaticFunctionGetter(ExecState* exec, JSValue, const Identifie static JSValue childFrameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - return toJS(exec, static_cast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(identifierToAtomicString(propertyName))->domWindow()); + return toJS(exec, jsCast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(identifierToAtomicString(propertyName))->domWindow()); } static JSValue indexGetter(ExecState* exec, JSValue slotBase, unsigned index) { - return toJS(exec, static_cast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(index)->domWindow()); + return toJS(exec, jsCast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(index)->domWindow()); } static JSValue namedItemGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSDOMWindowBase* thisObj = static_cast<JSDOMWindow*>(asObject(slotBase)); + JSDOMWindowBase* thisObj = jsCast<JSDOMWindow*>(asObject(slotBase)); Document* document = thisObj->impl()->frame()->document(); ASSERT(thisObj->allowsAccessFrom(exec)); @@ -424,7 +424,8 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value) if (exec->hadException()) return; - impl()->setLocation(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec)); + if (Location* location = impl()->location()) + location->setHref(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec)); } JSValue JSDOMWindow::event(ExecState* exec) const @@ -515,7 +516,7 @@ inline JSValue DialogHandler::returnValue() const return jsUndefined(); Identifier identifier(m_exec, "returnValue"); PropertySlot slot; - if (!globalObject->methodTable()->getOwnPropertySlot(globalObject, m_exec, identifier, slot)) + if (!JSGlobalObject::getOwnPropertySlot(globalObject, m_exec, identifier, slot)) return jsUndefined(); return slot.getValue(m_exec, identifier); } @@ -663,9 +664,9 @@ DOMWindow* toDOMWindow(JSValue value) return 0; JSObject* object = asObject(value); if (object->inherits(&JSDOMWindow::s_info)) - return static_cast<JSDOMWindow*>(object)->impl(); + return jsCast<JSDOMWindow*>(object)->impl(); if (object->inherits(&JSDOMWindowShell::s_info)) - return static_cast<JSDOMWindowShell*>(object)->impl(); + return jsCast<JSDOMWindowShell*>(object)->impl(); return 0; } diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.h b/Source/WebCore/bindings/js/JSDOMWindowCustom.h index 7551fe4b6..57e816680 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowCustom.h +++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.h @@ -28,7 +28,7 @@ namespace WebCore { inline JSDOMWindow* asJSDOMWindow(JSC::JSGlobalObject* globalObject) { - return static_cast<JSDOMWindow*>(globalObject); + return JSC::jsCast<JSDOMWindow*>(globalObject); } inline const JSDOMWindow* asJSDOMWindow(const JSC::JSGlobalObject* globalObject) diff --git a/Source/WebCore/bindings/js/JSDOMWindowShell.h b/Source/WebCore/bindings/js/JSDOMWindowShell.h index b7c750140..8be0fb181 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowShell.h +++ b/Source/WebCore/bindings/js/JSDOMWindowShell.h @@ -43,12 +43,11 @@ namespace WebCore { JSDOMWindowShell(PassRefPtr<DOMWindow>, JSC::Structure*, DOMWrapperWorld*); static void destroy(JSCell*); - JSDOMWindow* window() const { return static_cast<JSDOMWindow*>(m_unwrappedObject.get()); } + JSDOMWindow* window() const { return JSC::jsCast<JSDOMWindow*>(unwrappedObject()); } void setWindow(JSC::JSGlobalData& globalData, JSDOMWindow* window) { ASSERT_ARG(window, window); - m_unwrappedObject.set(globalData, this, window); - setPrototype(globalData, window->prototype()); + setUnwrappedObject(globalData, window); } void setWindow(PassRefPtr<DOMWindow>); diff --git a/Source/WebCore/bindings/js/JSDOMWrapper.h b/Source/WebCore/bindings/js/JSDOMWrapper.h index 74f156aae..f0a8a3a42 100644 --- a/Source/WebCore/bindings/js/JSDOMWrapper.h +++ b/Source/WebCore/bindings/js/JSDOMWrapper.h @@ -33,7 +33,7 @@ class JSDOMWrapper : public JSC::JSNonFinalObject { public: JSDOMGlobalObject* globalObject() const { - return static_cast<JSDOMGlobalObject*>(JSC::JSNonFinalObject::globalObject()); + return JSC::jsCast<JSDOMGlobalObject*>(JSC::JSNonFinalObject::globalObject()); } ScriptExecutionContext* scriptExecutionContext() const diff --git a/Source/WebCore/bindings/js/JSDataViewCustom.cpp b/Source/WebCore/bindings/js/JSDataViewCustom.cpp index 87d44582f..3eb7a3e1a 100644 --- a/Source/WebCore/bindings/js/JSDataViewCustom.cpp +++ b/Source/WebCore/bindings/js/JSDataViewCustom.cpp @@ -58,14 +58,14 @@ EncodedJSValue JSC_HOST_CALL JSDataViewConstructor::constructJSDataView(ExecStat return JSValue::encode(jsUndefined()); } - JSDataViewConstructor* jsConstructor = static_cast<JSDataViewConstructor*>(exec->callee()); + JSDataViewConstructor* jsConstructor = jsCast<JSDataViewConstructor*>(exec->callee()); return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), view.get()))); } static JSValue getDataViewMember(ExecState* exec, DataView* imp, DataViewAccessType type) { if (exec->argumentCount() < 1) - return throwError(exec, createTypeError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; unsigned byteOffset = exec->argument(0).toUInt32(exec); if (exec->hadException()) @@ -122,7 +122,7 @@ JSValue JSDataView::getFloat64(ExecState* exec) static JSValue setDataViewMember(ExecState* exec, DataView* imp, DataViewAccessType type) { if (exec->argumentCount() < 2) - return throwError(exec, createTypeError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; unsigned byteOffset = exec->argument(0).toUInt32(exec); if (exec->hadException()) diff --git a/Source/WebCore/bindings/js/JSPeerConnectionCustom.cpp b/Source/WebCore/bindings/js/JSDeprecatedPeerConnectionCustom.cpp index df37f9159..56d5ee7c0 100644 --- a/Source/WebCore/bindings/js/JSPeerConnectionCustom.cpp +++ b/Source/WebCore/bindings/js/JSDeprecatedPeerConnectionCustom.cpp @@ -27,26 +27,26 @@ #if ENABLE(MEDIA_STREAM) -#include "JSPeerConnection.h" +#include "JSDeprecatedPeerConnection.h" #include "CallbackFunction.h" +#include "DeprecatedPeerConnection.h" #include "JSSignalingCallback.h" -#include "PeerConnection.h" #include <runtime/Error.h> using namespace JSC; namespace WebCore { -EncodedJSValue JSC_HOST_CALL JSPeerConnectionConstructor::constructJSPeerConnection(ExecState* exec) +EncodedJSValue JSC_HOST_CALL JSDeprecatedPeerConnectionConstructor::constructJSDeprecatedPeerConnection(ExecState* exec) { - JSPeerConnectionConstructor* jsConstructor = static_cast<JSPeerConnectionConstructor*>(exec->callee()); + JSDeprecatedPeerConnectionConstructor* jsConstructor = static_cast<JSDeprecatedPeerConnectionConstructor*>(exec->callee()); ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); if (!context) - return throwVMError(exec, createReferenceError(exec, "PeerConnection constructor associated document is unavailable")); + return throwVMError(exec, createReferenceError(exec, "DeprecatedPeerConnection constructor associated document is unavailable")); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); String serverConfiguration = ustringToString(exec->argument(0).toString(exec)->value(exec)); if (exec->hadException()) @@ -56,8 +56,8 @@ EncodedJSValue JSC_HOST_CALL JSPeerConnectionConstructor::constructJSPeerConnect if (exec->hadException()) return JSValue::encode(JSValue()); - RefPtr<PeerConnection> peerConnection = PeerConnection::create(context, serverConfiguration, signalingCallback.release()); - return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), PeerConnection, peerConnection.get())); + RefPtr<DeprecatedPeerConnection> peerConnection = DeprecatedPeerConnection::create(context, serverConfiguration, signalingCallback.release()); + return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), DeprecatedPeerConnection, peerConnection.get())); } } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp b/Source/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp index 16a962c56..38c682311 100644 --- a/Source/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp +++ b/Source/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2012 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 @@ -30,14 +31,12 @@ #include "config.h" -#if ENABLE(NOTIFICATIONS) +#if ENABLE(LEGACY_NOTIFICATIONS) #include "Document.h" #include "JSCustomVoidCallback.h" #include "JSEventListener.h" -#include "JSNotification.h" #include "JSNotificationCenter.h" -#include "Notification.h" #include "NotificationCenter.h" #include <runtime/Error.h> @@ -68,6 +67,6 @@ JSValue JSNotificationCenter::requestPermission(ExecState* exec) return jsUndefined(); } -} // namespace +} // namespace WebCore -#endif // ENABLE(NOTIFICATIONS) +#endif // ENABLE(LEGACY_NOTIFICATIONS) diff --git a/Source/WebCore/bindings/js/JSDictionary.cpp b/Source/WebCore/bindings/js/JSDictionary.cpp index d7913fa16..ead297a2c 100644 --- a/Source/WebCore/bindings/js/JSDictionary.cpp +++ b/Source/WebCore/bindings/js/JSDictionary.cpp @@ -42,7 +42,7 @@ using namespace JSC; namespace WebCore { -JSDictionary::GetPropertyResult JSDictionary::tryGetProperty(const char* propertyName, JSValue& finalResult) +JSDictionary::GetPropertyResult JSDictionary::tryGetProperty(const char* propertyName, JSValue& finalResult) const { Identifier identifier(m_exec, propertyName); PropertySlot slot(m_initializerObject); diff --git a/Source/WebCore/bindings/js/JSDictionary.h b/Source/WebCore/bindings/js/JSDictionary.h index fb8ea003a..8f6337d6e 100644 --- a/Source/WebCore/bindings/js/JSDictionary.h +++ b/Source/WebCore/bindings/js/JSDictionary.h @@ -48,11 +48,18 @@ public: { } + // Returns false if any exceptions were thrown, regardless of whether the property was found. template <typename Result> - bool tryGetProperty(const char* propertyName, Result&); - + bool tryGetProperty(const char* propertyName, Result&) const; template <typename T, typename Result> - bool tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&)); + bool tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const; + + // Returns true if the property was found in the dictionary, and the value could be converted to the desired type. + template <typename Result> + bool get(const char* propertyName, Result&) const; + + JSC::ExecState* execState() const { return m_exec; } + bool isValid() const { return m_exec && m_initializerObject; } private: template <typename Result> @@ -68,7 +75,10 @@ private: NoPropertyFound, PropertyFound }; - GetPropertyResult tryGetProperty(const char* propertyName, JSC::JSValue&); + + template <typename T, typename Result> + GetPropertyResult tryGetPropertyAndResult(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const; + GetPropertyResult tryGetProperty(const char* propertyName, JSC::JSValue&) const; static void convertValue(JSC::ExecState*, JSC::JSValue, bool& result); static void convertValue(JSC::ExecState*, JSC::JSValue, int& result); @@ -95,20 +105,38 @@ private: JSC::JSObject* m_initializerObject; }; +template <typename T, typename Result> +bool JSDictionary::tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const +{ + return tryGetPropertyAndResult(propertyName, context, setter) != ExceptionThrown; +} + +template <typename Result> +bool JSDictionary::tryGetProperty(const char* propertyName, Result& finalResult) const +{ + return tryGetPropertyAndResult(propertyName, &finalResult, IdentitySetter<Result>::identitySetter) != ExceptionThrown; +} + +template <typename Result> +bool JSDictionary::get(const char* propertyName, Result& finalResult) const +{ + return tryGetPropertyAndResult(propertyName, &finalResult, IdentitySetter<Result>::identitySetter) == PropertyFound; +} template <typename T, typename Result> -bool JSDictionary::tryGetProperty(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) +JSDictionary::GetPropertyResult JSDictionary::tryGetPropertyAndResult(const char* propertyName, T* context, void (*setter)(T* context, const Result&)) const { JSC::JSValue value; - switch (tryGetProperty(propertyName, value)) { + GetPropertyResult getPropertyResult = tryGetProperty(propertyName, value); + switch (getPropertyResult) { case ExceptionThrown: - return false; + return getPropertyResult; case PropertyFound: { Result result; convertValue(m_exec, value, result); if (m_exec->hadException()) - return false; + return ExceptionThrown; setter(context, result); break; @@ -117,13 +145,7 @@ bool JSDictionary::tryGetProperty(const char* propertyName, T* context, void (*s break; } - return true; -} - -template <typename Result> -bool JSDictionary::tryGetProperty(const char* propertyName, Result& finalResult) -{ - return tryGetProperty(propertyName, &finalResult, IdentitySetter<Result>::identitySetter); + return getPropertyResult; } } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSDirectoryEntryCustom.cpp b/Source/WebCore/bindings/js/JSDirectoryEntryCustom.cpp index 57d980cfb..15fb3f567 100644 --- a/Source/WebCore/bindings/js/JSDirectoryEntryCustom.cpp +++ b/Source/WebCore/bindings/js/JSDirectoryEntryCustom.cpp @@ -48,7 +48,7 @@ namespace WebCore { JSValue JSDirectoryEntry::getFile(ExecState* exec) { if (exec->argumentCount() < 1) - return throwError(exec, createTypeError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); DirectoryEntry* imp = static_cast<DirectoryEntry*>(impl()); const String& path = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); @@ -96,7 +96,7 @@ JSValue JSDirectoryEntry::getFile(ExecState* exec) JSValue JSDirectoryEntry::getDirectory(ExecState* exec) { if (exec->argumentCount() < 1) - return throwError(exec, createTypeError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); DirectoryEntry* imp = static_cast<DirectoryEntry*>(impl()); const String& path = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); diff --git a/Source/WebCore/bindings/js/JSDocumentCustom.cpp b/Source/WebCore/bindings/js/JSDocumentCustom.cpp index 8377a0912..b6de16225 100644 --- a/Source/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/Source/WebCore/bindings/js/JSDocumentCustom.cpp @@ -69,18 +69,12 @@ void JSDocument::setLocation(ExecState* exec, JSValue value) if (!frame) return; - String str = ustringToString(value.toString(exec)->value(exec)); - - Frame* lexicalFrame = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->frame(); - - // IE and Mozilla both resolve the URL relative to the source frame, - // not the target frame. - Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); - str = activeFrame->document()->completeURL(str).string(); + UString locationString = value.toString(exec)->value(exec); + if (exec->hadException()) + return; - bool lockHistory = !ScriptController::processingUserGesture(); - frame->navigationScheduler()->scheduleLocationChange(lexicalFrame->document()->securityOrigin(), - str, activeFrame->loader()->outgoingReferrer(), lockHistory, false); + if (Location* location = frame->domWindow()->location()) + location->setHref(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec)); } JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Document* document) diff --git a/Source/WebCore/bindings/js/JSEventListener.cpp b/Source/WebCore/bindings/js/JSEventListener.cpp index 58369005f..ab28ca813 100644 --- a/Source/WebCore/bindings/js/JSEventListener.cpp +++ b/Source/WebCore/bindings/js/JSEventListener.cpp @@ -37,7 +37,7 @@ namespace WebCore { JSEventListener::JSEventListener(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) : EventListener(JSEventListenerType) - , m_wrapper(*isolatedWorld->globalData(), wrapper) + , m_wrapper(wrapper) , m_isAttribute(isAttribute) , m_isolatedWorld(isolatedWorld) { @@ -87,7 +87,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext Frame* frame = 0; if (scriptExecutionContext->isDocument()) { - JSDOMWindow* window = static_cast<JSDOMWindow*>(globalObject); + JSDOMWindow* window = jsCast<JSDOMWindow*>(globalObject); frame = window->impl()->frame(); if (!frame) return; diff --git a/Source/WebCore/bindings/js/JSEventListener.h b/Source/WebCore/bindings/js/JSEventListener.h index 32a8c5634..ebcc8fd9f 100644 --- a/Source/WebCore/bindings/js/JSEventListener.h +++ b/Source/WebCore/bindings/js/JSEventListener.h @@ -22,6 +22,7 @@ #include "EventListener.h" #include "JSDOMWindow.h" +#include <heap/StrongInlines.h> #include <heap/Weak.h> namespace WebCore { @@ -53,7 +54,7 @@ namespace WebCore { DOMWrapperWorld* isolatedWorld() const { return m_isolatedWorld.get(); } JSC::JSObject* wrapper() const { return m_wrapper.get(); } - void setWrapper(JSC::JSGlobalData& globalData, JSC::JSObject* wrapper) const { m_wrapper = JSC::PassWeak<JSC::JSObject>(globalData, wrapper, 0); } + void setWrapper(JSC::JSGlobalData&, JSC::JSObject* wrapper) const { m_wrapper = JSC::PassWeak<JSC::JSObject>(wrapper); } private: virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const; @@ -74,6 +75,11 @@ namespace WebCore { inline JSC::JSObject* JSEventListener::jsFunction(ScriptExecutionContext* scriptExecutionContext) const { + // initializeJSFunction can trigger code that deletes this event listener + // before we're done. It should always return 0 in this case. + RefPtr<JSEventListener> protect(const_cast<JSEventListener*>(this)); + JSC::Strong<JSC::JSObject> wrapper(*m_isolatedWorld->globalData(), m_wrapper.get()); + if (!m_jsFunction) { JSC::JSObject* function = initializeJSFunction(scriptExecutionContext); m_jsFunction.setMayBeNull(*scriptExecutionContext->globalData(), m_wrapper.get(), function); diff --git a/Source/WebCore/bindings/js/JSEventTarget.cpp b/Source/WebCore/bindings/js/JSEventTarget.cpp index 45fad7f7c..66e157615 100644 --- a/Source/WebCore/bindings/js/JSEventTarget.cpp +++ b/Source/WebCore/bindings/js/JSEventTarget.cpp @@ -66,12 +66,12 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ #define TRY_TO_UNWRAP_WITH_INTERFACE(interfaceName) \ if (value.inherits(&JS##interfaceName::s_info)) \ - return static_cast<interfaceName*>(static_cast<JS##interfaceName*>(asObject(value))->impl()); + return static_cast<interfaceName*>(jsCast<JS##interfaceName*>(asObject(value))->impl()); EventTarget* toEventTarget(JSC::JSValue value) { if (value.inherits(&JSDOMWindowShell::s_info)) - return static_cast<JSDOMWindowShell*>(asObject(value))->impl(); + return jsCast<JSDOMWindowShell*>(asObject(value))->impl(); DOM_EVENT_TARGET_INTERFACES_FOR_EACH(TRY_TO_UNWRAP_WITH_INTERFACE) return 0; diff --git a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp index ed3b11265..cade52e38 100644 --- a/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSFloat32ArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSFloat32ArrayConstructor::constructJSFloat32Array(ExecState* exec) { - JSFloat32ArrayConstructor* jsConstructor = static_cast<JSFloat32ArrayConstructor*>(exec->callee()); + JSFloat32ArrayConstructor* jsConstructor = jsCast<JSFloat32ArrayConstructor*>(exec->callee()); RefPtr<Float32Array> array = constructArrayBufferView<Float32Array, float>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp b/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp index fbd82b51d..15619e325 100644 --- a/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSFloat64ArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSFloat64Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec) { - JSFloat64ArrayConstructor* jsConstructor = static_cast<JSFloat64ArrayConstructor*>(exec->callee()); + JSFloat64ArrayConstructor* jsConstructor = jsCast<JSFloat64ArrayConstructor*>(exec->callee()); RefPtr<Float64Array> array = constructArrayBufferView<Float64Array, double>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSGeolocationCustom.cpp b/Source/WebCore/bindings/js/JSGeolocationCustom.cpp index caac380ac..57fb180a3 100644 --- a/Source/WebCore/bindings/js/JSGeolocationCustom.cpp +++ b/Source/WebCore/bindings/js/JSGeolocationCustom.cpp @@ -37,10 +37,6 @@ #include "JSPositionErrorCallback.h" #include "PositionOptions.h" -#if !ENABLE(CLIENT_BASED_GEOLOCATION) -#include "GeolocationService.h" -#endif - using namespace JSC; using namespace std; @@ -105,12 +101,12 @@ JSValue JSGeolocation::getCurrentPosition(ExecState* exec) { // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions - RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<JSPositionCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(0)); + RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<JSPositionCallback>(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(0)); if (exec->hadException()) return jsUndefined(); ASSERT(positionCallback); - RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<JSPositionErrorCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(1), CallbackAllowUndefined | CallbackAllowNull); + RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<JSPositionErrorCallback>(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(1), CallbackAllowUndefined | CallbackAllowNull); if (exec->hadException()) return jsUndefined(); @@ -127,12 +123,12 @@ JSValue JSGeolocation::watchPosition(ExecState* exec) { // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions - RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<JSPositionCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(0)); + RefPtr<PositionCallback> positionCallback = createFunctionOnlyCallback<JSPositionCallback>(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(0)); if (exec->hadException()) return jsUndefined(); ASSERT(positionCallback); - RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<JSPositionErrorCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(1), CallbackAllowUndefined | CallbackAllowNull); + RefPtr<PositionErrorCallback> positionErrorCallback = createFunctionOnlyCallback<JSPositionErrorCallback>(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(1), CallbackAllowUndefined | CallbackAllowNull); if (exec->hadException()) return jsUndefined(); diff --git a/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp b/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp index 3626cdc34..f98c17650 100644 --- a/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLAllCollectionCustom.cpp @@ -64,7 +64,7 @@ static EncodedJSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec) return JSValue::encode(jsUndefined()); // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case. - JSHTMLAllCollection* jsCollection = static_cast<JSHTMLAllCollection*>(exec->callee()); + JSHTMLAllCollection* jsCollection = jsCast<JSHTMLAllCollection*>(exec->callee()); HTMLAllCollection* collection = static_cast<HTMLAllCollection*>(jsCollection->impl()); // Also, do we need the TypeError test here ? @@ -106,7 +106,7 @@ bool JSHTMLAllCollection::canGetItemsForName(ExecState*, HTMLAllCollection* coll JSValue JSHTMLAllCollection::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSHTMLAllCollection* thisObj = static_cast<JSHTMLAllCollection*>(asObject(slotBase)); + JSHTMLAllCollection* thisObj = jsCast<JSHTMLAllCollection*>(asObject(slotBase)); return getNamedItems(exec, thisObj, propertyName); } diff --git a/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp index df1866f6e..e6e65f9d5 100644 --- a/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp @@ -80,11 +80,10 @@ JSValue JSHTMLCanvasElement::getContext(ExecState* exec) JSValue JSHTMLCanvasElement::toDataURL(ExecState* exec) { - const String& type = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl()); ExceptionCode ec = 0; - - JSC::JSValue result; + + const String& type = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); double quality; double* qualityPtr = 0; if (exec->argumentCount() > 1) { @@ -95,7 +94,7 @@ JSValue JSHTMLCanvasElement::toDataURL(ExecState* exec) } } - result = jsString(exec, canvas->toDataURL(type, qualityPtr, ec)); + JSValue result = jsString(exec, canvas->toDataURL(type, qualityPtr, ec)); setDOMException(exec, ec); return result; } diff --git a/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp b/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp index d3f936fed..4f5f56c10 100644 --- a/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp @@ -33,11 +33,6 @@ #include <wtf/Vector.h> #include <wtf/text/AtomicString.h> -#if ENABLE(MICRODATA) -#include "HTMLPropertiesCollection.h" -#include "JSHTMLPropertiesCollection.h" -#endif - using namespace JSC; namespace WebCore { @@ -65,7 +60,7 @@ bool JSHTMLCollection::canGetItemsForName(ExecState*, HTMLCollection* collection JSValue JSHTMLCollection::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slotBase)); + JSHTMLCollection* thisObj = jsCast<JSHTMLCollection*>(asObject(slotBase)); return getNamedItems(exec, thisObj, propertyName); } @@ -91,11 +86,6 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, HTMLCollection* c case DocAll: wrapper = CREATE_DOM_WRAPPER(exec, globalObject, HTMLAllCollection, collection); break; -#if ENABLE(MICRODATA) - case ItemProperties: - wrapper = CREATE_DOM_WRAPPER(exec, globalObject, HTMLPropertiesCollection, collection); - break; -#endif default: wrapper = CREATE_DOM_WRAPPER(exec, globalObject, HTMLCollection, collection); break; diff --git a/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp b/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp index e64e24381..5d2e83ce1 100644 --- a/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp @@ -59,7 +59,7 @@ bool JSHTMLDocument::canGetItemsForName(ExecState*, HTMLDocument* document, cons JSValue JSHTMLDocument::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(asObject(slotBase)); + JSHTMLDocument* thisObj = jsCast<JSHTMLDocument*>(asObject(slotBase)); HTMLDocument* document = static_cast<HTMLDocument*>(thisObj->impl()); HTMLCollection* collection = document->documentNamedItems(identifierToAtomicString(propertyName)); diff --git a/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp index 757b50276..3087cd4ab 100644 --- a/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLFormElementCustom.cpp @@ -46,7 +46,7 @@ bool JSHTMLFormElement::canGetItemsForName(ExecState*, HTMLFormElement* form, co JSValue JSHTMLFormElement::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSHTMLElement* jsForm = static_cast<JSHTMLFormElement*>(asObject(slotBase)); + JSHTMLElement* jsForm = jsCast<JSHTMLFormElement*>(asObject(slotBase)); HTMLFormElement* form = static_cast<HTMLFormElement*>(jsForm->impl()); Vector<RefPtr<Node> > namedItems; diff --git a/Source/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp index 07bac6168..95093c939 100644 --- a/Source/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp @@ -49,7 +49,7 @@ bool JSHTMLFrameSetElement::canGetItemsForName(ExecState*, HTMLFrameSetElement* JSValue JSHTMLFrameSetElement::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - HTMLElement* element = static_cast<JSHTMLElement*>(asObject(slotBase))->impl(); + HTMLElement* element = jsCast<JSHTMLElement*>(asObject(slotBase))->impl(); Node* frameElement = element->children()->namedItem(identifierToAtomicString(propertyName)); if (Document* document = static_cast<HTMLFrameElement*>(frameElement)->contentDocument()) { if (JSDOMWindowShell* window = toJSDOMWindowShell(document->frame(), currentWorld(exec))) diff --git a/Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp b/Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp index d98602a44..480b88a44 100644 --- a/Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp @@ -91,7 +91,7 @@ JSValue JSHTMLOptionsCollection::add(ExecState* exec) JSValue JSHTMLOptionsCollection::remove(ExecState* exec) { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); - JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, globalObject(), imp->base()))); + JSHTMLSelectElement* base = jsCast<JSHTMLSelectElement*>(asObject(toJS(exec, globalObject(), imp->base()))); return base->remove(exec); } diff --git a/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp b/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp index 506f15f2c..defa656e7 100644 --- a/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp +++ b/Source/WebCore/bindings/js/JSIDBAnyCustom.cpp @@ -33,11 +33,13 @@ #include "IDBAny.h" #include "IDBCursor.h" +#include "IDBCursorWithValue.h" #include "IDBDatabase.h" #include "IDBFactory.h" #include "IDBIndex.h" #include "IDBKey.h" #include "IDBObjectStore.h" +#include "JSDOMStringList.h" #include "JSIDBCursor.h" #include "JSIDBDatabase.h" #include "JSIDBFactory.h" @@ -61,8 +63,12 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, IDBAny* idbAny) return jsUndefined(); case IDBAny::NullType: return jsNull(); + case IDBAny::DOMStringListType: + return toJS(exec, globalObject, idbAny->domStringList()); case IDBAny::IDBCursorType: return toJS(exec, globalObject, idbAny->idbCursor()); + case IDBAny::IDBCursorWithValueType: + return toJS(exec, globalObject, idbAny->idbCursorWithValue()); case IDBAny::IDBDatabaseType: return toJS(exec, globalObject, idbAny->idbDatabase()); case IDBAny::IDBFactoryType: diff --git a/Source/WebCore/bindings/js/JSIDBKeyCustom.cpp b/Source/WebCore/bindings/js/JSIDBKeyCustom.cpp index 62fa7cbe1..b2b78ec57 100644 --- a/Source/WebCore/bindings/js/JSIDBKeyCustom.cpp +++ b/Source/WebCore/bindings/js/JSIDBKeyCustom.cpp @@ -37,18 +37,34 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, JSDOMGlobalObject*, IDBKey* key) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, IDBKey* key) { if (!key) return jsNull(); switch (key->type()) { - case IDBKey::NumberType: - return jsNumber(key->number()); + case IDBKey::ArrayType: + { + const IDBKey::KeyArray& inArray = key->array(); + size_t size = inArray.size(); + JSArray* outArray = constructEmptyArray(exec, globalObject, size); + JSGlobalData& globalData = exec->globalData(); + for (size_t i = 0; i < size; ++i) { + IDBKey* arrayKey = inArray.at(i).get(); + outArray->initializeIndex(globalData, i, toJS(exec, globalObject, arrayKey)); + } + return JSValue(outArray); + } case IDBKey::StringType: return jsString(exec, key->string()); - // FIXME: Implement dates. - // FIXME: Implement arrays. + case IDBKey::DateType: + return jsDateOrNull(exec, key->date()); + case IDBKey::NumberType: + return jsNumber(key->number()); + case IDBKey::MinType: + case IDBKey::InvalidType: + ASSERT_NOT_REACHED(); + return jsUndefined(); } ASSERT_NOT_REACHED(); diff --git a/Source/WebCore/bindings/js/JSIDBVersionChangeRequestCustom.cpp b/Source/WebCore/bindings/js/JSIDBVersionChangeRequestCustom.cpp new file mode 100644 index 000000000..f559f41d1 --- /dev/null +++ b/Source/WebCore/bindings/js/JSIDBVersionChangeRequestCustom.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2012, 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 GOOGLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + */ + +#include "config.h" +#include "JSIDBVersionChangeRequest.h" + +#if ENABLE(INDEXED_DATABASE) + +#include <wtf/Assertions.h> + +namespace WebCore { + +void JSIDBVersionChangeRequest::visitChildren(JSCell*, JSC::SlotVisitor&) +{ + // FIXME: Implement this. +} + +} + +#endif diff --git a/Source/WebCore/bindings/js/JSImageConstructor.cpp b/Source/WebCore/bindings/js/JSImageConstructor.cpp index 956c9615a..9a6116074 100644 --- a/Source/WebCore/bindings/js/JSImageConstructor.cpp +++ b/Source/WebCore/bindings/js/JSImageConstructor.cpp @@ -49,7 +49,7 @@ void JSImageConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* glob static EncodedJSValue JSC_HOST_CALL constructImage(ExecState* exec) { - JSImageConstructor* jsConstructor = static_cast<JSImageConstructor*>(exec->callee()); + JSImageConstructor* jsConstructor = jsCast<JSImageConstructor*>(exec->callee()); Document* document = jsConstructor->document(); if (!document) return throwVMError(exec, createReferenceError(exec, "Image constructor associated document is unavailable")); diff --git a/Source/WebCore/bindings/js/JSImageDataCustom.cpp b/Source/WebCore/bindings/js/JSImageDataCustom.cpp index d2ca476c7..d9d694ec7 100644 --- a/Source/WebCore/bindings/js/JSImageDataCustom.cpp +++ b/Source/WebCore/bindings/js/JSImageDataCustom.cpp @@ -25,11 +25,11 @@ #include "config.h" #include "JSImageData.h" +#include "JSUint8ClampedArray.h" #include "ImageData.h" #include "PlatformString.h" -#include <runtime/JSByteArray.h> #include <wtf/StdLibExtras.h> using namespace JSC; @@ -47,10 +47,7 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData* imageD wrapper = CREATE_DOM_WRAPPER(exec, globalObject, ImageData, imageData); Identifier dataName(exec, "data"); - Structure* cpaStructure = getCachedDOMStructure(globalObject, &JSByteArray::s_info); - if (!cpaStructure) - cpaStructure = cacheDOMStructure(globalObject, JSByteArray::createStructure(exec->globalData(), globalObject, jsNull(), &JSByteArray::s_info), &JSByteArray::s_info); - wrapper->putDirect(exec->globalData(), dataName, JSByteArray::create(exec, cpaStructure, imageData->data()->data()), DontDelete | ReadOnly); + wrapper->putDirect(exec->globalData(), dataName, toJS(exec, globalObject, imageData->data()), DontDelete | ReadOnly); exec->heap()->reportExtraMemoryCost(imageData->data()->length()); return wrapper; diff --git a/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp index 70402bc46..b5a03b959 100644 --- a/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp +++ b/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp @@ -42,13 +42,23 @@ #endif #include "ExceptionCode.h" #include "InjectedScriptHost.h" +#include "InspectorDOMAgent.h" #include "InspectorDebuggerAgent.h" #include "InspectorValues.h" +#include "JSEventListener.h" +#include "JSFloat32Array.h" +#include "JSFloat64Array.h" #include "JSHTMLAllCollection.h" #include "JSHTMLCollection.h" +#include "JSInt16Array.h" +#include "JSInt32Array.h" +#include "JSInt8Array.h" #include "JSNode.h" #include "JSNodeList.h" #include "JSStorage.h" +#include "JSUint16Array.h" +#include "JSUint32Array.h" +#include "JSUint8Array.h" #include "ScriptValue.h" #include "Storage.h" #include <parser/SourceCode.h> @@ -86,7 +96,11 @@ JSValue JSInjectedScriptHost::inspectedObject(ExecState* exec) return jsUndefined(); JSLock lock(SilenceAssertionsOnly); - return object->get(exec).jsValue(); + ScriptValue scriptValue = object->get(exec); + if (scriptValue.hasNoValue()) + return jsUndefined(); + + return scriptValue.jsValue(); } JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec) @@ -132,6 +146,12 @@ JSValue JSInjectedScriptHost::type(ExecState* exec) return jsString(exec, String("array")); if (value.inherits(&JSHTMLCollection::s_info)) return jsString(exec, String("array")); + if (value.inherits(&JSInt8Array::s_info) || value.inherits(&JSInt16Array::s_info) || value.inherits(&JSInt32Array::s_info)) + return jsString(exec, String("array")); + if (value.inherits(&JSUint8Array::s_info) || value.inherits(&JSUint16Array::s_info) || value.inherits(&JSUint32Array::s_info)) + return jsString(exec, String("array")); + if (value.inherits(&JSFloat32Array::s_info) || value.inherits(&JSFloat64Array::s_info)) + return jsString(exec, String("array")); return jsUndefined(); } @@ -142,7 +162,7 @@ JSValue JSInjectedScriptHost::functionDetails(ExecState* exec) JSValue value = exec->argument(0); if (!value.asCell()->inherits(&JSFunction::s_info)) return jsUndefined(); - JSFunction* function = asFunction(value); + JSFunction* function = jsCast<JSFunction*>(value); const SourceCode* sourceCode = function->sourceCode(); if (!sourceCode) @@ -167,6 +187,58 @@ JSValue JSInjectedScriptHost::functionDetails(ExecState* exec) return result; } +static JSArray* getJSListenerFunctions(ExecState* exec, Document* document, const EventListenerInfo& listenerInfo) +{ + JSArray* result = constructEmptyArray(exec); + size_t handlersCount = listenerInfo.eventListenerVector.size(); + for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) { + const JSEventListener* jsListener = JSEventListener::cast(listenerInfo.eventListenerVector[i].listener.get()); + if (!jsListener) { + ASSERT_NOT_REACHED(); + continue; + } + // Hide listeners from other contexts. + if (jsListener->isolatedWorld() != currentWorld(exec)) + continue; + JSObject* function = jsListener->jsFunction(document); + JSObject* listenerEntry = constructEmptyObject(exec); + listenerEntry->putDirect(exec->globalData(), Identifier(exec, "listener"), function); + listenerEntry->putDirect(exec->globalData(), Identifier(exec, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i].useCapture)); + result->putDirectIndex(exec, outputIndex++, JSValue(listenerEntry)); + } + return result; +} + +JSValue JSInjectedScriptHost::getEventListeners(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + JSValue value = exec->argument(0); + if (!value.isObject() || value.isNull()) + return jsUndefined(); + Node* node = toNode(value); + if (!node) + return jsUndefined(); + // This can only happen for orphan DocumentType nodes. + Document* document = node->document(); + if (!node->document()) + return jsUndefined(); + + Vector<EventListenerInfo> listenersArray; + impl()->getEventListenersImpl(node, listenersArray); + + JSObject* result = constructEmptyObject(exec); + for (size_t i = 0; i < listenersArray.size(); ++i) { + JSArray* listeners = getJSListenerFunctions(exec, document, listenersArray[i]); + if (!listeners->length()) + continue; + AtomicString eventType = listenersArray[i].eventType; + result->putDirect(exec->globalData(), Identifier(exec, eventType.impl()), JSValue(listeners)); + } + + return result; +} + JSValue JSInjectedScriptHost::inspect(ExecState* exec) { if (exec->argumentCount() >= 2) { @@ -184,7 +256,7 @@ JSValue JSInjectedScriptHost::databaseId(ExecState* exec) #if ENABLE(SQL_DATABASE) Database* database = toDatabase(exec->argument(0)); if (database) - return jsNumber(impl()->databaseIdImpl(database)); + return jsString(exec, impl()->databaseIdImpl(database)); #endif return jsUndefined(); } @@ -195,7 +267,7 @@ JSValue JSInjectedScriptHost::storageId(ExecState* exec) return jsUndefined(); Storage* storage = toStorage(exec->argument(0)); if (storage) - return jsNumber(impl()->storageIdImpl(storage)); + return jsString(exec, impl()->storageIdImpl(storage)); return jsUndefined(); } diff --git a/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp b/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp index 500737dea..249993f27 100644 --- a/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp +++ b/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp @@ -54,7 +54,7 @@ ScriptObject InjectedScriptManager::createInjectedScript(const String& source, S JSLock lock(SilenceAssertionsOnly); SourceCode sourceCode = makeSource(stringToUString(source)); - JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); + JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); JSValue globalThisValue = scriptState->globalThisValue(); JSValue evaluationException; @@ -80,14 +80,14 @@ ScriptObject InjectedScriptManager::createInjectedScript(const String& source, S void InjectedScriptManager::discardInjectedScript(ScriptState* scriptState) { - JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); + JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); globalObject->setInjectedScript(0); } InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState* scriptState) { JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); + JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); JSObject* injectedScript = globalObject->injectedScript(); if (injectedScript) return InjectedScript(ScriptObject(scriptState, injectedScript), m_inspectedStateAccessCheck); diff --git a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp index 76aaba017..bc77a6d2b 100644 --- a/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt16ArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSInt16Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSInt16ArrayConstructor::constructJSInt16Array(ExecState* exec) { - JSInt16ArrayConstructor* jsConstructor = static_cast<JSInt16ArrayConstructor*>(exec->callee()); + JSInt16ArrayConstructor* jsConstructor = jsCast<JSInt16ArrayConstructor*>(exec->callee()); RefPtr<Int16Array> array = constructArrayBufferView<Int16Array, short>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp index 43390b1c0..d85287f44 100644 --- a/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt32ArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSInt32Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSInt32ArrayConstructor::constructJSInt32Array(ExecState* exec) { - JSInt32ArrayConstructor* jsConstructor = static_cast<JSInt32ArrayConstructor*>(exec->callee()); + JSInt32ArrayConstructor* jsConstructor = jsCast<JSInt32ArrayConstructor*>(exec->callee()); RefPtr<Int32Array> array = constructArrayBufferView<Int32Array, int>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp index bb7fe8ad6..b6e15076f 100644 --- a/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp @@ -51,7 +51,7 @@ JSC::JSValue JSInt8Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSInt8ArrayConstructor::constructJSInt8Array(ExecState* exec) { - JSInt8ArrayConstructor* jsConstructor = static_cast<JSInt8ArrayConstructor*>(exec->callee()); + JSInt8ArrayConstructor* jsConstructor = jsCast<JSInt8ArrayConstructor*>(exec->callee()); RefPtr<Int8Array> array = constructArrayBufferView<Int8Array, signed char>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSLazyEventListener.cpp b/Source/WebCore/bindings/js/JSLazyEventListener.cpp index 4e300124b..f11bf900c 100644 --- a/Source/WebCore/bindings/js/JSLazyEventListener.cpp +++ b/Source/WebCore/bindings/js/JSLazyEventListener.cpp @@ -104,7 +104,7 @@ JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* exec return 0; } - JSFunction* listenerAsFunction = static_cast<JSFunction*>(jsFunction); + JSFunction* listenerAsFunction = jsCast<JSFunction*>(jsFunction); if (m_originalNode) { if (!wrapper()) { // Ensure that 'node' has a JavaScript wrapper to mark the event listener we're creating. @@ -115,7 +115,7 @@ JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* exec // Add the event's home element to the scope // (and the document, and the form - see JSHTMLElement::eventHandlerScope) - listenerAsFunction->setScope(exec->globalData(), static_cast<JSNode*>(wrapper())->pushEventHandlerScope(exec, listenerAsFunction->scope())); + listenerAsFunction->setScope(exec->globalData(), jsCast<JSNode*>(wrapper())->pushEventHandlerScope(exec, listenerAsFunction->scope())); } // Since we only parse once, there's no need to keep data used for parsing around anymore. diff --git a/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp b/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp index 464756c1b..4375ce417 100644 --- a/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp +++ b/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp @@ -58,12 +58,14 @@ bool JSMutationCallback::handleEvent(MutationRecordArray* mutations, WebKitMutat for (size_t i = 0; i < mutations->size(); ++i) mutationList.append(toJS(exec, m_data->globalObject(), mutations->at(i).get())); + JSValue jsObserver = toJS(exec, m_data->globalObject(), observer); + MarkedArgumentBuffer args; args.append(constructArray(exec, m_data->globalObject(), mutationList)); - args.append(toJS(exec, m_data->globalObject(), observer)); + args.append(jsObserver); bool raisedException = false; - m_data->invokeCallback(args, &raisedException); + m_data->invokeCallback(jsObserver, args, &raisedException); return !raisedException; } diff --git a/Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp b/Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp index 871f06afc..b128032ee 100644 --- a/Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp +++ b/Source/WebCore/bindings/js/JSNamedNodeMapCustom.cpp @@ -42,7 +42,7 @@ bool JSNamedNodeMap::canGetItemsForName(ExecState*, NamedNodeMap* impl, const Id JSValue JSNamedNodeMap::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSNamedNodeMap* thisObj = static_cast<JSNamedNodeMap*>(asObject(slotBase)); + JSNamedNodeMap* thisObj = jsCast<JSNamedNodeMap*>(asObject(slotBase)); return toJS(exec, thisObj->globalObject(), thisObj->impl()->getNamedItem(identifierToString(propertyName))); } diff --git a/Source/WebCore/bindings/js/JSNodeCustom.cpp b/Source/WebCore/bindings/js/JSNodeCustom.cpp index 7d00c099d..394d0f33d 100644 --- a/Source/WebCore/bindings/js/JSNodeCustom.cpp +++ b/Source/WebCore/bindings/js/JSNodeCustom.cpp @@ -116,7 +116,7 @@ static inline bool isReachableFromDOM(JSNode* jsNode, Node* node, SlotVisitor& v } #if ENABLE(VIDEO) else if (node->hasTagName(audioTag)) { - if (!static_cast<HTMLAudioElement*>(node)->hasPendingActivity()) + if (!static_cast<HTMLAudioElement*>(node)->paused()) return true; } #endif @@ -132,13 +132,13 @@ static inline bool isReachableFromDOM(JSNode* jsNode, Node* node, SlotVisitor& v bool JSNodeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSNode* jsNode = static_cast<JSNode*>(handle.get().asCell()); + JSNode* jsNode = jsCast<JSNode*>(handle.get().asCell()); return isReachableFromDOM(jsNode, jsNode->impl(), visitor); } void JSNodeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSNode* jsNode = static_cast<JSNode*>(handle.get().asCell()); + JSNode* jsNode = jsCast<JSNode*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsNode->impl(), jsNode); jsNode->releaseImpl(); diff --git a/Source/WebCore/bindings/js/JSNodeCustom.h b/Source/WebCore/bindings/js/JSNodeCustom.h index 7688eea3e..dd242e3c7 100644 --- a/Source/WebCore/bindings/js/JSNodeCustom.h +++ b/Source/WebCore/bindings/js/JSNodeCustom.h @@ -42,7 +42,6 @@ inline bool setInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWrap { if (!world->isNormal()) return false; - ASSERT(!node->wrapper()); node->setWrapper(*world->globalData(), wrapper, wrapperOwner(world, node), wrapperContext(world, node)); return true; } @@ -51,8 +50,7 @@ inline bool clearInlineCachedWrapper(DOMWrapperWorld* world, Node* node, JSDOMWr { if (!world->isNormal()) return false; - ASSERT_UNUSED(wrapper, node->wrapper() == wrapper); - node->clearWrapper(); + node->clearWrapper(wrapper); return true; } @@ -63,7 +61,7 @@ inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, if (!node) return JSC::jsNull(); - JSNode* wrapper = static_cast<JSNode*>(getCachedWrapper(currentWorld(exec), node)); + JSNode* wrapper = JSC::jsCast<JSNode*>(getCachedWrapper(currentWorld(exec), node)); if (wrapper) return wrapper; diff --git a/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp b/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp index 91b9156a4..86b51c492 100644 --- a/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp +++ b/Source/WebCore/bindings/js/JSNodeFilterCondition.cpp @@ -33,8 +33,8 @@ using namespace JSC; ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition); -JSNodeFilterCondition::JSNodeFilterCondition(JSGlobalData& globalData, NodeFilter* owner, JSValue filter) - : m_filter(globalData, filter, &m_weakOwner, owner) +JSNodeFilterCondition::JSNodeFilterCondition(JSGlobalData&, NodeFilter* owner, JSValue filter) + : m_filter(filter.isObject() ? PassWeak<JSObject>(jsCast<JSObject*>(filter), &m_weakOwner, owner) : 0) { } @@ -42,24 +42,20 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) { JSLock lock(SilenceAssertionsOnly); - if (!m_filter.isObject()) + if (!m_filter) return NodeFilter::FILTER_ACCEPT; - // The exec argument here should only be null if this was called from a - // non-JavaScript language, and this is a JavaScript filter, and the document - // in question is not associated with the frame. In that case, we're going to - // behave incorrectly, and just reject nodes instead of calling the filter function. - // To fix that we'd need to come up with a way to find a suitable JavaScript - // execution context for the filter function to run in. + // Exec is null if we've been called from a non-JavaScript language and the document + // is no longer able to run JavaScript (e.g., it's disconnected from its frame). if (!exec) return NodeFilter::FILTER_REJECT; - JSValue function = m_filter.get(); + JSValue filter = m_filter.get(); CallData callData; - CallType callType = getCallData(function, callData); + CallType callType = getCallData(filter, callData); if (callType == CallTypeNone) { - function = m_filter.get().get(exec, Identifier(exec, "acceptNode")); - callType = getCallData(function, callData); + filter = filter.get(exec, Identifier(exec, "acceptNode")); + callType = getCallData(filter, callData); if (callType == CallTypeNone) { throwError(exec, createTypeError(exec, "NodeFilter object does not have an acceptNode function")); return NodeFilter::FILTER_REJECT; @@ -73,7 +69,7 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) if (exec->hadException()) return NodeFilter::FILTER_REJECT; - JSValue result = JSMainThreadExecState::call(exec, function, callType, callData, m_filter.get(), args); + JSValue result = JSMainThreadExecState::call(exec, filter, callType, callData, m_filter.get(), args); if (exec->hadException()) return NodeFilter::FILTER_REJECT; diff --git a/Source/WebCore/bindings/js/JSNodeFilterCondition.h b/Source/WebCore/bindings/js/JSNodeFilterCondition.h index 9b056a0c0..fef8684f3 100644 --- a/Source/WebCore/bindings/js/JSNodeFilterCondition.h +++ b/Source/WebCore/bindings/js/JSNodeFilterCondition.h @@ -46,7 +46,7 @@ namespace WebCore { virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&); }; WeakOwner m_weakOwner; - mutable JSC::Weak<JSC::Unknown> m_filter; + mutable JSC::Weak<JSC::JSObject> m_filter; }; } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSNodeFilterCustom.cpp b/Source/WebCore/bindings/js/JSNodeFilterCustom.cpp index f4023429f..3d9cf3d4f 100644 --- a/Source/WebCore/bindings/js/JSNodeFilterCustom.cpp +++ b/Source/WebCore/bindings/js/JSNodeFilterCustom.cpp @@ -49,7 +49,7 @@ void JSNodeFilter::visitChildren(JSCell* cell, SlotVisitor& visitor) PassRefPtr<NodeFilter> toNodeFilter(JSGlobalData& globalData, JSValue value) { if (value.inherits(&JSNodeFilter::s_info)) - return static_cast<JSNodeFilter*>(asObject(value))->impl(); + return jsCast<JSNodeFilter*>(asObject(value))->impl(); RefPtr<NodeFilter> result = NodeFilter::create(); result->setCondition(JSNodeFilterCondition::create(globalData, result.get(), value)); diff --git a/Source/WebCore/bindings/js/JSNodeListCustom.cpp b/Source/WebCore/bindings/js/JSNodeListCustom.cpp index 5602d2423..725e053a5 100644 --- a/Source/WebCore/bindings/js/JSNodeListCustom.cpp +++ b/Source/WebCore/bindings/js/JSNodeListCustom.cpp @@ -38,7 +38,7 @@ namespace WebCore { bool JSNodeListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSNodeList* jsNodeList = static_cast<JSNodeList*>(handle.get().asCell()); + JSNodeList* jsNodeList = jsCast<JSNodeList*>(handle.get().asCell()); if (!jsNodeList->hasCustomProperties()) return false; if (!jsNodeList->impl()->isDynamicNodeList()) @@ -53,7 +53,7 @@ bool JSNodeList::canGetItemsForName(ExecState*, NodeList* impl, const Identifier JSValue JSNodeList::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSNodeList* thisObj = static_cast<JSNodeList*>(asObject(slotBase)); + JSNodeList* thisObj = jsCast<JSNodeList*>(asObject(slotBase)); return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(identifierToAtomicString(propertyName))); } diff --git a/Source/WebCore/bindings/js/JSNotificationCustom.cpp b/Source/WebCore/bindings/js/JSNotificationCustom.cpp new file mode 100644 index 000000000..f39576577 --- /dev/null +++ b/Source/WebCore/bindings/js/JSNotificationCustom.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2012 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" + +#if ENABLE(NOTIFICATIONS) +#include "JSNotification.h" + +#include "CallbackFunction.h" +#include "JSNotificationPermissionCallback.h" +#include <runtime/Error.h> + +using namespace JSC; + +namespace WebCore { + +JSValue JSNotification::requestPermission(ExecState* exec) +{ + // Arguments: NotificationPermissionCallback + if (!exec->argument(0).isObject()) + return throwTypeError(exec); + + RefPtr<NotificationPermissionCallback> callback = createFunctionOnlyCallback<JSNotificationPermissionCallback>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), exec->argument(0)); + if (exec->hadException()) + return jsUndefined(); + + ASSERT(callback); + ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + Notification::requestPermission(scriptContext, callback.release()); + return jsUndefined(); +} + +} // namespace WebCore + +#endif // ENABLE(NOTIFICATIONS) diff --git a/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp b/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp index 2d6553af4..83819e3dc 100644 --- a/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp +++ b/Source/WebCore/bindings/js/JSPluginElementFunctions.cpp @@ -102,7 +102,7 @@ JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement) JSValue runtimeObjectPropertyGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSHTMLElement* element = static_cast<JSHTMLElement*>(asObject(slotBase)); + JSHTMLElement* element = jsCast<JSHTMLElement*>(asObject(slotBase)); JSObject* scriptObject = pluginScriptObject(exec, element); if (!scriptObject) return jsUndefined(); @@ -151,7 +151,7 @@ bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSV static EncodedJSValue JSC_HOST_CALL callPlugin(ExecState* exec) { - JSHTMLElement* element = static_cast<JSHTMLElement*>(exec->callee()); + JSHTMLElement* element = jsCast<JSHTMLElement*>(exec->callee()); // Get the plug-in script object. JSObject* scriptObject = pluginScriptObject(exec, element); diff --git a/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp b/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp index f01f84b90..3de2807d1 100644 --- a/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp +++ b/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp @@ -70,7 +70,7 @@ JSValue JSPopStateEvent::state(ExecState* exec) const JSValue result; if (isSameState) { - JSHistory* jsHistory = static_cast<JSHistory*>(toJS(exec, globalObject(), history).asCell()); + JSHistory* jsHistory = jsCast<JSHistory*>(toJS(exec, globalObject(), history).asCell()); result = jsHistory->state(exec); } else result = event->serializedState()->deserialize(exec, globalObject(), 0); diff --git a/Source/WebCore/bindings/js/JSRequestAnimationFrameCallbackCustom.cpp b/Source/WebCore/bindings/js/JSRequestAnimationFrameCallbackCustom.cpp index c6be647f8..67d830833 100644 --- a/Source/WebCore/bindings/js/JSRequestAnimationFrameCallbackCustom.cpp +++ b/Source/WebCore/bindings/js/JSRequestAnimationFrameCallbackCustom.cpp @@ -33,7 +33,7 @@ using namespace JSC; namespace WebCore { -bool JSRequestAnimationFrameCallback::handleEvent(DOMTimeStamp time) +bool JSRequestAnimationFrameCallback::handleEvent(double highResNowMs) { if (!canInvokeCallback()) return true; @@ -43,7 +43,7 @@ bool JSRequestAnimationFrameCallback::handleEvent(DOMTimeStamp time) JSLock lock(SilenceAssertionsOnly); MarkedArgumentBuffer args; - args.append(jsNumber(time)); + args.append(jsNumber(highResNowMs)); bool raisedException = false; m_data->invokeCallback(args, &raisedException); diff --git a/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp b/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp index 30aae1b54..a3c198f85 100644 --- a/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp +++ b/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp @@ -96,7 +96,7 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec) return jsUndefined(); } - callback = JSSQLStatementCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject())); + callback = JSSQLStatementCallback::create(object, jsCast<JSDOMGlobalObject*>(globalObject())); } RefPtr<SQLStatementErrorCallback> errorCallback; @@ -107,7 +107,7 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec) return jsUndefined(); } - errorCallback = JSSQLStatementErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject())); + errorCallback = JSSQLStatementErrorCallback::create(object, jsCast<JSDOMGlobalObject*>(globalObject())); } ExceptionCode ec = 0; diff --git a/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp b/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp index 7057b2189..02ea9d636 100644 --- a/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp +++ b/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp @@ -81,7 +81,7 @@ JSValue JSSVGLength::convertToSpecifiedUnits(ExecState* exec) SVGLength& podImp = impl()->propertyReference(); if (exec->argumentCount() < 1) - return throwError(exec, createSyntaxError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); unsigned short unitType = exec->argument(0).toUInt32(exec); if (exec->hadException()) diff --git a/Source/WebCore/bindings/js/JSScriptProfileNodeCustom.cpp b/Source/WebCore/bindings/js/JSScriptProfileNodeCustom.cpp index 8cf75bdd1..2e4afa07d 100644 --- a/Source/WebCore/bindings/js/JSScriptProfileNodeCustom.cpp +++ b/Source/WebCore/bindings/js/JSScriptProfileNodeCustom.cpp @@ -26,40 +26,20 @@ #include "config.h" -#include "JSScriptProfileNode.h" - #if ENABLE(JAVASCRIPT_DEBUGGER) -#include <profiler/ProfileNode.h> -#endif -#include <runtime/JSArray.h> +#include "JSScriptProfileNode.h" using namespace JSC; namespace WebCore { -#if ENABLE(JAVASCRIPT_DEBUGGER) - JSValue JSScriptProfileNode::callUID(ExecState*) const { JSValue result = jsNumber(impl()->callIdentifier().hash()); return result; } -typedef Vector<RefPtr<ProfileNode> > ProfileNodesList; - -JSValue JSScriptProfileNode::children(ExecState* exec) const -{ - const ProfileNodesList& children = impl()->children(); - MarkedArgumentBuffer list; - - ProfileNodesList::const_iterator end = children.end(); - for (ProfileNodesList::const_iterator iter = children.begin(); iter != end; ++iter) - list.append(toJS(exec, globalObject(), iter->get())); - - return constructArray(exec, globalObject(), list); -} +} // namespace WebCore #endif - -} // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp b/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp index fb8dc18ef..c79b793fa 100644 --- a/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp +++ b/Source/WebCore/bindings/js/JSSharedWorkerCustom.cpp @@ -57,10 +57,10 @@ void JSSharedWorker::visitChildren(JSCell* cell, SlotVisitor& visitor) EncodedJSValue JSC_HOST_CALL JSSharedWorkerConstructor::constructJSSharedWorker(ExecState* exec) { - JSSharedWorkerConstructor* jsConstructor = static_cast<JSSharedWorkerConstructor*>(exec->callee()); + JSSharedWorkerConstructor* jsConstructor = jsCast<JSSharedWorkerConstructor*>(exec->callee()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); UString scriptURL = exec->argument(0).toString(exec)->value(exec); UString name; diff --git a/Source/WebCore/bindings/js/JSStorageCustom.cpp b/Source/WebCore/bindings/js/JSStorageCustom.cpp index 31be269aa..3df221bfa 100644 --- a/Source/WebCore/bindings/js/JSStorageCustom.cpp +++ b/Source/WebCore/bindings/js/JSStorageCustom.cpp @@ -41,7 +41,12 @@ bool JSStorage::canGetItemsForName(ExecState*, Storage* impl, const Identifier& JSValue JSStorage::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSStorage* thisObj = static_cast<JSStorage*>(asObject(slotBase)); + JSStorage* thisObj = jsCast<JSStorage*>(asObject(slotBase)); + + JSValue prototype = asObject(slotBase)->prototype(); + if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName)) + return asObject(prototype)->get(exec, propertyName); + return jsStringOrNull(exec, thisObj->impl()->getItem(identifierToString(propertyName))); } diff --git a/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp b/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp index a2c8b67fe..c05eef5b1 100644 --- a/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp +++ b/Source/WebCore/bindings/js/JSStyleSheetListCustom.cpp @@ -42,7 +42,7 @@ bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheet JSValue JSStyleSheetList::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { - JSStyleSheetList* thisObj = static_cast<JSStyleSheetList*>(asObject(slotBase)); + JSStyleSheetList* thisObj = jsCast<JSStyleSheetList*>(asObject(slotBase)); HTMLStyleElement* element = thisObj->impl()->getNamedItem(identifierToString(propertyName)); ASSERT(element); return toJS(exec, thisObj->globalObject(), element->sheet()); diff --git a/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp b/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp index c6de15fc8..5dd9dca76 100644 --- a/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp +++ b/Source/WebCore/bindings/js/JSTextTrackCueCustom.cpp @@ -36,7 +36,7 @@ namespace WebCore { bool JSTextTrackCueOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTextTrackCue* jsTextTrackCue = static_cast<JSTextTrackCue*>(handle.get().asCell()); + JSTextTrackCue* jsTextTrackCue = jsCast<JSTextTrackCue*>(handle.get().asCell()); TextTrackCue* textTrackCue = static_cast<TextTrackCue*>(jsTextTrackCue->impl()); // If the cue is firing event listeners, its wrapper is reachable because diff --git a/Source/WebCore/bindings/js/JSTextTrackCustom.cpp b/Source/WebCore/bindings/js/JSTextTrackCustom.cpp index 613bbe39e..5d6412466 100644 --- a/Source/WebCore/bindings/js/JSTextTrackCustom.cpp +++ b/Source/WebCore/bindings/js/JSTextTrackCustom.cpp @@ -37,7 +37,7 @@ namespace WebCore { bool JSTextTrackOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTextTrack* jsTextTrack = static_cast<JSTextTrack*>(handle.get().asCell()); + JSTextTrack* jsTextTrack = jsCast<JSTextTrack*>(handle.get().asCell()); TextTrack* textTrack = static_cast<TextTrack*>(jsTextTrack->impl()); // If the cue is firing event listeners, its wrapper is reachable because diff --git a/Source/WebCore/bindings/js/JSTextTrackListCustom.cpp b/Source/WebCore/bindings/js/JSTextTrackListCustom.cpp index 8fc1e56b2..a967fe1f7 100644 --- a/Source/WebCore/bindings/js/JSTextTrackListCustom.cpp +++ b/Source/WebCore/bindings/js/JSTextTrackListCustom.cpp @@ -36,7 +36,7 @@ namespace WebCore { bool JSTextTrackListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTextTrackList* jsTextTrackList = static_cast<JSTextTrackList*>(handle.get().asCell()); + JSTextTrackList* jsTextTrackList = jsCast<JSTextTrackList*>(handle.get().asCell()); TextTrackList* textTrackList = static_cast<TextTrackList*>(jsTextTrackList->impl()); // If the list is firing event listeners, its wrapper is reachable because diff --git a/Source/WebCore/bindings/js/JSTrackCustom.cpp b/Source/WebCore/bindings/js/JSTrackCustom.cpp index 1d9ca000e..7b97945ca 100644 --- a/Source/WebCore/bindings/js/JSTrackCustom.cpp +++ b/Source/WebCore/bindings/js/JSTrackCustom.cpp @@ -42,7 +42,7 @@ TrackBase* toTrack(JSValue value) JSObject* object = asObject(value); if (object->inherits(&JSTextTrack::s_info)) - return static_cast<JSTextTrack*>(object)->impl(); + return jsCast<JSTextTrack*>(object)->impl(); // FIXME: Fill in additional tests and casts here for VideoTrack and AudioTrack when // they have been added to WebCore. diff --git a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp index a21d35170..47b4402ba 100644 --- a/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint16ArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSUint16Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSUint16ArrayConstructor::constructJSUint16Array(ExecState* exec) { - JSUint16ArrayConstructor* jsConstructor = static_cast<JSUint16ArrayConstructor*>(exec->callee()); + JSUint16ArrayConstructor* jsConstructor = jsCast<JSUint16ArrayConstructor*>(exec->callee()); RefPtr<Uint16Array> array = constructArrayBufferView<Uint16Array, unsigned short>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp index 8288044bf..aa8b8267f 100644 --- a/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint32ArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSUint32Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSUint32ArrayConstructor::constructJSUint32Array(ExecState* exec) { - JSUint32ArrayConstructor* jsConstructor = static_cast<JSUint32ArrayConstructor*>(exec->callee()); + JSUint32ArrayConstructor* jsConstructor = jsCast<JSUint32ArrayConstructor*>(exec->callee()); RefPtr<Uint32Array> array = constructArrayBufferView<Uint32Array, unsigned int>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp index 0b2864768..6a4fa1df5 100644 --- a/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSUint8Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSUint8ArrayConstructor::constructJSUint8Array(ExecState* exec) { - JSUint8ArrayConstructor* jsConstructor = static_cast<JSUint8ArrayConstructor*>(exec->callee()); + JSUint8ArrayConstructor* jsConstructor = jsCast<JSUint8ArrayConstructor*>(exec->callee()); RefPtr<Uint8Array> array = constructArrayBufferView<Uint8Array, unsigned char>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp b/Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp index 1566d04d0..2d5ca785d 100644 --- a/Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp +++ b/Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp @@ -50,7 +50,7 @@ JSC::JSValue JSUint8ClampedArray::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSUint8ClampedArrayConstructor::constructJSUint8ClampedArray(ExecState* exec) { - JSUint8ClampedArrayConstructor* jsConstructor = static_cast<JSUint8ClampedArrayConstructor*>(exec->callee()); + JSUint8ClampedArrayConstructor* jsConstructor = jsCast<JSUint8ClampedArrayConstructor*>(exec->callee()); RefPtr<Uint8ClampedArray> array = constructArrayBufferView<Uint8ClampedArray, unsigned char>(exec); if (!array.get()) // Exception has already been thrown. diff --git a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp index 6d71e5e13..0d5e60813 100644 --- a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp @@ -143,7 +143,7 @@ enum ObjectType { static JSValue getObjectParameter(JSWebGLRenderingContext* obj, ExecState* exec, ObjectType objectType) { if (exec->argumentCount() != 2) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(obj->impl()); @@ -222,7 +222,7 @@ void JSWebGLRenderingContext::visitChildren(JSCell* cell, SlotVisitor& visitor) JSValue JSWebGLRenderingContext::getAttachedShaders(ExecState* exec) { if (exec->argumentCount() < 1) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl()); if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(&JSWebGLProgram::s_info)) @@ -247,7 +247,7 @@ JSValue JSWebGLRenderingContext::getAttachedShaders(ExecState* exec) JSValue JSWebGLRenderingContext::getExtension(ExecState* exec) { if (exec->argumentCount() < 1) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl()); const String& name = ustringToString(exec->argument(0).toString(exec)->value(exec)); @@ -265,7 +265,7 @@ JSValue JSWebGLRenderingContext::getBufferParameter(ExecState* exec) JSValue JSWebGLRenderingContext::getFramebufferAttachmentParameter(ExecState* exec) { if (exec->argumentCount() != 3) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl()); @@ -289,7 +289,7 @@ JSValue JSWebGLRenderingContext::getFramebufferAttachmentParameter(ExecState* ex JSValue JSWebGLRenderingContext::getParameter(ExecState* exec) { if (exec->argumentCount() != 1) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl()); @@ -307,7 +307,7 @@ JSValue JSWebGLRenderingContext::getParameter(ExecState* exec) JSValue JSWebGLRenderingContext::getProgramParameter(ExecState* exec) { if (exec->argumentCount() != 2) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl()); @@ -333,7 +333,7 @@ JSValue JSWebGLRenderingContext::getRenderbufferParameter(ExecState* exec) JSValue JSWebGLRenderingContext::getShaderParameter(ExecState* exec) { if (exec->argumentCount() != 2) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl()); @@ -371,7 +371,7 @@ JSValue JSWebGLRenderingContext::getTexParameter(ExecState* exec) JSValue JSWebGLRenderingContext::getUniform(ExecState* exec) { if (exec->argumentCount() != 2) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl()); @@ -445,7 +445,7 @@ static bool functionForUniform(DataFunctionToCall f) static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContext* context) { if (exec->argumentCount() != 2) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); WebGLUniformLocation* location = 0; long index = -1; @@ -535,7 +535,7 @@ static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, We static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState* exec, WebGLRenderingContext* context) { if (exec->argumentCount() != 2) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(&JSWebGLUniformLocation::s_info)) return throwTypeError(exec); @@ -600,7 +600,7 @@ static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState* exec, We static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecState* exec, WebGLRenderingContext* context) { if (exec->argumentCount() != 3) - return throwSyntaxError(exec); + return throwError(exec, createNotEnoughArgumentsError(exec)); if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(&JSWebGLUniformLocation::s_info)) return throwTypeError(exec); diff --git a/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp b/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp index 455f4d4e0..39a246a15 100644 --- a/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp +++ b/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp @@ -51,7 +51,7 @@ namespace WebCore { EncodedJSValue JSC_HOST_CALL JSWebKitMutationObserverConstructor::constructJSWebKitMutationObserver(ExecState* exec) { if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); JSObject* object = exec->argument(0).getObject(); if (!object) { @@ -59,7 +59,7 @@ EncodedJSValue JSC_HOST_CALL JSWebKitMutationObserverConstructor::constructJSWeb return JSValue::encode(jsUndefined()); } - JSWebKitMutationObserverConstructor* jsConstructor = static_cast<JSWebKitMutationObserverConstructor*>(exec->callee()); + JSWebKitMutationObserverConstructor* jsConstructor = jsCast<JSWebKitMutationObserverConstructor*>(exec->callee()); RefPtr<MutationCallback> callback = JSMutationCallback::create(object, jsConstructor->globalObject()); return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), WebKitMutationObserver::create(callback.release())))); } @@ -83,7 +83,7 @@ static const size_t numBooleanOptions = sizeof(booleanOptions) / sizeof(BooleanO JSValue JSWebKitMutationObserver::observe(ExecState* exec) { if (exec->argumentCount() < 2) - return throwError(exec, createTypeError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); Node* target = toNode(exec->argument(0)); if (exec->hadException()) return jsUndefined(); diff --git a/Source/WebCore/bindings/js/JSWebKitPointCustom.cpp b/Source/WebCore/bindings/js/JSWebKitPointCustom.cpp index e1b20cedf..aa14e65a2 100644 --- a/Source/WebCore/bindings/js/JSWebKitPointCustom.cpp +++ b/Source/WebCore/bindings/js/JSWebKitPointCustom.cpp @@ -34,7 +34,7 @@ namespace WebCore { EncodedJSValue JSC_HOST_CALL JSWebKitPointConstructor::constructJSWebKitPoint(ExecState* exec) { - JSWebKitPointConstructor* jsConstructor = static_cast<JSWebKitPointConstructor*>(exec->callee()); + JSWebKitPointConstructor* jsConstructor = jsCast<JSWebKitPointConstructor*>(exec->callee()); float x = 0; float y = 0; diff --git a/Source/WebCore/bindings/js/JSWebSocketCustom.cpp b/Source/WebCore/bindings/js/JSWebSocketCustom.cpp index c8e0069ef..49b822a62 100644 --- a/Source/WebCore/bindings/js/JSWebSocketCustom.cpp +++ b/Source/WebCore/bindings/js/JSWebSocketCustom.cpp @@ -52,13 +52,13 @@ namespace WebCore { EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecState* exec) { - JSWebSocketConstructor* jsConstructor = static_cast<JSWebSocketConstructor*>(exec->callee()); + JSWebSocketConstructor* jsConstructor = jsCast<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")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); String urlString = ustringToString(exec->argument(0).toString(exec)->value(exec)); if (exec->hadException()) @@ -93,7 +93,7 @@ EncodedJSValue JSC_HOST_CALL JSWebSocketConstructor::constructJSWebSocket(ExecSt JSValue JSWebSocket::send(ExecState* exec) { if (!exec->argumentCount()) - return throwError(exec, createSyntaxError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); JSValue message = exec->argument(0); ExceptionCode ec = 0; diff --git a/Source/WebCore/bindings/js/JSWorkerContextBase.cpp b/Source/WebCore/bindings/js/JSWorkerContextBase.cpp index e79c6e4bd..2c13a9d77 100644 --- a/Source/WebCore/bindings/js/JSWorkerContextBase.cpp +++ b/Source/WebCore/bindings/js/JSWorkerContextBase.cpp @@ -93,7 +93,7 @@ JSDedicatedWorkerContext* toJSDedicatedWorkerContext(JSValue value) return 0; const ClassInfo* classInfo = asObject(value)->classInfo(); if (classInfo == &JSDedicatedWorkerContext::s_info) - return static_cast<JSDedicatedWorkerContext*>(asObject(value)); + return jsCast<JSDedicatedWorkerContext*>(asObject(value)); return 0; } @@ -104,7 +104,7 @@ JSSharedWorkerContext* toJSSharedWorkerContext(JSValue value) return 0; const ClassInfo* classInfo = asObject(value)->classInfo(); if (classInfo == &JSSharedWorkerContext::s_info) - return static_cast<JSSharedWorkerContext*>(asObject(value)); + return jsCast<JSSharedWorkerContext*>(asObject(value)); return 0; } #endif diff --git a/Source/WebCore/bindings/js/JSWorkerCustom.cpp b/Source/WebCore/bindings/js/JSWorkerCustom.cpp index ca0f76195..7145fcf34 100644 --- a/Source/WebCore/bindings/js/JSWorkerCustom.cpp +++ b/Source/WebCore/bindings/js/JSWorkerCustom.cpp @@ -52,10 +52,10 @@ JSC::JSValue JSWorker::webkitPostMessage(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSWorkerConstructor::constructJSWorker(ExecState* exec) { - JSWorkerConstructor* jsConstructor = static_cast<JSWorkerConstructor*>(exec->callee()); + JSWorkerConstructor* jsConstructor = jsCast<JSWorkerConstructor*>(exec->callee()); if (!exec->argumentCount()) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); UString scriptURL = exec->argument(0).toString(exec)->value(exec); if (exec->hadException()) diff --git a/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp index 4cdf68c75..496231216 100644 --- a/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp +++ b/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp @@ -83,7 +83,7 @@ void JSXMLHttpRequest::visitChildren(JSCell* cell, SlotVisitor& visitor) JSValue JSXMLHttpRequest::open(ExecState* exec) { if (exec->argumentCount() < 2) - return throwError(exec, createSyntaxError(exec, "Not enough arguments")); + return throwError(exec, createNotEnoughArgumentsError(exec)); const KURL& url = impl()->scriptExecutionContext()->completeURL(ustringToString(exec->argument(1).toString(exec)->value(exec))); String method = ustringToString(exec->argument(0).toString(exec)->value(exec)); diff --git a/Source/WebCore/bindings/js/JSXSLTProcessorCustom.cpp b/Source/WebCore/bindings/js/JSXSLTProcessorCustom.cpp index da80097dd..70b69809d 100644 --- a/Source/WebCore/bindings/js/JSXSLTProcessorCustom.cpp +++ b/Source/WebCore/bindings/js/JSXSLTProcessorCustom.cpp @@ -50,7 +50,7 @@ JSValue JSXSLTProcessor::importStylesheet(ExecState* exec) { JSValue nodeVal = exec->argument(0); if (nodeVal.inherits(&JSNode::s_info)) { - JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); + JSNode* node = jsCast<JSNode*>(asObject(nodeVal)); impl()->importStylesheet(node->impl()); return jsUndefined(); } @@ -63,8 +63,8 @@ JSValue JSXSLTProcessor::transformToFragment(ExecState* exec) JSValue nodeVal = exec->argument(0); JSValue docVal = exec->argument(1); if (nodeVal.inherits(&JSNode::s_info) && docVal.inherits(&JSDocument::s_info)) { - WebCore::Node* node = static_cast<JSNode*>(asObject(nodeVal))->impl(); - Document* doc = static_cast<Document*>(static_cast<JSDocument*>(asObject(docVal))->impl()); + WebCore::Node* node = jsCast<JSNode*>(asObject(nodeVal))->impl(); + Document* doc = static_cast<Document*>(jsCast<JSDocument*>(asObject(docVal))->impl()); return toJS(exec, globalObject(), impl()->transformToFragment(node, doc).get()); } // Throw exception? @@ -75,7 +75,7 @@ JSValue JSXSLTProcessor::transformToDocument(ExecState* exec) { JSValue nodeVal = exec->argument(0); if (nodeVal.inherits(&JSNode::s_info)) { - JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); + JSNode* node = jsCast<JSNode*>(asObject(nodeVal)); RefPtr<Document> resultDocument = impl()->transformToDocument(node->impl()); if (resultDocument) return toJS(exec, globalObject(), resultDocument.get()); diff --git a/Source/WebCore/bindings/js/PageScriptDebugServer.cpp b/Source/WebCore/bindings/js/PageScriptDebugServer.cpp index c8f16f5a9..efe4b6768 100755 --- a/Source/WebCore/bindings/js/PageScriptDebugServer.cpp +++ b/Source/WebCore/bindings/js/PageScriptDebugServer.cpp @@ -69,6 +69,7 @@ PageScriptDebugServer& PageScriptDebugServer::shared() PageScriptDebugServer::PageScriptDebugServer() : ScriptDebugServer() + , m_pausedPage(0) { } @@ -82,11 +83,11 @@ void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag ASSERT_ARG(listener, listener); ASSERT_ARG(page, page); - pair<PageListenersMap::iterator, bool> result = m_pageListenersMap.add(page, 0); - if (result.second) - result.first->second = new ListenerSet; + PageListenersMap::AddResult result = m_pageListenersMap.add(page, 0); + if (result.isNewEntry) + result.iterator->second = new ListenerSet; - ListenerSet* listeners = result.first->second; + ListenerSet* listeners = result.iterator->second; listeners->add(listener); recompileAllJSFunctionsSoon(); @@ -131,20 +132,34 @@ ScriptDebugServer::ListenerSet* PageScriptDebugServer::getListenersForGlobalObje void PageScriptDebugServer::didPause(JSC::JSGlobalObject* globalObject) { + ASSERT(!m_pausedPage); + Page* page = toPage(globalObject); + ASSERT(page); + if (!page) + return; + m_pausedPage = page; + setJavaScriptPaused(page->group(), true); } void PageScriptDebugServer::didContinue(JSC::JSGlobalObject* globalObject) { + // Page can be null if we are continuing because the Page closed. Page* page = toPage(globalObject); + ASSERT(!page || page == m_pausedPage); + m_pausedPage = 0; - setJavaScriptPaused(page->group(), false); + + if (page) + setJavaScriptPaused(page->group(), false); } void PageScriptDebugServer::didRemoveLastListener(Page* page) { + ASSERT(page); + if (m_pausedPage == page) m_doneProcessingDebuggerEvents = true; diff --git a/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp b/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp index 28988beb7..2100c6b02 100644 --- a/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp +++ b/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp @@ -45,7 +45,6 @@ using namespace JSC; namespace WebCore { ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame) - : m_domWindow(0) { JSLock lock(SilenceAssertionsOnly); @@ -56,17 +55,11 @@ ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame) for (ScriptController::ShellMap::iterator iter = windowShells.begin(); iter != windowShellsEnd; ++iter) { JSDOMWindow* window = iter->second->window(); m_windows.add(iter->first.get(), Strong<JSDOMWindow>(window->globalData(), window)); - m_domWindow = window->impl(); } scriptController->attachDebugger(0); } -DOMWindow* ScriptCachedFrameData::domWindow() const -{ - return m_domWindow; -} - ScriptCachedFrameData::~ScriptCachedFrameData() { clear(); diff --git a/Source/WebCore/bindings/js/ScriptCachedFrameData.h b/Source/WebCore/bindings/js/ScriptCachedFrameData.h index a85e16f97..05c109ee6 100644 --- a/Source/WebCore/bindings/js/ScriptCachedFrameData.h +++ b/Source/WebCore/bindings/js/ScriptCachedFrameData.h @@ -38,7 +38,6 @@ namespace WebCore { class Frame; class JSDOMWindow; - class DOMWindow; class DOMWrapperWorld; class ScriptCachedFrameData { @@ -51,11 +50,9 @@ namespace WebCore { void restore(Frame*); void clear(); - DOMWindow* domWindow() const; private: JSDOMWindowSet m_windows; - DOMWindow* m_domWindow; }; } // namespace WebCore diff --git a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp b/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp index 9b446e3d4..ccf673fd4 100644 --- a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp +++ b/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp @@ -70,7 +70,7 @@ PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t m exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function); UString functionName; if (function) - functionName = asFunction(function)->name(exec); + functionName = jsCast<JSFunction*>(function)->name(exec); else { // Caller is unknown, but if frames is empty we should still add the frame, because // something called us, and gave us arguments. @@ -90,7 +90,7 @@ PassRefPtr<ScriptCallStack> createScriptCallStackForInspector(JSC::ExecState* ex { size_t maxStackSize = 1; if (InspectorInstrumentation::hasFrontends()) { - ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptExecutionContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (InspectorInstrumentation::hasFrontendForScriptContext(scriptExecutionContext)) maxStackSize = ScriptCallStack::maxCallStackSizeToCapture; } diff --git a/Source/WebCore/bindings/js/ScriptController.cpp b/Source/WebCore/bindings/js/ScriptController.cpp index 4143f44b5..0a7e09086 100644 --- a/Source/WebCore/bindings/js/ScriptController.cpp +++ b/Source/WebCore/bindings/js/ScriptController.cpp @@ -167,7 +167,7 @@ PassRefPtr<DOMWrapperWorld> ScriptController::createWorld() return DOMWrapperWorld::create(JSDOMWindow::commonJSGlobalData()); } -void ScriptController::getAllWorlds(Vector<DOMWrapperWorld*>& worlds) +void ScriptController::getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds) { static_cast<WebCoreJSClientData*>(JSDOMWindow::commonJSGlobalData()->clientData)->getAllWorlds(worlds); } diff --git a/Source/WebCore/bindings/js/ScriptController.h b/Source/WebCore/bindings/js/ScriptController.h index 5e151aae3..37fb7edcf 100644 --- a/Source/WebCore/bindings/js/ScriptController.h +++ b/Source/WebCore/bindings/js/ScriptController.h @@ -84,7 +84,7 @@ public: return windowShell(world)->window(); } - static void getAllWorlds(Vector<DOMWrapperWorld*>&); + static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >&); ScriptValue executeScript(const ScriptSourceCode&); ScriptValue executeScript(const String& script, bool forceUserGesture = false); diff --git a/Source/WebCore/bindings/js/ScriptControllerBlackBerry.cpp b/Source/WebCore/bindings/js/ScriptControllerBlackBerry.cpp new file mode 100644 index 000000000..3183e8dae --- /dev/null +++ b/Source/WebCore/bindings/js/ScriptControllerBlackBerry.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ + * Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "ScriptController.h" + +#include "Bridge.h" +#include "PluginView.h" +#include "runtime_root.h" + +namespace WebCore { + +PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(Widget* widget) +{ + if (!widget->isPluginView()) + return 0; + + return static_cast<PluginView*>(widget)->bindingInstance(); +} + +} diff --git a/Source/WebCore/bindings/js/ScriptControllerMac.mm b/Source/WebCore/bindings/js/ScriptControllerMac.mm index f7ad3ffab..50a5a7e71 100644 --- a/Source/WebCore/bindings/js/ScriptControllerMac.mm +++ b/Source/WebCore/bindings/js/ScriptControllerMac.mm @@ -148,7 +148,7 @@ static void updateStyleIfNeededForBindings(JSC::ExecState*, JSC::JSObject* rootO if (!rootObject) return; - JSDOMWindow* window = static_cast<JSDOMWindow*>(rootObject); + JSDOMWindow* window = JSC::jsCast<JSDOMWindow*>(rootObject); if (!window) return; diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.cpp b/Source/WebCore/bindings/js/ScriptDebugServer.cpp index f0cf5d21a..1d6117cfd 100644 --- a/Source/WebCore/bindings/js/ScriptDebugServer.cpp +++ b/Source/WebCore/bindings/js/ScriptDebugServer.cpp @@ -75,7 +75,7 @@ String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBrea return ""; SourceIdToBreakpointsMap::iterator it = m_sourceIdToBreakpoints.find(sourceIDValue); if (it == m_sourceIdToBreakpoints.end()) - it = m_sourceIdToBreakpoints.set(sourceIDValue, LineToBreakpointMap()).first; + it = m_sourceIdToBreakpoints.set(sourceIDValue, LineToBreakpointMap()).iterator; if (it->second.contains(scriptBreakpoint.lineNumber + 1)) return ""; it->second.set(scriptBreakpoint.lineNumber + 1, scriptBreakpoint); @@ -211,7 +211,7 @@ void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener) JSValue jsCallFrame; { if (m_currentCallFrame->isValid() && globalObject->inherits(&JSDOMGlobalObject::s_info)) { - JSDOMGlobalObject* domGlobalObject = static_cast<JSDOMGlobalObject*>(globalObject); + JSDOMGlobalObject* domGlobalObject = jsCast<JSDOMGlobalObject*>(globalObject); JSLock lock(SilenceAssertionsOnly); jsCallFrame = toJS(state, domGlobalObject, m_currentCallFrame.get()); } else @@ -236,8 +236,10 @@ void ScriptDebugServer::dispatchDidParseSource(const ListenerSet& listeners, Sou script.startColumn = sourceProvider->startPosition().m_column.zeroBasedInt(); script.isContentScript = isContentScript; +#if ENABLE(INSPECTOR) if (script.url.isEmpty()) script.url = ContentSearchUtils::findSourceURL(script.source); +#endif int sourceLength = script.source.length(); int lineCount = 1; diff --git a/Source/WebCore/bindings/js/ScriptEventListener.cpp b/Source/WebCore/bindings/js/ScriptEventListener.cpp index c21090789..c66a7d1fd 100644 --- a/Source/WebCore/bindings/js/ScriptEventListener.cpp +++ b/Source/WebCore/bindings/js/ScriptEventListener.cpp @@ -97,6 +97,7 @@ PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame* frame, Attri String eventListenerHandlerBody(Document* document, EventListener* eventListener) { const JSEventListener* jsListener = JSEventListener::cast(eventListener); + ASSERT(jsListener); if (!jsListener) return ""; JSLock lock(SilenceAssertionsOnly); @@ -110,12 +111,14 @@ String eventListenerHandlerBody(Document* document, EventListener* eventListener bool eventListenerHandlerLocation(Document* document, EventListener* eventListener, String& sourceName, int& lineNumber) { const JSEventListener* jsListener = JSEventListener::cast(eventListener); + ASSERT(jsListener); if (!jsListener) return false; + JSLock lock(SilenceAssertionsOnly); JSC::JSObject* jsObject = jsListener->jsFunction(document); if (!jsObject) return false; - JSC::JSFunction* jsFunction = static_cast<JSFunction*>(jsObject); + JSC::JSFunction* jsFunction = jsDynamicCast<JSFunction*>(jsObject); if (!jsFunction || jsFunction->isHostFunction()) return false; JSC::FunctionExecutable* funcExecutable = jsFunction->jsExecutable(); diff --git a/Source/WebCore/bindings/js/ScriptHeapSnapshot.h b/Source/WebCore/bindings/js/ScriptHeapSnapshot.h index e5738544f..c7082cb8c 100644 --- a/Source/WebCore/bindings/js/ScriptHeapSnapshot.h +++ b/Source/WebCore/bindings/js/ScriptHeapSnapshot.h @@ -36,6 +36,8 @@ namespace WebCore { +typedef uint32_t SnapshotObjectId; + class ScriptHeapSnapshot : public RefCounted<ScriptHeapSnapshot> { public: class OutputStream { @@ -51,6 +53,7 @@ public: unsigned int uid() const { return 0; } void writeJSON(OutputStream*) { } + SnapshotObjectId maxSnapshotJSObjectId() const { return 0; } private: ScriptHeapSnapshot() { } diff --git a/Source/WebCore/bindings/js/ScriptObject.cpp b/Source/WebCore/bindings/js/ScriptObject.cpp index 6760e47bf..1fcd9cb80 100644 --- a/Source/WebCore/bindings/js/ScriptObject.cpp +++ b/Source/WebCore/bindings/js/ScriptObject.cpp @@ -70,7 +70,7 @@ bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const S bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorFrontendHost* value) { JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); + JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); globalObject->putDirect(scriptState->globalData(), Identifier(scriptState, name), toJS(scriptState, globalObject, value)); return handleException(scriptState); } @@ -78,7 +78,7 @@ bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, Inspect bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InjectedScriptHost* value) { JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); + JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); globalObject->putDirect(scriptState->globalData(), Identifier(scriptState, name), toJS(scriptState, globalObject, value)); return handleException(scriptState); } diff --git a/Source/WebCore/bindings/js/ScriptProfiler.cpp b/Source/WebCore/bindings/js/ScriptProfiler.cpp index 790739b21..c8dddbac3 100644 --- a/Source/WebCore/bindings/js/ScriptProfiler.cpp +++ b/Source/WebCore/bindings/js/ScriptProfiler.cpp @@ -43,7 +43,7 @@ namespace WebCore { void ScriptProfiler::collectGarbage() { - gcController().garbageCollectNow(); + gcController().garbageCollectSoon(); } ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned) diff --git a/Source/WebCore/bindings/js/ScriptState.cpp b/Source/WebCore/bindings/js/ScriptState.cpp index eb66bdcfa..780ca4d9d 100644 --- a/Source/WebCore/bindings/js/ScriptState.cpp +++ b/Source/WebCore/bindings/js/ScriptState.cpp @@ -68,7 +68,7 @@ DOMWindow* domWindowFromScriptState(ScriptState* scriptState) JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject(); if (!globalObject->inherits(&JSDOMWindowBase::s_info)) return 0; - return static_cast<JSDOMWindowBase*>(globalObject)->impl(); + return JSC::jsCast<JSDOMWindowBase*>(globalObject)->impl(); } ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState* scriptState) @@ -76,7 +76,7 @@ ScriptExecutionContext* scriptExecutionContextFromScriptState(ScriptState* scrip JSC::JSGlobalObject* globalObject = scriptState->lexicalGlobalObject(); if (!globalObject->inherits(&JSDOMGlobalObject::s_info)) return 0; - return static_cast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext(); + return JSC::jsCast<JSDOMGlobalObject*>(globalObject)->scriptExecutionContext(); } bool evalEnabled(ScriptState* scriptState) diff --git a/Source/WebCore/bindings/js/ScriptValue.cpp b/Source/WebCore/bindings/js/ScriptValue.cpp index f75851f39..dea2a483e 100644 --- a/Source/WebCore/bindings/js/ScriptValue.cpp +++ b/Source/WebCore/bindings/js/ScriptValue.cpp @@ -31,6 +31,7 @@ #include "ScriptValue.h" #include "InspectorValues.h" +#include "JSDOMBinding.h" #include "SerializedScriptValue.h" #include <JavaScriptCore/APICast.h> diff --git a/Source/WebCore/bindings/js/ScriptValue.h b/Source/WebCore/bindings/js/ScriptValue.h index a4d597a91..cfb99e520 100644 --- a/Source/WebCore/bindings/js/ScriptValue.h +++ b/Source/WebCore/bindings/js/ScriptValue.h @@ -31,7 +31,6 @@ #ifndef ScriptValue_h #define ScriptValue_h -#include "JSDOMBinding.h" #include "PlatformString.h" #include "SerializedScriptValue.h" #include "ScriptState.h" @@ -66,8 +65,6 @@ public: PassRefPtr<SerializedScriptValue> serialize(ScriptState*, SerializationErrorMode = Throwing); static ScriptValue deserialize(ScriptState*, SerializedScriptValue*, SerializationErrorMode = Throwing); - static ScriptValue undefined(); - #if ENABLE(INSPECTOR) PassRefPtr<InspectorValue> toInspectorValue(ScriptState*) const; #endif diff --git a/Source/WebCore/bindings/js/ScriptWrappable.h b/Source/WebCore/bindings/js/ScriptWrappable.h index 92d05e804..cfffcab37 100644 --- a/Source/WebCore/bindings/js/ScriptWrappable.h +++ b/Source/WebCore/bindings/js/ScriptWrappable.h @@ -43,13 +43,15 @@ public: return m_wrapper.get(); } - void setWrapper(JSC::JSGlobalData& globalData, JSDOMWrapper* wrapper, JSC::WeakHandleOwner* wrapperOwner, void* context) + void setWrapper(JSC::JSGlobalData&, JSDOMWrapper* wrapper, JSC::WeakHandleOwner* wrapperOwner, void* context) { - m_wrapper = JSC::PassWeak<JSDOMWrapper>(globalData, wrapper, wrapperOwner, context); + ASSERT(!m_wrapper); + m_wrapper = JSC::PassWeak<JSDOMWrapper>(wrapper, wrapperOwner, context); } - void clearWrapper() + void clearWrapper(JSDOMWrapper* wrapper) { + ASSERT_UNUSED(wrapper, m_wrapper.was(wrapper)); m_wrapper.clear(); } diff --git a/Source/WebCore/bindings/js/SerializedScriptValue.cpp b/Source/WebCore/bindings/js/SerializedScriptValue.cpp index 7c586aa67..7c716c0ba 100644 --- a/Source/WebCore/bindings/js/SerializedScriptValue.cpp +++ b/Source/WebCore/bindings/js/SerializedScriptValue.cpp @@ -50,6 +50,7 @@ #include "JSUint32Array.h" #include "JSUint8Array.h" #include "JSUint8ClampedArray.h" +#include "NotImplemented.h" #include "ScriptValue.h" #include "SharedBuffer.h" #include <limits> @@ -62,8 +63,8 @@ #include <runtime/RegExp.h> #include <runtime/RegExpObject.h> #include <wtf/ArrayBuffer.h> -#include <wtf/ByteArray.h> #include <wtf/HashTraits.h> +#include <wtf/Uint8ClampedArray.h> #include <wtf/Vector.h> using namespace JSC; @@ -320,9 +321,9 @@ class CloneSerializer : CloneBase { public: static SerializationReturnCode serialize(ExecState* exec, JSValue value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, - Vector<uint8_t>& out) + Vector<String>& blobURLs, Vector<uint8_t>& out) { - CloneSerializer serializer(exec, messagePorts, arrayBuffers, out); + CloneSerializer serializer(exec, messagePorts, arrayBuffers, blobURLs, out); return serializer.serialize(value); } @@ -353,9 +354,10 @@ public: private: typedef HashMap<JSObject*, uint32_t> ObjectPool; - CloneSerializer(ExecState* exec, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, Vector<uint8_t>& out) + CloneSerializer(ExecState* exec, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, Vector<String>& blobURLs, Vector<uint8_t>& out) : CloneBase(exec) , m_buffer(out) + , m_blobURLs(blobURLs) , m_emptyIdentifier(exec, UString("", 0)) { write(CurrentVersion); @@ -368,7 +370,7 @@ private: { if (!input) return; - JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()); + JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()); for (size_t i = 0; i < input->size(); i++) { JSC::JSValue value = toJS(m_exec, globalObject, input->at(i).get()); JSC::JSObject* obj = value.getObject(); @@ -387,20 +389,33 @@ private: return isJSArray(object) || object->inherits(&JSArray::s_info); } - bool startObjectInternal(JSObject* object) + bool checkForDuplicate(JSObject* object) { // Record object for graph reconstruction - pair<ObjectPool::iterator, bool> iter = m_objectPool.add(object, m_objectPool.size()); - + ObjectPool::const_iterator found = m_objectPool.find(object); + // Handle duplicate references - if (!iter.second) { + if (found != m_objectPool.end()) { write(ObjectReferenceTag); - ASSERT(static_cast<int32_t>(iter.first->second) < m_objectPool.size()); - writeObjectIndex(iter.first->second); - return false; + ASSERT(static_cast<int32_t>(found->second) < m_objectPool.size()); + writeObjectIndex(found->second); + return true; } - + + return false; + } + + void recordObject(JSObject* object) + { + m_objectPool.add(object, m_objectPool.size()); m_gcBuffer.append(object); + } + + bool startObjectInternal(JSObject* object) + { + if (checkForDuplicate(object)) + return false; + recordObject(object); return true; } @@ -524,7 +539,7 @@ private: code = ValidationError; return true; } - JSValue bufferObj = toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()), arrayBuffer.get()); + JSValue bufferObj = toJS(m_exec, jsCast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()), arrayBuffer.get()); return dumpIfTerminal(bufferObj, code); } @@ -582,6 +597,7 @@ private: if (obj->inherits(&JSBlob::s_info)) { write(BlobTag); Blob* blob = toBlob(obj); + m_blobURLs.append(blob->url()); write(blob->url()); write(blob->type()); write(blob->size()); @@ -593,7 +609,7 @@ private: write(data->width()); write(data->height()); write(data->data()->length()); - write(data->data()->data()->data(), data->data()->length()); + write(data->data()->data(), data->data()->length()); return true; } if (obj->inherits(&RegExpObject::s_info)) { @@ -640,9 +656,11 @@ private: return true; } if (obj->inherits(&JSArrayBufferView::s_info)) { - if (!startObjectInternal(obj)) + if (checkForDuplicate(obj)) return true; - return dumpArrayBufferView(obj, code); + bool success = dumpArrayBufferView(obj, code); + recordObject(obj); + return success; } CallData unusedData; @@ -723,10 +741,10 @@ private: void write(const Identifier& ident) { UString str = ident.ustring(); - pair<StringConstantPool::iterator, bool> iter = m_constantPool.add(str.impl(), m_constantPool.size()); - if (!iter.second) { + StringConstantPool::AddResult addResult = m_constantPool.add(str.impl(), m_constantPool.size()); + if (!addResult.isNewEntry) { write(StringPoolTag); - writeStringIndex(iter.first->second); + writeStringIndex(addResult.iterator->second); return; } @@ -766,6 +784,7 @@ private: void write(const File* file) { + m_blobURLs.append(file->url()); write(file->path()); write(file->url()); write(file->type()); @@ -777,6 +796,7 @@ private: } Vector<uint8_t>& m_buffer; + Vector<String>& m_blobURLs; ObjectPool m_objectPool; ObjectPool m_transferredMessagePorts; ObjectPool m_transferredArrayBuffers; @@ -1330,7 +1350,7 @@ private: template<class T> JSValue getJSValue(T* nativeObj) { - return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), nativeObj); + return toJS(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), nativeObj); } JSValue readTerminal() @@ -1373,7 +1393,7 @@ private: return JSValue(); if (!m_isDOMGlobalObject) return jsNull(); - return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_globalObject), file.get()); + return toJS(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), file.get()); } case FileListTag: { unsigned length = 0; @@ -1410,7 +1430,7 @@ private: return jsNull(); } RefPtr<ImageData> result = ImageData::create(IntSize(width, height)); - memcpy(result->data()->data()->data(), m_ptr, length); + memcpy(result->data()->data(), m_ptr, length); m_ptr += length; return getJSValue(result.get()); } @@ -1661,10 +1681,17 @@ SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>& buffer) m_data.swap(buffer); } -SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>& buffer, PassOwnPtr<ArrayBufferContentsArray> arrayBufferContentsArray) +SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>& buffer, Vector<String>& blobURLs) +{ + m_data.swap(buffer); + m_blobURLs.swap(blobURLs); +} + +SerializedScriptValue::SerializedScriptValue(Vector<uint8_t>& buffer, Vector<String>& blobURLs, PassOwnPtr<ArrayBufferContentsArray> arrayBufferContentsArray) : m_arrayBufferContentsArray(arrayBufferContentsArray) { m_data.swap(buffer); + m_blobURLs.swap(blobURLs); } PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValue::transferArrayBuffers( @@ -1702,7 +1729,8 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec, SerializationErrorMode throwExceptions) { Vector<uint8_t> buffer; - SerializationReturnCode code = CloneSerializer::serialize(exec, value, messagePorts, arrayBuffers, buffer); + Vector<String> blobURLs; + SerializationReturnCode code = CloneSerializer::serialize(exec, value, messagePorts, arrayBuffers, blobURLs, buffer); OwnPtr<ArrayBufferContentsArray> arrayBufferContentsArray; @@ -1715,7 +1743,7 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(ExecState* exec, if (!serializationDidCompleteSuccessfully(code)) return 0; - return adoptRef(new SerializedScriptValue(buffer, arrayBufferContentsArray.release())); + return adoptRef(new SerializedScriptValue(buffer, blobURLs, arrayBufferContentsArray.release())); } PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() @@ -1732,6 +1760,37 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& st return adoptRef(new SerializedScriptValue(buffer)); } +#if ENABLE(INDEXED_DATABASE) +PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(JSC::ExecState*, JSC::JSValue) +{ + notImplemented(); + return PassRefPtr<SerializedScriptValue>(); +} + +String SerializedScriptValue::toWireString() const +{ + notImplemented(); + return String(); +} +PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const String&) +{ + notImplemented(); + return PassRefPtr<SerializedScriptValue>(); +} + +PassRefPtr<SerializedScriptValue> SerializedScriptValue::numberValue(double) +{ + notImplemented(); + return PassRefPtr<SerializedScriptValue>(); +} + +JSValue SerializedScriptValue::deserialize(JSC::ExecState*, JSC::JSGlobalObject*) +{ + notImplemented(); + return JSValue(); +} +#endif + PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(JSContextRef originContext, JSValueRef apiValue, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, JSValueRef* exception) diff --git a/Source/WebCore/bindings/js/SerializedScriptValue.h b/Source/WebCore/bindings/js/SerializedScriptValue.h index 3f8da5e8f..1a2de0068 100644 --- a/Source/WebCore/bindings/js/SerializedScriptValue.h +++ b/Source/WebCore/bindings/js/SerializedScriptValue.h @@ -27,6 +27,7 @@ #ifndef SerializedScriptValue_h #define SerializedScriptValue_h +#include "PlatformString.h" #include "ScriptState.h" #include <heap/Strong.h> #include <runtime/JSValue.h> @@ -58,7 +59,12 @@ enum SerializationErrorMode { NonThrowing, Throwing }; class ScriptValue; class SharedBuffer; -class SerializedScriptValue : public RefCounted<SerializedScriptValue> { +class SerializedScriptValue : +#if ENABLE(INDEXED_DATABASE) + public ThreadSafeRefCounted<SerializedScriptValue> { +#else + public RefCounted<SerializedScriptValue> { +#endif public: static PassRefPtr<SerializedScriptValue> create(JSC::ExecState*, JSC::JSValue, MessagePortArray*, ArrayBufferArray*, SerializationErrorMode = Throwing); @@ -87,6 +93,15 @@ public: #endif const Vector<uint8_t>& data() { return m_data; } + const Vector<String>& blobURLs() const { return m_blobURLs; } + +#if ENABLE(INDEXED_DATABASE) + static PassRefPtr<SerializedScriptValue> create(JSC::ExecState*, JSC::JSValue); + static PassRefPtr<SerializedScriptValue> createFromWire(const String& data); + String toWireString() const; + static PassRefPtr<SerializedScriptValue> numberValue(double value); + JSC::JSValue deserialize(JSC::ExecState*, JSC::JSGlobalObject*); +#endif ~SerializedScriptValue(); @@ -95,11 +110,13 @@ private: static void maybeThrowExceptionIfSerializationFailed(JSC::ExecState*, SerializationReturnCode); static bool serializationDidCompleteSuccessfully(SerializationReturnCode); static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBufferArray&, SerializationReturnCode&); - + SerializedScriptValue(Vector<unsigned char>&); - SerializedScriptValue(Vector<unsigned char>&, PassOwnPtr<ArrayBufferContentsArray>); + SerializedScriptValue(Vector<unsigned char>&, Vector<String>& blobURLs); + SerializedScriptValue(Vector<unsigned char>&, Vector<String>& blobURLs, PassOwnPtr<ArrayBufferContentsArray>); Vector<unsigned char> m_data; OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; + Vector<String> m_blobURLs; }; } diff --git a/Source/WebCore/bindings/js/StringSourceProvider.h b/Source/WebCore/bindings/js/StringSourceProvider.h index ed302f8dd..8b6718891 100644 --- a/Source/WebCore/bindings/js/StringSourceProvider.h +++ b/Source/WebCore/bindings/js/StringSourceProvider.h @@ -42,7 +42,15 @@ namespace WebCore { return adoptRef(new StringSourceProvider(source, url, startPosition)); } - JSC::UString getRange(int start, int end) const { return JSC::UString(m_source.characters() + start, end - start); } + virtual JSC::UString getRange(int start, int end) const OVERRIDE + { + int length = end - start; + ASSERT(length >= 0); + ASSERT(start + length <= this->length()); + + return JSC::UString(StringImpl::create(m_source.impl(), start, length)); + } + const StringImpl* data() const { return m_source.impl(); } int length() const { return m_source.length(); } const String& source() const { return m_source; } diff --git a/Source/WebCore/bindings/js/WebCoreJSClientData.h b/Source/WebCore/bindings/js/WebCoreJSClientData.h index 6e2d7bed3..44d1d450c 100644 --- a/Source/WebCore/bindings/js/WebCoreJSClientData.h +++ b/Source/WebCore/bindings/js/WebCoreJSClientData.h @@ -47,7 +47,7 @@ public: DOMWrapperWorld* normalWorld() { return m_normalWorld.get(); } - void getAllWorlds(Vector<DOMWrapperWorld*>& worlds) + void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds) { copyToVector(m_worldSet, worlds); } diff --git a/Source/WebCore/bindings/js/WorkerScriptController.cpp b/Source/WebCore/bindings/js/WorkerScriptController.cpp index 6cff92b22..b11544981 100644 --- a/Source/WebCore/bindings/js/WorkerScriptController.cpp +++ b/Source/WebCore/bindings/js/WorkerScriptController.cpp @@ -64,9 +64,9 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) WorkerScriptController::~WorkerScriptController() { - m_workerContextWrapper.clear(); // Unprotect the global object. - m_globalData->clearBuiltinStructures(); - m_globalData->heap.destroy(); + JSLock lock(SilenceAssertionsOnly); + m_workerContextWrapper.clear(); + m_globalData.clear(); } void WorkerScriptController::initScript() diff --git a/Source/WebCore/bindings/objc/DOM.mm b/Source/WebCore/bindings/objc/DOM.mm index 7bd99a148..abc529892 100644 --- a/Source/WebCore/bindings/objc/DOM.mm +++ b/Source/WebCore/bindings/objc/DOM.mm @@ -389,6 +389,7 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget) range->textRects(rects); return kit(rects); } + @end @implementation DOMRange (DOMRangeExtensions) diff --git a/Source/WebCore/bindings/objc/PublicDOMInterfaces.h b/Source/WebCore/bindings/objc/PublicDOMInterfaces.h index 1239971be..9d6521e84 100644 --- a/Source/WebCore/bindings/objc/PublicDOMInterfaces.h +++ b/Source/WebCore/bindings/objc/PublicDOMInterfaces.h @@ -244,10 +244,6 @@ @interface DOMFile : DOMBlob WEBKIT_VERSION_4_0 @property(readonly, copy) NSString *name; - -// FIXME: obsolete properties. To be removed. -@property(readonly, copy) NSString *fileName; -@property(readonly) unsigned long long fileSize; @end @interface DOMFileList : DOMObject WEBKIT_VERSION_4_0 diff --git a/Source/WebCore/bindings/objc/WebScriptObject.mm b/Source/WebCore/bindings/objc/WebScriptObject.mm index d0df7bf57..aeef94131 100644 --- a/Source/WebCore/bindings/objc/WebScriptObject.mm +++ b/Source/WebCore/bindings/objc/WebScriptObject.mm @@ -221,7 +221,7 @@ static void _didExecute(WebScriptObject *obj) if (!_private->originRootObject->isValid()) return false; - return static_cast<JSDOMWindowBase*>(root->globalObject())->allowsAccessFrom(_private->originRootObject->globalObject()); + return jsCast<JSDOMWindowBase*>(root->globalObject())->allowsAccessFrom(_private->originRootObject->globalObject()); } - (void)dealloc @@ -519,7 +519,7 @@ static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* root if (object->inherits(&JSHTMLElement::s_info)) { // Plugin elements cache the instance internally. - HTMLElement* el = static_cast<JSHTMLElement*>(object)->impl(); + HTMLElement* el = jsCast<JSHTMLElement*>(object)->impl(); ObjcInstance* instance = static_cast<ObjcInstance*>(pluginInstance(el)); if (instance) return instance->getObject(); diff --git a/Source/WebCore/bindings/scripts/CodeGenerator.pm b/Source/WebCore/bindings/scripts/CodeGenerator.pm index ea5835996..4698f745f 100644 --- a/Source/WebCore/bindings/scripts/CodeGenerator.pm +++ b/Source/WebCore/bindings/scripts/CodeGenerator.pm @@ -340,11 +340,15 @@ sub ParseInterface # Helpers for all CodeGenerator***.pm modules -sub AvoidInclusionOfType +sub SkipIncludeHeader { my $object = shift; my $type = shift; + return 1 if $primitiveTypeHash{$type}; + return 1 if $numericTypeHash{$type}; + return 1 if $type eq "String"; + # Special case: SVGPoint.h / SVGNumber.h do not exist. return 1 if $type eq "SVGPoint" or $type eq "SVGNumber"; return 0; @@ -445,6 +449,15 @@ sub IsSVGAnimatedType return 0; } +sub GetArrayType +{ + my $object = shift; + my $type = shift; + + return $1 if $type =~ /^sequence<([\w\d_\s]+)>.*/; + return ""; +} + # Uppercase the first letter while respecting WebKit style guidelines. # E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang. sub WK_ucfirst @@ -505,6 +518,9 @@ sub AttributeNameForGetterAndSetter my ($generator, $attribute) = @_; my $attributeName = $attribute->signature->name; + if ($attribute->signature->extendedAttributes->{"ImplementedAs"}) { + $attributeName = $attribute->signature->extendedAttributes->{"ImplementedAs"}; + } my $attributeType = $generator->StripModule($attribute->signature->type); # Avoid clash with C++ keyword. @@ -592,6 +608,19 @@ sub ShouldCheckEnums return not $dataNode->extendedAttributes->{"DoNotCheckConstants"}; } +sub GenerateConditionalString +{ + my $generator = shift; + my $node = shift; + + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + return $generator->GenerateConditionalStringFromAttributeValue($conditional); + } else { + return ""; + } +} + sub GenerateConditionalStringFromAttributeValue { my $generator = shift; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm b/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm index 5a1c2b93f..a365c683c 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm @@ -187,22 +187,45 @@ sub GetParent return $parent; } -sub ShouldSkipType +sub SkipFunction { - my $typeInfo = shift; + my $function = shift; - return 1 if $typeInfo->signature->extendedAttributes->{"Custom"} - or $typeInfo->signature->extendedAttributes->{"CustomGetter"}; + return 1 if $function->signature->extendedAttributes->{"Custom"}; # FIXME: We don't generate bindings for SVG related interfaces yet - return 1 if $typeInfo->signature->name =~ /getSVGDocument/; + return 1 if $function->signature->name =~ /getSVGDocument/; + + if ($codeGenerator->GetArrayType($function->signature->type)) { + return 1; + } + + foreach my $param (@{$function->parameters}) { + return 1 if $codeGenerator->GetArrayType($param->type); + } + + # FIXME: This is typically used to add script execution state arguments to the method. + # These functions will not compile with the C++ bindings as is, so disable them + # to restore compilation until a proper implementation can be developed. + return 1 if $function->signature->extendedAttributes->{"CallWith"}; +} + +sub SkipAttribute +{ + my $attribute = shift; + + return 1 if $attribute->signature->extendedAttributes->{"Custom"} + or $attribute->signature->extendedAttributes->{"CustomGetter"}; + + return 1 if $attribute->signature->type =~ /Constructor$/; + + return 1 if $codeGenerator->GetArrayType($attribute->signature->type); - return 1 if $typeInfo->signature->type =~ /Constructor$/; - # FIXME: This is typically used to add script execution state arguments to the method. # These functions will not compile with the C++ bindings as is, so disable them # to restore compilation until a proper implementation can be developed. - return 1 if $typeInfo->signature->extendedAttributes->{"CallWith"}; + return 1 if $attribute->signature->extendedAttributes->{"CallWith"}; + return 0; } @@ -262,6 +285,7 @@ sub AddIncludesForType { my $type = $codeGenerator->StripModule(shift); + return if $codeGenerator->GetArrayType($type); return if $codeGenerator->IsNonPointerType($type); return if $type =~ /Constructor/; @@ -305,17 +329,6 @@ sub AddIncludesForType $implIncludes{"WebDOM$type.h"} = 1; } -sub GenerateConditionalString -{ - my $node = shift; - my $conditional = $node->extendedAttributes->{"Conditional"}; - if ($conditional) { - return $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - } else { - return ""; - } -} - sub GetNamespaceForClass { my $type = shift; @@ -349,7 +362,7 @@ sub GenerateHeader push(@headerContentHeader, "\n#ifndef $className" . "_h"); push(@headerContentHeader, "\n#define $className" . "_h\n\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; # - INCLUDES - @@ -424,9 +437,9 @@ sub GenerateHeader # - Add attribute getters/setters. if ($numAttributes > 0) { foreach my $attribute (@{$dataNode->attributes}) { - next if ShouldSkipType($attribute); + next if SkipAttribute($attribute); - my $attributeConditionalString = GenerateConditionalString($attribute->signature); + my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); my $attributeName = $attribute->signature->name; my $attributeType = GetCPPType($attribute->signature->type, 0); my $attributeIsReadonly = ($attribute->type =~ /^readonly/); @@ -463,7 +476,7 @@ sub GenerateHeader # - Add functions. if ($numFunctions > 0) { foreach my $function (@{$dataNode->functions}) { - next if ShouldSkipType($function); + next if SkipFunction($function); my $functionName = $function->signature->extendedAttributes->{"ImplementedAs"} || $function->signature->name; my $returnType = GetCPPType($function->signature->type, 0); @@ -494,7 +507,7 @@ sub GenerateHeader AddForwardDeclarationsForType($type, 1); } - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@headerFunctions, "#if ${conditionalString}\n") if $conditionalString; push(@headerFunctions, " "); push(@headerFunctions, $functionDeclaration); @@ -601,7 +614,7 @@ sub GenerateImplementation # - INCLUDES - push(@implContentHeader, "\n#include \"config.h\"\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; push(@implContentHeader, "#include \"$className.h\"\n\n"); @@ -678,7 +691,7 @@ sub GenerateImplementation # - Attributes if ($numAttributes > 0) { foreach my $attribute (@{$dataNode->attributes}) { - next if ShouldSkipType($attribute); + next if SkipAttribute($attribute); AddIncludesForType($attribute->signature->type); my $idlType = $codeGenerator->StripModule($attribute->signature->type); @@ -718,7 +731,7 @@ sub GenerateImplementation } my $getterContent = "${getterContentHead}${functionName}(" . join(", ", @arguments) . ")${getterContentTail}"; - my $attributeConditionalString = GenerateConditionalString($attribute->signature); + my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, $getterSig); @@ -784,7 +797,7 @@ sub GenerateImplementation if ($numFunctions > 0) { foreach my $function (@{$dataNode->functions}) { # Treat CPPPureInterface as Custom as well, since the WebCore versions will take a script context as well - next if ShouldSkipType($function) || $dataNode->extendedAttributes->{"CPPPureInterface"}; + next if SkipFunction($function) || $dataNode->extendedAttributes->{"CPPPureInterface"}; AddIncludesForType($function->signature->type); my $functionName = $function->signature->name; @@ -887,7 +900,7 @@ sub GenerateImplementation } } - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; push(@implContent, "$functionSig\n"); diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm index 47677a8c3..04898db17 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -114,6 +114,21 @@ sub FixUpDecamelizedName { return $classname; } +sub HumanReadableConditional { + my @conditional = split('_', shift); + my @upperCaseExceptions = ("SQL", "API"); + my @humanReadable; + + for $part (@conditional) { + if (!grep {$_ eq $part} @upperCaseExceptions) { + $part = camelize(lc($part)); + } + push(@humanReadable, $part); + } + + return join(' ', @humanReadable); +} + sub ClassNameToGObjectType { my $className = shift; my $CLASS_NAME = uc(decamelize($className)); @@ -164,6 +179,10 @@ sub SkipAttribute { return 1; } + if ($codeGenerator->GetArrayType($propType)) { + return 1; + } + # This is for DOMWindow.idl location attribute if ($attribute->signature->name eq "location") { return 1; @@ -188,6 +207,7 @@ sub SkipFunction { my $prefix = shift; my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($function->signature->name); + my $functionReturnType = $prefix eq "set_" ? "void" : $function->signature->type; my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"}; my $callWith = $function->signature->extendedAttributes->{"CallWith"}; my $isUnsupportedCallWith = $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments") || $codeGenerator->ExtendedAttributeContains($callWith, "CallStack"); @@ -210,13 +230,18 @@ sub SkipFunction { return 1; } + if ($codeGenerator->GetArrayType($functionReturnType)) { + return 1; + } + # Skip functions that have ["Callback"] parameters, because this # code generator doesn't know how to auto-generate callbacks. - # Skip functions that have "MediaQueryListListener" parameters, because this - # code generator doesn't know how to auto-generate MediaQueryListListener. + # Skip functions that have "MediaQueryListListener" or sequence<T> parameters, because this + # code generator doesn't know how to auto-generate MediaQueryListListener or sequence<T>. foreach my $param (@{$function->parameters}) { if ($param->extendedAttributes->{"Callback"} || - $param->type eq "MediaQueryListListener") { + $param->type eq "MediaQueryListListener" || + $codeGenerator->GetArrayType($param->type)) { return 1; } } @@ -318,29 +343,47 @@ sub GetWriteableProperties { return @result; } -sub GenerateConditionalString +sub GenerateConditionalWarning { my $node = shift; + my $indentSize = shift; + if (!$indentSize) { + $indentSize = 4; + } + my $conditional = $node->extendedAttributes->{"Conditional"}; + my @warn; + if ($conditional) { if ($conditional =~ /&/) { - return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + my @splitConditionals = split(/&/, $conditional); + foreach $condition (@splitConditionals) { + push(@warn, "#if !ENABLE($condition)\n"); + push(@warn, ' ' x $indentSize . "WEBKIT_WARN_FEATURE_NOT_PRESENT(\"" . HumanReadableConditional($condition) . "\")\n"); + push(@warn, "#endif\n"); + } } elsif ($conditional =~ /\|/) { - return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + foreach $condition (split(/\|/, $conditional)) { + push(@warn, ' ' x $indentSize . "WEBKIT_WARN_FEATURE_NOT_PRESENT(\"" . HumanReadableConditional($condition) . "\")\n"); + } } else { - return "ENABLE(" . $conditional . ")"; + push(@warn, ' ' x $indentSize . "WEBKIT_WARN_FEATURE_NOT_PRESENT(\"" . HumanReadableConditional($conditional) . "\")\n"); } - } else { - return ""; } + + return @warn; } sub GenerateProperty { my $attribute = shift; my $interfaceName = shift; my @writeableProperties = @{shift @_}; + my $parentNode = shift; - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); + my @conditionalWarn = GenerateConditionalWarning($attribute->signature, 8); + my $parentConditionalString = $codeGenerator->GenerateConditionalString($parentNode); + my @parentConditionalWarn = GenerateConditionalWarning($parentNode, 8); my $camelPropName = $attribute->signature->name; my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName); my $getPropNameFunction = $codeGenerator->WK_lcfirst($camelPropName); @@ -349,9 +392,7 @@ 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; + push(@cBodyProperties, " ${propEnum},\n"); my $propType = $attribute->signature->type; my ${propGType} = decamelize($propType); @@ -400,16 +441,23 @@ sub GenerateProperty { push(@setterArguments, "ec") if @{$attribute->setterExceptions}; if (grep {$_ eq $attribute} @writeableProperties) { + push(@txtSetProps, " case ${propEnum}: {\n"); + push(@txtSetProps, "#if ${parentConditionalString}\n") if $parentConditionalString; 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, " ${setterFunctionName}(" . join(", ", @setterArguments) . ");\n"); - push(@txtSetProps, " break;\n }\n"); + push(@txtSetProps, "#else\n") if $conditionalString; + push(@txtSetProps, @conditionalWarn) if scalar(@conditionalWarn); push(@txtSetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; + push(@txtSetProps, "#else\n") if $parentConditionalString; + push(@txtSetProps, @parentConditionalWarn) if scalar(@parentConditionalWarn); + push(@txtSetProps, "#endif /* ${parentConditionalString} */\n") if $parentConditionalString; + push(@txtSetProps, " break;\n }\n"); } + push(@txtGetProps, " case ${propEnum}: {\n"); + push(@txtGetProps, "#if ${parentConditionalString}\n") if $parentConditionalString; push(@txtGetProps, "#if ${conditionalString}\n") if $conditionalString; - push(@txtGetProps, " case ${propEnum}:\n {\n"); push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->getterExceptions}; my $postConvertFunction = ""; @@ -439,8 +487,13 @@ sub GenerateProperty { } } - push(@txtGetProps, " break;\n }\n"); + push(@txtGetProps, "#else\n") if $conditionalString; + push(@txtGetProps, @conditionalWarn) if scalar(@conditionalWarn); push(@txtGetProps, "#endif /* ${conditionalString} */\n") if $conditionalString; + push(@txtGetProps, "#else\n") if $parentConditionalString; + push(@txtGetProps, @parentConditionalWarn) if scalar(@parentConditionalWarn); + push(@txtGetProps, "#endif /* ${parentConditionalString} */\n") if $parentConditionalString; + push(@txtGetProps, " break;\n }\n"); my %param_spec_options = ("int", "G_MININT, /* min */\nG_MAXINT, /* max */\n0, /* default */", "boolean", "FALSE, /* default */", @@ -466,9 +519,7 @@ sub GenerateProperty { $param_spec_options{$gtype} ${gparamflag})); EOF - push(@txtInstallProps, "#if ${conditionalString}\n") if $conditionalString; push(@txtInstallProps, $txtInstallProp); - push(@txtInstallProps, "#endif /* ${conditionalString} */\n") if $conditionalString; } sub GenerateProperties { @@ -477,6 +528,14 @@ sub GenerateProperties { my $clsCaps = substr(ClassNameToGObjectType($className), 12); my $lowerCaseIfaceName = "webkit_dom_" . (FixUpDecamelizedName(decamelize($interfaceName))); + my $conditionGuardStart = ""; + my $conditionGuardEnd = ""; + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); + if ($conditionalString) { + $conditionGuardStart = "#if ${conditionalString}"; + $conditionGuardEnd = "#endif // ${conditionalString}"; + } + # Properties my $implContent = ""; @@ -485,14 +544,14 @@ sub GenerateProperties { enum { PROP_0, EOF - push(@cBodyPriv, $implContent); + push(@cBodyProperties, $implContent); my @readableProperties = GetReadableProperties($dataNode->attributes); my $privFunction = GetCoreObject($interfaceName, "coreSelf", "self"); my $txtGetProp = << "EOF"; -static void ${lowerCaseIfaceName}_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void ${lowerCaseIfaceName}_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; EOF @@ -502,18 +561,18 @@ EOF ${className}* self = WEBKIT_DOM_${clsCaps}(object); $privFunction EOF - push(@txtGetProps, $txtGetProp); + push(@txtGetProps, $txtGetProp); } $txtGetProp = << "EOF"; - switch (prop_id) { + switch (propertyId) { EOF push(@txtGetProps, $txtGetProp); my @writeableProperties = GetWriteableProperties(\@readableProperties); my $txtSetProps = << "EOF"; -static void ${lowerCaseIfaceName}_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void ${lowerCaseIfaceName}_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; EOF @@ -528,22 +587,22 @@ EOF } $txtSetProps = << "EOF"; - switch (prop_id) { + switch (propertyId) { EOF push(@txtSetProps, $txtSetProps); foreach my $attribute (@readableProperties) { if ($attribute->signature->type ne "EventListener" && $attribute->signature->type ne "MediaQueryListListener") { - GenerateProperty($attribute, $interfaceName, \@writeableProperties); + GenerateProperty($attribute, $interfaceName, \@writeableProperties, $dataNode); } } - push(@cBodyPriv, "};\n\n"); + push(@cBodyProperties, "};\n\n"); $txtGetProp = << "EOF"; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -552,7 +611,7 @@ EOF $txtSetProps = << "EOF"; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -563,19 +622,20 @@ EOF $" = ""; $implContent = << "EOF"; - static void ${lowerCaseIfaceName}_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); +$conditionGuardStart + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::${interfaceName}* coreObject = static_cast<WebCore::${interfaceName} *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::${interfaceName}* coreObject = static_cast<WebCore::${interfaceName}*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } +$conditionGuardEnd G_OBJECT_CLASS(${lowerCaseIfaceName}_parent_class)->finalize(object); } @@ -587,7 +647,7 @@ static void ${lowerCaseIfaceName}_finalize(GObject* object) static void ${lowerCaseIfaceName}_constructed(GObject* object) { EOF - push(@cBodyPriv, $implContent); + push(@cBodyProperties, $implContent); $implContent = << "EOF"; @txtInstallEventListeners @@ -597,7 +657,7 @@ EOF static void ${lowerCaseIfaceName}_class_init(${className}Class* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = ${lowerCaseIfaceName}_finalize; gobjectClass->set_property = ${lowerCaseIfaceName}_set_property; gobjectClass->get_property = ${lowerCaseIfaceName}_get_property; @@ -612,7 +672,7 @@ static void ${lowerCaseIfaceName}_init(${className}* request) } EOF - push(@cBodyPriv, $implContent); + push(@cBodyProperties, $implContent); } sub GenerateHeader { @@ -716,7 +776,7 @@ sub addIncludeInBody { } sub GenerateFunction { - my ($object, $interfaceName, $function, $prefix) = @_; + my ($object, $interfaceName, $function, $prefix, $parentNode) = @_; my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); @@ -733,7 +793,11 @@ sub GenerateFunction { my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($functionSigName); my $returnType = GetGlibTypeName($functionSigType); my $returnValueIsGDOMType = IsGDOMClassType($functionSigType); - my $conditionalString = GenerateConditionalString($function->signature); + + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); + my $parentConditionalString = $codeGenerator->GenerateConditionalString($parentNode); + my @conditionalWarn = GenerateConditionalWarning($function->signature); + my @parentConditionalWarn = GenerateConditionalWarning($parentNode); my $functionSig = "${className}* self"; @@ -748,7 +812,7 @@ sub GenerateFunction { addIncludeInBody($paramIDLType); my $paramType = GetGlibTypeName($paramIDLType); my $const = $paramType eq "gchar*" ? "const " : ""; - my $paramName = decamelize($param->name); + my $paramName = $param->name; $functionSig .= ", ${const}$paramType $paramName"; @@ -759,7 +823,7 @@ sub GenerateFunction { } } if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) { - $paramName = "converted_" . $paramName; + $paramName = "converted" . $codeGenerator->WK_ucfirst($paramName); } push(@callImplParams, $paramName); } @@ -775,8 +839,8 @@ sub GenerateFunction { $implIncludes{"${functionSigType}.h"} = 1; } - if(@{$function->raisesExceptions}) { - $functionSig .= ", GError **error"; + if (@{$function->raisesExceptions}) { + $functionSig .= ", GError** error"; } # Insert introspection annotations @@ -788,7 +852,7 @@ sub GenerateFunction { my $paramType = GetGlibTypeName($param->type); # $paramType can have a trailing * in some cases $paramType =~ s/\*$//; - my $paramName = decamelize($param->name); + my $paramName = $param->name; push(@hBody, " * \@${paramName}: A #${paramType}\n"); } if(@{$function->raisesExceptions}) { @@ -807,6 +871,7 @@ sub GenerateFunction { push(@hBody, "\n"); push(@cBody, "$returnType\n$functionName($functionSig)\n{\n"); + push(@cBody, "#if ${parentConditionalString}\n") if $parentConditionalString; push(@cBody, "#if ${conditionalString}\n") if $conditionalString; if ($returnType ne "void") { @@ -818,12 +883,11 @@ sub GenerateFunction { push(@cBody, " WebCore::JSMainThreadNullState state;\n"); - # The WebKit::core implementations check for NULL already; no need to - # duplicate effort. - push(@cBody, " WebCore::${interfaceName} * item = WebKit::core(self);\n"); + # The WebKit::core implementations check for null already; no need to duplicate effort. + push(@cBody, " WebCore::${interfaceName}* item = WebKit::core(self);\n"); foreach my $param (@{$function->parameters}) { - my $paramName = decamelize($param->name); + my $paramName = $param->name; my $paramIDLType = $param->type; my $paramTypeIsPrimitive = $codeGenerator->IsPrimitiveType($paramIDLType); my $paramIsGDOMType = IsGDOMClassType($paramIDLType); @@ -844,28 +908,29 @@ sub GenerateFunction { $returnParamName = ""; foreach my $param (@{$function->parameters}) { my $paramIDLType = $param->type; - my $paramName = decamelize($param->name); + my $paramName = $param->name; my $paramIsGDOMType = IsGDOMClassType($paramIDLType); + $convertedParamName = "converted" . $codeGenerator->WK_ucfirst($paramName); if ($paramIDLType eq "DOMString") { - push(@cBody, " WTF::String converted_${paramName} = WTF::String::fromUTF8($paramName);\n"); + push(@cBody, " WTF::String ${convertedParamName} = WTF::String::fromUTF8($paramName);\n"); } elsif ($paramIDLType eq "CompareHow") { - push(@cBody, " WebCore::Range::CompareHow converted_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); + push(@cBody, " WebCore::Range::CompareHow ${convertedParamName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); } elsif ($paramIsGDOMType) { - push(@cBody, " WebCore::${paramIDLType} * converted_${paramName} = NULL;\n"); - push(@cBody, " if (${paramName} != NULL) {\n"); - push(@cBody, " converted_${paramName} = WebKit::core($paramName);\n"); + push(@cBody, " WebCore::${paramIDLType}* ${convertedParamName} = 0;\n"); + push(@cBody, " if (${paramName}) {\n"); + push(@cBody, " ${convertedParamName} = WebKit::core($paramName);\n"); if ($returnType ne "void") { # TODO: return proper default result - push(@cBody, " g_return_val_if_fail(converted_${paramName}, 0);\n"); + push(@cBody, " g_return_val_if_fail(${convertedParamName}, 0);\n"); } else { - push(@cBody, " g_return_if_fail(converted_${paramName});\n"); + push(@cBody, " g_return_if_fail(${convertedParamName});\n"); } push(@cBody, " }\n"); } - $returnParamName = "converted_".$paramName if $param->extendedAttributes->{"CustomReturn"}; + $returnParamName = $convertedParamName if $param->extendedAttributes->{"CustomReturn"}; } my $assign = ""; @@ -879,14 +944,14 @@ sub GenerateFunction { $functionName eq "webkit_dom_node_insert_before" || $functionName eq "webkit_dom_node_replace_child" || $functionName eq "webkit_dom_node_remove_child"; - + if ($returnType ne "void" && !$functionHasCustomReturn) { if ($returnValueIsGDOMType) { - $assign = "PassRefPtr<WebCore::${functionSigType}> g_res = "; + $assign = "RefPtr<WebCore::${functionSigType}> gobjectResult = "; $assignPre = "WTF::getPtr("; $assignPost = ")"; } else { - $assign = "${returnType} res = "; + $assign = "${returnType} result = "; } } @@ -900,8 +965,8 @@ sub GenerateFunction { my $customNodeAppendChild = << "EOF"; if (ok) { - ${returnType} res = WebKit::kit($returnParamName); - return res; + ${returnType} result = WebKit::kit($returnParamName); + return result; } EOF push(@cBody, $customNodeAppendChild); @@ -914,7 +979,7 @@ EOF EOF push(@cBody, $exceptionHandling); } - push(@cBody, "return NULL;"); + push(@cBody, "return 0;"); push(@cBody, "}\n\n"); return; } elsif ($functionSigType eq "DOMString") { @@ -997,26 +1062,40 @@ EOF if ($returnType ne "void" && !$functionHasCustomReturn) { if ($functionSigType ne "DOMObject") { if ($returnValueIsGDOMType) { - push(@cBody, " ${returnType} res = WebKit::kit(g_res.get());\n"); + push(@cBody, " ${returnType} result = WebKit::kit(gobjectResult.get());\n"); } } if ($functionSigType eq "DOMObject") { - push(@cBody, " return NULL; /* TODO: return canvas object */\n"); + push(@cBody, " return 0; // TODO: return canvas object\n"); } else { - push(@cBody, " return res;\n"); + push(@cBody, " return result;\n"); } } if ($conditionalString) { + push(@cBody, "#else\n"); + push(@cBody, @conditionalWarn) if scalar(@conditionalWarn); if ($returnType ne "void") { - push(@cBody, "#else\n"); if ($codeGenerator->IsNonPointerType($functionSigType)) { push(@cBody, " return static_cast<${returnType}>(0);\n"); } else { - push(@cBody, " return NULL;\n"); + push(@cBody, " return 0;\n"); } } - push(@cBody, "#endif /* ${conditionalString} */\n") if $conditionalString; + push(@cBody, "#endif /* ${conditionalString} */\n"); + } + + if ($parentConditionalString) { + push(@cBody, "#else\n"); + push(@cBody, @parentConditionalWarn) if scalar(@parentConditionalWarn); + if ($returnType ne "void") { + if ($codeGenerator->IsNonPointerType($functionSigType)) { + push(@cBody, " return static_cast<${returnType}>(0);\n"); + } else { + push(@cBody, " return 0;\n"); + } + } + push(@cBody, "#endif /* ${parentConditionalString} */\n"); } push(@cBody, "}\n\n"); @@ -1038,7 +1117,7 @@ sub GenerateFunctions { my ($object, $interfaceName, $dataNode) = @_; foreach my $function (@{$dataNode->functions}) { - $object->GenerateFunction($interfaceName, $function, ""); + $object->GenerateFunction($interfaceName, $function, "", $dataNode); } TOP: @@ -1071,7 +1150,7 @@ sub GenerateFunctions { my $function = new domFunction(); $function->signature($attribute->signature); $function->raisesExceptions($attribute->getterExceptions); - $object->GenerateFunction($interfaceName, $function, "get_"); + $object->GenerateFunction($interfaceName, $function, "get_", $dataNode); # FIXME: We are not generating setters for 'Replaceable' # attributes now, but we should somehow. @@ -1093,13 +1172,13 @@ sub GenerateFunctions { $param->name("value"); $param->type($attribute->signature->type); my %attributes = (); - $param->extendedAttributes("attributes"); + $param->extendedAttributes(\%attributes); my $arrayRef = $function->parameters; push(@$arrayRef, $param); $function->raisesExceptions($attribute->setterExceptions); - $object->GenerateFunction($interfaceName, $function, "set_"); + $object->GenerateFunction($interfaceName, $function, "set_", $dataNode); } } @@ -1118,8 +1197,10 @@ sub GenerateCFile { $implContent = << "EOF"; ${defineTypeMacro}(${className}, ${lowerCaseIfaceName}, ${parentGObjType}${defineTypeInterfaceImplementation} -namespace WebKit { +EOF + push(@cBodyProperties, $implContent); + $implContent = << "EOF"; WebCore::${interfaceName}* core(${className}* request) { g_return_val_if_fail(request, 0); @@ -1130,29 +1211,24 @@ WebCore::${interfaceName}* core(${className}* request) return coreObject; } -} // namespace WebKit EOF - push(@cBodyPriv, $implContent); + $object->GenerateProperties($interfaceName, $dataNode); $object->GenerateFunctions($interfaceName, $dataNode); my $wrapMethod = << "EOF"; -namespace WebKit { ${className}* wrap${interfaceName}(WebCore::${interfaceName}* coreObject) { g_return_val_if_fail(coreObject, 0); - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). coreObject->ref(); - return WEBKIT_DOM_${clsCaps}(g_object_new(WEBKIT_TYPE_DOM_${clsCaps}, - "core-object", coreObject, NULL)); + return WEBKIT_DOM_${clsCaps}(g_object_new(WEBKIT_TYPE_DOM_${clsCaps}, "core-object", coreObject, NULL)); } -} // namespace WebKit + EOF push(@cBodyPriv, $wrapMethod); } @@ -1220,7 +1296,7 @@ static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface) EOF - push(@cBody, $impl); + push(@cBodyProperties, $impl); $defineTypeMacro = "G_DEFINE_TYPE_WITH_CODE"; $defineTypeInterfaceImplementation = ", G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_DOM_EVENT_TARGET, webkit_dom_event_target_init))"; @@ -1233,11 +1309,6 @@ 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"); @@ -1258,8 +1329,6 @@ sub Generate { if (!UsesManualKitImplementation($interfaceName)) { my $converter = << "EOF"; -namespace WebKit { - ${className}* kit(WebCore::$interfaceName* obj) { g_return_val_if_fail(obj, 0); @@ -1269,11 +1338,9 @@ ${className}* kit(WebCore::$interfaceName* obj) return static_cast<${className}*>(DOMObjectCache::put(obj, WebKit::wrap${interfaceName}(obj))); } - -} // namespace WebKit // EOF - push(@cBody, $converter); + push(@cBodyPriv, $converter); } $object->GenerateHeader($interfaceName, $parentClassName); @@ -1289,9 +1356,12 @@ sub WriteData { # Write a private header. my $interfaceName = $dataNode->name; my $filename = "$outputDir/" . $className . "Private.h"; - my $guard = uc(decamelize($className)) . "_PRIVATE_H"; + my $guard = "${className}Private_h"; my $parentClassName = GetParentClassName($dataNode); + # Add the guard if the 'Conditional' extended attribute exists + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); + open(PRIVHEADER, ">$filename") or die "Couldn't open file $filename for writing"; print PRIVHEADER split("\r", $licenceTemplate); @@ -1301,41 +1371,35 @@ sub WriteData { #ifndef $guard #define $guard +#include "${interfaceName}.h" #include <glib-object.h> #include <webkit/${parentClassName}.h> -#include "${interfaceName}.h" EOF print PRIVHEADER $text; + print PRIVHEADER "#if ${conditionalString}\n" if $conditionalString; print PRIVHEADER map { "#include \"$_\"\n" } sort keys(%hdrPropIncludes); - print PRIVHEADER "\n" if keys(%hdrPropIncludes); + print PRIVHEADER "\n"; $text = << "EOF"; namespace WebKit { - ${className} * - wrap${interfaceName}(WebCore::${interfaceName} *coreObject); - - WebCore::${interfaceName} * - core(${className} *request); - +${className}* wrap${interfaceName}(WebCore::${interfaceName}*); +WebCore::${interfaceName}* core(${className}* request); EOF print PRIVHEADER $text; if ($className ne "WebKitDOMNode") { - $text = << "EOF"; - ${className}* - kit(WebCore::${interfaceName}* node); - -EOF - print PRIVHEADER $text; + print PRIVHEADER "${className}* kit(WebCore::${interfaceName}* node);\n" } $text = << "EOF"; } // namespace WebKit -#endif /* ${guard} */ EOF + print PRIVHEADER $text; + print PRIVHEADER "#endif /* ${conditionalString} */\n\n" if $conditionalString; + print PRIVHEADER "#endif /* ${guard} */\n"; close(PRIVHEADER); @@ -1343,17 +1407,16 @@ EOF $basename =~ s/_//g; # Write public header. - my $hdrFName = "$outputDir/" . $basename . ".h"; - open(HEADER, ">$hdrFName") or die "Couldn't open file $hdrFName"; + my $fullHeaderFilename = "$outputDir/" . $basename . ".h"; + my $installedHeaderFilename = "${basename}.h"; + open(HEADER, ">$fullHeaderFilename") or die "Couldn't open file $fullHeaderFilename"; print HEADER @hPrefix; print HEADER @hPrefixGuard; - print HEADER "#include \"webkit/webkitdomdefines.h\"\n"; print HEADER "#include <glib-object.h>\n"; + print HEADER map { "#include <$_>\n" } sort keys(%hdrIncludes); print HEADER "#include <webkit/webkitdefines.h>\n"; - print HEADER map { "#include \"$_\"\n" } sort keys(%hdrIncludes); - print HEADER "\n" if keys(%hdrIncludes); - print HEADER "\n"; + print HEADER "#include <webkit/webkitdomdefines.h>\n\n"; print HEADER @hBodyPre; print HEADER @hBody; print HEADER @hPrefixGuardEnd; @@ -1365,18 +1428,26 @@ EOF open(IMPL, ">$implFileName") or die "Couldn't open file $implFileName"; print IMPL @cPrefix; + print IMPL "#include \"config.h\"\n"; + print IMPL "#include \"$installedHeaderFilename\"\n\n"; + + # Remove the implementation header from the list of included files. + %includesCopy = %implIncludes; + delete ($includesCopy{"webkit/$installedHeaderFilename"}); + print IMPL map { "#include \"$_\"\n" } sort keys(%includesCopy); + 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); - print IMPL "\n" if keys(%implIncludes); - print IMPL @cBody; + print IMPL "#include <wtf/RefPtr.h>\n\n"; + print IMPL "#if ${conditionalString}\n\n" if $conditionalString; - print IMPL "\n"; + print IMPL "namespace WebKit {\n\n"; print IMPL @cBodyPriv; - print IMPL @conditionGuardEnd; + print IMPL "} // namespace WebKit\n\n"; + print IMPL "#endif // ${conditionalString}\n\n" if $conditionalString; + + print IMPL @cBodyProperties; + print IMPL @cBody; close(IMPL); @@ -1388,6 +1459,7 @@ EOF @cPrefix = (); @cBody = (); @cBodyPriv = (); + @cBodyProperties = (); } sub GenerateInterface { diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm index 99ca0be11..1c2065816 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -248,7 +248,7 @@ sub AddIncludesForType # When we're finished with the one-file-per-class # reorganization, we won't need these special cases. - if ($codeGenerator->IsPrimitiveType($type) or $codeGenerator->AvoidInclusionOfType($type) + if ($codeGenerator->IsPrimitiveType($type) or $codeGenerator->SkipIncludeHeader($type) or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array" or $type eq "DOMTimeStamp") { } elsif ($type =~ /SVGPathSeg/) { my $joinedName = $type; @@ -266,6 +266,7 @@ sub AddIncludesForType $includesRef->{"JS${type}.h"} = 1; } elsif (IsTypedArrayType($type)) { $includesRef->{"<wtf/${type}.h>"} = 1; + } elsif ($codeGenerator->GetArrayType($type)) { } else { # default, include the same named file $includesRef->{"${type}.h"} = 1; @@ -381,17 +382,6 @@ sub prototypeHashTableAccessor } } -sub GenerateConditionalString -{ - my $node = shift; - my $conditional = $node->extendedAttributes->{"Conditional"}; - if ($conditional) { - return $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - } else { - return ""; - } -} - sub GenerateGetOwnPropertySlotBody { my ($dataNode, $interfaceName, $className, $implClassName, $hasAttributes, $inlined) = @_; @@ -402,7 +392,7 @@ sub GenerateGetOwnPropertySlotBody if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { push(@getOwnPropertySlotImpl, " ${namespaceMaybe}JSValue proto = thisObject->prototype();\n"); - push(@getOwnPropertySlotImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); + push(@getOwnPropertySlotImpl, " if (proto.isObject() && jsCast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); push(@getOwnPropertySlotImpl, " return false;\n\n"); } @@ -494,7 +484,7 @@ sub GenerateGetOwnPropertyDescriptorBody if ($interfaceName eq "NamedNodeMap" or $interfaceName eq "HTMLCollection" or $interfaceName eq "HTMLAllCollection") { push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}JSValue proto = thisObject->prototype();\n"); - push(@getOwnPropertyDescriptorImpl, " if (proto.isObject() && static_cast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); + push(@getOwnPropertyDescriptorImpl, " if (proto.isObject() && jsCast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n"); push(@getOwnPropertyDescriptorImpl, " return false;\n\n"); } @@ -588,7 +578,7 @@ sub GenerateHeaderContentHeader push(@headerContentHeader, "\n#ifndef $className" . "_h"); push(@headerContentHeader, "\n#define $className" . "_h\n\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; return @headerContentHeader; } @@ -601,7 +591,7 @@ sub GenerateImplementationContentHeader my @implContentHeader = split("\r", $headerTemplate); push(@implContentHeader, "\n#include \"config.h\"\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; push(@implContentHeader, "#include \"$className.h\"\n\n"); return @implContentHeader; @@ -844,7 +834,7 @@ sub GenerateHeader $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}); $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCustomSetter"}); if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; push(@headerContent, " JSC::WriteBarrier<JSC::Unknown> m_" . $attribute->signature->name . ";\n"); $numCachedAttributes++; @@ -864,7 +854,7 @@ sub GenerateHeader push(@headerContent, "\n // Custom attributes\n"); foreach my $attribute (@{$dataNode->attributes}) { - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCustomGetter"}) { push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; my $methodName = $codeGenerator->WK_lcfirst($attribute->signature->name); @@ -888,7 +878,7 @@ sub GenerateHeader foreach my $function (@{$dataNode->functions}) { next unless $function->signature->extendedAttributes->{"Custom"} or $function->signature->extendedAttributes->{"JSCustom"}; next if $function->{overloads} && $function->{overloadIndex} != 1; - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementedAs"} || $codeGenerator->WK_lcfirst($function->signature->name); push(@headerContent, " " . ($function->isStatic ? "static " : "") . "JSC::JSValue " . $functionImplementationName . "(JSC::ExecState*);\n"); @@ -1078,7 +1068,7 @@ sub GenerateHeader push(@headerContent,"// Functions\n\n"); foreach my $function (@{$dataNode->functions}) { next if $function->{overloadIndex} && $function->{overloadIndex} > 1; - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; my $functionName = GetFunctionName($className, $function); push(@headerContent, "JSC::EncodedJSValue JSC_HOST_CALL ${functionName}(JSC::ExecState*);\n"); @@ -1089,7 +1079,7 @@ sub GenerateHeader if ($numAttributes > 0 || !$dataNode->extendedAttributes->{"OmitConstructor"}) { push(@headerContent,"// Attributes\n\n"); foreach my $attribute (@{$dataNode->attributes}) { - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);\n"); @@ -1114,7 +1104,7 @@ sub GenerateHeader if ($numConstants > 0) { push(@headerContent,"// Constants\n\n"); foreach my $constant (@{$dataNode->constants}) { - my $conditionalString = GenerateConditionalString($constant); + my $conditionalString = $codeGenerator->GenerateConditionalString($constant); push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); push(@headerContent, "JSC::JSValue ${getter}(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);\n"); @@ -1122,7 +1112,7 @@ sub GenerateHeader } } - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@headerContent, "\n} // namespace WebCore\n\n"); push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; push(@headerContent, "#endif\n"); @@ -1230,7 +1220,7 @@ sub GenerateParametersCheckExpression $usedArguments{$parameterIndex} = 1; } elsif ($parameter->extendedAttributes->{"Callback"}) { # For Callbacks only checks if the value is null or object. - push(@andExpression, "(${value}.isNull() || ${value}.isObject())"); + push(@andExpression, "(${value}.isNull() || ${value}.isFunction())"); $usedArguments{$parameterIndex} = 1; } elsif (IsArrayType($type)) { # FIXME: Add proper support for T[], T[]?, sequence<T> @@ -1681,12 +1671,12 @@ sub GenerateImplementation my $getFunctionName = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); my $implGetterFunctionName = $codeGenerator->WK_lcfirst($name); - my $attributeConditionalString = GenerateConditionalString($attribute->signature); + my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, const Identifier&)\n"); push(@implContent, "{\n"); - push(@implContent, " ${className}* castedThis = static_cast<$className*>(asObject(slotBase));\n"); + push(@implContent, " ${className}* castedThis = jsCast<$className*>(asObject(slotBase));\n"); if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) { $needsMarkChildren = 1; @@ -1704,7 +1694,7 @@ sub GenerateImplementation } elsif ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { $implIncludes{"JSDOMBinding.h"} = 1; push(@implContent, " $implClassName* impl = static_cast<$implClassName*>(castedThis->impl());\n"); - push(@implContent, " return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n"); + push(@implContent, " return shouldAllowAccessToNode(exec, impl->" . $attribute->signature->name . "()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, "impl->$implGetterFunctionName()", "castedThis") . " : jsNull();\n"); } elsif ($type eq "EventListener") { $implIncludes{"EventListener.h"} = 1; push(@implContent, " UNUSED_PARAM(exec);\n"); @@ -1805,7 +1795,7 @@ sub GenerateImplementation push(@implContent, "JSValue ${constructorFunctionName}(ExecState* exec, JSValue slotBase, const Identifier&)\n"); push(@implContent, "{\n"); - push(@implContent, " ${className}* domObject = static_cast<$className*>(asObject(slotBase));\n"); + push(@implContent, " ${className}* domObject = jsCast<$className*>(asObject(slotBase));\n"); if ($dataNode->extendedAttributes->{"CheckSecurity"}) { push(@implContent, " if (!domObject->allowsAccessFrom(exec))\n"); @@ -1872,7 +1862,7 @@ sub GenerateImplementation my $putFunctionName = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name); - my $attributeConditionalString = GenerateConditionalString($attribute->signature); + my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, "void ${putFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n"); @@ -1880,19 +1870,19 @@ sub GenerateImplementation if ($dataNode->extendedAttributes->{"CheckSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"}) { if ($interfaceName eq "DOMWindow") { - push(@implContent, " if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n"); + push(@implContent, " if (!jsCast<$className*>(thisObject)->allowsAccessFrom(exec))\n"); } else { - push(@implContent, " if (!shouldAllowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n"); + push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n"); } push(@implContent, " return;\n"); } if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCustomSetter"}) { - push(@implContent, " static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n"); + push(@implContent, " jsCast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n"); } elsif ($type eq "EventListener") { $implIncludes{"JSEventListener.h"} = 1; push(@implContent, " UNUSED_PARAM(exec);\n"); - push(@implContent, " ${className}* castedThis = static_cast<${className}*>(thisObject);\n"); + push(@implContent, " ${className}* castedThis = jsCast<${className}*>(thisObject);\n"); my $windowEventListener = $attribute->signature->extendedAttributes->{"JSWindowEventListener"}; if ($windowEventListener) { push(@implContent, " JSDOMGlobalObject* globalObject = castedThis->globalObject();\n"); @@ -1916,15 +1906,15 @@ sub GenerateImplementation push(@implContent, " // Shadowing a built-in constructor\n"); if ($interfaceName eq "DOMWindow" && $className eq "JSblah") { # FIXME: This branch never executes and should be removed. - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); + push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); } else { - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); + push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); } } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) { push(@implContent, " // Shadowing a built-in object\n"); - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); + push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); } else { - push(@implContent, " $className* castedThis = static_cast<$className*>(thisObject);\n"); + push(@implContent, " $className* castedThis = jsCast<$className*>(thisObject);\n"); push(@implContent, " $implType* impl = static_cast<$implType*>(castedThis->impl());\n"); push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; @@ -2005,9 +1995,9 @@ sub GenerateImplementation push(@implContent, "{\n"); if ($dataNode->extendedAttributes->{"CheckSecurity"}) { if ($interfaceName eq "DOMWindow") { - push(@implContent, " if (!static_cast<$className*>(thisObject)->allowsAccessFrom(exec))\n"); + push(@implContent, " if (!jsCast<$className*>(thisObject)->allowsAccessFrom(exec))\n"); } else { - push(@implContent, " if (!shouldAllowAccessToFrame(exec, static_cast<$className*>(thisObject)->impl()->frame()))\n"); + push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n"); } push(@implContent, " return;\n"); } @@ -2015,7 +2005,7 @@ sub GenerateImplementation push(@implContent, " // Shadowing a built-in constructor\n"); if ($interfaceName eq "DOMWindow") { - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); + push(@implContent, " jsCast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); } else { die "No way to handle interface with ReplaceableConstructor extended attribute: $interfaceName"; } @@ -2039,7 +2029,7 @@ sub GenerateImplementation if (!$dataNode->extendedAttributes->{"OmitConstructor"}) { push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n"); - push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));\n"); + push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));\n"); push(@implContent, "}\n\n"); } @@ -2105,7 +2095,7 @@ sub GenerateImplementation push(@implContent, " JSValue thisValue = exec->hostThisValue();\n"); push(@implContent, " if (!thisValue.inherits(&${className}::s_info))\n"); push(@implContent, " return throwVMTypeError(exec);\n"); - push(@implContent, " $className* castedThis = static_cast<$className*>(asObject(thisValue));\n"); + push(@implContent, " $className* castedThis = jsCast<$className*>(asObject(thisValue));\n"); } push(@implContent, " ASSERT_GC_OBJECT_INHERITS(castedThis, &${className}::s_info);\n"); @@ -2137,7 +2127,7 @@ sub GenerateImplementation if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { push(@implContent, " if (!shouldAllowAccessToNode(exec, impl->" . $function->signature->name . "(" . (@{$function->raisesExceptions} ? "ec" : "") .")))\n"); - push(@implContent, " return JSValue::encode(jsUndefined());\n"); + push(@implContent, " return JSValue::encode(jsNull());\n"); $implIncludes{"JSDOMBinding.h"} = 1; } @@ -2223,7 +2213,7 @@ sub GenerateImplementation if ($dataNode->extendedAttributes->{"IndexedGetter"}) { push(@implContent, "\nJSValue ${className}::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)\n"); push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObj = static_cast<$className*>(asObject(slotBase));\n"); + push(@implContent, " ${className}* thisObj = jsCast<$className*>(asObject(slotBase));\n"); push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);\n"); if (IndexGetterReturnsStrings($implClassName)) { $implIncludes{"KURL.h"} = 1; @@ -2262,7 +2252,7 @@ sub GenerateImplementation push(@implContent, "}\n\n"); push(@implContent, "JSValue ${className}::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)\n"); push(@implContent, "{\n"); - push(@implContent, " ${className}* thisObj = static_cast<$className*>(asObject(slotBase));\n"); + push(@implContent, " ${className}* thisObj = jsCast<$className*>(asObject(slotBase));\n"); push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->namedItem(identifierToAtomicString(propertyName)));\n"); push(@implContent, "}\n\n"); } @@ -2282,7 +2272,7 @@ sub GenerateImplementation push(@implContent, "bool JS${implClassName}Owner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)\n"); push(@implContent, "{\n"); - push(@implContent, " JS${implClassName}* js${implClassName} = static_cast<JS${implClassName}*>(handle.get().asCell());\n"); + push(@implContent, " JS${implClassName}* js${implClassName} = jsCast<JS${implClassName}*>(handle.get().asCell());\n"); # All ActiveDOMObjects implement hasPendingActivity(), but not all of them # increment their C++ reference counts when hasPendingActivity() becomes # true. As a result, ActiveDOMObjects can be prematurely destroyed before @@ -2339,7 +2329,7 @@ sub GenerateImplementation $dataNode->extendedAttributes->{"ActiveDOMObject"})) { push(@implContent, "void JS${implClassName}Owner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)\n"); push(@implContent, "{\n"); - push(@implContent, " JS${implClassName}* js${implClassName} = static_cast<JS${implClassName}*>(handle.get().asCell());\n"); + push(@implContent, " JS${implClassName}* js${implClassName} = jsCast<JS${implClassName}*>(handle.get().asCell());\n"); push(@implContent, " DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);\n"); push(@implContent, " uncacheWrapper(world, js${implClassName}->impl(), js${implClassName});\n"); push(@implContent, " js${implClassName}->releaseImpl();\n"); @@ -2360,13 +2350,13 @@ sub GenerateImplementation if ((!$hasParent or $dataNode->extendedAttributes->{"JSGenerateToNativeObject"}) and !$dataNode->extendedAttributes->{"JSCustomToNativeObject"}) { push(@implContent, "$implType* to${interfaceName}(JSC::JSValue value)\n"); push(@implContent, "{\n"); - push(@implContent, " return value.inherits(&${className}::s_info) ? static_cast<$className*>(asObject(value))->impl() : 0"); + push(@implContent, " return value.inherits(&${className}::s_info) ? jsCast<$className*>(asObject(value))->impl() : 0"); push(@implContent, ";\n}\n"); } push(@implContent, "\n}\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } @@ -2383,7 +2373,7 @@ sub GenerateCallWith push(@callWithArgs, "exec"); } if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) { - push(@$outputArray, " ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n"); + push(@$outputArray, " ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();\n"); push(@$outputArray, " if (!scriptContext)\n"); push(@$outputArray, " return" . ($returnValue ? " " . $returnValue : "") . ";\n"); push(@callWithArgs, "scriptContext"); @@ -2419,7 +2409,7 @@ sub GenerateArgumentsCountCheck if ($numMandatoryParams >= 1) { push(@$outputArray, " if (exec->argumentCount() < $numMandatoryParams)\n"); - push(@$outputArray, " return throwVMError(exec, createTypeError(exec, \"Not enough arguments\"));\n"); + push(@$outputArray, " return throwVMError(exec, createNotEnoughArgumentsError(exec));\n"); } } @@ -2499,14 +2489,14 @@ sub GenerateParametersCheck if ($optional) { push(@$outputArray, " RefPtr<$argType> $name;\n"); push(@$outputArray, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isUndefinedOrNull()) {\n"); - push(@$outputArray, " if (!exec->argument($argsIndex).isObject()) {\n"); + push(@$outputArray, " if (!exec->argument($argsIndex).isFunction()) {\n"); push(@$outputArray, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); push(@$outputArray, " }\n"); push(@$outputArray, " $name = ${callbackClassName}::create(asObject(exec->argument($argsIndex)), castedThis->globalObject());\n"); push(@$outputArray, " }\n"); } else { - push(@$outputArray, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isObject()) {\n"); + push(@$outputArray, " if (exec->argumentCount() <= $argsIndex || !exec->argument($argsIndex).isFunction()) {\n"); push(@$outputArray, " setDOMException(exec, TYPE_MISMATCH_ERR);\n"); push(@$outputArray, " return JSValue::encode(jsUndefined());\n"); push(@$outputArray, " }\n"); @@ -2635,7 +2625,7 @@ sub GenerateCallbackHeader push(@headerContent, "};\n\n"); push(@headerContent, "} // namespace WebCore\n\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; push(@headerContent, "#endif\n"); } @@ -2695,14 +2685,24 @@ sub GenerateCallbackImplementation push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "("); my @args = (); + my @argsCheck = (); + my $thisType = $function->signature->extendedAttributes->{"PassThisToCallback"}; foreach my $param (@params) { + my $paramName = $param->name; AddIncludesForTypeInImpl($param->type, 1); - push(@args, GetNativeType($param->type) . " " . $param->name); + push(@args, GetNativeType($param->type) . " " . $paramName); + if ($thisType and $thisType eq $param->type) { + push(@argsCheck, <<END); + ASSERT(${paramName}); + +END + } } push(@implContent, join(", ", @args)); push(@implContent, ")\n"); push(@implContent, "{\n"); + push(@implContent, @argsCheck) if @argsCheck; push(@implContent, " if (!canInvokeCallback())\n"); push(@implContent, " return true;\n\n"); push(@implContent, " RefPtr<$className> protect(this);\n\n"); @@ -2714,20 +2714,35 @@ sub GenerateCallbackImplementation my $paramName = $param->name; if ($param->type eq "DOMString") { push(@implContent, " args.append(jsString(exec, ${paramName}));\n"); + } elsif ($param->type eq "boolean") { + push(@implContent, " args.append(jsBoolean(${paramName}));\n"); } else { push(@implContent, " args.append(toJS(exec, m_data->globalObject(), ${paramName}));\n"); } } push(@implContent, "\n bool raisedException = false;\n"); - push(@implContent, " m_data->invokeCallback(args, &raisedException);\n"); + if ($thisType) { + foreach my $param (@params) { + next if $param->type ne $thisType; + my $paramName = $param->name; + push(@implContent, <<END); + JSValue js${paramName} = toJS(exec, m_data->globalObject(), ${paramName}); + m_data->invokeCallback(js${paramName}, args, &raisedException); + +END + last; + } + } else { + push(@implContent, " m_data->invokeCallback(args, &raisedException);\n"); + } push(@implContent, " return !raisedException;\n"); push(@implContent, "}\n"); } } push(@implContent, "\n}\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } @@ -2754,7 +2769,8 @@ sub GenerateImplementationFunctionCall() push(@implContent, $indent . "return JSValue::encode(jsUndefined());\n"); } else { - push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, $functionString, "castedThis") . ";\n"); + my $thisObject = $function->isStatic ? 0 : "castedThis"; + push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, $functionString, $thisObject) . ";\n"); push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; if ($codeGenerator->ExtendedAttributeContains($function->signature->extendedAttributes->{"CallWith"}, "ScriptState")) { @@ -2787,7 +2803,8 @@ my %nativeType = ( "DOMObject" => "ScriptValue", "NodeFilter" => "RefPtr<NodeFilter>", "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", - "IDBKey" => "RefPtr<IDBKey>", + "IDBKey" => "PassRefPtr<IDBKey>", + "Dictionary" => "Dictionary", "boolean" => "bool", "double" => "double", "float" => "float", @@ -2923,6 +2940,11 @@ sub JSValueToNative return "createIDBKeyFromValue(exec, $value)"; } + if ($type eq "Dictionary") { + AddToImplIncludes("Dictionary.h", $conditional); + return "exec, $value"; + } + if ($type eq "DOMString[]") { AddToImplIncludes("JSDOMStringList.h", $conditional); return "toDOMStringList($value)"; @@ -2937,6 +2959,11 @@ sub JSValueToNative AddToImplIncludes("JSCustomVoidCallback.h", $conditional) if $type eq "VoidCallback"; AddToImplIncludes("Event.h", $conditional) if $type eq "Event"; + my $arrayType = $codeGenerator->GetArrayType($type); + if ($arrayType) { + return "toNativeArray<$arrayType>(exec, $value)"; + } + # Default, assume autogenerated type conversion routines AddToImplIncludes("JS$type.h", $conditional); return "to$type($value)"; @@ -2983,7 +3010,10 @@ sub NativeToJSValue return "jsString(exec, $value)"; } - my $globalObject = "$thisValue->globalObject()"; + my $globalObject; + if ($thisValue) { + $globalObject = "$thisValue->globalObject()"; + } if ($type eq "CSSStyleDeclaration") { AddToImplIncludes("StylePropertySet.h", $conditional); @@ -2993,6 +3023,16 @@ sub NativeToJSValue AddToImplIncludes("NameNodeList.h", $conditional); } + my $arrayType = $codeGenerator->GetArrayType($type); + if ($arrayType) { + if (!$codeGenerator->SkipIncludeHeader($arrayType)) { + AddToImplIncludes("JS$arrayType.h", $conditional); + AddToImplIncludes("$arrayType.h", $conditional); + } + AddToImplIncludes("<runtime/JSArray.h>", $conditional); + return "jsArray(exec, $thisValue->globalObject(), $value)"; + } + if ($type eq "DOMObject") { if ($implClassName eq "Document") { AddToImplIncludes("JSCanvasRenderingContext2D.h", $conditional); @@ -3013,9 +3053,9 @@ sub NativeToJSValue # Default, include header with same name. AddToImplIncludes("JS$type.h", $conditional); if (IsTypedArrayType($type)) { - AddToImplIncludes("<wtf/$type.h>", $conditional) if not $codeGenerator->AvoidInclusionOfType($type); + AddToImplIncludes("<wtf/$type.h>", $conditional) if not $codeGenerator->SkipIncludeHeader($type); } else { - AddToImplIncludes("$type.h", $conditional) if not $codeGenerator->AvoidInclusionOfType($type); + AddToImplIncludes("$type.h", $conditional) if not $codeGenerator->SkipIncludeHeader($type); } } @@ -3060,8 +3100,11 @@ sub NativeToJSValue $value = "${tearOffType}::create($value)"; } } - - return "toJS(exec, $globalObject, WTF::getPtr($value))"; + if ($globalObject) { + return "toJS(exec, $globalObject, WTF::getPtr($value))"; + } else { + return "toJS(exec, jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()), WTF::getPtr($value))"; + } } sub ceilingToPowerOf2 @@ -3462,12 +3505,12 @@ sub GenerateConstructorDefinition push(@$outputArray, "bool ${constructorClassName}::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n"); push(@$outputArray, "{\n"); - push(@$outputArray, " return getStatic${kind}Slot<${constructorClassName}, JSDOMWrapper>(exec, &${constructorClassName}Table, static_cast<${constructorClassName}*>(cell), propertyName, slot);\n"); + push(@$outputArray, " return getStatic${kind}Slot<${constructorClassName}, JSDOMWrapper>(exec, &${constructorClassName}Table, jsCast<${constructorClassName}*>(cell), propertyName, slot);\n"); push(@$outputArray, "}\n\n"); push(@$outputArray, "bool ${constructorClassName}::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)\n"); push(@$outputArray, "{\n"); - push(@$outputArray, " return getStatic${kind}Descriptor<${constructorClassName}, JSDOMWrapper>(exec, &${constructorClassName}Table, static_cast<${constructorClassName}*>(object), propertyName, descriptor);\n"); + push(@$outputArray, " return getStatic${kind}Descriptor<${constructorClassName}, JSDOMWrapper>(exec, &${constructorClassName}Table, jsCast<${constructorClassName}*>(object), propertyName, descriptor);\n"); push(@$outputArray, "}\n\n"); } @@ -3479,7 +3522,7 @@ sub GenerateConstructorDefinition push(@$outputArray, <<END); EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec) { - ${constructorClassName}* jsConstructor = static_cast<${constructorClassName}*>(exec->callee()); + ${constructorClassName}* jsConstructor = jsCast<${constructorClassName}*>(exec->callee()); ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext(); if (!executionContext) @@ -3540,7 +3583,7 @@ END push(@$outputArray, "EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct${className}(ExecState* exec)\n"); push(@$outputArray, "{\n"); - push(@$outputArray, " ${constructorClassName}* jsConstructor = static_cast<${constructorClassName}*>(exec->callee());\n"); + push(@$outputArray, " ${constructorClassName}* castedThis = jsCast<${constructorClassName}*>(exec->callee());\n"); my $function = $dataNode->constructor; my @constructorArgList; @@ -3554,20 +3597,20 @@ END push(@$outputArray, " ExceptionCode ec = 0;\n"); } - # For now, we do not support SVG constructors. - # We do not also support a constructor [Optional] argument without CallWithDefaultValue - # nor CallWithNullValue. + # FIXME: For now, we do not support SVG constructors. + # FIXME: Currently [Constructor(...)] does not yet support [Optional] arguments. + # It just supports [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString]. my $numParameters = @{$function->parameters}; my ($dummy, $paramIndex) = GenerateParametersCheck($outputArray, $function, $dataNode, $numParameters, $interfaceName, "constructorCallback", undef, undef, undef); if ($codeGenerator->ExtendedAttributeContains($dataNode->extendedAttributes->{"CallWith"}, "ScriptExecutionContext")) { push(@constructorArgList, "context"); - push(@$outputArray, " ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();\n"); + push(@$outputArray, " ScriptExecutionContext* context = castedThis->scriptExecutionContext();\n"); push(@$outputArray, " if (!context)\n"); push(@$outputArray, " return throwVMError(exec, createReferenceError(exec, \"${interfaceName} constructor associated document is unavailable\"));\n"); } if ($generatingNamedConstructor) { - push(@constructorArgList, "jsConstructor->document()"); + push(@constructorArgList, "castedThis->document()"); } my $index = 0; @@ -3594,7 +3637,7 @@ END push(@$outputArray, " }\n"); } - push(@$outputArray, " return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get())));\n"); + push(@$outputArray, " return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));\n"); push(@$outputArray, "}\n\n"); } diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 4543414ed..0a964893e 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -269,23 +269,6 @@ sub ReadPublicInterfaces $interfaceAvailabilityVersion = "WEBKIT_VERSION_LATEST" if $newPublicClass; } -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 ""; - } -} - # Params: 'domClass' struct sub GenerateInterface { @@ -464,6 +447,34 @@ sub IsNativeObjCType return 0; } +sub SkipFunction +{ + my $function = shift; + + return 1 if $codeGenerator->GetArrayType($function->signature->type); + + foreach my $param (@{$function->parameters}) { + return 1 if $codeGenerator->GetArrayType($param->type); + } + + return 0; +} + +sub SkipAttribute +{ + my $attribute = shift; + + return 1 if $codeGenerator->GetArrayType($attribute->signature->type); + + # This is for DynamicsCompressorNode.idl + if ($attribute->signature->name eq "release") { + return 1; + } + + return 0; +} + + sub GetObjCType { my $type = shift; @@ -528,7 +539,8 @@ sub AddForwardDeclarationsForType my $type = $codeGenerator->StripModule(shift); my $public = shift; - return if $codeGenerator->IsNonPointerType($type) ; + return if $codeGenerator->IsNonPointerType($type); + return if $codeGenerator->GetArrayType($type); my $class = GetClassName($type); @@ -550,6 +562,7 @@ sub AddIncludesForType my $type = $codeGenerator->StripModule(shift); return if $codeGenerator->IsNonPointerType($type); + return if $codeGenerator->GetArrayType($type); if (IsNativeObjCType($type)) { if ($type eq "Color") { @@ -621,7 +634,7 @@ sub AddIncludesForType $implIncludes{"NameNodeList.h"} = 1 if $type eq "NodeList"; # Default, include the same named file (the implementation) and the same name prefixed with "DOM". - $implIncludes{"$type.h"} = 1 if not $codeGenerator->AvoidInclusionOfType($type); + $implIncludes{"$type.h"} = 1 if not $codeGenerator->SkipIncludeHeader($type); $implIncludes{"DOM${type}Internal.h"} = 1; } @@ -771,6 +784,7 @@ sub GenerateHeader # - Add attribute getters/setters. if ($numAttributes > 0) { foreach my $attribute (@{$dataNode->attributes}) { + next if SkipAttribute($attribute); my $attributeName = $attribute->signature->name; if ($attributeName eq "id" or $attributeName eq "hash" or $attributeName eq "description") { @@ -825,7 +839,7 @@ sub GenerateHeader push(@headerAttributes, $property) if $public; push(@privateHeaderAttributes, $property) unless $public; } else { - my $attributeConditionalString = GenerateConditionalString($attribute->signature); + my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); if ($attributeConditionalString) { push(@headerAttributes, "#if ${attributeConditionalString}\n") if $public; push(@privateHeaderAttributes, "#if ${attributeConditionalString}\n") unless $public; @@ -860,6 +874,7 @@ sub GenerateHeader # - Add functions. if ($numFunctions > 0) { foreach my $function (@{$dataNode->functions}) { + next if SkipFunction($function); my $functionName = $function->signature->name; my $returnType = GetObjCType($function->signature->type); @@ -920,7 +935,7 @@ sub GenerateHeader AddForwardDeclarationsForType($type, $public) unless $public and $needsDeprecatedVersion; } - my $functionConditionalString = GenerateConditionalString($function->signature); + my $functionConditionalString = $codeGenerator->GenerateConditionalString($function->signature); if ($functionConditionalString) { push(@headerFunctions, "#if ${functionConditionalString}\n") if $public; push(@privateHeaderFunctions, "#if ${functionConditionalString}\n") unless $public; @@ -1093,7 +1108,7 @@ sub GenerateImplementation # - INCLUDES - push(@implContentHeader, "\n#import \"config.h\"\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; push(@implContentHeader, "#import \"DOMInternal.h\"\n\n"); @@ -1118,7 +1133,7 @@ sub GenerateImplementation if ($interfaceName =~ /(\w+)(Abs|Rel)$/) { $implIncludes{"$1.h"} = 1; } else { - if (!$codeGenerator->AvoidInclusionOfType($implClassName)) { + if (!$codeGenerator->SkipIncludeHeader($implClassName)) { $implIncludes{"$implClassName.h"} = 1 ; } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($implClassName)) { my $includeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); @@ -1182,6 +1197,7 @@ sub GenerateImplementation # - Attributes if ($numAttributes > 0) { foreach my $attribute (@{$dataNode->attributes}) { + next if SkipAttribute($attribute); AddIncludesForType($attribute->signature->type); my $idlType = $codeGenerator->StripModule($attribute->signature->type); @@ -1329,7 +1345,7 @@ sub GenerateImplementation my $type = $attribute->signature->type; if ($codeGenerator->IsSVGTypeNeedingTearOff($type) and not $implClassName =~ /List$/) { my $idlTypeWithNamespace = GetSVGTypeWithNamespace($type); - $implIncludes{"$type.h"} = 1 if not $codeGenerator->AvoidInclusionOfType($type); + $implIncludes{"$type.h"} = 1 if not $codeGenerator->SkipIncludeHeader($type); if ($codeGenerator->IsSVGTypeWithWritablePropertiesNeedingTearOff($type) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { $idlTypeWithNamespace =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassNameWithNamespace, /; $implIncludes{"SVGStaticPropertyTearOff.h"} = 1; @@ -1363,7 +1379,7 @@ sub GenerateImplementation $getterContent = $getterContentHead . $getterContentTail; } - my $attributeConditionalString = GenerateConditionalString($attribute->signature); + my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, $getterSig); push(@implContent, "{\n"); @@ -1478,6 +1494,7 @@ sub GenerateImplementation # - Functions if ($numFunctions > 0) { foreach my $function (@{$dataNode->functions}) { + next if SkipFunction($function); AddIncludesForType($function->signature->type); my $functionName = $function->signature->name; @@ -1692,7 +1709,7 @@ sub GenerateImplementation } } - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; push(@implContent, "$functionSig\n"); diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm index a5dabdfd5..3bd3291fa 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -144,7 +144,7 @@ sub AddIncludesForType if (IsTypedArrayType($type)) { AddToImplIncludes("wtf/${type}.h"); } - if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringType($type) and !$codeGenerator->AvoidInclusionOfType($type) and $type ne "Date") { + if (!$codeGenerator->IsPrimitiveType($type) and !$codeGenerator->IsStringType($type) and !$codeGenerator->SkipIncludeHeader($type) and $type ne "Date") { # default, include the same named file AddToImplIncludes(GetV8HeaderName(${type})); @@ -181,17 +181,6 @@ sub AddIncludesForType } } -sub GenerateConditionalString -{ - my $node = shift; - my $conditional = $node->extendedAttributes->{"Conditional"}; - if ($conditional) { - return $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional); - } else { - return ""; - } -} - sub GetSVGPropertyTypes { my $implType = shift; @@ -289,7 +278,7 @@ sub GenerateHeader push(@headerContent, "\n"); push(@headerContent, "class FloatRect;\n") if $svgPropertyType && $svgPropertyType eq "FloatRect"; - push(@headerContent, "class OptionsObject;\n") if IsConstructorTemplate($dataNode, "Event"); + push(@headerContent, "class Dictionary;\n") if IsConstructorTemplate($dataNode, "Event"); my $nativeType = GetNativeTypeForConversions($dataNode, $interfaceName); if ($dataNode->extendedAttributes->{"NamedConstructor"}) { @@ -325,7 +314,6 @@ END push(@headerContent, "false;\n"); } - my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName); my $forceNewObjectParameter = IsDOMNodeType($interfaceName) ? ", bool forceNewObject = false" : ""; my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : ""; my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : ""; @@ -338,7 +326,7 @@ END { return reinterpret_cast<${nativeType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(${nativeType}*${forceNewObjectParameter}); + inline static v8::Handle<v8::Object> wrap(${nativeType}*, v8::Isolate* = 0${forceNewObjectParameter}); static void derefObject(void*); static WrapperTypeInfo info; END @@ -355,7 +343,7 @@ END if ($implClassName eq "HTMLDocument") { push(@headerContent, <<END); static v8::Local<v8::Object> WrapInShadowObject(v8::Local<v8::Object> wrapper, Node* impl); - static v8::Handle<v8::Value> GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key); + static v8::Handle<v8::Value> GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key, v8::Isolate*); END } @@ -365,7 +353,7 @@ END my $attrExt = $function->signature->extendedAttributes; if (($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) && !$attrExt->{"ImplementedBy"} && $function->{overloadIndex} == 1) { - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@headerContent, "#if ${conditionalString}\n") if $conditionalString; push(@headerContent, <<END); static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments&); @@ -387,7 +375,7 @@ END foreach my $attribute (@{$dataNode->attributes}) { my $name = $attribute->signature->name; my $attrExt = $attribute->signature->extendedAttributes; - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); if (($attrExt->{"V8CustomGetter"} || $attrExt->{"CustomGetter"} || $attrExt->{"V8Custom"} || $attrExt->{"Custom"}) && !$attrExt->{"ImplementedBy"}) { @@ -422,36 +410,29 @@ END END } + my $wrapSlowArgumentType = GetPassRefPtrType($nativeType); push(@headerContent, <<END); - static v8::Handle<v8::Object> existingWrapper(${nativeType}*); - private: - static v8::Handle<v8::Object> wrapSlow(${nativeType}*); + static v8::Handle<v8::Object> wrapSlow(${wrapSlowArgumentType}, v8::Isolate*); }; END push(@headerContent, <<END); -ALWAYS_INLINE v8::Handle<v8::Object> ${className}::existingWrapper(${nativeType}* impl) -{ -END - my $getWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getExistingWrapper(impl)" : "${domMapFunction}.get(impl)"; - push(@headerContent, <<END); - return ${getWrapper}; -} - -v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) +v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl, v8::Isolate* isolate${forceNewObjectInput}) { END push(@headerContent, " if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName); + my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName, "isolate"); + my $getCachedWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getCachedWrapper(impl)" : "${domMapFunction}.get(impl)"; push(@headerContent, <<END); - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = $getCachedWrapper; if (!wrapper.IsEmpty()) return wrapper; END push(@headerContent, " }\n") if IsDOMNodeType($interfaceName); push(@headerContent, <<END); - return ${className}::wrapSlow(impl); + return ${className}::wrapSlow(impl, isolate); } END @@ -460,51 +441,52 @@ END } elsif (!($dataNode->extendedAttributes->{"CustomToJSObject"} or $dataNode->extendedAttributes->{"V8CustomToJSObject"})) { push(@headerContent, <<END); -inline v8::Handle<v8::Value> toV8(${nativeType}* impl${forceNewObjectParameter}) +inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Isolate* isolate = 0${forceNewObjectParameter}) { if (!impl) return v8::Null(); - return ${className}::wrap(impl${forceNewObjectCall}); + return ${className}::wrap(impl, isolate${forceNewObjectCall}); } END } elsif ($interfaceName ne 'Node') { push(@headerContent, <<END); -v8::Handle<v8::Value> toV8(${nativeType}*${forceNewObjectParameter}); +v8::Handle<v8::Value> toV8(${nativeType}*, v8::Isolate* = 0${forceNewObjectParameter}); END } else { push(@headerContent, <<END); -v8::Handle<v8::Value> toV8Slow(Node*, bool); +v8::Handle<v8::Value> toV8Slow(Node*, v8::Isolate*, bool); -inline v8::Handle<v8::Value> toV8(Node* impl, bool forceNewObject = false) +inline v8::Handle<v8::Value> toV8(Node* impl, v8::Isolate* isolate = 0, bool forceNewObject = false) { if (UNLIKELY(!impl)) return v8::Null(); if (UNLIKELY(forceNewObject)) - return toV8Slow(impl, forceNewObject); - return V8DOMWrapper::getWrapper(impl); + return toV8Slow(impl, isolate, forceNewObject); + v8::Handle<v8::Value> wrapper = V8DOMWrapper::getCachedWrapper(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return toV8Slow(impl, isolate, false); } END } - if (IsRefPtrType($implClassName)) { - push(@headerContent, <<END); -inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl${forceNewObjectParameter}) + push(@headerContent, <<END); +inline v8::Handle<v8::Value> toV8(PassRefPtr< ${nativeType} > impl, v8::Isolate* isolate = 0${forceNewObjectParameter}) { - return toV8(impl.get()${forceNewObjectCall}); + return toV8(impl.get(), isolate${forceNewObjectCall}); } END - } if (IsConstructorTemplate($dataNode, "Event")) { - push(@headerContent, "\nbool fill${implClassName}Init(${implClassName}Init&, const OptionsObject&);\n"); + push(@headerContent, "\nbool fill${implClassName}Init(${implClassName}Init&, const Dictionary&);\n"); } push(@headerContent, "\n}\n\n"); push(@headerContent, "#endif // $className" . "_h\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; } @@ -539,7 +521,7 @@ sub GetHeaderClassInclude $className =~ s/Abs|Rel//; } return "wtf/${className}.h" if IsTypedArrayType($className); - return "" if ($codeGenerator->AvoidInclusionOfType($className)); + return "" if ($codeGenerator->SkipIncludeHeader($className)); return "${className}.h"; } @@ -654,10 +636,11 @@ sub GenerateHeaderCustomCall sub GenerateSetDOMException { my $indent = shift; + my $getIsolate = shift; my $result = ""; $result .= $indent . "if (UNLIKELY(ec)) {\n"; - $result .= $indent . " V8Proxy::setDOMException(ec);\n"; + $result .= $indent . " V8Proxy::setDOMException(ec, $getIsolate);\n"; $result .= $indent . " return v8::Handle<v8::Value>();\n"; $result .= $indent . "}\n"; @@ -759,11 +742,11 @@ END // Get the proxy corresponding to the DOMWindow if possible to // make sure that the constructor function is constructed in the // context of the DOMWindow and not in the context of the caller. - return V8DOMWrapper::getConstructor(type, V8DOMWindow::toNative(info.Holder())); + return V8DOMWrapper::constructorForType(type, V8DOMWindow::toNative(info.Holder())); END } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { push(@implContentDecls, <<END); - return V8DOMWrapper::getConstructor(type, V8WorkerContext::toNative(info.Holder())); + return V8DOMWrapper::constructorForType(type, V8WorkerContext::toNative(info.Holder())); END } else { push(@implContentDecls, " return v8::Handle<v8::Value>();"); @@ -791,7 +774,7 @@ sub GenerateNormalAttrGetter my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($implClassName); # Getter - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; push(@implContentDecls, <<END); @@ -862,7 +845,7 @@ END # Generate security checks if necessary if ($attribute->signature->extendedAttributes->{"CheckSecurityForNode"}) { - push(@implContentDecls, " if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->" . $attribute->signature->name . "()))\n return v8::Handle<v8::Value>();\n\n"); + push(@implContentDecls, " if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->" . $attribute->signature->name . "()))\n return v8::Handle<v8::Value>(v8::Null());\n\n"); } my $useExceptions = 1 if @{$attribute->getterExceptions}; @@ -907,7 +890,7 @@ END } else { push(@implContentDecls, " $nativeType v = $getterString;\n"); } - push(@implContentDecls, GenerateSetDOMException(" ")); + push(@implContentDecls, GenerateSetDOMException(" ", "info.GetIsolate()")); if ($codeGenerator->ExtendedAttributeContains($attribute->signature->extendedAttributes->{"CallWith"}, "ScriptState")) { push(@implContentDecls, " if (state.hadException())\n"); @@ -928,14 +911,28 @@ END # the newly created wrapper into an internal field of the holder object. if (!IsNodeSubType($dataNode) && $attrName ne "self" && (IsWrapperType($returnType) && ($attribute->type =~ /^readonly/ || $attribute->signature->extendedAttributes->{"Replaceable"}) && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow" + && $returnType ne "MessagePortArray" && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType))) { + + my $arrayType = $codeGenerator->GetArrayType($returnType); + if ($arrayType) { + if (!$codeGenerator->SkipIncludeHeader($arrayType)) { + AddToImplIncludes("V8$arrayType.h"); + AddToImplIncludes("$arrayType.h"); + } + push(@implContentDecls, " return v8Array(${getterString}, info.GetIsolate());\n"); + push(@implContentDecls, "}\n\n"); + return; + } + AddIncludesForType($returnType); # Check for a wrapper in the wrapper cache. If there is one, we know that a hidden reference has already # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. push(@implContentDecls, " RefPtr<$returnType> result = ${getterString};\n"); - push(@implContentDecls, " v8::Handle<v8::Value> wrapper = result.get() ? V8${returnType}::existingWrapper(result.get()) : v8::Handle<v8::Object>();\n"); + my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName, "info.GetIsolate()"); + push(@implContentDecls, " v8::Handle<v8::Value> wrapper = result.get() ? ${domMapFunction}.get(result.get()) : v8::Handle<v8::Object>();\n"); push(@implContentDecls, " if (wrapper.IsEmpty()) {\n"); - push(@implContentDecls, " wrapper = toV8(result.get());\n"); + push(@implContentDecls, " wrapper = toV8(result.get(), info.GetIsolate());\n"); push(@implContentDecls, " if (!wrapper.IsEmpty())\n"); if ($dataNode->name eq "DOMWindow") { push(@implContentDecls, " V8DOMWrapper::setNamedHiddenWindowReference(imp->frame(), \"${attrName}\", wrapper);\n"); @@ -953,7 +950,7 @@ END AddToImplIncludes("V8$attrType.h"); my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($attrType); # Convert from abstract SVGProperty to real type, so the right toJS() method can be invoked. - push(@implContentDecls, " return toV8(static_cast<$svgNativeType*>($result));\n"); + push(@implContentDecls, " return toV8(static_cast<$svgNativeType*>($result), info.GetIsolate());\n"); } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($attrType) and not $implClassName =~ /List$/) { AddToImplIncludes("V8$attrType.h"); AddToImplIncludes("SVGPropertyTearOff.h"); @@ -976,20 +973,34 @@ END $result =~ s/matrix/svgMatrix/; } - push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(wrapper, $result, $updateMethod)));\n"); + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(wrapper, $result, $updateMethod)), info.GetIsolate());\n"); } else { AddToImplIncludes("SVGStaticPropertyTearOff.h"); $tearOffType =~ s/SVGPropertyTearOff</SVGStaticPropertyTearOff<$implClassName, /; - push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(imp, $result, $updateMethod)));\n"); + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(imp, $result, $updateMethod)), info.GetIsolate());\n"); } } elsif ($tearOffType =~ /SVGStaticListPropertyTearOff/) { - push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(imp, $result)));\n"); + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create(imp, $result)), info.GetIsolate());\n"); } elsif ($tearOffType =~ /SVG(Point|PathSeg)List/) { - push(@implContentDecls, " return toV8(WTF::getPtr($result));\n"); + push(@implContentDecls, " return toV8(WTF::getPtr($result), info.GetIsolate());\n"); } else { - push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create($result)));\n"); + push(@implContentDecls, " return toV8(WTF::getPtr(${tearOffType}::create($result)), info.GetIsolate());\n"); } + } elsif ($attribute->signature->type eq "MessagePortArray") { + AddToImplIncludes("V8Array.h"); + AddToImplIncludes("MessagePort.h"); + my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name); + push(@implContentDecls, <<END); + MessagePortArray* ports = imp->${getterFunc}(); + if (!ports) + return v8::Array::New(0); + MessagePortArray portsCopy(*ports); + v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); + for (size_t i = 0; i < portsCopy.size(); ++i) + portArray->Set(v8::Integer::New(i), toV8(portsCopy[i].get(), info.GetIsolate())); + return portArray; +END } else { if ($attribute->signature->type eq "SerializedScriptValue" && $attrExt->{"CachedAttribute"}) { my $getterFunc = $codeGenerator->WK_lcfirst($attribute->signature->name); @@ -1000,7 +1011,7 @@ END return value; END } else { - push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n"); + push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, "info.GetIsolate()").";\n"); } } @@ -1020,7 +1031,7 @@ sub GenerateNormalAttrSetter my $attrName = $attribute->signature->name; my $attrExt = $attribute->signature->extendedAttributes; - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; push(@implContentDecls, "static void ${attrName}AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)\n{\n"); @@ -1052,7 +1063,7 @@ END AddToImplIncludes("ExceptionCode.h"); push(@implContentDecls, " $svgNativeType* wrapper = V8${implClassName}::toNative(info.Holder());\n"); push(@implContentDecls, " if (wrapper->role() == AnimValRole) {\n"); - push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR);\n"); + push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, info.GetIsolate());\n"); push(@implContentDecls, " return;\n"); push(@implContentDecls, " }\n"); push(@implContentDecls, " $svgWrappedNativeType& impInstance = wrapper->propertyReference();\n"); @@ -1101,17 +1112,21 @@ END push(@implContentDecls, " return;\n"); } } else { - my $value = JSValueToNative($attribute->signature, "value"); + my $value = JSValueToNative($attribute->signature, "value", "info.GetIsolate()"); + my $arrayType = $codeGenerator->GetArrayType($nativeType); + if ($nativeType =~ /^V8Parameter/) { - push(@implContentDecls, " " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $value, "VOID") . "\n"); + push(@implContentDecls, " " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $value, "VOID") . "\n"); + } elsif ($arrayType) { + push(@implContentDecls, " Vector<$arrayType> v = $value;\n"); } else { - push(@implContentDecls, " $nativeType v = $value;\n"); + push(@implContentDecls, " $nativeType v = $value;\n"); } } my $result = "v"; my $returnType = GetTypeFromSignature($attribute->signature); - if (IsRefPtrType($returnType)) { + if (IsRefPtrType($returnType) && !$codeGenerator->GetArrayType($returnType)) { $result = "WTF::getPtr(" . $result . ")"; } @@ -1165,7 +1180,7 @@ END if ($useExceptions) { push(@implContentDecls, " if (UNLIKELY(ec))\n"); - push(@implContentDecls, " V8Proxy::setDOMException(ec);\n"); + push(@implContentDecls, " V8Proxy::setDOMException(ec, info.GetIsolate());\n"); } if ($codeGenerator->ExtendedAttributeContains($attribute->signature->extendedAttributes->{"CallWith"}, "ScriptState")) { @@ -1208,7 +1223,7 @@ sub GetFunctionTemplateCallbackName } return "V8${interfaceName}::${name}Callback"; } else { - return "${interfaceName}Internal::${name}Callback"; + return "${interfaceName}V8Internal::${name}Callback"; } } @@ -1273,7 +1288,7 @@ sub GenerateParametersCheckExpression push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())"); } elsif ($parameter->extendedAttributes->{"Callback"}) { # For Callbacks only checks if the value is null or object. - push(@andExpression, "(${value}->IsNull() || ${value}->IsObject())"); + push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())"); } elsif (IsArrayType($type)) { # FIXME: Add proper support for T[], T[]?, sequence<T>. push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())"); @@ -1317,7 +1332,7 @@ sub GenerateOverloadedFunctionCallback # declaration in the IDL. my $name = $function->signature->name; - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; push(@implContentDecls, <<END); static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments& args) @@ -1363,7 +1378,7 @@ sub GenerateFunctionCallback return; } - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@implContentDecls, "#if ${conditionalString}\n\n") if $conditionalString; push(@implContentDecls, <<END); static v8::Handle<v8::Value> ${name}Callback(const v8::Arguments& args) @@ -1383,7 +1398,7 @@ END AddToImplIncludes("ExceptionCode.h"); push(@implContentDecls, " $nativeClassName wrapper = V8${implClassName}::toNative(args.Holder());\n"); push(@implContentDecls, " if (wrapper->role() == AnimValRole) {\n"); - push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR);\n"); + push(@implContentDecls, " V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate());\n"); push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); push(@implContentDecls, " }\n"); my $svgWrappedNativeType = $codeGenerator->GetSVGWrappedTypeNeedingTearOff($implClassName); @@ -1427,20 +1442,20 @@ END if ($function->signature->extendedAttributes->{"CheckSecurityForNode"}) { push(@implContentDecls, " if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->" . $function->signature->name . "(ec)))\n"); - push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); + push(@implContentDecls, " return v8::Handle<v8::Value>(v8::Null());\n"); END } - my ($parameterCheckString, $paramIndex) = GenerateParametersCheck($function, $implClassName); + my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $implClassName); push(@implContentDecls, $parameterCheckString); # Build the function call string. - push(@implContentDecls, GenerateFunctionCallString($function, $paramIndex, " ", $implClassName)); + push(@implContentDecls, GenerateFunctionCallString($function, $paramIndex, " ", $implClassName, %replacements)); if ($raisesExceptions) { push(@implContentDecls, " }\n"); push(@implContentDecls, " fail:\n"); - push(@implContentDecls, " V8Proxy::setDOMException(ec);\n"); + push(@implContentDecls, " V8Proxy::setDOMException(ec, args.GetIsolate());\n"); push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); } @@ -1511,11 +1526,25 @@ sub GenerateArgumentsCountCheck my $argumentsCountCheckString = ""; if ($numMandatoryParams >= 1) { $argumentsCountCheckString .= " if (args.Length() < $numMandatoryParams)\n"; - $argumentsCountCheckString .= " return throwError(\"Not enough arguments\", V8Proxy::TypeError);\n"; + $argumentsCountCheckString .= " return V8Proxy::throwNotEnoughArgumentsError();\n"; } return $argumentsCountCheckString; } +sub GetIndexOf +{ + my $paramName = shift; + my @paramList = @_; + my $index = 0; + foreach my $param (@paramList) { + if ($paramName eq $param) { + return $index; + } + $index++; + } + return -1; +} + sub GenerateParametersCheck { my $function = shift; @@ -1523,6 +1552,9 @@ sub GenerateParametersCheck my $parameterCheckString = ""; my $paramIndex = 0; + my @paramTransferListNames = (); + my %replacements = (); + foreach my $parameter (@{$function->parameters}) { TranslateParameter($parameter); @@ -1533,7 +1565,7 @@ sub GenerateParametersCheck my $optional = $parameter->extendedAttributes->{"Optional"}; if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && !$parameter->extendedAttributes->{"Callback"}) { $parameterCheckString .= " if (args.Length() <= $paramIndex) {\n"; - my $functionCall = GenerateFunctionCallString($function, $paramIndex, " " x 2, $implClassName); + my $functionCall = GenerateFunctionCallString($function, $paramIndex, " " x 2, $implClassName, %replacements); $parameterCheckString .= $functionCall; $parameterCheckString .= " }\n"; } @@ -1543,6 +1575,12 @@ sub GenerateParametersCheck $parameterDefaultPolicy = "DefaultIsNullString"; } + if (GetIndexOf($parameterName, @paramTransferListNames) != -1) { + $replacements{$parameterName} = "messagePortArray" . ucfirst($parameterName); + $paramIndex++; + next; + } + AddToImplIncludes("ExceptionCode.h"); my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); if ($parameter->extendedAttributes->{"Callback"}) { @@ -1551,30 +1589,61 @@ sub GenerateParametersCheck if ($optional) { $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName;\n"; $parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n"; - $parameterCheckString .= " if (!args[$paramIndex]->IsObject())\n"; + $parameterCheckString .= " if (!args[$paramIndex]->IsFunction())\n"; $parameterCheckString .= " return throwError(TYPE_MISMATCH_ERR);\n"; $parameterCheckString .= " $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"; $parameterCheckString .= " }\n"; } else { - $parameterCheckString .= " if (args.Length() <= $paramIndex || !args[$paramIndex]->IsObject())\n"; + $parameterCheckString .= " if (args.Length() <= $paramIndex || !args[$paramIndex]->IsFunction())\n"; $parameterCheckString .= " return throwError(TYPE_MISMATCH_ERR);\n"; $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName = ${className}::create(args[$paramIndex], getScriptExecutionContext());\n"; } } elsif ($parameter->type eq "SerializedScriptValue") { AddToImplIncludes("SerializedScriptValue.h"); + my $useTransferList = 0; + my $transferListName = ""; + my $TransferListName = ""; + if ($parameter->extendedAttributes->{"TransferList"}) { + $transferListName = $parameter->extendedAttributes->{"TransferList"}; + push(@paramTransferListNames, $transferListName); + + my @allParameterNames = (); + foreach my $parameter (@{$function->parameters}) { + push(@allParameterNames, $parameter->name); + } + my $transferListIndex = GetIndexOf($transferListName, @allParameterNames); + if ($transferListIndex == -1) { + die "IDL error: TransferList refers to a nonexistent argument"; + } + + AddToImplIncludes("wtf/ArrayBuffer.h"); + AddToImplIncludes("MessagePort.h"); + $TransferListName = ucfirst($transferListName); + $parameterCheckString .= " MessagePortArray messagePortArray$TransferListName;\n"; + $parameterCheckString .= " ArrayBufferArray arrayBufferArray$TransferListName;\n"; + $parameterCheckString .= " if (args.Length() > $transferListIndex) {\n"; + $parameterCheckString .= " if (!extractTransferables(args[$transferListIndex], messagePortArray$TransferListName, arrayBufferArray$TransferListName))\n"; + $parameterCheckString .= " return throwError(\"Could not extract transferables\", V8Proxy::TypeError);\n"; + $parameterCheckString .= " }\n"; + $useTransferList = 1; + } $parameterCheckString .= " bool ${parameterName}DidThrow = false;\n"; - $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow);\n"; + if (!$useTransferList) { + $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], 0, 0, ${parameterName}DidThrow, args.GetIsolate());\n"; + } else { + $parameterCheckString .= " $nativeType $parameterName = SerializedScriptValue::create(args[$paramIndex], &messagePortArray$TransferListName, &arrayBufferArray$TransferListName, ${parameterName}DidThrow, args.GetIsolate());\n"; + } $parameterCheckString .= " if (${parameterName}DidThrow)\n"; $parameterCheckString .= " return v8::Undefined();\n"; } elsif (TypeCanFailConversion($parameter)) { $parameterCheckString .= " $nativeType $parameterName = " . - JSValueToNative($parameter, "args[$paramIndex]") . ";\n"; + JSValueToNative($parameter, "args[$paramIndex]", "args.GetIsolate()") . ";\n"; $parameterCheckString .= " if (UNLIKELY(!$parameterName)) {\n"; $parameterCheckString .= " ec = TYPE_MISMATCH_ERR;\n"; $parameterCheckString .= " goto fail;\n"; $parameterCheckString .= " }\n"; } elsif ($nativeType =~ /^V8Parameter/) { - my $value = JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)"); + my $value = JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)", "args.GetIsolate()"); $parameterCheckString .= " " . ConvertToV8Parameter($parameter, $nativeType, $parameterName, $value) . "\n"; } else { AddToImplIncludes("V8BindingMacros.h"); @@ -1595,11 +1664,13 @@ sub GenerateParametersCheck } } $parameterCheckString .= " EXCEPTION_BLOCK($nativeType, $parameterName, " . - JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)") . ");\n"; - if ($nativeType eq 'OptionsObject') { + JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)", "args.GetIsolate()") . ");\n"; + if ($nativeType eq 'Dictionary') { $parameterCheckString .= " if (args.Length() > $paramIndex && !$parameterName.isUndefinedOrNull() && !$parameterName.isObject()) {\n"; - $parameterCheckString .= " ec = TYPE_MISMATCH_ERR;\n"; - $parameterCheckString .= " V8Proxy::setDOMException(ec);\n"; + if (@{$function->raisesExceptions}) { + $parameterCheckString .= " ec = TYPE_MISMATCH_ERR;\n"; + $parameterCheckString .= " V8Proxy::setDOMException(ec, args.GetIsolate());\n"; + } $parameterCheckString .= " return throwError(\"Not an object.\", V8Proxy::TypeError);\n"; $parameterCheckString .= " }\n"; } @@ -1614,7 +1685,7 @@ sub GenerateParametersCheck $paramIndex++; } - return ($parameterCheckString, $paramIndex); + return ($parameterCheckString, $paramIndex, %replacements); } sub GenerateConstructorCallback @@ -1657,7 +1728,9 @@ END push(@implContent, " ExceptionCode ec = 0;\n"); } - my ($parameterCheckString, $paramIndex) = GenerateParametersCheck($function, $implClassName); + # FIXME: Currently [Constructor(...)] does not yet support [Optional] arguments. + # It just supports [Optional=DefaultIsUndefined] or [Optional=DefaultIsNullString]. + my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $implClassName); push(@implContent, $parameterCheckString); if ($dataNode->extendedAttributes->{"CallWith"} && $dataNode->extendedAttributes->{"CallWith"} eq "ScriptExecutionContext") { @@ -1678,7 +1751,11 @@ END my $index = 0; foreach my $parameter (@{$function->parameters}) { last if $index eq $paramIndex; - push(@argumentList, $parameter->name); + if ($replacements{$parameter->name}) { + push(@argumentList, $replacements{$parameter->name}); + } else { + push(@argumentList, $parameter->name); + } $index++; } @@ -1692,18 +1769,11 @@ END push(@implContent, " goto fail;\n"); } - my $DOMObject = "DOMObject"; - if (IsNodeSubType($dataNode)) { - $DOMObject = "DOMNode"; - } elsif ($dataNode->extendedAttributes->{"ActiveDOMObject"}) { - $DOMObject = "ActiveDOMObject"; - } - + my $DOMObject = GetDomMapName($dataNode, $implClassName); push(@implContent, <<END); V8DOMWrapper::setDOMWrapper(wrapper, &info, impl.get()); - impl->ref(); - V8DOMWrapper::setJSWrapperFor${DOMObject}(impl.get(), v8::Persistent<v8::Object>::New(wrapper)); + V8DOMWrapper::setJSWrapperFor${DOMObject}(impl.release(), v8::Persistent<v8::Object>::New(wrapper), args.GetIsolate()); return args.Holder(); END @@ -1721,7 +1791,7 @@ sub GenerateEventConstructorCallback my $dataNode = shift; my $implClassName = shift; - AddToImplIncludes("OptionsObject.h"); + AddToImplIncludes("Dictionary.h"); AddToImplIncludes("V8BindingMacros.h"); push(@implContent, <<END); v8::Handle<v8::Value> V8${implClassName}::constructorCallback(const v8::Arguments& args) @@ -1735,12 +1805,12 @@ v8::Handle<v8::Value> V8${implClassName}::constructorCallback(const v8::Argument return args.Holder(); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, args[0]); ${implClassName}Init eventInit; if (args.Length() >= 2) { - EXCEPTION_BLOCK(OptionsObject, options, args[1]); + EXCEPTION_BLOCK(Dictionary, options, args[1]); if (!fill${implClassName}Init(eventInit, options)) return v8::Undefined(); } @@ -1748,10 +1818,11 @@ v8::Handle<v8::Value> V8${implClassName}::constructorCallback(const v8::Argument RefPtr<${implClassName}> event = ${implClassName}::create(type, eventInit); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, event.get()); - return toV8(event.release(), args.Holder()); + V8DOMWrapper::setJSWrapperForDOMObject(event.release(), v8::Persistent<v8::Object>::New(args.Holder()), args.GetIsolate()); + return args.Holder(); } -bool fill${implClassName}Init(${implClassName}Init& eventInit, const OptionsObject& options) +bool fill${implClassName}Init(${implClassName}Init& eventInit, const Dictionary& options) { END @@ -1830,7 +1901,7 @@ static v8::Handle<v8::Value> V8${implClassName}ConstructorCallback(const v8::Arg // Make sure the document is added to the DOM Node map. Otherwise, the ${implClassName} instance // may end up being the only node in the map and get garbage-collected prematurely. - toV8(document); + toV8(document, args.GetIsolate()); END @@ -1842,7 +1913,7 @@ END push(@implContent, " ExceptionCode ec = 0;\n"); } - my ($parameterCheckString, $paramIndex) = GenerateParametersCheck($function, $implClassName); + my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersCheck($function, $implClassName); push(@implContent, $parameterCheckString); push(@beforeArgumentList, "document"); @@ -1855,7 +1926,11 @@ END my $index = 0; foreach my $parameter (@{$function->parameters}) { last if $index eq $paramIndex; - push(@argumentList, $parameter->name); + if ($replacements{$parameter->name}) { + push(@argumentList, $replacements{$parameter->name}); + } else { + push(@argumentList, $parameter->name); + } $index++; } @@ -1869,19 +1944,11 @@ END push(@implContent, " goto fail;\n"); } - my $DOMObject = "DOMObject"; - # A DOMObject that is an ActiveDOMObject and also a DOMNode should be treated as an DOMNode here. - # setJSWrapperForDOMNode() will look if node is active and choose correct map to add node to. - if (IsNodeSubType($dataNode)) { - $DOMObject = "DOMNode"; - } elsif ($dataNode->extendedAttributes->{"ActiveDOMObject"}) { - $DOMObject = "ActiveDOMObject"; - } + my $DOMObject = GetDomMapName($dataNode, $implClassName); push(@implContent, <<END); V8DOMWrapper::setDOMWrapper(wrapper, &V8${implClassName}Constructor::info, impl.get()); - impl->ref(); - V8DOMWrapper::setJSWrapperFor${DOMObject}(impl.get(), v8::Persistent<v8::Object>::New(wrapper)); + V8DOMWrapper::setJSWrapperFor${DOMObject}(impl.release(), v8::Persistent<v8::Object>::New(wrapper), args.GetIsolate()); return args.Holder(); END @@ -1922,7 +1989,7 @@ sub GenerateBatchedAttributeData my $attributes = shift; foreach my $attribute (@$attributes) { - my $conditionalString = GenerateConditionalString($attribute->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($attribute->signature); push(@implContent, "#if ${conditionalString}\n") if $conditionalString; GenerateSingleBatchedAttribute($interfaceName, $attribute, ",", ""); push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; @@ -1997,15 +2064,15 @@ sub GenerateSingleBatchedAttribute $getter = "V8${customAccessor}AccessorGetter"; } else { $data = "&V8${constructorType}::info"; - $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter"; + $getter = "${interfaceName}V8Internal::${interfaceName}ConstructorGetter"; } $setter = "0"; $propAttr = "v8::ReadOnly"; } else { # Default Getter and Setter - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "${interfaceName}Internal::${attrName}AttrSetter"; + $getter = "${interfaceName}V8Internal::${attrName}AttrGetter"; + $setter = "${interfaceName}V8Internal::${attrName}AttrSetter"; # Custom Setter if ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"} || $attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { @@ -2268,7 +2335,7 @@ sub GenerateImplementation push(@implContentDecls, "namespace WebCore {\n\n"); my $parentClassInfo = $parentClass ? "&${parentClass}::info" : "0"; push(@implContentDecls, "WrapperTypeInfo ${className}::info = { ${className}::GetTemplate, ${className}::derefObject, ${toActive}, ${parentClassInfo} };\n\n"); - push(@implContentDecls, "namespace ${interfaceName}Internal {\n\n"); + push(@implContentDecls, "namespace ${interfaceName}V8Internal {\n\n"); push(@implContentDecls, "template <typename T> void V8_USE(T) { }\n\n"); my $hasConstructors = 0; @@ -2416,7 +2483,7 @@ sub GenerateImplementation } my $name = $function->signature->name; my $callback = GetFunctionTemplateCallbackName($function, $interfaceName); - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@implContent, "#if ${conditionalString}\n") if $conditionalString; push(@implContent, <<END); {"$name", $callback}, @@ -2463,7 +2530,7 @@ END push(@implContent, $codeGenerator->GenerateCompileTimeCheckForEnumsIfNeeded($dataNode)); } - push(@implContentDecls, "} // namespace ${interfaceName}Internal\n\n"); + push(@implContentDecls, "} // namespace ${interfaceName}V8Internal\n\n"); if ($dataNode->extendedAttributes->{"NamedConstructor"} && !($dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { GenerateNamedConstructorCallback($dataNode->constructor, $dataNode, $interfaceName); @@ -2563,7 +2630,7 @@ END # Setup the enable-at-runtime attrs if we have them foreach my $runtime_attr (@enabledAtRuntime) { my $enable_function = GetRuntimeEnableFunctionName($runtime_attr->signature); - my $conditionalString = GenerateConditionalString($runtime_attr->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($runtime_attr->signature); push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; push(@implContent, " if (${enable_function}()) {\n"); push(@implContent, " static const BatchedAttribute attrData =\\\n"); @@ -2578,7 +2645,7 @@ END # Setup the enable-at-runtime constants if we have them foreach my $runtime_const (@constantsEnabledAtRuntime) { my $enable_function = GetRuntimeEnableFunctionName($runtime_const); - my $conditionalString = GenerateConditionalString($runtime_const); + my $conditionalString = $codeGenerator->GenerateConditionalString($runtime_const); my $name = $runtime_const->name; my $value = $runtime_const->value; push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; @@ -2651,7 +2718,7 @@ END push(@implContent, <<END); // $commentInfo - ${conditional}$template->SetAccessor(v8::String::New("$name"), ${interfaceName}Internal::${name}AttrGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes)); + ${conditional}$template->SetAccessor(v8::String::New("$name"), ${interfaceName}V8Internal::${name}AttrGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes)); END $num_callbacks++; next; @@ -2681,7 +2748,7 @@ END next; } - my $conditionalString = GenerateConditionalString($function->signature); + my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature); push(@implContent, "#if ${conditionalString}\n") if $conditionalString; push(@implContent, <<END); @@ -2803,21 +2870,13 @@ END void ${className}::derefObject(void* object) { -END - - if (IsRefPtrType($interfaceName)) { - push(@implContent, <<END); static_cast<${nativeType}*>(object)->deref(); -END - } - - push(@implContent, <<END); } } // namespace WebCore END - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; # We've already added the header for this file in implFixedHeader, so remove @@ -2829,7 +2888,7 @@ sub GenerateHeaderContentHeader { my $dataNode = shift; my $className = "V8" . $dataNode->name; - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); my @headerContentHeader = split("\r", $headerTemplate); @@ -2843,7 +2902,7 @@ sub GenerateImplementationContentHeader { my $dataNode = shift; my $className = "V8" . $dataNode->name; - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); my @implContentHeader = split("\r", $headerTemplate); @@ -2926,7 +2985,7 @@ END push(@headerContent, "}\n\n"); push(@headerContent, "#endif // $className" . "_h\n\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; } @@ -2977,14 +3036,24 @@ END push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "("); my @args = (); + my @argsCheck = (); + my $thisType = $function->signature->extendedAttributes->{"PassThisToCallback"}; foreach my $param (@params) { + my $paramName = $param->name; AddIncludesForType($param->type); - push(@args, GetNativeTypeForCallbacks($param->type) . " " . $param->name); + push(@args, GetNativeTypeForCallbacks($param->type) . " " . $paramName); + if ($thisType and $thisType eq $param->type) { + push(@argsCheck, <<END); + ASSERT(${paramName}); + +END + } } push(@implContent, join(", ", @args)); push(@implContent, ")\n"); push(@implContent, "{\n"); + push(@implContent, @argsCheck) if @argsCheck; push(@implContent, " if (!canInvokeCallback())\n"); push(@implContent, " return true;\n\n"); push(@implContent, " v8::HandleScope handleScope;\n\n"); @@ -2996,7 +3065,7 @@ END @args = (); foreach my $param (@params) { my $paramName = $param->name; - push(@implContent, " v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName) . ";\n"); + push(@implContent, " v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName, "0") . ";\n"); push(@implContent, " if (${paramName}Handle.IsEmpty()) {\n"); push(@implContent, " if (!isScriptControllerTerminating())\n"); push(@implContent, " CRASH();\n"); @@ -3013,14 +3082,23 @@ END push(@implContent, "\n v8::Handle<v8::Value> *argv = 0;\n\n"); } push(@implContent, " bool callbackReturnValue = false;\n"); - push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); + if ($thisType) { + foreach my $param (@params) { + next if $param->type ne $thisType; + my $paramName = $param->name; + push(@implContent, " return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); + last; + } + } else { + push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n"); + } push(@implContent, "}\n"); } } push(@implContent, "\n} // namespace WebCore\n\n"); - my $conditionalString = GenerateConditionalString($dataNode); + my $conditionalString = $codeGenerator->GenerateConditionalString($dataNode); push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; } @@ -3031,13 +3109,14 @@ sub GenerateToV8Converters my $className = shift; my $nativeType = shift; - my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName); + my $domMapName = GetDomMapName($dataNode, $interfaceName); my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : ""; my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : ""; + my $wrapSlowArgumentType = GetPassRefPtrType($nativeType); push(@implContent, <<END); -v8::Handle<v8::Object> ${className}::wrapSlow(${nativeType}* impl) +v8::Handle<v8::Object> ${className}::wrapSlow(${wrapSlowArgumentType} impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; END @@ -3060,7 +3139,7 @@ END push(@implContent, <<END); if (proxy && proxy->windowShell()->context().IsEmpty() && proxy->windowShell()->initContextIfNeeded()) { // initContextIfNeeded may have created a wrapper for the object, retry from the start. - return ${className}::wrap(impl); + return ${className}::wrap(impl.get(), isolate); } END } @@ -3081,18 +3160,20 @@ END if (IsNodeSubType($dataNode) || IsVisibleAcrossOrigins($dataNode)) { push(@implContent, <<END); + // Enter the node's context and create the wrapper in that context. v8::Handle<v8::Context> context; - if (proxy) + if (proxy && !proxy->matchesCurrentContext()) { + // For performance, we enter the context only if the currently running context + // is different from the context that we are about to enter. context = proxy->context(); - - // Enter the node's context and create the wrapper in that context. - if (!context.IsEmpty()) - context->Enter(); + if (!context.IsEmpty()) + context->Enter(); + } END } push(@implContent, <<END); - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); END if (IsNodeSubType($dataNode) || IsVisibleAcrossOrigins($dataNode)) { push(@implContent, <<END); @@ -3105,10 +3186,7 @@ END push(@implContent, <<END); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; -END - push(@implContent, "\n impl->ref();\n") if IsRefPtrType($interfaceName); - push(@implContent, <<END); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) @@ -3118,12 +3196,9 @@ END push(@implContent, <<END); wrapperHandle.SetWrapperClassId(v8DOMSubtreeClassId); END - } - push(@implContent, <<END); - ${domMapFunction}.set(impl, wrapperHandle); -END - + } push(@implContent, <<END); + V8DOMWrapper::setJSWrapperFor${domMapName}(impl, wrapperHandle, isolate); return wrapper; } END @@ -3132,12 +3207,21 @@ END sub GetDomMapFunction { my $dataNode = shift; + my $interfaceName = shift; + my $getIsolate = shift; + + return "get" . GetDomMapName($dataNode, $interfaceName) . "Map(" . $getIsolate . ")"; +} + +sub GetDomMapName +{ + my $dataNode = shift; my $type = shift; - return "getDOMSVGElementInstanceMap()" if $type eq "SVGElementInstance"; - return "getActiveDOMNodeMap()" if (IsNodeSubType($dataNode) && $dataNode->extendedAttributes->{"ActiveDOMObject"}); - return "getDOMNodeMap()" if (IsNodeSubType($dataNode)); - return "getActiveDOMObjectMap()" if $dataNode->extendedAttributes->{"ActiveDOMObject"}; - return "getDOMObjectMap()"; + + return "ActiveDOMNode" if (IsNodeSubType($dataNode) && $dataNode->extendedAttributes->{"ActiveDOMObject"}); + return "DOMNode" if IsNodeSubType($dataNode); + return "ActiveDOMObject" if $dataNode->extendedAttributes->{"ActiveDOMObject"}; + return "DOMObject"; } sub GetNativeTypeForConversions @@ -3155,6 +3239,7 @@ sub GenerateFunctionCallString() my $numberOfParameters = shift; my $indent = shift; my $implClassName = shift; + my %replacements = @_; my $name = $function->signature->name; my $returnType = GetTypeFromSignature($function->signature); @@ -3199,12 +3284,14 @@ sub GenerateFunctionCallString() my $paramName = $parameter->name; my $paramType = $parameter->type; - if ($parameter->type eq "IDBKey" || $parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") { + if ($replacements{$paramName}) { + push @arguments, $replacements{$paramName}; + } elsif ($parameter->type eq "IDBKey" || $parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") { push @arguments, "$paramName.get()"; } elsif ($codeGenerator->IsSVGTypeNeedingTearOff($parameter->type) and not $implClassName =~ /List$/) { push @arguments, "$paramName->propertyReference()"; $result .= $indent . "if (!$paramName) {\n"; - $result .= $indent . " V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR);\n"; + $result .= $indent . " V8Proxy::setDOMException(WebCore::TYPE_MISMATCH_ERR, args.GetIsolate());\n"; $result .= $indent . " return v8::Handle<v8::Value>();\n"; $result .= $indent . "}\n"; } elsif ($parameter->type eq "SVGMatrix" and $implClassName eq "SVGTransformList") { @@ -3252,7 +3339,7 @@ sub GenerateFunctionCallString() AddToImplIncludes("V8$returnType.h"); AddToImplIncludes("SVGPropertyTearOff.h"); my $svgNativeType = $codeGenerator->GetSVGTypeNeedingTearOff($returnType); - $result .= $indent . "return toV8(WTF::getPtr(${svgNativeType}::create($return)));\n"; + $result .= $indent . "return toV8(WTF::getPtr(${svgNativeType}::create($return)), args.GetIsolate());\n"; return $result; } @@ -3262,7 +3349,7 @@ sub GenerateFunctionCallString() } $return .= ".release()" if ($returnIsRef); - $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n"; + $result .= $indent . ReturnNativeToJSValue($function->signature, $return, "args.GetIsolate()") . ";\n"; return $result; } @@ -3360,7 +3447,7 @@ sub GetNativeType return "Node*" if $type eq "EventTarget" and $isParameter; return "double" if $type eq "Date"; return "ScriptValue" if $type eq "DOMObject"; - return "OptionsObject" if $type eq "OptionsObject"; + return "Dictionary" if $type eq "Dictionary"; return "String" if $type eq "DOMUserData"; # FIXME: Temporary hack? @@ -3424,6 +3511,7 @@ sub JSValueToNative { my $signature = shift; my $value = shift; + my $getIsolate = shift; my $type = GetTypeFromSignature($signature); @@ -3454,7 +3542,7 @@ sub JSValueToNative if ($type eq "SerializedScriptValue") { AddToImplIncludes("SerializedScriptValue.h"); - return "SerializedScriptValue::create($value)"; + return "SerializedScriptValue::create($value, $getIsolate)"; } if ($type eq "IDBKey") { @@ -3463,8 +3551,8 @@ sub JSValueToNative return "createIDBKeyFromValue($value)"; } - if ($type eq "OptionsObject") { - AddToImplIncludes("OptionsObject.h"); + if ($type eq "Dictionary") { + AddToImplIncludes("Dictionary.h"); return $value; } @@ -3494,6 +3582,11 @@ sub JSValueToNative return "V8DOMWrapper::getXPathNSResolver($value)"; } + my $arrayType = $codeGenerator->GetArrayType($type); + if ($arrayType) { + return "toNativeArray<$arrayType>($value)"; + } + AddIncludesForType($type); if (IsDOMNodeType($type)) { @@ -3541,8 +3634,13 @@ sub CreateCustomSignature $result .= "v8::Handle<v8::FunctionTemplate>()"; } else { my $type = $parameter->type; - my $header = GetV8HeaderName($type); - AddToImplIncludes($header); + my $arrayType = $codeGenerator->GetArrayType($type); + if ($arrayType) { + AddToImplIncludes("$arrayType.h"); + } else { + my $header = GetV8HeaderName($type); + AddToImplIncludes($header); + } $result .= "V8${type}::GetRawTemplate()"; } } else { @@ -3567,6 +3665,9 @@ sub RequiresCustomSignature if (@{$function->{overloads}} > 1) { return 0; } + if ($function->isStatic) { + return 0; + } # Type checking is performed in the generated code if ($function->signature->extendedAttributes->{"StrictTypeChecking"}) { return 0; @@ -3612,7 +3713,7 @@ my %non_wrapper_types = ( 'NodeFilter' => 1, 'EventListener' => 1, 'IDBKey' => 1, - 'OptionsObject' => 1, + 'Dictionary' => 1, 'Date' => 1, 'MediaQueryListListener' => 1 ); @@ -3666,7 +3767,7 @@ sub NativeToJSValue { my $signature = shift; my $value = shift; - my $indent = shift; + my $getIsolate = shift; my $type = GetTypeFromSignature($signature); return "v8Boolean($value)" if $type eq "boolean"; @@ -3698,20 +3799,29 @@ sub NativeToJSValue if ($codeGenerator->IsStringType($type)) { my $conv = $signature->extendedAttributes->{"TreatReturnedNullStringAs"}; if (defined $conv) { - return "v8StringOrNull($value)" if $conv eq "Null"; - return "v8StringOrUndefined($value)" if $conv eq "Undefined"; - return "v8StringOrFalse($value)" if $conv eq "False"; + return "v8StringOrNull($value, $getIsolate)" if $conv eq "Null"; + return "v8StringOrUndefined($value, $getIsolate)" if $conv eq "Undefined"; + return "v8StringOrFalse($value, $getIsolate)" if $conv eq "False"; die "Unknown value for TreatReturnedNullStringAs extended attribute"; } - return "v8String($value)"; + return "v8String($value, $getIsolate)"; + } + + my $arrayType = $codeGenerator->GetArrayType($type); + if ($arrayType) { + if (!$codeGenerator->SkipIncludeHeader($arrayType)) { + AddToImplIncludes("V8$arrayType.h"); + AddToImplIncludes("$arrayType.h"); + } + return "v8Array($value, $getIsolate)"; } AddIncludesForType($type); # special case for non-DOM node interfaces if (IsDOMNodeType($type)) { - return "toV8(${value}" . ($signature->extendedAttributes->{"ReturnNewObject"} ? ", true)" : ")"); + return "toV8(${value}" . ($signature->extendedAttributes->{"ReturnNewObject"} ? ", $getIsolate, true)" : ", $getIsolate)"); } if ($type eq "EventTarget") { @@ -3732,7 +3842,7 @@ sub NativeToJSValue AddToImplIncludes("wtf/RefPtr.h"); AddToImplIncludes("wtf/GetPtr.h"); - return "toV8($value)"; + return "toV8($value, $getIsolate)"; } sub ReturnNativeToJSValue @@ -3841,6 +3951,14 @@ sub GetRuntimeEnableFunctionName return "RuntimeEnabledFeatures::" . $codeGenerator->WK_lcfirst($signature->name) . "Enabled"; } +sub GetPassRefPtrType +{ + my $className = shift; + + my $angleBracketSpace = $className =~ />$/ ? " " : ""; + return "PassRefPtr<${className}${angleBracketSpace}>"; +} + sub DebugPrint { my $output = shift; diff --git a/Source/WebCore/bindings/scripts/IDLAttributes.txt b/Source/WebCore/bindings/scripts/IDLAttributes.txt index d105e0872..a467bfee5 100644 --- a/Source/WebCore/bindings/scripts/IDLAttributes.txt +++ b/Source/WebCore/bindings/scripts/IDLAttributes.txt @@ -91,12 +91,14 @@ ObjCPolymorphic ObjCProtocol OmitConstructor Optional=|DefaultIsNullString|DefaultIsUndefined +PassThisToCallback=* Reflect=* Replaceable ReplaceableConstructor ReturnNewObject StrictTypeChecking Supplemental=* +TransferList=* TreatNullAs=NullString TreatReturnedNullStringAs=False|Null|Undefined TreatUndefinedAs=NullString diff --git a/Source/WebCore/bindings/scripts/IDLParser.pm b/Source/WebCore/bindings/scripts/IDLParser.pm index 4d126db84..0f08a353d 100644 --- a/Source/WebCore/bindings/scripts/IDLParser.pm +++ b/Source/WebCore/bindings/scripts/IDLParser.pm @@ -32,6 +32,7 @@ use constant MODE_UNDEF => 0; # Default mode. use constant MODE_MODULE => 10; # 'module' section use constant MODE_INTERFACE => 11; # 'interface' section +use constant MODE_EXCEPTION => 12; # 'exception' section # Helper variables my @temporaryContent; @@ -274,7 +275,7 @@ sub ParseInterface $data =~ s/[\n\r]/ /g; # Beginning of the regexp parsing magic - if ($sectionName eq "interface") { + if ($sectionName eq "interface" || $sectionName eq "exception") { print " |- Trying to parse interface...\n" unless $beQuiet; my $interfaceName = ""; @@ -283,12 +284,14 @@ sub ParseInterface # Match identifier of the interface, and enclosed data... $data =~ /$IDLStructure::interfaceSelector/; - my $interfaceExtendedAttributes = (defined($1) ? $1 : " "); chop($interfaceExtendedAttributes); - $interfaceName = (defined($2) ? $2 : die("Parsing error!\nSource:\n$data\n)")); - my $interfaceBase = (defined($3) ? $3 : ""); - $interfaceData = (defined($4) ? $4 : die("Parsing error!\nSource:\n$data\n)")); + my $isException = (defined($1) ? ($1 eq 'exception') : die("Parsing error!\nSource:\n$data\n)")); + my $interfaceExtendedAttributes = (defined($2) ? $2 : " "); chop($interfaceExtendedAttributes); + $interfaceName = (defined($3) ? $3 : die("Parsing error!\nSource:\n$data\n)")); + my $interfaceBase = (defined($4) ? $4 : ""); + $interfaceData = (defined($5) ? $5 : die("Parsing error!\nSource:\n$data\n)")); # Fill in known parts of the domClass datastructure now... + $dataNode->isException($isException); $dataNode->name($interfaceName); my $extendedAttributes = parseExtendedAttributes($interfaceExtendedAttributes); if (defined $extendedAttributes->{"Constructor"}) { @@ -430,6 +433,8 @@ sub DetermineParseMode $mode = MODE_MODULE; } elsif ($_ =~ /interface/) { $mode = MODE_INTERFACE; + } elsif ($_ =~ /exception/) { + $mode = MODE_EXCEPTION; } return $mode; @@ -444,9 +449,10 @@ sub ProcessSection die ("Two modules in one file! Fatal error!\n") if ($document ne 0); $document = new idlDocument(); $object->ParseModule($document); - } elsif ($parseMode eq MODE_INTERFACE) { + } elsif ($parseMode eq MODE_INTERFACE || $parseMode eq MODE_EXCEPTION) { my $node = new domClass(); - $object->ParseInterface($node, "interface"); + my $sectionName = $parseMode eq MODE_INTERFACE ? "interface" : "exception"; + $object->ParseInterface($node, $sectionName); die ("No module specified! Fatal Error!\n") if ($document eq 0); my $arrayRef = $document->classes; diff --git a/Source/WebCore/bindings/scripts/IDLStructure.pm b/Source/WebCore/bindings/scripts/IDLStructure.pm index 63f4090e9..5424153dc 100644 --- a/Source/WebCore/bindings/scripts/IDLStructure.pm +++ b/Source/WebCore/bindings/scripts/IDLStructure.pm @@ -41,6 +41,7 @@ struct( domClass => { attributes => '@', # List of 'domAttribute' extendedAttributes => '$', # Extended attributes constructor => '$', # Constructor + isException => '$', # Used for exception interfaces }); # Used to represent domClass contents (name of method, signature) @@ -88,7 +89,7 @@ our $constValue = '("[^"\r\n]*")|(0[xX][a-fA-F0-9]+)|(-?[0-9]*)'; our $idlDataType = '[a-zA-Z0-9\ ]'; # Generic data type identifier # Magic IDL parsing regular expressions -my $supportedTypes = "((?:(?:unsigned )?(?:int|short|(?:long )?long)|(?:$idlIdNs*))(?:\\[\\])?)"; +my $supportedTypes = "((?:(?:unsigned )?(?:int|short|(?:long )?long)|(?:$idlIdNs*))(?:\\[\\]|<(?:$idlIdNsList*)>)?)"; # Special IDL notations. This regular expression extracts the string between the first [ and its corresponding ]. our $extendedAttributeSyntax = qr/\[[^\[\]]*(?:(??{$IDLStructure::extendedAttributeSyntax})[^\[\]]*)*\]/x; # Used for extended attributes @@ -103,8 +104,8 @@ our $setterRaisesSelector = '\bsetter\s+raises\s*\((' . $idlIdNsList . '*)\s*\)' our $typeNamespaceSelector = '((?:' . $idlId . '*::)*)\s*(' . $idlDataType . '*)'; -our $interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([-a-zA-Z0-9_"=\s(),;:\[\]&\|]*)'; -our $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)(static\s+)?' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]]*)'; +our $interfaceSelector = '(interface|exception)\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([-a-zA-Z0-9_"=\s(),;:\[\]<>&\|]*)'; +our $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)(static\s+)?' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]<>]*)'; our $interfaceParameterSelector = '(in|out)\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)'; our $interfaceAttributeSelector = '\s*(readonly attribute|attribute)\s*(' . $extendedAttributeSyntax . ' )?' . $supportedTypes . '\s*(' . $idlType . '*)'; diff --git a/Source/WebCore/bindings/scripts/InFilesCompiler.pm b/Source/WebCore/bindings/scripts/InFilesCompiler.pm index e12606879..3dcd7729e 100644 --- a/Source/WebCore/bindings/scripts/InFilesCompiler.pm +++ b/Source/WebCore/bindings/scripts/InFilesCompiler.pm @@ -166,6 +166,23 @@ sub toMacroStyle($$) die "Ok, you got me. This script is really just a giant hack. (\$camelCase=${camelCase})"; } +sub preferredConditional() +{ + my $object = shift; + my $conditional = shift; + + my @conditionals = split('\\|', $conditional); + return $conditionals[0]; +} + +sub conditionalStringFromAttributeValue() +{ + my $object = shift; + my $conditional = shift; + + return "ENABLE(" . join(') || ENABLE(', split('\\|', $conditional)) . ")"; +} + sub generateInterfacesHeader() { my $object = shift; @@ -202,17 +219,18 @@ sub generateInterfacesHeader() my $macroStyledNamespace = $object->toMacroStyle($namespace); for my $conditional (sort keys %interfacesByConditional) { - print F "#if ENABLE($conditional)\n"; - print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro) \\\n"; + my $preferredConditional = $object->preferredConditional($conditional); + print F "#if " . $object->conditionalStringFromAttributeValue($conditional) . "\n"; + print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional(macro) \\\n"; for my $interface (sort keys %{ $interfacesByConditional{$conditional} }) { next if defined($unconditionalInterfaces{$interface}); print F " macro($interface) \\\n"; } - print F "// End of DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional\n"; + print F "// End of DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional\n"; print F "#else\n"; - print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro)\n"; + print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional(macro)\n"; print F "#endif\n"; print F "\n"; } @@ -224,7 +242,8 @@ sub generateInterfacesHeader() } print F " \\\n"; for my $conditional (sort keys %interfacesByConditional) { - print F " DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro) \\\n"; + my $preferredConditional = $object->preferredConditional($conditional); + print F " DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional(macro) \\\n"; } print F "\n"; @@ -258,7 +277,7 @@ sub generateHeadersHeader() next if defined($includedInterfaces{$interfaceName}); $includedInterfaces{$interfaceName} = 1; - print F "#if ENABLE($conditional)\n" if $conditional; + print F "#if " . $object->conditionalStringFromAttributeValue($conditional) . "\n" if $conditional; print F "#include \"$interfaceName.h\"\n"; print F "#if USE(JSC)\n"; print F "#include \"JS$interfaceName.h\"\n"; diff --git a/Source/WebCore/bindings/scripts/preprocessor.pm b/Source/WebCore/bindings/scripts/preprocessor.pm index e1da48806..86a7e382c 100644 --- a/Source/WebCore/bindings/scripts/preprocessor.pm +++ b/Source/WebCore/bindings/scripts/preprocessor.pm @@ -21,6 +21,7 @@ use strict; use warnings; +use Config; use IPC::Open2; BEGIN { @@ -40,17 +41,17 @@ sub applyPreprocessor my $defines = shift; my $preprocessor = shift; + my @args = (); if (!$preprocessor) { require Config; - my $gccLocation = ""; if ($ENV{CC}) { - $gccLocation = $ENV{CC}; + $preprocessor = $ENV{CC}; } elsif (($Config::Config{'osname'}) =~ /solaris/i) { - $gccLocation = "/usr/sfw/bin/gcc"; + $preprocessor = "/usr/sfw/bin/gcc"; } else { - $gccLocation = "/usr/bin/gcc"; + $preprocessor = "/usr/bin/gcc"; } - $preprocessor = $gccLocation . " -E -P -x c++"; + push(@args, qw(-E -P -x c++)); } # Remove double quotations from $defines and extract macros. @@ -60,7 +61,20 @@ sub applyPreprocessor my @macros = grep { $_ } split(/\s+/, $defines); # grep skips empty macros. @macros = map { "-D$_" } @macros; - my $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), @macros, $fileName); + my $pid = 0; + if ($Config{osname} eq "cygwin") { + # This call can fail if Windows rebases cygwin, so retry a few times until it succeeds. + for (my $tries = 0; !$pid && ($tries < 20); $tries++) { + eval { + $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), @args, @macros, $fileName); + 1; + } or do { + sleep 1; + } + }; + } else { + $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), @args, @macros, $fileName); + } close PP_IN; my @documentContent = <PP_OUT>; close PP_OUT; diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp index a082c4ad3..963efb4cd 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.cpp @@ -27,14 +27,18 @@ #include "Class1.h" #include "Class2.h" #include "Class3.h" +#include "Class8.h" #include "DOMStringList.h" #include "KURL.h" #include "TestCallback.h" +#include "ThisClass.h" #include "WebDOMClass1.h" #include "WebDOMClass2.h" #include "WebDOMClass3.h" +#include "WebDOMClass8.h" #include "WebDOMDOMStringList.h" #include "WebDOMString.h" +#include "WebDOMThisClass.h" #include "WebExceptionHandler.h" #include "wtf/text/AtomicString.h" #include <wtf/GetPtr.h> @@ -125,6 +129,22 @@ bool WebDOMTestCallback::callbackWithStringList(const WebDOMDOMStringList& listP return impl()->callbackWithStringList(toWebCore(listParam)); } +bool WebDOMTestCallback::callbackWithBoolean(bool boolParam) +{ + if (!impl()) + return false; + + return impl()->callbackWithBoolean(boolParam); +} + +bool WebDOMTestCallback::callbackRequiresThisToPass(const WebDOMClass8& class8Param, const WebDOMThisClass& thisClassParam) +{ + if (!impl()) + return false; + + return impl()->callbackRequiresThisToPass(toWebCore(class8Param), toWebCore(thisClassParam)); +} + WebCore::TestCallback* toWebCore(const WebDOMTestCallback& wrapper) { return wrapper.impl(); diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h index cec8b6c3c..8d9a230bd 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestCallback.h @@ -35,7 +35,9 @@ class TestCallback; class WebDOMClass1; class WebDOMClass2; class WebDOMClass3; +class WebDOMClass8; class WebDOMDOMStringList; +class WebDOMThisClass; class WebDOMTestCallback : public WebDOMObject { public: @@ -50,6 +52,8 @@ public: bool callbackWithClass2Param(const WebDOMClass2& class2Param, const WebDOMString& strArg); int callbackWithNonBoolReturnType(const WebDOMClass3& class3Param); bool callbackWithStringList(const WebDOMDOMStringList& listParam); + bool callbackWithBoolean(bool boolParam); + bool callbackRequiresThisToPass(const WebDOMClass8& class8Param, const WebDOMThisClass& thisClassParam); WebCore::TestCallback* impl() const; diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestException.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestException.cpp new file mode 100644 index 000000000..66bbbc3a0 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestException.cpp @@ -0,0 +1,93 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * 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 "WebDOMTestException.h" + +#include "KURL.h" +#include "TestException.h" +#include "WebDOMString.h" +#include "WebExceptionHandler.h" +#include "wtf/text/AtomicString.h" +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +struct WebDOMTestException::WebDOMTestExceptionPrivate { + WebDOMTestExceptionPrivate(WebCore::TestException* object = 0) + : impl(object) + { + } + + RefPtr<WebCore::TestException> impl; +}; + +WebDOMTestException::WebDOMTestException() + : WebDOMObject() + , m_impl(0) +{ +} + +WebDOMTestException::WebDOMTestException(WebCore::TestException* impl) + : WebDOMObject() + , m_impl(new WebDOMTestExceptionPrivate(impl)) +{ +} + +WebDOMTestException::WebDOMTestException(const WebDOMTestException& copy) + : WebDOMObject() +{ + m_impl = copy.impl() ? new WebDOMTestExceptionPrivate(copy.impl()) : 0; +} + +WebDOMTestException& WebDOMTestException::operator=(const WebDOMTestException& copy) +{ + delete m_impl; + m_impl = copy.impl() ? new WebDOMTestExceptionPrivate(copy.impl()) : 0; + return *this; +} + +WebCore::TestException* WebDOMTestException::impl() const +{ + return m_impl ? WTF::getPtr(m_impl->impl) : 0; +} + +WebDOMTestException::~WebDOMTestException() +{ + delete m_impl; + m_impl = 0; +} + +WebDOMString WebDOMTestException::name() const +{ + if (!impl()) + return WebDOMString(); + + return static_cast<const WTF::String&>(impl()->name()); +} + +WebCore::TestException* toWebCore(const WebDOMTestException& wrapper) +{ + return wrapper.impl(); +} + +WebDOMTestException toWebKit(WebCore::TestException* value) +{ + return WebDOMTestException(value); +} diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestException.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestException.h new file mode 100644 index 000000000..9d95c6627 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestException.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * 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. + */ + +#ifndef WebDOMTestException_h +#define WebDOMTestException_h + +#include <WebDOMObject.h> +#include <WebDOMString.h> + +namespace WebCore { +class TestException; +}; + + +class WebDOMTestException : public WebDOMObject { +public: + WebDOMTestException(); + explicit WebDOMTestException(WebCore::TestException*); + WebDOMTestException(const WebDOMTestException&); + WebDOMTestException& operator=(const WebDOMTestException&); + virtual ~WebDOMTestException(); + + WebDOMString name() const; + + WebCore::TestException* impl() const; + +protected: + struct WebDOMTestExceptionPrivate; + WebDOMTestExceptionPrivate* m_impl; +}; + +WebCore::TestException* toWebCore(const WebDOMTestException&); +WebDOMTestException toWebKit(WebCore::TestException*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestNode.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestNode.cpp new file mode 100644 index 000000000..ce1449a04 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestNode.cpp @@ -0,0 +1,52 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * 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 "WebDOMTestNode.h" + +#include "TestNode.h" +#include "WebExceptionHandler.h" +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +WebDOMTestNode::WebDOMTestNode() + : WebDOMNode() +{ +} + +WebDOMTestNode::WebDOMTestNode(WebCore::TestNode* impl) + : WebDOMNode(impl) +{ +} + +WebCore::TestNode* WebDOMTestNode::impl() const +{ + return static_cast<WebCore::TestNode*>(WebDOMNode::impl()); +} + +WebCore::TestNode* toWebCore(const WebDOMTestNode& wrapper) +{ + return wrapper.impl(); +} + +WebDOMTestNode toWebKit(WebCore::TestNode* value) +{ + return WebDOMTestNode(value); +} diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestNode.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestNode.h new file mode 100644 index 000000000..b363f2dc2 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestNode.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) Research In Motion Limited 2010. All rights reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * 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. + */ + +#ifndef WebDOMTestNode_h +#define WebDOMTestNode_h + +#include <WebDOMNode.h> +#include <WebDOMString.h> + +namespace WebCore { +class TestNode; +}; + + +class WebDOMTestNode : public WebDOMNode { +public: + WebDOMTestNode(); + explicit WebDOMTestNode(WebCore::TestNode*); + virtual ~WebDOMTestNode() { } + + + WebCore::TestNode* impl() const; +}; + +WebCore::TestNode* toWebCore(const WebDOMTestNode&); +WebDOMTestNode toWebKit(WebCore::TestNode*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp index 9d63fdde7..cb61197ed 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.cpp @@ -21,17 +21,17 @@ #include "config.h" #include "WebDOMTestObj.h" +#include "Dictionary.h" #include "Document.h" #include "HTMLNames.h" #include "IDBKey.h" #include "KURL.h" -#include "OptionsObject.h" #include "SVGPoint.h" #include "SerializedScriptValue.h" #include "TestObj.h" +#include "WebDOMDictionary.h" #include "WebDOMDocument.h" #include "WebDOMIDBKey.h" -#include "WebDOMOptionsObject.h" #include "WebDOMSVGPoint.h" #include "WebDOMString.h" #include "WebDOMa.h" @@ -581,6 +581,22 @@ void WebDOMTestObj::setImmutablePoint(const WebDOMSVGPoint& newImmutablePoint) impl()->setImmutablePoint(toWebCore(newImmutablePoint)); } +int WebDOMTestObj::strawberry() const +{ + if (!impl()) + return 0; + + return impl()->blueberry(); +} + +void WebDOMTestObj::setStrawberry(int newStrawberry) +{ + if (!impl()) + return; + + impl()->setBlueberry(newStrawberry); +} + float WebDOMTestObj::strictFloat() const { if (!impl()) @@ -704,7 +720,7 @@ void WebDOMTestObj::idbKey(const WebDOMIDBKey& key) impl()->idbKey(toWebCore(key)); } -void WebDOMTestObj::optionsObject(const WebDOMOptionsObject& oo, const WebDOMOptionsObject& ooo) +void WebDOMTestObj::optionsObject(const WebDOMDictionary& oo, const WebDOMDictionary& ooo) { if (!impl()) return; diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h index 8c72f2333..a5cf99e59 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestObj.h @@ -30,10 +30,10 @@ namespace WebCore { class TestObj; }; +class WebDOMDictionary; class WebDOMDocument; class WebDOMEventListener; class WebDOMIDBKey; -class WebDOMOptionsObject; class WebDOMSVGPoint; class WebDOMString; class WebDOMTestObj; @@ -134,6 +134,8 @@ public: void setMutablePoint(const WebDOMSVGPoint&); WebDOMSVGPoint immutablePoint() const; void setImmutablePoint(const WebDOMSVGPoint&); + int strawberry() const; + void setStrawberry(int); float strictFloat() const; void setStrictFloat(float); int description() const; @@ -150,7 +152,7 @@ public: WebDOMTestObj methodThatRequiresAllArgsAndThrows(const WebDOMString& strArg, const WebDOMTestObj& objArg); void serializedValue(const WebDOMString& serializedArg); void idbKey(const WebDOMIDBKey& key); - void optionsObject(const WebDOMOptionsObject& oo, const WebDOMOptionsObject& ooo); + void optionsObject(const WebDOMDictionary& oo, const WebDOMDictionary& ooo); void methodWithException(); void addEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture); void removeEventListener(const WebDOMString& type, const WebDOMEventListener& listener, bool useCapture); diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.cpp index 541546450..ad68c9a7b 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.cpp @@ -24,8 +24,12 @@ #include "WebDOMTestSerializedScriptValueInterface.h" +#include "Array.h" +#include "MessagePortArray.h" #include "SerializedScriptValue.h" #include "TestSerializedScriptValueInterface.h" +#include "WebDOMArray.h" +#include "WebDOMMessagePortArray.h" #include "WebExceptionHandler.h" #include <wtf/GetPtr.h> #include <wtf/RefPtr.h> @@ -115,6 +119,14 @@ void WebDOMTestSerializedScriptValueInterface::setCachedValue(const WebDOMString impl()->setCachedValue(WebCore::SerializedScriptValue::create(WTF::String(newCachedValue))); } +WebDOMMessagePortArray WebDOMTestSerializedScriptValueInterface::ports() const +{ + if (!impl()) + return WebDOMMessagePortArray(); + + return toWebKit(WTF::getPtr(impl()->ports())); +} + WebDOMString WebDOMTestSerializedScriptValueInterface::cachedReadonlyValue() const { if (!impl()) @@ -123,6 +135,22 @@ WebDOMString WebDOMTestSerializedScriptValueInterface::cachedReadonlyValue() con return impl()->cachedReadonlyValue()->toString(); } +void WebDOMTestSerializedScriptValueInterface::acceptTransferList(const WebDOMString& data, const WebDOMArray& transferList) +{ + if (!impl()) + return; + + impl()->acceptTransferList(WebCore::SerializedScriptValue::create(WTF::String(data)), toWebCore(transferList)); +} + +void WebDOMTestSerializedScriptValueInterface::multiTransferList(const WebDOMString& first, const WebDOMArray& tx, const WebDOMString& second, const WebDOMArray& txx) +{ + if (!impl()) + return; + + impl()->multiTransferList(WebCore::SerializedScriptValue::create(WTF::String(first)), toWebCore(tx), WebCore::SerializedScriptValue::create(WTF::String(second)), toWebCore(txx)); +} + WebCore::TestSerializedScriptValueInterface* toWebCore(const WebDOMTestSerializedScriptValueInterface& wrapper) { return wrapper.impl(); diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.h index d03b75e6a..13e5655cf 100644 --- a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.h +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.h @@ -32,6 +32,8 @@ namespace WebCore { class TestSerializedScriptValueInterface; }; +class WebDOMArray; +class WebDOMMessagePortArray; class WebDOMString; class WebDOMTestSerializedScriptValueInterface : public WebDOMObject { @@ -47,8 +49,12 @@ public: WebDOMString readonlyValue() const; WebDOMString cachedValue() const; void setCachedValue(const WebDOMString&); + WebDOMMessagePortArray ports() const; WebDOMString cachedReadonlyValue() const; + void acceptTransferList(const WebDOMString& data, const WebDOMArray& transferList); + void multiTransferList(const WebDOMString& first, const WebDOMArray& tx, const WebDOMString& second, const WebDOMArray& txx); + WebCore::TestSerializedScriptValueInterface* impl() const; protected: diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.cpp index 34033de62..3ab8d4aed 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.cpp @@ -18,11 +18,9 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMFloat64Array.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "Float64Array.h" @@ -32,16 +30,18 @@ #include "gobject/ConvertToUTF8String.h" #include "webkit/WebKitDOMFloat32Array.h" #include "webkit/WebKitDOMFloat32ArrayPrivate.h" -#include "webkit/WebKitDOMFloat64Array.h" #include "webkit/WebKitDOMFloat64ArrayPrivate.h" #include "webkit/WebKitDOMInt32Array.h" #include "webkit/WebKitDOMInt32ArrayPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMFloat64Array* kit(WebCore::Float64Array* obj) { g_return_val_if_fail(obj, 0); @@ -51,30 +51,6 @@ WebKitDOMFloat64Array* kit(WebCore::Float64Array* obj) return static_cast<WebKitDOMFloat64Array*>(DOMObjectCache::put(obj, WebKit::wrapFloat64Array(obj))); } - -} // namespace WebKit // - -WebKitDOMInt32Array* -webkit_dom_float64array_foo(WebKitDOMFloat64Array* self, WebKitDOMFloat32Array* array) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::Float64Array * item = WebKit::core(self); - g_return_val_if_fail(array, 0); - WebCore::Float32Array * converted_array = NULL; - if (array != NULL) { - converted_array = WebKit::core(array); - g_return_val_if_fail(converted_array, 0); - } - PassRefPtr<WebCore::Int32Array> g_res = WTF::getPtr(item->foo(converted_array)); - WebKitDOMInt32Array* res = WebKit::kit(g_res.get()); - return res; -} - - -G_DEFINE_TYPE(WebKitDOMFloat64Array, webkit_dom_float64array, WEBKIT_TYPE_DOM_ARRAY_BUFFER_VIEW) - -namespace WebKit { WebCore::Float64Array* core(WebKitDOMFloat64Array* request) { @@ -86,45 +62,60 @@ WebCore::Float64Array* core(WebKitDOMFloat64Array* request) return coreObject; } +WebKitDOMFloat64Array* wrapFloat64Array(WebCore::Float64Array* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_FLOAT64ARRAY(g_object_new(WEBKIT_TYPE_DOM_FLOAT64ARRAY, "core-object", coreObject, NULL)); +} + } // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMFloat64Array, webkit_dom_float64array, WEBKIT_TYPE_DOM_ARRAY_BUFFER_VIEW) + enum { PROP_0, }; - static void webkit_dom_float64array_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::Float64Array* coreObject = static_cast<WebCore::Float64Array *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::Float64Array* coreObject = static_cast<WebCore::Float64Array*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } + G_OBJECT_CLASS(webkit_dom_float64array_parent_class)->finalize(object); } -static void webkit_dom_float64array_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_float64array_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_float64array_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_float64array_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -139,7 +130,7 @@ static void webkit_dom_float64array_constructed(GObject* object) static void webkit_dom_float64array_class_init(WebKitDOMFloat64ArrayClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_float64array_finalize; gobjectClass->set_property = webkit_dom_float64array_set_property; gobjectClass->get_property = webkit_dom_float64array_get_property; @@ -153,18 +144,20 @@ static void webkit_dom_float64array_init(WebKitDOMFloat64Array* request) { } -namespace WebKit { -WebKitDOMFloat64Array* wrapFloat64Array(WebCore::Float64Array* coreObject) +WebKitDOMInt32Array* +webkit_dom_float64array_foo(WebKitDOMFloat64Array* self, WebKitDOMFloat32Array* array) { - g_return_val_if_fail(coreObject, 0); - - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); - - return WEBKIT_DOM_FLOAT64ARRAY(g_object_new(WEBKIT_TYPE_DOM_FLOAT64ARRAY, - "core-object", coreObject, NULL)); + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::Float64Array* item = WebKit::core(self); + g_return_val_if_fail(array, 0); + WebCore::Float32Array* convertedArray = 0; + if (array) { + convertedArray = WebKit::core(array); + g_return_val_if_fail(convertedArray, 0); + } + RefPtr<WebCore::Int32Array> gobjectResult = WTF::getPtr(item->foo(convertedArray)); + WebKitDOMInt32Array* result = WebKit::kit(gobjectResult.get()); + return result; } -} // namespace WebKit + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.h index 0dbc986f7..addbc851d 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64Array.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMFloat64Array_h #define WebKitDOMFloat64Array_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMArrayBufferView.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMArrayBufferView.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_FLOAT64ARRAY (webkit_dom_float64array_get_type()) diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64ArrayPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64ArrayPrivate.h index b0ec614f2..8fa93b8bf 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64ArrayPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMFloat64ArrayPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_FLOAT64ARRAY_PRIVATE_H -#define WEB_KIT_DOM_FLOAT64ARRAY_PRIVATE_H +#ifndef WebKitDOMFloat64ArrayPrivate_h +#define WebKitDOMFloat64ArrayPrivate_h +#include "Float64Array.h" #include <glib-object.h> #include <webkit/WebKitDOMArrayBufferView.h> -#include "Float64Array.h" -namespace WebKit { - WebKitDOMFloat64Array * - wrapFloat64Array(WebCore::Float64Array *coreObject); - - WebCore::Float64Array * - core(WebKitDOMFloat64Array *request); - - WebKitDOMFloat64Array* - kit(WebCore::Float64Array* node); +namespace WebKit { +WebKitDOMFloat64Array* wrapFloat64Array(WebCore::Float64Array*); +WebCore::Float64Array* core(WebKitDOMFloat64Array* request); +WebKitDOMFloat64Array* kit(WebCore::Float64Array* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_FLOAT64ARRAY_PRIVATE_H */ +#endif /* WebKitDOMFloat64ArrayPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.cpp index c93a92cd9..cd6ade536 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.cpp @@ -18,11 +18,9 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestActiveDOMObject.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" @@ -31,14 +29,16 @@ #include "gobject/ConvertToUTF8String.h" #include "webkit/WebKitDOMNode.h" #include "webkit/WebKitDOMNodePrivate.h" -#include "webkit/WebKitDOMTestActiveDOMObject.h" #include "webkit/WebKitDOMTestActiveDOMObjectPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMTestActiveDOMObject* kit(WebCore::TestActiveDOMObject* obj) { g_return_val_if_fail(obj, 0); @@ -48,49 +48,6 @@ WebKitDOMTestActiveDOMObject* kit(WebCore::TestActiveDOMObject* obj) return static_cast<WebKitDOMTestActiveDOMObject*>(DOMObjectCache::put(obj, WebKit::wrapTestActiveDOMObject(obj))); } - -} // namespace WebKit // - -void -webkit_dom_test_active_dom_object_exciting_function(WebKitDOMTestActiveDOMObject* self, WebKitDOMNode* next_child) -{ - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestActiveDOMObject * item = WebKit::core(self); - g_return_if_fail(next_child); - WebCore::Node * converted_next_child = NULL; - if (next_child != NULL) { - converted_next_child = WebKit::core(next_child); - g_return_if_fail(converted_next_child); - } - item->excitingFunction(converted_next_child); -} - -void -webkit_dom_test_active_dom_object_post_message(WebKitDOMTestActiveDOMObject* self, const gchar* message) -{ - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestActiveDOMObject * item = WebKit::core(self); - g_return_if_fail(message); - WTF::String converted_message = WTF::String::fromUTF8(message); - item->postMessage(converted_message); -} - -glong -webkit_dom_test_active_dom_object_get_exciting_attr(WebKitDOMTestActiveDOMObject* self) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestActiveDOMObject * item = WebKit::core(self); - glong res = item->excitingAttr(); - return res; -} - - -G_DEFINE_TYPE(WebKitDOMTestActiveDOMObject, webkit_dom_test_active_dom_object, WEBKIT_TYPE_DOM_OBJECT) - -namespace WebKit { WebCore::TestActiveDOMObject* core(WebKitDOMTestActiveDOMObject* request) { @@ -102,53 +59,67 @@ WebCore::TestActiveDOMObject* core(WebKitDOMTestActiveDOMObject* request) return coreObject; } +WebKitDOMTestActiveDOMObject* wrapTestActiveDOMObject(WebCore::TestActiveDOMObject* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_ACTIVE_DOM_OBJECT(g_object_new(WEBKIT_TYPE_DOM_TEST_ACTIVE_DOM_OBJECT, "core-object", coreObject, NULL)); +} + } // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMTestActiveDOMObject, webkit_dom_test_active_dom_object, WEBKIT_TYPE_DOM_OBJECT) + enum { PROP_0, PROP_EXCITING_ATTR, }; - static void webkit_dom_test_active_dom_object_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestActiveDOMObject* coreObject = static_cast<WebCore::TestActiveDOMObject *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestActiveDOMObject* coreObject = static_cast<WebCore::TestActiveDOMObject*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } + G_OBJECT_CLASS(webkit_dom_test_active_dom_object_parent_class)->finalize(object); } -static void webkit_dom_test_active_dom_object_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_active_dom_object_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_active_dom_object_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_active_dom_object_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; WebKitDOMTestActiveDOMObject* self = WEBKIT_DOM_TEST_ACTIVE_DOM_OBJECT(object); WebCore::TestActiveDOMObject* coreSelf = WebKit::core(self); - switch (prop_id) { - case PROP_EXCITING_ATTR: - { + switch (propertyId) { + case PROP_EXCITING_ATTR: { g_value_set_long(value, coreSelf->excitingAttr()); break; } default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -163,7 +134,7 @@ static void webkit_dom_test_active_dom_object_constructed(GObject* object) static void webkit_dom_test_active_dom_object_class_init(WebKitDOMTestActiveDOMObjectClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_active_dom_object_finalize; gobjectClass->set_property = webkit_dom_test_active_dom_object_set_property; gobjectClass->get_property = webkit_dom_test_active_dom_object_get_property; @@ -186,18 +157,39 @@ static void webkit_dom_test_active_dom_object_init(WebKitDOMTestActiveDOMObject* { } -namespace WebKit { -WebKitDOMTestActiveDOMObject* wrapTestActiveDOMObject(WebCore::TestActiveDOMObject* coreObject) +void +webkit_dom_test_active_dom_object_exciting_function(WebKitDOMTestActiveDOMObject* self, WebKitDOMNode* nextChild) { - g_return_val_if_fail(coreObject, 0); + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestActiveDOMObject* item = WebKit::core(self); + g_return_if_fail(nextChild); + WebCore::Node* convertedNextChild = 0; + if (nextChild) { + convertedNextChild = WebKit::core(nextChild); + g_return_if_fail(convertedNextChild); + } + item->excitingFunction(convertedNextChild); +} - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); +void +webkit_dom_test_active_dom_object_post_message(WebKitDOMTestActiveDOMObject* self, const gchar* message) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestActiveDOMObject* item = WebKit::core(self); + g_return_if_fail(message); + WTF::String convertedMessage = WTF::String::fromUTF8(message); + item->postMessage(convertedMessage); +} - return WEBKIT_DOM_TEST_ACTIVE_DOM_OBJECT(g_object_new(WEBKIT_TYPE_DOM_TEST_ACTIVE_DOM_OBJECT, - "core-object", coreObject, NULL)); +glong +webkit_dom_test_active_dom_object_get_exciting_attr(WebKitDOMTestActiveDOMObject* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestActiveDOMObject* item = WebKit::core(self); + glong result = item->excitingAttr(); + return result; } -} // namespace WebKit + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.h index f3cfdb3a9..42594a056 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObject.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestActiveDOMObject_h #define WebKitDOMTestActiveDOMObject_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_ACTIVE_DOM_OBJECT (webkit_dom_test_active_dom_object_get_type()) @@ -49,13 +48,13 @@ webkit_dom_test_active_dom_object_get_type (void); /** * webkit_dom_test_active_dom_object_exciting_function: * @self: A #WebKitDOMTestActiveDOMObject - * @next_child: A #WebKitDOMNode + * @nextChild: A #WebKitDOMNode * * Returns: * **/ WEBKIT_API void -webkit_dom_test_active_dom_object_exciting_function(WebKitDOMTestActiveDOMObject* self, WebKitDOMNode* next_child); +webkit_dom_test_active_dom_object_exciting_function(WebKitDOMTestActiveDOMObject* self, WebKitDOMNode* nextChild); /** * webkit_dom_test_active_dom_object_post_message: diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObjectPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObjectPrivate.h index f28c7f9d1..547cdaae3 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObjectPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestActiveDOMObjectPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_ACTIVE_DOM_OBJECT_PRIVATE_H -#define WEB_KIT_DOM_TEST_ACTIVE_DOM_OBJECT_PRIVATE_H +#ifndef WebKitDOMTestActiveDOMObjectPrivate_h +#define WebKitDOMTestActiveDOMObjectPrivate_h +#include "TestActiveDOMObject.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestActiveDOMObject.h" -namespace WebKit { - WebKitDOMTestActiveDOMObject * - wrapTestActiveDOMObject(WebCore::TestActiveDOMObject *coreObject); - - WebCore::TestActiveDOMObject * - core(WebKitDOMTestActiveDOMObject *request); - - WebKitDOMTestActiveDOMObject* - kit(WebCore::TestActiveDOMObject* node); +namespace WebKit { +WebKitDOMTestActiveDOMObject* wrapTestActiveDOMObject(WebCore::TestActiveDOMObject*); +WebCore::TestActiveDOMObject* core(WebKitDOMTestActiveDOMObject* request); +WebKitDOMTestActiveDOMObject* kit(WebCore::TestActiveDOMObject* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_ACTIVE_DOM_OBJECT_PRIVATE_H */ +#endif /* WebKitDOMTestActiveDOMObjectPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp index 72412f6f7..5cb21fec5 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -18,13 +18,9 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestCallback.h" -#if ENABLE(SQL_DATABASE) - -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" @@ -37,16 +33,24 @@ #include "webkit/WebKitDOMClass2Private.h" #include "webkit/WebKitDOMClass3.h" #include "webkit/WebKitDOMClass3Private.h" +#include "webkit/WebKitDOMClass8.h" +#include "webkit/WebKitDOMClass8Private.h" #include "webkit/WebKitDOMDOMStringList.h" #include "webkit/WebKitDOMDOMStringListPrivate.h" -#include "webkit/WebKitDOMTestCallback.h" #include "webkit/WebKitDOMTestCallbackPrivate.h" +#include "webkit/WebKitDOMThisClass.h" +#include "webkit/WebKitDOMThisClassPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +#if ENABLE(SQL_DATABASE) namespace WebKit { - + WebKitDOMTestCallback* kit(WebCore::TestCallback* obj) { g_return_val_if_fail(obj, 0); @@ -56,139 +60,73 @@ WebKitDOMTestCallback* kit(WebCore::TestCallback* obj) return static_cast<WebKitDOMTestCallback*>(DOMObjectCache::put(obj, WebKit::wrapTestCallback(obj))); } - -} // namespace WebKit // - -gboolean -webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestCallback * item = WebKit::core(self); - gboolean res = item->callbackWithNoParam(); - return res; -} -gboolean -webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param) +WebCore::TestCallback* core(WebKitDOMTestCallback* request) { - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestCallback * item = WebKit::core(self); - g_return_val_if_fail(class1param, 0); - WebCore::Class1 * converted_class1param = NULL; - if (class1param != NULL) { - converted_class1param = WebKit::core(class1param); - g_return_val_if_fail(converted_class1param, 0); - } - gboolean res = item->callbackWithClass1Param(converted_class1param); - return res; -} + g_return_val_if_fail(request, 0); -gboolean -webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2param, const gchar* str_arg) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestCallback * item = WebKit::core(self); - g_return_val_if_fail(class2param, 0); - g_return_val_if_fail(str_arg, 0); - WebCore::Class2 * converted_class2param = NULL; - if (class2param != NULL) { - converted_class2param = WebKit::core(class2param); - g_return_val_if_fail(converted_class2param, 0); - } - WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); - gboolean res = item->callbackWithClass2Param(converted_class2param, converted_str_arg); - return res; -} + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); -glong -webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3param) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestCallback * item = WebKit::core(self); - g_return_val_if_fail(class3param, 0); - WebCore::Class3 * converted_class3param = NULL; - if (class3param != NULL) { - converted_class3param = WebKit::core(class3param); - g_return_val_if_fail(converted_class3param, 0); - } - glong res = item->callbackWithNonBoolReturnType(converted_class3param); - return res; + return coreObject; } -gboolean -webkit_dom_test_callback_callback_with_string_list(WebKitDOMTestCallback* self, WebKitDOMDOMStringList* list_param) +WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback* coreObject) { - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestCallback * item = WebKit::core(self); - g_return_val_if_fail(list_param, 0); - WebCore::DOMStringList * converted_list_param = NULL; - if (list_param != NULL) { - converted_list_param = WebKit::core(list_param); - g_return_val_if_fail(converted_list_param, 0); - } - gboolean res = item->callbackWithStringList(converted_list_param); - return res; -} - + g_return_val_if_fail(coreObject, 0); -G_DEFINE_TYPE(WebKitDOMTestCallback, webkit_dom_test_callback, WEBKIT_TYPE_DOM_OBJECT) + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); -namespace WebKit { + return WEBKIT_DOM_TEST_CALLBACK(g_object_new(WEBKIT_TYPE_DOM_TEST_CALLBACK, "core-object", coreObject, NULL)); +} -WebCore::TestCallback* core(WebKitDOMTestCallback* request) -{ - g_return_val_if_fail(request, 0); +} // namespace WebKit - WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback*>(WEBKIT_DOM_OBJECT(request)->coreObject); - g_return_val_if_fail(coreObject, 0); +#endif // ENABLE(SQL_DATABASE) - return coreObject; -} +G_DEFINE_TYPE(WebKitDOMTestCallback, webkit_dom_test_callback, WEBKIT_TYPE_DOM_OBJECT) -} // namespace WebKit enum { PROP_0, }; - static void webkit_dom_test_callback_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); +#if ENABLE(SQL_DATABASE) + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } +#endif // ENABLE(SQL_DATABASE) G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->finalize(object); } -static void webkit_dom_test_callback_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_callback_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_callback_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_callback_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -203,7 +141,7 @@ static void webkit_dom_test_callback_constructed(GObject* object) static void webkit_dom_test_callback_class_init(WebKitDOMTestCallbackClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_callback_finalize; gobjectClass->set_property = webkit_dom_test_callback_set_property; gobjectClass->get_property = webkit_dom_test_callback_get_property; @@ -217,19 +155,146 @@ static void webkit_dom_test_callback_init(WebKitDOMTestCallback* request) { } -namespace WebKit { -WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback* coreObject) +gboolean +webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self) { - g_return_val_if_fail(coreObject, 0); +#if ENABLE(SQL_DATABASE) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback* item = WebKit::core(self); + gboolean result = item->callbackWithNoParam(); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("SQL Database") + return static_cast<gboolean>(0); +#endif /* ENABLE(SQL_DATABASE) */ +} - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); +gboolean +webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1Param) +{ +#if ENABLE(SQL_DATABASE) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback* item = WebKit::core(self); + g_return_val_if_fail(class1Param, 0); + WebCore::Class1* convertedClass1Param = 0; + if (class1Param) { + convertedClass1Param = WebKit::core(class1Param); + g_return_val_if_fail(convertedClass1Param, 0); + } + gboolean result = item->callbackWithClass1Param(convertedClass1Param); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("SQL Database") + return static_cast<gboolean>(0); +#endif /* ENABLE(SQL_DATABASE) */ +} - return WEBKIT_DOM_TEST_CALLBACK(g_object_new(WEBKIT_TYPE_DOM_TEST_CALLBACK, - "core-object", coreObject, NULL)); +gboolean +webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2Param, const gchar* strArg) +{ +#if ENABLE(SQL_DATABASE) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback* item = WebKit::core(self); + g_return_val_if_fail(class2Param, 0); + g_return_val_if_fail(strArg, 0); + WebCore::Class2* convertedClass2Param = 0; + if (class2Param) { + convertedClass2Param = WebKit::core(class2Param); + g_return_val_if_fail(convertedClass2Param, 0); + } + WTF::String convertedStrArg = WTF::String::fromUTF8(strArg); + gboolean result = item->callbackWithClass2Param(convertedClass2Param, convertedStrArg); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("SQL Database") + return static_cast<gboolean>(0); +#endif /* ENABLE(SQL_DATABASE) */ } -} // namespace WebKit + +glong +webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3Param) +{ +#if ENABLE(SQL_DATABASE) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback* item = WebKit::core(self); + g_return_val_if_fail(class3Param, 0); + WebCore::Class3* convertedClass3Param = 0; + if (class3Param) { + convertedClass3Param = WebKit::core(class3Param); + g_return_val_if_fail(convertedClass3Param, 0); + } + glong result = item->callbackWithNonBoolReturnType(convertedClass3Param); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("SQL Database") + return static_cast<glong>(0); +#endif /* ENABLE(SQL_DATABASE) */ +} + +gboolean +webkit_dom_test_callback_callback_with_string_list(WebKitDOMTestCallback* self, WebKitDOMDOMStringList* listParam) +{ +#if ENABLE(SQL_DATABASE) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback* item = WebKit::core(self); + g_return_val_if_fail(listParam, 0); + WebCore::DOMStringList* convertedListParam = 0; + if (listParam) { + convertedListParam = WebKit::core(listParam); + g_return_val_if_fail(convertedListParam, 0); + } + gboolean result = item->callbackWithStringList(convertedListParam); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("SQL Database") + return static_cast<gboolean>(0); +#endif /* ENABLE(SQL_DATABASE) */ +} + +gboolean +webkit_dom_test_callback_callback_with_boolean(WebKitDOMTestCallback* self, gboolean boolParam) +{ +#if ENABLE(SQL_DATABASE) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback* item = WebKit::core(self); + gboolean result = item->callbackWithBoolean(boolParam); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("SQL Database") + return static_cast<gboolean>(0); +#endif /* ENABLE(SQL_DATABASE) */ +} + +gboolean +webkit_dom_test_callback_callback_requires_this_to_pass(WebKitDOMTestCallback* self, WebKitDOMClass8* class8Param, WebKitDOMThisClass* thisClassParam) +{ +#if ENABLE(SQL_DATABASE) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestCallback* item = WebKit::core(self); + g_return_val_if_fail(class8Param, 0); + g_return_val_if_fail(thisClassParam, 0); + WebCore::Class8* convertedClass8Param = 0; + if (class8Param) { + convertedClass8Param = WebKit::core(class8Param); + g_return_val_if_fail(convertedClass8Param, 0); + } + WebCore::ThisClass* convertedThisClassParam = 0; + if (thisClassParam) { + convertedThisClassParam = WebKit::core(thisClassParam); + g_return_val_if_fail(convertedThisClassParam, 0); + } + gboolean result = item->callbackRequiresThisToPass(convertedClass8Param, convertedThisClassParam); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("SQL Database") + return static_cast<gboolean>(0); #endif /* ENABLE(SQL_DATABASE) */ +} + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h index 3c01fa22f..9b2e14034 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestCallback_h #define WebKitDOMTestCallback_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_CALLBACK (webkit_dom_test_callback_get_type()) @@ -59,47 +58,70 @@ webkit_dom_test_callback_callback_with_no_param(WebKitDOMTestCallback* self); /** * webkit_dom_test_callback_callback_with_class1param: * @self: A #WebKitDOMTestCallback - * @class1param: A #WebKitDOMClass1 + * @class1Param: A #WebKitDOMClass1 * * Returns: * **/ WEBKIT_API gboolean -webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1param); +webkit_dom_test_callback_callback_with_class1param(WebKitDOMTestCallback* self, WebKitDOMClass1* class1Param); /** * webkit_dom_test_callback_callback_with_class2param: * @self: A #WebKitDOMTestCallback - * @class2param: A #WebKitDOMClass2 - * @str_arg: A #gchar + * @class2Param: A #WebKitDOMClass2 + * @strArg: A #gchar * * Returns: * **/ WEBKIT_API gboolean -webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2param, const gchar* str_arg); +webkit_dom_test_callback_callback_with_class2param(WebKitDOMTestCallback* self, WebKitDOMClass2* class2Param, const gchar* strArg); /** * webkit_dom_test_callback_callback_with_non_bool_return_type: * @self: A #WebKitDOMTestCallback - * @class3param: A #WebKitDOMClass3 + * @class3Param: A #WebKitDOMClass3 * * Returns: * **/ WEBKIT_API glong -webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3param); +webkit_dom_test_callback_callback_with_non_bool_return_type(WebKitDOMTestCallback* self, WebKitDOMClass3* class3Param); /** * webkit_dom_test_callback_callback_with_string_list: * @self: A #WebKitDOMTestCallback - * @list_param: A #WebKitDOMDOMStringList + * @listParam: A #WebKitDOMDOMStringList + * + * Returns: + * +**/ +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_string_list(WebKitDOMTestCallback* self, WebKitDOMDOMStringList* listParam); + +/** + * webkit_dom_test_callback_callback_with_boolean: + * @self: A #WebKitDOMTestCallback + * @boolParam: A #gboolean + * + * Returns: + * +**/ +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_boolean(WebKitDOMTestCallback* self, gboolean boolParam); + +/** + * webkit_dom_test_callback_callback_requires_this_to_pass: + * @self: A #WebKitDOMTestCallback + * @class8Param: A #WebKitDOMClass8 + * @thisClassParam: A #WebKitDOMThisClass * * Returns: * **/ WEBKIT_API gboolean -webkit_dom_test_callback_callback_with_string_list(WebKitDOMTestCallback* self, WebKitDOMDOMStringList* list_param); +webkit_dom_test_callback_callback_requires_this_to_pass(WebKitDOMTestCallback* self, WebKitDOMClass8* class8Param, WebKitDOMThisClass* thisClassParam); G_END_DECLS diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h index 3ad6ff444..358da2d76 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h @@ -18,22 +18,20 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H -#define WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H +#ifndef WebKitDOMTestCallbackPrivate_h +#define WebKitDOMTestCallbackPrivate_h +#include "TestCallback.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestCallback.h" -namespace WebKit { - WebKitDOMTestCallback * - wrapTestCallback(WebCore::TestCallback *coreObject); - - WebCore::TestCallback * - core(WebKitDOMTestCallback *request); - - WebKitDOMTestCallback* - kit(WebCore::TestCallback* node); +#if ENABLE(SQL_DATABASE) +namespace WebKit { +WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback*); +WebCore::TestCallback* core(WebKitDOMTestCallback* request); +WebKitDOMTestCallback* kit(WebCore::TestCallback* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H */ +#endif /* ENABLE(SQL_DATABASE) */ + +#endif /* WebKitDOMTestCallbackPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.cpp index ea648f564..306baea6f 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.cpp @@ -18,25 +18,25 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestCustomNamedGetter.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" #include "TestCustomNamedGetter.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" -#include "webkit/WebKitDOMTestCustomNamedGetter.h" #include "webkit/WebKitDOMTestCustomNamedGetterPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMTestCustomNamedGetter* kit(WebCore::TestCustomNamedGetter* obj) { g_return_val_if_fail(obj, 0); @@ -46,24 +46,6 @@ WebKitDOMTestCustomNamedGetter* kit(WebCore::TestCustomNamedGetter* obj) return static_cast<WebKitDOMTestCustomNamedGetter*>(DOMObjectCache::put(obj, WebKit::wrapTestCustomNamedGetter(obj))); } - -} // namespace WebKit // - -void -webkit_dom_test_custom_named_getter_another_function(WebKitDOMTestCustomNamedGetter* self, const gchar* str) -{ - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestCustomNamedGetter * item = WebKit::core(self); - g_return_if_fail(str); - WTF::String converted_str = WTF::String::fromUTF8(str); - item->anotherFunction(converted_str); -} - - -G_DEFINE_TYPE(WebKitDOMTestCustomNamedGetter, webkit_dom_test_custom_named_getter, WEBKIT_TYPE_DOM_OBJECT) - -namespace WebKit { WebCore::TestCustomNamedGetter* core(WebKitDOMTestCustomNamedGetter* request) { @@ -75,45 +57,60 @@ WebCore::TestCustomNamedGetter* core(WebKitDOMTestCustomNamedGetter* request) return coreObject; } +WebKitDOMTestCustomNamedGetter* wrapTestCustomNamedGetter(WebCore::TestCustomNamedGetter* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_CUSTOM_NAMED_GETTER(g_object_new(WEBKIT_TYPE_DOM_TEST_CUSTOM_NAMED_GETTER, "core-object", coreObject, NULL)); +} + } // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMTestCustomNamedGetter, webkit_dom_test_custom_named_getter, WEBKIT_TYPE_DOM_OBJECT) + enum { PROP_0, }; - static void webkit_dom_test_custom_named_getter_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestCustomNamedGetter* coreObject = static_cast<WebCore::TestCustomNamedGetter *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestCustomNamedGetter* coreObject = static_cast<WebCore::TestCustomNamedGetter*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } + G_OBJECT_CLASS(webkit_dom_test_custom_named_getter_parent_class)->finalize(object); } -static void webkit_dom_test_custom_named_getter_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_custom_named_getter_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_custom_named_getter_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_custom_named_getter_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -128,7 +125,7 @@ static void webkit_dom_test_custom_named_getter_constructed(GObject* object) static void webkit_dom_test_custom_named_getter_class_init(WebKitDOMTestCustomNamedGetterClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_custom_named_getter_finalize; gobjectClass->set_property = webkit_dom_test_custom_named_getter_set_property; gobjectClass->get_property = webkit_dom_test_custom_named_getter_get_property; @@ -142,18 +139,14 @@ static void webkit_dom_test_custom_named_getter_init(WebKitDOMTestCustomNamedGet { } -namespace WebKit { -WebKitDOMTestCustomNamedGetter* wrapTestCustomNamedGetter(WebCore::TestCustomNamedGetter* coreObject) +void +webkit_dom_test_custom_named_getter_another_function(WebKitDOMTestCustomNamedGetter* self, const gchar* str) { - g_return_val_if_fail(coreObject, 0); - - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); - - return WEBKIT_DOM_TEST_CUSTOM_NAMED_GETTER(g_object_new(WEBKIT_TYPE_DOM_TEST_CUSTOM_NAMED_GETTER, - "core-object", coreObject, NULL)); + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestCustomNamedGetter* item = WebKit::core(self); + g_return_if_fail(str); + WTF::String convertedStr = WTF::String::fromUTF8(str); + item->anotherFunction(convertedStr); } -} // namespace WebKit + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.h index 956a254aa..f016e3fc4 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetter.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestCustomNamedGetter_h #define WebKitDOMTestCustomNamedGetter_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_CUSTOM_NAMED_GETTER (webkit_dom_test_custom_named_getter_get_type()) diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetterPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetterPrivate.h index fedd14afc..2e882cd8f 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetterPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCustomNamedGetterPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_CUSTOM_NAMED_GETTER_PRIVATE_H -#define WEB_KIT_DOM_TEST_CUSTOM_NAMED_GETTER_PRIVATE_H +#ifndef WebKitDOMTestCustomNamedGetterPrivate_h +#define WebKitDOMTestCustomNamedGetterPrivate_h +#include "TestCustomNamedGetter.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestCustomNamedGetter.h" -namespace WebKit { - WebKitDOMTestCustomNamedGetter * - wrapTestCustomNamedGetter(WebCore::TestCustomNamedGetter *coreObject); - - WebCore::TestCustomNamedGetter * - core(WebKitDOMTestCustomNamedGetter *request); - - WebKitDOMTestCustomNamedGetter* - kit(WebCore::TestCustomNamedGetter* node); +namespace WebKit { +WebKitDOMTestCustomNamedGetter* wrapTestCustomNamedGetter(WebCore::TestCustomNamedGetter*); +WebCore::TestCustomNamedGetter* core(WebKitDOMTestCustomNamedGetter* request); +WebKitDOMTestCustomNamedGetter* kit(WebCore::TestCustomNamedGetter* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_CUSTOM_NAMED_GETTER_PRIVATE_H */ +#endif /* WebKitDOMTestCustomNamedGetterPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.cpp index 3788f1844..8b3e98000 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.cpp @@ -18,25 +18,25 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestEventConstructor.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" #include "TestEventConstructor.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" -#include "webkit/WebKitDOMTestEventConstructor.h" #include "webkit/WebKitDOMTestEventConstructorPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMTestEventConstructor* kit(WebCore::TestEventConstructor* obj) { g_return_val_if_fail(obj, 0); @@ -46,33 +46,6 @@ WebKitDOMTestEventConstructor* kit(WebCore::TestEventConstructor* obj) return static_cast<WebKitDOMTestEventConstructor*>(DOMObjectCache::put(obj, WebKit::wrapTestEventConstructor(obj))); } - -} // namespace WebKit // - -gchar* -webkit_dom_test_event_constructor_get_attr1(WebKitDOMTestEventConstructor* self) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestEventConstructor * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->attr1()); - return res; -} - -gchar* -webkit_dom_test_event_constructor_get_attr2(WebKitDOMTestEventConstructor* self) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestEventConstructor * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->attr2()); - return res; -} - - -G_DEFINE_TYPE(WebKitDOMTestEventConstructor, webkit_dom_test_event_constructor, WEBKIT_TYPE_DOM_OBJECT) - -namespace WebKit { WebCore::TestEventConstructor* core(WebKitDOMTestEventConstructor* request) { @@ -84,59 +57,72 @@ WebCore::TestEventConstructor* core(WebKitDOMTestEventConstructor* request) return coreObject; } +WebKitDOMTestEventConstructor* wrapTestEventConstructor(WebCore::TestEventConstructor* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_EVENT_CONSTRUCTOR(g_object_new(WEBKIT_TYPE_DOM_TEST_EVENT_CONSTRUCTOR, "core-object", coreObject, NULL)); +} + } // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMTestEventConstructor, webkit_dom_test_event_constructor, WEBKIT_TYPE_DOM_OBJECT) + enum { PROP_0, PROP_ATTR1, PROP_ATTR2, }; - static void webkit_dom_test_event_constructor_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestEventConstructor* coreObject = static_cast<WebCore::TestEventConstructor *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestEventConstructor* coreObject = static_cast<WebCore::TestEventConstructor*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } + G_OBJECT_CLASS(webkit_dom_test_event_constructor_parent_class)->finalize(object); } -static void webkit_dom_test_event_constructor_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_event_constructor_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_event_constructor_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_event_constructor_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; WebKitDOMTestEventConstructor* self = WEBKIT_DOM_TEST_EVENT_CONSTRUCTOR(object); WebCore::TestEventConstructor* coreSelf = WebKit::core(self); - switch (prop_id) { - case PROP_ATTR1: - { + switch (propertyId) { + case PROP_ATTR1: { g_value_take_string(value, convertToUTF8String(coreSelf->attr1())); break; } - case PROP_ATTR2: - { + case PROP_ATTR2: { g_value_take_string(value, convertToUTF8String(coreSelf->attr2())); break; } default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -151,7 +137,7 @@ static void webkit_dom_test_event_constructor_constructed(GObject* object) static void webkit_dom_test_event_constructor_class_init(WebKitDOMTestEventConstructorClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_event_constructor_finalize; gobjectClass->set_property = webkit_dom_test_event_constructor_set_property; gobjectClass->get_property = webkit_dom_test_event_constructor_get_property; @@ -179,18 +165,23 @@ static void webkit_dom_test_event_constructor_init(WebKitDOMTestEventConstructor { } -namespace WebKit { -WebKitDOMTestEventConstructor* wrapTestEventConstructor(WebCore::TestEventConstructor* coreObject) +gchar* +webkit_dom_test_event_constructor_get_attr1(WebKitDOMTestEventConstructor* self) { - g_return_val_if_fail(coreObject, 0); - - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestEventConstructor* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->attr1()); + return result; +} - return WEBKIT_DOM_TEST_EVENT_CONSTRUCTOR(g_object_new(WEBKIT_TYPE_DOM_TEST_EVENT_CONSTRUCTOR, - "core-object", coreObject, NULL)); +gchar* +webkit_dom_test_event_constructor_get_attr2(WebKitDOMTestEventConstructor* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestEventConstructor* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->attr2()); + return result; } -} // namespace WebKit + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.h index 2f337fb60..c2f4055a1 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructor.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestEventConstructor_h #define WebKitDOMTestEventConstructor_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_EVENT_CONSTRUCTOR (webkit_dom_test_event_constructor_get_type()) diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructorPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructorPrivate.h index bc0e85289..e7fc01875 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructorPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventConstructorPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_EVENT_CONSTRUCTOR_PRIVATE_H -#define WEB_KIT_DOM_TEST_EVENT_CONSTRUCTOR_PRIVATE_H +#ifndef WebKitDOMTestEventConstructorPrivate_h +#define WebKitDOMTestEventConstructorPrivate_h +#include "TestEventConstructor.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestEventConstructor.h" -namespace WebKit { - WebKitDOMTestEventConstructor * - wrapTestEventConstructor(WebCore::TestEventConstructor *coreObject); - - WebCore::TestEventConstructor * - core(WebKitDOMTestEventConstructor *request); - - WebKitDOMTestEventConstructor* - kit(WebCore::TestEventConstructor* node); +namespace WebKit { +WebKitDOMTestEventConstructor* wrapTestEventConstructor(WebCore::TestEventConstructor*); +WebCore::TestEventConstructor* core(WebKitDOMTestEventConstructor* request); +WebKitDOMTestEventConstructor* kit(WebCore::TestEventConstructor* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_EVENT_CONSTRUCTOR_PRIVATE_H */ +#endif /* WebKitDOMTestEventConstructorPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.cpp index c6ad86e43..0233cdf39 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.cpp @@ -18,11 +18,9 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestEventTarget.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "GObjectEventListener.h" @@ -37,14 +35,16 @@ #include "webkit/WebKitDOMEventPrivate.h" #include "webkit/WebKitDOMNode.h" #include "webkit/WebKitDOMNodePrivate.h" -#include "webkit/WebKitDOMTestEventTarget.h" #include "webkit/WebKitDOMTestEventTargetPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMTestEventTarget* kit(WebCore::TestEventTarget* obj) { g_return_val_if_fail(obj, 0); @@ -54,8 +54,29 @@ WebKitDOMTestEventTarget* kit(WebCore::TestEventTarget* obj) return static_cast<WebKitDOMTestEventTarget*>(DOMObjectCache::put(obj, WebKit::wrapTestEventTarget(obj))); } - -} // namespace WebKit // + +WebCore::TestEventTarget* core(WebKitDOMTestEventTarget* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestEventTarget* coreObject = static_cast<WebCore::TestEventTarget*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +WebKitDOMTestEventTarget* wrapTestEventTarget(WebCore::TestEventTarget* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_EVENT_TARGET(g_object_new(WEBKIT_TYPE_DOM_TEST_EVENT_TARGET, "core-object", coreObject, NULL)); +} + +} // namespace WebKit static void webkit_dom_test_event_target_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error) { @@ -89,92 +110,47 @@ static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface) iface->remove_event_listener = webkit_dom_test_event_target_remove_event_listener; } -WebKitDOMNode* -webkit_dom_test_event_target_item(WebKitDOMTestEventTarget* self, gulong index) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestEventTarget * item = WebKit::core(self); - PassRefPtr<WebCore::Node> g_res = WTF::getPtr(item->item(index)); - WebKitDOMNode* res = WebKit::kit(g_res.get()); - return res; -} - -gboolean -webkit_dom_test_event_target_dispatch_event(WebKitDOMTestEventTarget* self, WebKitDOMEvent* evt, GError **error) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestEventTarget * item = WebKit::core(self); - g_return_val_if_fail(evt, 0); - WebCore::Event * converted_evt = NULL; - if (evt != NULL) { - converted_evt = WebKit::core(evt); - g_return_val_if_fail(converted_evt, 0); - } - WebCore::ExceptionCode ec = 0; - gboolean res = item->dispatchEvent(converted_evt, ec); - if (ec) { - WebCore::ExceptionCodeDescription ecdesc(ec); - g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); - } - return res; -} - - G_DEFINE_TYPE_WITH_CODE(WebKitDOMTestEventTarget, webkit_dom_test_event_target, WEBKIT_TYPE_DOM_OBJECT, G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_DOM_EVENT_TARGET, webkit_dom_event_target_init)) -namespace WebKit { - -WebCore::TestEventTarget* core(WebKitDOMTestEventTarget* request) -{ - g_return_val_if_fail(request, 0); - - WebCore::TestEventTarget* coreObject = static_cast<WebCore::TestEventTarget*>(WEBKIT_DOM_OBJECT(request)->coreObject); - g_return_val_if_fail(coreObject, 0); - - return coreObject; -} - -} // namespace WebKit enum { PROP_0, }; - static void webkit_dom_test_event_target_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestEventTarget* coreObject = static_cast<WebCore::TestEventTarget *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestEventTarget* coreObject = static_cast<WebCore::TestEventTarget*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } + G_OBJECT_CLASS(webkit_dom_test_event_target_parent_class)->finalize(object); } -static void webkit_dom_test_event_target_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_event_target_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_event_target_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_event_target_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -189,7 +165,7 @@ static void webkit_dom_test_event_target_constructed(GObject* object) static void webkit_dom_test_event_target_class_init(WebKitDOMTestEventTargetClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_event_target_finalize; gobjectClass->set_property = webkit_dom_test_event_target_set_property; gobjectClass->get_property = webkit_dom_test_event_target_get_property; @@ -203,18 +179,35 @@ static void webkit_dom_test_event_target_init(WebKitDOMTestEventTarget* request) { } -namespace WebKit { -WebKitDOMTestEventTarget* wrapTestEventTarget(WebCore::TestEventTarget* coreObject) +WebKitDOMNode* +webkit_dom_test_event_target_item(WebKitDOMTestEventTarget* self, gulong index) { - g_return_val_if_fail(coreObject, 0); - - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestEventTarget* item = WebKit::core(self); + RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(item->item(index)); + WebKitDOMNode* result = WebKit::kit(gobjectResult.get()); + return result; +} - return WEBKIT_DOM_TEST_EVENT_TARGET(g_object_new(WEBKIT_TYPE_DOM_TEST_EVENT_TARGET, - "core-object", coreObject, NULL)); +gboolean +webkit_dom_test_event_target_dispatch_event(WebKitDOMTestEventTarget* self, WebKitDOMEvent* evt, GError** error) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestEventTarget* item = WebKit::core(self); + g_return_val_if_fail(evt, 0); + WebCore::Event* convertedEvt = 0; + if (evt) { + convertedEvt = WebKit::core(evt); + g_return_val_if_fail(convertedEvt, 0); + } + WebCore::ExceptionCode ec = 0; + gboolean result = item->dispatchEvent(convertedEvt, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc(ec); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + return result; } -} // namespace WebKit + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.h index c10635b57..80f9d5205 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTarget.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestEventTarget_h #define WebKitDOMTestEventTarget_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_EVENT_TARGET (webkit_dom_test_event_target_get_type()) @@ -67,7 +66,7 @@ webkit_dom_test_event_target_item(WebKitDOMTestEventTarget* self, gulong index); * **/ WEBKIT_API gboolean -webkit_dom_test_event_target_dispatch_event(WebKitDOMTestEventTarget* self, WebKitDOMEvent* evt, GError **error); +webkit_dom_test_event_target_dispatch_event(WebKitDOMTestEventTarget* self, WebKitDOMEvent* evt, GError** error); G_END_DECLS diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTargetPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTargetPrivate.h index e5616e3df..1cac5f77f 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTargetPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestEventTargetPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_EVENT_TARGET_PRIVATE_H -#define WEB_KIT_DOM_TEST_EVENT_TARGET_PRIVATE_H +#ifndef WebKitDOMTestEventTargetPrivate_h +#define WebKitDOMTestEventTargetPrivate_h +#include "TestEventTarget.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestEventTarget.h" -namespace WebKit { - WebKitDOMTestEventTarget * - wrapTestEventTarget(WebCore::TestEventTarget *coreObject); - - WebCore::TestEventTarget * - core(WebKitDOMTestEventTarget *request); - - WebKitDOMTestEventTarget* - kit(WebCore::TestEventTarget* node); +namespace WebKit { +WebKitDOMTestEventTarget* wrapTestEventTarget(WebCore::TestEventTarget*); +WebCore::TestEventTarget* core(WebKitDOMTestEventTarget* request); +WebKitDOMTestEventTarget* kit(WebCore::TestEventTarget* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_EVENT_TARGET_PRIVATE_H */ +#endif /* WebKitDOMTestEventTargetPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestException.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestException.cpp new file mode 100644 index 000000000..74fe6a672 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestException.cpp @@ -0,0 +1,165 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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 "WebKitDOMTestException.h" + +#include "DOMObjectCache.h" +#include "ExceptionCode.h" +#include "JSMainThreadExecState.h" +#include "TestException.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMTestExceptionPrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" +#include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +namespace WebKit { + +WebKitDOMTestException* kit(WebCore::TestException* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<WebKitDOMTestException*>(ret); + + return static_cast<WebKitDOMTestException*>(DOMObjectCache::put(obj, WebKit::wrapTestException(obj))); +} + +WebCore::TestException* core(WebKitDOMTestException* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestException* coreObject = static_cast<WebCore::TestException*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +WebKitDOMTestException* wrapTestException(WebCore::TestException* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_EXCEPTION(g_object_new(WEBKIT_TYPE_DOM_TEST_EXCEPTION, "core-object", coreObject, NULL)); +} + +} // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMTestException, webkit_dom_test_exception, WEBKIT_TYPE_DOM_OBJECT) + +enum { + PROP_0, + PROP_NAME, +}; + +static void webkit_dom_test_exception_finalize(GObject* object) +{ + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); + + if (domObject->coreObject) { + WebCore::TestException* coreObject = static_cast<WebCore::TestException*>(domObject->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + domObject->coreObject = 0; + } + + + G_OBJECT_CLASS(webkit_dom_test_exception_parent_class)->finalize(object); +} + +static void webkit_dom_test_exception_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (propertyId) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + + +static void webkit_dom_test_exception_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + WebKitDOMTestException* self = WEBKIT_DOM_TEST_EXCEPTION(object); + WebCore::TestException* coreSelf = WebKit::core(self); + switch (propertyId) { + case PROP_NAME: { + g_value_take_string(value, convertToUTF8String(coreSelf->name())); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + + +static void webkit_dom_test_exception_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_exception_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_exception_parent_class)->constructed(object); +} + +static void webkit_dom_test_exception_class_init(WebKitDOMTestExceptionClass* requestClass) +{ + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_exception_finalize; + gobjectClass->set_property = webkit_dom_test_exception_set_property; + gobjectClass->get_property = webkit_dom_test_exception_get_property; + gobjectClass->constructed = webkit_dom_test_exception_constructed; + + g_object_class_install_property(gobjectClass, + PROP_NAME, + g_param_spec_string("name", /* name */ + "test_exception_name", /* short description */ + "read-only gchar* TestException.name", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + + +} + +static void webkit_dom_test_exception_init(WebKitDOMTestException* request) +{ +} + +gchar* +webkit_dom_test_exception_get_name(WebKitDOMTestException* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestException* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->name()); + return result; +} + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestException.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestException.h new file mode 100644 index 000000000..1e1aa5ca0 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestException.h @@ -0,0 +1,60 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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. +*/ + +#ifndef WebKitDOMTestException_h +#define WebKitDOMTestException_h + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include <webkit/webkitdefines.h> +#include <webkit/webkitdomdefines.h> + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_EXCEPTION (webkit_dom_test_exception_get_type()) +#define WEBKIT_DOM_TEST_EXCEPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_EXCEPTION, WebKitDOMTestException)) +#define WEBKIT_DOM_TEST_EXCEPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_EXCEPTION, WebKitDOMTestExceptionClass) +#define WEBKIT_DOM_IS_TEST_EXCEPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_EXCEPTION)) +#define WEBKIT_DOM_IS_TEST_EXCEPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_EXCEPTION)) +#define WEBKIT_DOM_TEST_EXCEPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_EXCEPTION, WebKitDOMTestExceptionClass)) + +struct _WebKitDOMTestException { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestExceptionClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_exception_get_type (void); + +/** + * webkit_dom_test_exception_get_name: + * @self: A #WebKitDOMTestException + * + * Returns: + * +**/ +WEBKIT_API gchar* +webkit_dom_test_exception_get_name(WebKitDOMTestException* self); + +G_END_DECLS + +#endif /* WebKitDOMTestException_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestExceptionPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestExceptionPrivate.h new file mode 100644 index 000000000..f8e0f3fc3 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestExceptionPrivate.h @@ -0,0 +1,34 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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. +*/ + +#ifndef WebKitDOMTestExceptionPrivate_h +#define WebKitDOMTestExceptionPrivate_h + +#include "TestException.h" +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> + +namespace WebKit { +WebKitDOMTestException* wrapTestException(WebCore::TestException*); +WebCore::TestException* core(WebKitDOMTestException* request); +WebKitDOMTestException* kit(WebCore::TestException* node); +} // namespace WebKit + +#endif /* WebKitDOMTestExceptionPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp index e6b5ac23c..fb4734fc9 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -18,13 +18,9 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestInterface.h" -#if ENABLE(Condition1) || ENABLE(Condition2) - -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" @@ -36,16 +32,20 @@ #include "gobject/ConvertToUTF8String.h" #include "webkit/WebKitDOMNode.h" #include "webkit/WebKitDOMNodePrivate.h" -#include "webkit/WebKitDOMTestInterface.h" #include "webkit/WebKitDOMTestInterfacePrivate.h" #include "webkit/WebKitDOMTestObj.h" #include "webkit/WebKitDOMTestObjPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +#if ENABLE(Condition1) || ENABLE(Condition2) namespace WebKit { - + WebKitDOMTestInterface* kit(WebCore::TestInterface* obj) { g_return_val_if_fail(obj, 0); @@ -55,228 +55,137 @@ WebKitDOMTestInterface* kit(WebCore::TestInterface* obj) return static_cast<WebKitDOMTestInterface*>(DOMObjectCache::put(obj, WebKit::wrapTestInterface(obj))); } - -} // namespace WebKit // -void -webkit_dom_test_interface_supplemental_method1(WebKitDOMTestInterface* self) -{ -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - WebCore::TestSupplemental::supplementalMethod1(item); -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -} - -WebKitDOMTestObj* -webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error) +WebCore::TestInterface* core(WebKitDOMTestInterface* request) { -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - g_return_val_if_fail(str_arg, 0); - g_return_val_if_fail(obj_arg, 0); - WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); - WebCore::TestObj * converted_obj_arg = NULL; - if (obj_arg != NULL) { - 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(WebCore::TestSupplemental::supplementalMethod2(item, converted_str_arg, converted_obj_arg, ec)); - if (ec) { - WebCore::ExceptionCodeDescription ecdesc(ec); - g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); - } - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; -#else - return NULL; -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -} + g_return_val_if_fail(request, 0); -void -webkit_dom_test_interface_supplemental_method4(WebKitDOMTestInterface* self) -{ -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - WebCore::TestSupplemental::supplementalMethod4(item); -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -} + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); -gchar* -webkit_dom_test_interface_get_supplemental_str1(WebKitDOMTestInterface* self) -{ -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - gchar* res = convertToUTF8String(WebCore::TestSupplemental::supplementalStr1(item)); - return res; -#else - return NULL; -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ + return coreObject; } -gchar* -webkit_dom_test_interface_get_supplemental_str2(WebKitDOMTestInterface* self) +WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface* coreObject) { -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - gchar* res = convertToUTF8String(WebCore::TestSupplemental::supplementalStr2(item)); - return res; -#else - return NULL; -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -} + g_return_val_if_fail(coreObject, 0); -void -webkit_dom_test_interface_set_supplemental_str2(WebKitDOMTestInterface* self, const gchar* value) -{ -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); - WebCore::TestSupplemental::setSupplementalStr2(item, converted_value); -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -} + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); -WebKitDOMNode* -webkit_dom_test_interface_get_supplemental_node(WebKitDOMTestInterface* self) -{ -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - PassRefPtr<WebCore::Node> g_res = WTF::getPtr(WebCore::TestSupplemental::supplementalNode(item)); - WebKitDOMNode* res = WebKit::kit(g_res.get()); - return res; -#else - return NULL; -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ + return WEBKIT_DOM_TEST_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_INTERFACE, "core-object", coreObject, NULL)); } -void -webkit_dom_test_interface_set_supplemental_node(WebKitDOMTestInterface* self, WebKitDOMNode* value) -{ -#if ENABLE(Condition11) || ENABLE(Condition12) - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestInterface * item = WebKit::core(self); - g_return_if_fail(value); - WebCore::Node * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); - } - WebCore::TestSupplemental::setSupplementalNode(item, converted_value); -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -} +} // namespace WebKit +#endif // ENABLE(Condition1) || ENABLE(Condition2) G_DEFINE_TYPE(WebKitDOMTestInterface, webkit_dom_test_interface, WEBKIT_TYPE_DOM_OBJECT) -namespace WebKit { - -WebCore::TestInterface* core(WebKitDOMTestInterface* request) -{ - g_return_val_if_fail(request, 0); - - WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface*>(WEBKIT_DOM_OBJECT(request)->coreObject); - g_return_val_if_fail(coreObject, 0); - - return coreObject; -} - -} // namespace WebKit enum { PROP_0, -#if ENABLE(Condition11) || ENABLE(Condition12) PROP_SUPPLEMENTAL_STR1, -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -#if ENABLE(Condition11) || ENABLE(Condition12) PROP_SUPPLEMENTAL_STR2, -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -#if ENABLE(Condition11) || ENABLE(Condition12) PROP_SUPPLEMENTAL_NODE, -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ }; - static void webkit_dom_test_interface_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); +#if ENABLE(Condition1) || ENABLE(Condition2) + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } +#endif // ENABLE(Condition1) || ENABLE(Condition2) G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->finalize(object); } -static void webkit_dom_test_interface_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_interface_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; WebKitDOMTestInterface* self = WEBKIT_DOM_TEST_INTERFACE(object); WebCore::TestInterface* coreSelf = WebKit::core(self); - switch (prop_id) { + switch (propertyId) { + case PROP_SUPPLEMENTAL_STR2: { +#if ENABLE(Condition1) || ENABLE(Condition2) #if ENABLE(Condition11) || ENABLE(Condition12) - case PROP_SUPPLEMENTAL_STR2: - { WebCore::TestSupplemental::setSupplementalStr2(coreSelf, WTF::String::fromUTF8(g_value_get_string(value))); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_interface_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_interface_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; WebKitDOMTestInterface* self = WEBKIT_DOM_TEST_INTERFACE(object); WebCore::TestInterface* coreSelf = WebKit::core(self); - switch (prop_id) { + switch (propertyId) { + case PROP_SUPPLEMENTAL_STR1: { +#if ENABLE(Condition1) || ENABLE(Condition2) #if ENABLE(Condition11) || ENABLE(Condition12) - case PROP_SUPPLEMENTAL_STR1: - { g_value_take_string(value, convertToUTF8String(WebCore::TestSupplemental::supplementalStr1(coreSelf))); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ + case PROP_SUPPLEMENTAL_STR2: { +#if ENABLE(Condition1) || ENABLE(Condition2) #if ENABLE(Condition11) || ENABLE(Condition12) - case PROP_SUPPLEMENTAL_STR2: - { g_value_take_string(value, convertToUTF8String(WebCore::TestSupplemental::supplementalStr2(coreSelf))); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ + case PROP_SUPPLEMENTAL_NODE: { +#if ENABLE(Condition1) || ENABLE(Condition2) #if ENABLE(Condition11) || ENABLE(Condition12) - case PROP_SUPPLEMENTAL_NODE: - { RefPtr<WebCore::Node> ptr = WebCore::TestSupplemental::supplementalNode(coreSelf); g_value_set_object(value, WebKit::kit(ptr.get())); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -291,13 +200,12 @@ static void webkit_dom_test_interface_constructed(GObject* object) static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_interface_finalize; gobjectClass->set_property = webkit_dom_test_interface_set_property; gobjectClass->get_property = webkit_dom_test_interface_get_property; gobjectClass->constructed = webkit_dom_test_interface_constructed; -#if ENABLE(Condition11) || ENABLE(Condition12) g_object_class_install_property(gobjectClass, PROP_SUPPLEMENTAL_STR1, g_param_spec_string("supplemental-str1", /* name */ @@ -305,8 +213,6 @@ static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* re "read-only gchar* TestInterface.supplemental-str1", /* longer - could do with some extra doc stuff here */ "", /* default */ WEBKIT_PARAM_READABLE)); -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -#if ENABLE(Condition11) || ENABLE(Condition12) g_object_class_install_property(gobjectClass, PROP_SUPPLEMENTAL_STR2, g_param_spec_string("supplemental-str2", /* name */ @@ -314,8 +220,6 @@ static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* re "read-write gchar* TestInterface.supplemental-str2", /* longer - could do with some extra doc stuff here */ "", /* default */ WEBKIT_PARAM_READWRITE)); -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ -#if ENABLE(Condition11) || ENABLE(Condition12) g_object_class_install_property(gobjectClass, PROP_SUPPLEMENTAL_NODE, g_param_spec_object("supplemental-node", /* name */ @@ -323,7 +227,6 @@ static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* re "read-write WebKitDOMNode* TestInterface.supplemental-node", /* longer - could do with some extra doc stuff here */ WEBKIT_TYPE_DOM_NODE, /* gobject type */ WEBKIT_PARAM_READWRITE)); -#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ } @@ -332,19 +235,190 @@ static void webkit_dom_test_interface_init(WebKitDOMTestInterface* request) { } -namespace WebKit { -WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface* coreObject) +void +webkit_dom_test_interface_supplemental_method1(WebKitDOMTestInterface* self) { - g_return_val_if_fail(coreObject, 0); +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + WebCore::TestSupplemental::supplementalMethod1(item); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); +WebKitDOMTestObj* +webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, const gchar* strArg, WebKitDOMTestObj* objArg, GError** error) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + g_return_val_if_fail(strArg, 0); + g_return_val_if_fail(objArg, 0); + WTF::String convertedStrArg = WTF::String::fromUTF8(strArg); + WebCore::TestObj* convertedObjArg = 0; + if (objArg) { + convertedObjArg = WebKit::core(objArg); + g_return_val_if_fail(convertedObjArg, 0); + } + WebCore::ExceptionCode ec = 0; + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(WebCore::TestSupplemental::supplementalMethod2(item, convertedStrArg, convertedObjArg, ec)); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc(ec); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") + return 0; +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} - return WEBKIT_DOM_TEST_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_INTERFACE, - "core-object", coreObject, NULL)); +void +webkit_dom_test_interface_supplemental_method4(WebKitDOMTestInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + WebCore::TestSupplemental::supplementalMethod4(item); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ } -} // namespace WebKit + +gchar* +webkit_dom_test_interface_get_supplemental_str1(WebKitDOMTestInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + gchar* result = convertToUTF8String(WebCore::TestSupplemental::supplementalStr1(item)); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") + return 0; +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; #endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +gchar* +webkit_dom_test_interface_get_supplemental_str2(WebKitDOMTestInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + gchar* result = convertToUTF8String(WebCore::TestSupplemental::supplementalStr2(item)); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") + return 0; +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +void +webkit_dom_test_interface_set_supplemental_str2(WebKitDOMTestInterface* self, const gchar* value) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + g_return_if_fail(value); + WTF::String convertedValue = WTF::String::fromUTF8(value); + WebCore::TestSupplemental::setSupplementalStr2(item, convertedValue); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +WebKitDOMNode* +webkit_dom_test_interface_get_supplemental_node(WebKitDOMTestInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + RefPtr<WebCore::Node> gobjectResult = WTF::getPtr(WebCore::TestSupplemental::supplementalNode(item)); + WebKitDOMNode* result = WebKit::kit(gobjectResult.get()); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") + return 0; +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +void +webkit_dom_test_interface_set_supplemental_node(WebKitDOMTestInterface* self, WebKitDOMNode* value) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) +#if ENABLE(Condition11) || ENABLE(Condition12) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestInterface* item = WebKit::core(self); + g_return_if_fail(value); + WebCore::Node* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); + } + WebCore::TestSupplemental::setSupplementalNode(item, convertedValue); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition11") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition12") +#endif /* ENABLE(Condition11) || ENABLE(Condition12) */ +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h index 0b688920e..c5461e907 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestInterface_h #define WebKitDOMTestInterface_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_INTERFACE (webkit_dom_test_interface_get_type()) @@ -59,15 +58,15 @@ webkit_dom_test_interface_supplemental_method1(WebKitDOMTestInterface* self); /** * webkit_dom_test_interface_supplemental_method2: * @self: A #WebKitDOMTestInterface - * @str_arg: A #gchar - * @obj_arg: A #WebKitDOMTestObj + * @strArg: A #gchar + * @objArg: A #WebKitDOMTestObj * @error: #GError * * Returns: (transfer none): * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error); +webkit_dom_test_interface_supplemental_method2(WebKitDOMTestInterface* self, const gchar* strArg, WebKitDOMTestObj* objArg, GError** error); /** * webkit_dom_test_interface_supplemental_method4: diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h index 0a4e3a207..12a6c77cf 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h @@ -18,22 +18,20 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H -#define WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H +#ifndef WebKitDOMTestInterfacePrivate_h +#define WebKitDOMTestInterfacePrivate_h +#include "TestInterface.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestInterface.h" -namespace WebKit { - WebKitDOMTestInterface * - wrapTestInterface(WebCore::TestInterface *coreObject); - - WebCore::TestInterface * - core(WebKitDOMTestInterface *request); - - WebKitDOMTestInterface* - kit(WebCore::TestInterface* node); +#if ENABLE(Condition1) || ENABLE(Condition2) +namespace WebKit { +WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface*); +WebCore::TestInterface* core(WebKitDOMTestInterface* request); +WebKitDOMTestInterface* kit(WebCore::TestInterface* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H */ +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + +#endif /* WebKitDOMTestInterfacePrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp index 5946ec0c0..b5cbdffb4 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.cpp @@ -18,25 +18,25 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestMediaQueryListListener.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" #include "TestMediaQueryListListener.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" -#include "webkit/WebKitDOMTestMediaQueryListListener.h" #include "webkit/WebKitDOMTestMediaQueryListListenerPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMTestMediaQueryListListener* kit(WebCore::TestMediaQueryListListener* obj) { g_return_val_if_fail(obj, 0); @@ -46,13 +46,6 @@ WebKitDOMTestMediaQueryListListener* kit(WebCore::TestMediaQueryListListener* ob return static_cast<WebKitDOMTestMediaQueryListListener*>(DOMObjectCache::put(obj, WebKit::wrapTestMediaQueryListListener(obj))); } - -} // namespace WebKit // - - -G_DEFINE_TYPE(WebKitDOMTestMediaQueryListListener, webkit_dom_test_media_query_list_listener, WEBKIT_TYPE_DOM_OBJECT) - -namespace WebKit { WebCore::TestMediaQueryListListener* core(WebKitDOMTestMediaQueryListListener* request) { @@ -64,45 +57,60 @@ WebCore::TestMediaQueryListListener* core(WebKitDOMTestMediaQueryListListener* r return coreObject; } +WebKitDOMTestMediaQueryListListener* wrapTestMediaQueryListListener(WebCore::TestMediaQueryListListener* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER(g_object_new(WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER, "core-object", coreObject, NULL)); +} + } // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMTestMediaQueryListListener, webkit_dom_test_media_query_list_listener, WEBKIT_TYPE_DOM_OBJECT) + enum { PROP_0, }; - static void webkit_dom_test_media_query_list_listener_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestMediaQueryListListener* coreObject = static_cast<WebCore::TestMediaQueryListListener *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestMediaQueryListListener* coreObject = static_cast<WebCore::TestMediaQueryListListener*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } + G_OBJECT_CLASS(webkit_dom_test_media_query_list_listener_parent_class)->finalize(object); } -static void webkit_dom_test_media_query_list_listener_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_media_query_list_listener_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_media_query_list_listener_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_media_query_list_listener_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -117,7 +125,7 @@ static void webkit_dom_test_media_query_list_listener_constructed(GObject* objec static void webkit_dom_test_media_query_list_listener_class_init(WebKitDOMTestMediaQueryListListenerClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_media_query_list_listener_finalize; gobjectClass->set_property = webkit_dom_test_media_query_list_listener_set_property; gobjectClass->get_property = webkit_dom_test_media_query_list_listener_get_property; @@ -131,18 +139,3 @@ static void webkit_dom_test_media_query_list_listener_init(WebKitDOMTestMediaQue { } -namespace WebKit { -WebKitDOMTestMediaQueryListListener* wrapTestMediaQueryListListener(WebCore::TestMediaQueryListListener* coreObject) -{ - g_return_val_if_fail(coreObject, 0); - - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); - - return WEBKIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER(g_object_new(WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER, - "core-object", coreObject, NULL)); -} -} // namespace WebKit diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h index 612439b52..90611274f 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListener.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestMediaQueryListListener_h #define WebKitDOMTestMediaQueryListListener_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_MEDIA_QUERY_LIST_LISTENER (webkit_dom_test_media_query_list_listener_get_type()) diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListenerPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListenerPrivate.h index 5fc652f3e..5562a4faa 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListenerPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestMediaQueryListListenerPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_PRIVATE_H -#define WEB_KIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_PRIVATE_H +#ifndef WebKitDOMTestMediaQueryListListenerPrivate_h +#define WebKitDOMTestMediaQueryListListenerPrivate_h +#include "TestMediaQueryListListener.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestMediaQueryListListener.h" -namespace WebKit { - WebKitDOMTestMediaQueryListListener * - wrapTestMediaQueryListListener(WebCore::TestMediaQueryListListener *coreObject); - - WebCore::TestMediaQueryListListener * - core(WebKitDOMTestMediaQueryListListener *request); - - WebKitDOMTestMediaQueryListListener* - kit(WebCore::TestMediaQueryListListener* node); +namespace WebKit { +WebKitDOMTestMediaQueryListListener* wrapTestMediaQueryListListener(WebCore::TestMediaQueryListListener*); +WebCore::TestMediaQueryListListener* core(WebKitDOMTestMediaQueryListListener* request); +WebKitDOMTestMediaQueryListListener* kit(WebCore::TestMediaQueryListListener* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_MEDIA_QUERY_LIST_LISTENER_PRIVATE_H */ +#endif /* WebKitDOMTestMediaQueryListListenerPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.cpp index 604172979..bba7b73f3 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.cpp @@ -18,25 +18,25 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestNamedConstructor.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" #include "TestNamedConstructor.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" -#include "webkit/WebKitDOMTestNamedConstructor.h" #include "webkit/WebKitDOMTestNamedConstructorPrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMTestNamedConstructor* kit(WebCore::TestNamedConstructor* obj) { g_return_val_if_fail(obj, 0); @@ -46,13 +46,6 @@ WebKitDOMTestNamedConstructor* kit(WebCore::TestNamedConstructor* obj) return static_cast<WebKitDOMTestNamedConstructor*>(DOMObjectCache::put(obj, WebKit::wrapTestNamedConstructor(obj))); } - -} // namespace WebKit // - - -G_DEFINE_TYPE(WebKitDOMTestNamedConstructor, webkit_dom_test_named_constructor, WEBKIT_TYPE_DOM_OBJECT) - -namespace WebKit { WebCore::TestNamedConstructor* core(WebKitDOMTestNamedConstructor* request) { @@ -64,45 +57,60 @@ WebCore::TestNamedConstructor* core(WebKitDOMTestNamedConstructor* request) return coreObject; } +WebKitDOMTestNamedConstructor* wrapTestNamedConstructor(WebCore::TestNamedConstructor* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_NAMED_CONSTRUCTOR(g_object_new(WEBKIT_TYPE_DOM_TEST_NAMED_CONSTRUCTOR, "core-object", coreObject, NULL)); +} + } // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMTestNamedConstructor, webkit_dom_test_named_constructor, WEBKIT_TYPE_DOM_OBJECT) + enum { PROP_0, }; - static void webkit_dom_test_named_constructor_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestNamedConstructor* coreObject = static_cast<WebCore::TestNamedConstructor *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestNamedConstructor* coreObject = static_cast<WebCore::TestNamedConstructor*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } + G_OBJECT_CLASS(webkit_dom_test_named_constructor_parent_class)->finalize(object); } -static void webkit_dom_test_named_constructor_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_named_constructor_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_named_constructor_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_named_constructor_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -117,7 +125,7 @@ static void webkit_dom_test_named_constructor_constructed(GObject* object) static void webkit_dom_test_named_constructor_class_init(WebKitDOMTestNamedConstructorClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_named_constructor_finalize; gobjectClass->set_property = webkit_dom_test_named_constructor_set_property; gobjectClass->get_property = webkit_dom_test_named_constructor_get_property; @@ -131,18 +139,3 @@ static void webkit_dom_test_named_constructor_init(WebKitDOMTestNamedConstructor { } -namespace WebKit { -WebKitDOMTestNamedConstructor* wrapTestNamedConstructor(WebCore::TestNamedConstructor* coreObject) -{ - g_return_val_if_fail(coreObject, 0); - - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); - - return WEBKIT_DOM_TEST_NAMED_CONSTRUCTOR(g_object_new(WEBKIT_TYPE_DOM_TEST_NAMED_CONSTRUCTOR, - "core-object", coreObject, NULL)); -} -} // namespace WebKit diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.h index b0f9c278f..cc05bef61 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructor.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestNamedConstructor_h #define WebKitDOMTestNamedConstructor_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_NAMED_CONSTRUCTOR (webkit_dom_test_named_constructor_get_type()) diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructorPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructorPrivate.h index b585171c2..dc7344df4 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructorPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNamedConstructorPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_NAMED_CONSTRUCTOR_PRIVATE_H -#define WEB_KIT_DOM_TEST_NAMED_CONSTRUCTOR_PRIVATE_H +#ifndef WebKitDOMTestNamedConstructorPrivate_h +#define WebKitDOMTestNamedConstructorPrivate_h +#include "TestNamedConstructor.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestNamedConstructor.h" -namespace WebKit { - WebKitDOMTestNamedConstructor * - wrapTestNamedConstructor(WebCore::TestNamedConstructor *coreObject); - - WebCore::TestNamedConstructor * - core(WebKitDOMTestNamedConstructor *request); - - WebKitDOMTestNamedConstructor* - kit(WebCore::TestNamedConstructor* node); +namespace WebKit { +WebKitDOMTestNamedConstructor* wrapTestNamedConstructor(WebCore::TestNamedConstructor*); +WebCore::TestNamedConstructor* core(WebKitDOMTestNamedConstructor* request); +WebKitDOMTestNamedConstructor* kit(WebCore::TestNamedConstructor* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_NAMED_CONSTRUCTOR_PRIVATE_H */ +#endif /* WebKitDOMTestNamedConstructorPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNode.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNode.cpp new file mode 100644 index 000000000..d74877381 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNode.cpp @@ -0,0 +1,176 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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 "WebKitDOMTestNode.h" + +#include "DOMObjectCache.h" +#include "ExceptionCode.h" +#include "GObjectEventListener.h" +#include "JSMainThreadExecState.h" +#include "TestNode.h" +#include "WebKitDOMBinding.h" +#include "WebKitDOMEventPrivate.h" +#include "WebKitDOMEventTarget.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMTestNodePrivate.h" +#include "webkitdefines.h" +#include "webkitglobalsprivate.h" +#include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +namespace WebKit { + +WebKitDOMTestNode* kit(WebCore::TestNode* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<WebKitDOMTestNode*>(ret); + + return static_cast<WebKitDOMTestNode*>(DOMObjectCache::put(obj, WebKit::wrapTestNode(obj))); +} + +WebCore::TestNode* core(WebKitDOMTestNode* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestNode* coreObject = static_cast<WebCore::TestNode*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +WebKitDOMTestNode* wrapTestNode(WebCore::TestNode* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_NODE(g_object_new(WEBKIT_TYPE_DOM_TEST_NODE, "core-object", coreObject, NULL)); +} + +} // namespace WebKit + +static void webkit_dom_test_node_dispatch_event(WebKitDOMEventTarget* target, WebKitDOMEvent* event, GError** error) +{ + WebCore::Event* coreEvent = WebKit::core(event); + WebCore::TestNode* coreTarget = static_cast<WebCore::TestNode*>(WEBKIT_DOM_OBJECT(target)->coreObject); + + WebCore::ExceptionCode ec = 0; + coreTarget->dispatchEvent(coreEvent, ec); + if (ec) { + WebCore::ExceptionCodeDescription description(ec); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), description.code, description.name); + } +} + +static gboolean webkit_dom_test_node_add_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble, gpointer userData) +{ + WebCore::TestNode* coreTarget = static_cast<WebCore::TestNode*>(WEBKIT_DOM_OBJECT(target)->coreObject); + return WebCore::GObjectEventListener::addEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble, userData); +} + +static gboolean webkit_dom_test_node_remove_event_listener(WebKitDOMEventTarget* target, const char* eventName, GCallback handler, gboolean bubble) +{ + WebCore::TestNode* coreTarget = static_cast<WebCore::TestNode*>(WEBKIT_DOM_OBJECT(target)->coreObject); + return WebCore::GObjectEventListener::removeEventListener(G_OBJECT(target), coreTarget, eventName, handler, bubble); +} + +static void webkit_dom_event_target_init(WebKitDOMEventTargetIface* iface) +{ + iface->dispatch_event = webkit_dom_test_node_dispatch_event; + iface->add_event_listener = webkit_dom_test_node_add_event_listener; + iface->remove_event_listener = webkit_dom_test_node_remove_event_listener; +} + +G_DEFINE_TYPE_WITH_CODE(WebKitDOMTestNode, webkit_dom_test_node, WEBKIT_TYPE_DOM_NODE, G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_DOM_EVENT_TARGET, webkit_dom_event_target_init)) + +enum { + PROP_0, +}; + +static void webkit_dom_test_node_finalize(GObject* object) +{ + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); + + if (domObject->coreObject) { + WebCore::TestNode* coreObject = static_cast<WebCore::TestNode*>(domObject->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + domObject->coreObject = 0; + } + + + G_OBJECT_CLASS(webkit_dom_test_node_parent_class)->finalize(object); +} + +static void webkit_dom_test_node_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (propertyId) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + + +static void webkit_dom_test_node_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + switch (propertyId) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + + +static void webkit_dom_test_node_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_node_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_node_parent_class)->constructed(object); +} + +static void webkit_dom_test_node_class_init(WebKitDOMTestNodeClass* requestClass) +{ + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_node_finalize; + gobjectClass->set_property = webkit_dom_test_node_set_property; + gobjectClass->get_property = webkit_dom_test_node_get_property; + gobjectClass->constructed = webkit_dom_test_node_constructed; + + + +} + +static void webkit_dom_test_node_init(WebKitDOMTestNode* request) +{ +} + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNode.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNode.h new file mode 100644 index 000000000..552fd8dc7 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNode.h @@ -0,0 +1,50 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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. +*/ + +#ifndef WebKitDOMTestNode_h +#define WebKitDOMTestNode_h + +#include <glib-object.h> +#include <webkit/WebKitDOMNode.h> +#include <webkit/webkitdefines.h> +#include <webkit/webkitdomdefines.h> + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_NODE (webkit_dom_test_node_get_type()) +#define WEBKIT_DOM_TEST_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_NODE, WebKitDOMTestNode)) +#define WEBKIT_DOM_TEST_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_NODE, WebKitDOMTestNodeClass) +#define WEBKIT_DOM_IS_TEST_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_NODE)) +#define WEBKIT_DOM_IS_TEST_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_NODE)) +#define WEBKIT_DOM_TEST_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_NODE, WebKitDOMTestNodeClass)) + +struct _WebKitDOMTestNode { + WebKitDOMNode parent_instance; +}; + +struct _WebKitDOMTestNodeClass { + WebKitDOMNodeClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_node_get_type (void); + +G_END_DECLS + +#endif /* WebKitDOMTestNode_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNodePrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNodePrivate.h new file mode 100644 index 000000000..4b46c94f8 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestNodePrivate.h @@ -0,0 +1,34 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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. +*/ + +#ifndef WebKitDOMTestNodePrivate_h +#define WebKitDOMTestNodePrivate_h + +#include "TestNode.h" +#include <glib-object.h> +#include <webkit/WebKitDOMNode.h> + +namespace WebKit { +WebKitDOMTestNode* wrapTestNode(WebCore::TestNode*); +WebCore::TestNode* core(WebKitDOMTestNode* request); +WebKitDOMTestNode* kit(WebCore::TestNode* node); +} // namespace WebKit + +#endif /* WebKitDOMTestNodePrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp index 35add3087..ef72eab44 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -18,11 +18,9 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestObj.h" -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "Document.h" #include "ExceptionCode.h" @@ -33,17 +31,16 @@ #include "WebKitDOMBinding.h" #include "bool.h" #include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMDictionary.h" +#include "webkit/WebKitDOMDictionaryPrivate.h" #include "webkit/WebKitDOMDocument.h" #include "webkit/WebKitDOMDocumentPrivate.h" #include "webkit/WebKitDOMIDBKey.h" #include "webkit/WebKitDOMIDBKeyPrivate.h" -#include "webkit/WebKitDOMOptionsObject.h" -#include "webkit/WebKitDOMOptionsObjectPrivate.h" #include "webkit/WebKitDOMSVGPoint.h" #include "webkit/WebKitDOMSVGPointPrivate.h" #include "webkit/WebKitDOMSerializedScriptValue.h" #include "webkit/WebKitDOMSerializedScriptValuePrivate.h" -#include "webkit/WebKitDOMTestObj.h" #include "webkit/WebKitDOMTestObjPrivate.h" #include "webkit/WebKitDOMa.h" #include "webkit/WebKitDOMaPrivate.h" @@ -60,9 +57,12 @@ #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> namespace WebKit { - + WebKitDOMTestObj* kit(WebCore::TestObj* obj) { g_return_val_if_fail(obj, 0); @@ -72,33 +72,847 @@ WebKitDOMTestObj* kit(WebCore::TestObj* obj) return static_cast<WebKitDOMTestObj*>(DOMObjectCache::put(obj, WebKit::wrapTestObj(obj))); } + +WebCore::TestObj* core(WebKitDOMTestObj* request) +{ + g_return_val_if_fail(request, 0); + + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); + + return coreObject; +} + +WebKitDOMTestObj* wrapTestObj(WebCore::TestObj* coreObject) +{ + g_return_val_if_fail(coreObject, 0); + + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); + + return WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, "core-object", coreObject, NULL)); +} + +} // namespace WebKit + +G_DEFINE_TYPE(WebKitDOMTestObj, webkit_dom_test_obj, WEBKIT_TYPE_DOM_OBJECT) + +enum { + PROP_0, + PROP_READ_ONLY_INT_ATTR, + PROP_READ_ONLY_STRING_ATTR, + PROP_READ_ONLY_TEST_OBJ_ATTR, + PROP_SHORT_ATTR, + PROP_UNSIGNED_SHORT_ATTR, + PROP_INT_ATTR, + PROP_LONG_LONG_ATTR, + PROP_UNSIGNED_LONG_LONG_ATTR, + PROP_STRING_ATTR, + PROP_TEST_OBJ_ATTR, + PROP_XML_OBJ_ATTR, + PROP_CREATE, + PROP_REFLECTED_STRING_ATTR, + PROP_REFLECTED_INTEGRAL_ATTR, + PROP_REFLECTED_UNSIGNED_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_CUSTOM_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_WITH_SCRIPT_STATE_ATTRIBUTE, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE, + PROP_WITH_SCRIPT_STATE_ATTRIBUTE_RAISES, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE_RAISES, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE_RAISES, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_WITH_SPACES_ATTRIBUTE, + PROP_WITH_SCRIPT_ARGUMENTS_AND_CALL_STACK_ATTRIBUTE, + PROP_CONDITIONAL_ATTR1, + PROP_CONDITIONAL_ATTR2, + PROP_CONDITIONAL_ATTR3, + PROP_CONTENT_DOCUMENT, + PROP_MUTABLE_POINT, + PROP_IMMUTABLE_POINT, + PROP_STRAWBERRY, + PROP_STRICT_FLOAT, + PROP_DESCRIPTION, + PROP_ID, + PROP_HASH, +}; + +static void webkit_dom_test_obj_finalize(GObject* object) +{ + + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); -} // namespace WebKit // + if (domObject->coreObject) { + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj*>(domObject->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + domObject->coreObject = 0; + } + + + G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->finalize(object); +} + +static void webkit_dom_test_obj_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (propertyId) { + case PROP_UNSIGNED_SHORT_ATTR: { + coreSelf->setUnsignedShortAttr((g_value_get_uint(value))); + break; + } + case PROP_INT_ATTR: { + coreSelf->setIntAttr((g_value_get_long(value))); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: { + coreSelf->setUnsignedLongLongAttr((g_value_get_uint64(value))); + break; + } + case PROP_STRING_ATTR: { + coreSelf->setStringAttr(WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_CREATE: { + coreSelf->setCreate((g_value_get_boolean(value))); + break; + } + case PROP_REFLECTED_STRING_ATTR: { + coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WTF::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_UNSIGNED_INTEGRAL_ATTR: { + coreSelf->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, (g_value_get_ulong(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, WTF::String::fromUTF8(g_value_get_string(value))); + break; + } + case PROP_REFLECTED_STRING_ATTR: { + coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WTF::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->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, (g_value_get_boolean(value))); + break; + } + case PROP_REFLECTED_CUSTOM_URL_ATTR: { + coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WTF::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: { + WebCore::ExceptionCode ec = 0; + coreSelf->setAttrWithSetterException((g_value_get_long(value)), ec); + break; + } + case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: { + WebCore::ExceptionCode ec = 0; + coreSelf->setStringAttrWithGetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); + break; + } + case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: { + WebCore::ExceptionCode ec = 0; + coreSelf->setStringAttrWithSetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); + break; + } + case PROP_WITH_SCRIPT_STATE_ATTRIBUTE: { + coreSelf->setWithScriptStateAttribute((g_value_get_long(value))); + break; + } + case PROP_CONDITIONAL_ATTR1: { +#if ENABLE(Condition1) + coreSelf->setConditionalAttr1((g_value_get_long(value))); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") +#endif /* ENABLE(Condition1) */ + break; + } + case PROP_CONDITIONAL_ATTR2: { +#if ENABLE(Condition1) && ENABLE(Condition2) + coreSelf->setConditionalAttr2((g_value_get_long(value))); +#else +#if !ENABLE(Condition1) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") +#endif +#if !ENABLE(Condition2) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ + break; + } + case PROP_CONDITIONAL_ATTR3: { +#if ENABLE(Condition1) || ENABLE(Condition2) + coreSelf->setConditionalAttr3((g_value_get_long(value))); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + break; + } + case PROP_STRICT_FLOAT: { + coreSelf->setStrictFloat((g_value_get_float(value))); + break; + } + case PROP_ID: { + coreSelf->setId((g_value_get_long(value))); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + + +static void webkit_dom_test_obj_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) +{ + WebCore::JSMainThreadNullState state; + WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (propertyId) { + case PROP_READ_ONLY_INT_ATTR: { + g_value_set_long(value, coreSelf->readOnlyIntAttr()); + break; + } + case PROP_READ_ONLY_STRING_ATTR: { + g_value_take_string(value, convertToUTF8String(coreSelf->readOnlyStringAttr())); + break; + } + case PROP_READ_ONLY_TEST_OBJ_ATTR: { + RefPtr<WebCore::TestObj> ptr = coreSelf->readOnlyTestObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_SHORT_ATTR: { + g_value_set_int(value, coreSelf->shortAttr()); + break; + } + case PROP_UNSIGNED_SHORT_ATTR: { + g_value_set_uint(value, coreSelf->unsignedShortAttr()); + break; + } + case PROP_INT_ATTR: { + g_value_set_long(value, coreSelf->intAttr()); + break; + } + case PROP_LONG_LONG_ATTR: { + g_value_set_int64(value, coreSelf->longLongAttr()); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: { + g_value_set_uint64(value, coreSelf->unsignedLongLongAttr()); + break; + } + case PROP_STRING_ATTR: { + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttr())); + break; + } + case PROP_TEST_OBJ_ATTR: { + RefPtr<WebCore::TestObj> ptr = coreSelf->testObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_XML_OBJ_ATTR: { + RefPtr<WebCore::TestObj> ptr = coreSelf->xmlObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_CREATE: { + g_value_set_boolean(value, coreSelf->isCreate()); + break; + } + case PROP_REFLECTED_STRING_ATTR: { + 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_UNSIGNED_INTEGRAL_ATTR: { + g_value_set_ulong(value, coreSelf->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)); + 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_CUSTOM_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_take_string(value, convertToUTF8String(coreSelf->stringAttrWithGetterException(ec))); + break; + } + case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: { + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttrWithSetterException())); + break; + } + case PROP_WITH_SCRIPT_STATE_ATTRIBUTE: { + g_value_set_long(value, coreSelf->withScriptStateAttribute()); + break; + } + case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE: { + RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAttribute(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_WITH_SCRIPT_STATE_ATTRIBUTE_RAISES: { + WebCore::ExceptionCode ec = 0; + RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptStateAttributeRaises(ec); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE_RAISES: { + WebCore::ExceptionCode ec = 0; + RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAttributeRaises(ec); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE: { + RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAndScriptStateAttribute(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE_RAISES: { + WebCore::ExceptionCode ec = 0; + RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAndScriptStateAttributeRaises(ec); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_WITH_SPACES_ATTRIBUTE: { + RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAndScriptStateWithSpacesAttribute(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_WITH_SCRIPT_ARGUMENTS_AND_CALL_STACK_ATTRIBUTE: { + RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptArgumentsAndCallStackAttribute(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_CONDITIONAL_ATTR1: { +#if ENABLE(Condition1) + g_value_set_long(value, coreSelf->conditionalAttr1()); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") +#endif /* ENABLE(Condition1) */ + break; + } + case PROP_CONDITIONAL_ATTR2: { +#if ENABLE(Condition1) && ENABLE(Condition2) + g_value_set_long(value, coreSelf->conditionalAttr2()); +#else +#if !ENABLE(Condition1) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") +#endif +#if !ENABLE(Condition2) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif +#endif /* ENABLE(Condition1) && ENABLE(Condition2) */ + break; + } + case PROP_CONDITIONAL_ATTR3: { +#if ENABLE(Condition1) || ENABLE(Condition2) + g_value_set_long(value, coreSelf->conditionalAttr3()); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + break; + } + case PROP_CONTENT_DOCUMENT: { + RefPtr<WebCore::Document> ptr = coreSelf->contentDocument(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_MUTABLE_POINT: { + RefPtr<WebCore::SVGPoint> ptr = coreSelf->mutablePoint(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_IMMUTABLE_POINT: { + RefPtr<WebCore::SVGPoint> ptr = coreSelf->immutablePoint(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_STRAWBERRY: { + g_value_set_int(value, coreSelf->blueberry()); + break; + } + case PROP_STRICT_FLOAT: { + g_value_set_float(value, coreSelf->strictFloat()); + break; + } + case PROP_DESCRIPTION: { + g_value_set_long(value, coreSelf->description()); + break; + } + case PROP_ID: { + g_value_set_long(value, coreSelf->id()); + break; + } + case PROP_HASH: { + g_value_take_string(value, convertToUTF8String(coreSelf->hash())); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + + +static void webkit_dom_test_obj_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed(object); +} + +static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass) +{ + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_obj_finalize; + gobjectClass->set_property = webkit_dom_test_obj_set_property; + gobjectClass->get_property = webkit_dom_test_obj_get_property; + gobjectClass->constructed = webkit_dom_test_obj_constructed; + + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_INT_ATTR, + g_param_spec_long("read-only-int-attr", /* name */ + "test_obj_read-only-int-attr", /* short description */ + "read-only glong TestObj.read-only-int-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_STRING_ATTR, + g_param_spec_string("read-only-string-attr", /* name */ + "test_obj_read-only-string-attr", /* short description */ + "read-only gchar* TestObj.read-only-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_TEST_OBJ_ATTR, + g_param_spec_object("read-only-test-obj-attr", /* name */ + "test_obj_read-only-test-obj-attr", /* short description */ + "read-only WebKitDOMTestObj* TestObj.read-only-test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_SHORT_ATTR, + g_param_spec_int("short-attr", /* name */ + "test_obj_short-attr", /* short description */ + "read-write gshort TestObj.short-attr", /* longer - could do with some extra doc stuff here */ + G_MININT, /* min */ +G_MAXINT, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_UNSIGNED_SHORT_ATTR, + g_param_spec_uint("unsigned-short-attr", /* name */ + "test_obj_unsigned-short-attr", /* short description */ + "read-write gushort TestObj.unsigned-short-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXUINT, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_INT_ATTR, + g_param_spec_long("int-attr", /* name */ + "test_obj_int-attr", /* short description */ + "read-write glong TestObj.int-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_LONG_LONG_ATTR, + g_param_spec_int64("long-long-attr", /* name */ + "test_obj_long-long-attr", /* short description */ + "read-write gint64 TestObj.long-long-attr", /* longer - could do with some extra doc stuff here */ + G_MININT64, /* min */ +G_MAXINT64, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_UNSIGNED_LONG_LONG_ATTR, + g_param_spec_uint64("unsigned-long-long-attr", /* name */ + "test_obj_unsigned-long-long-attr", /* short description */ + "read-write guint64 TestObj.unsigned-long-long-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXUINT64, /* min */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR, + g_param_spec_string("string-attr", /* name */ + "test_obj_string-attr", /* short description */ + "read-write gchar* TestObj.string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_TEST_OBJ_ATTR, + g_param_spec_object("test-obj-attr", /* name */ + "test_obj_test-obj-attr", /* short description */ + "read-write WebKitDOMTestObj* TestObj.test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_XML_OBJ_ATTR, + g_param_spec_object("xml-obj-attr", /* name */ + "test_obj_xml-obj-attr", /* short description */ + "read-write WebKitDOMTestObj* TestObj.xml-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_CREATE, + g_param_spec_boolean("create", /* name */ + "test_obj_create", /* short description */ + "read-write gboolean TestObj.create", /* longer - could do with some extra doc stuff here */ + FALSE, /* 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_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_REFLECTED_UNSIGNED_INTEGRAL_ATTR, + g_param_spec_ulong("reflected-unsigned-integral-attr", /* name */ + "test_obj_reflected-unsigned-integral-attr", /* short description */ + "read-write gulong TestObj.reflected-unsigned-integral-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXULONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + 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_CUSTOM_URL_ATTR, + g_param_spec_string("reflected-custom-url-attr", /* name */ + "test_obj_reflected-custom-url-attr", /* short description */ + "read-write gchar* TestObj.reflected-custom-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 */ + "read-write glong TestObj.attr-with-getter-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_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_WITH_SCRIPT_STATE_ATTRIBUTE, + g_param_spec_long("with-script-state-attribute", /* name */ + "test_obj_with-script-state-attribute", /* short description */ + "read-write glong TestObj.with-script-state-attribute", /* 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_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE, + g_param_spec_object("with-script-execution-context-attribute", /* name */ + "test_obj_with-script-execution-context-attribute", /* short description */ + "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-attribute", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_WITH_SCRIPT_STATE_ATTRIBUTE_RAISES, + g_param_spec_object("with-script-state-attribute-raises", /* name */ + "test_obj_with-script-state-attribute-raises", /* short description */ + "read-write WebKitDOMTestObj* TestObj.with-script-state-attribute-raises", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE_RAISES, + g_param_spec_object("with-script-execution-context-attribute-raises", /* name */ + "test_obj_with-script-execution-context-attribute-raises", /* short description */ + "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-attribute-raises", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE, + g_param_spec_object("with-script-execution-context-and-script-state-attribute", /* name */ + "test_obj_with-script-execution-context-and-script-state-attribute", /* short description */ + "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-and-script-state-attribute", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE_RAISES, + g_param_spec_object("with-script-execution-context-and-script-state-attribute-raises", /* name */ + "test_obj_with-script-execution-context-and-script-state-attribute-raises", /* short description */ + "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-and-script-state-attribute-raises", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_WITH_SPACES_ATTRIBUTE, + g_param_spec_object("with-script-execution-context-and-script-state-with-spaces-attribute", /* name */ + "test_obj_with-script-execution-context-and-script-state-with-spaces-attribute", /* short description */ + "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-and-script-state-with-spaces-attribute", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_WITH_SCRIPT_ARGUMENTS_AND_CALL_STACK_ATTRIBUTE, + g_param_spec_object("with-script-arguments-and-call-stack-attribute", /* name */ + "test_obj_with-script-arguments-and-call-stack-attribute", /* short description */ + "read-write WebKitDOMTestObj* TestObj.with-script-arguments-and-call-stack-attribute", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + 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)); + 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)); + 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)); + g_object_class_install_property(gobjectClass, + PROP_CONTENT_DOCUMENT, + g_param_spec_object("content-document", /* name */ + "test_obj_content-document", /* short description */ + "read-only WebKitDOMDocument* TestObj.content-document", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_DOCUMENT, /* gobject type */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_MUTABLE_POINT, + g_param_spec_object("mutable-point", /* name */ + "test_obj_mutable-point", /* short description */ + "read-write WebKitDOMSVGPoint* TestObj.mutable-point", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_SVG_POINT, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_IMMUTABLE_POINT, + g_param_spec_object("immutable-point", /* name */ + "test_obj_immutable-point", /* short description */ + "read-write WebKitDOMSVGPoint* TestObj.immutable-point", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_SVG_POINT, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRAWBERRY, + g_param_spec_int("strawberry", /* name */ + "test_obj_strawberry", /* short description */ + "read-write gint TestObj.strawberry", /* longer - could do with some extra doc stuff here */ + G_MININT, /* min */ +G_MAXINT, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRICT_FLOAT, + g_param_spec_float("strict-float", /* name */ + "test_obj_strict-float", /* short description */ + "read-write gfloat TestObj.strict-float", /* longer - could do with some extra doc stuff here */ + -G_MAXFLOAT, /* min */ +G_MAXFLOAT, /* max */ +0.0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_DESCRIPTION, + g_param_spec_long("description", /* name */ + "test_obj_description", /* short description */ + "read-only glong TestObj.description", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_ID, + g_param_spec_long("id", /* name */ + "test_obj_id", /* short description */ + "read-write glong TestObj.id", /* 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_HASH, + g_param_spec_string("hash", /* name */ + "test_obj_hash", /* short description */ + "read-only gchar* TestObj.hash", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + + +} + +static void webkit_dom_test_obj_init(WebKitDOMTestObj* request) +{ +} void webkit_dom_test_obj_void_method(WebKitDOMTestObj* self) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->voidMethod(); } void -webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg) +webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong intArg, const gchar* strArg, WebKitDOMTestObj* objArg) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - g_return_if_fail(str_arg); - g_return_if_fail(obj_arg); - WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); - WebCore::TestObj * converted_obj_arg = NULL; - if (obj_arg != NULL) { - converted_obj_arg = WebKit::core(obj_arg); - g_return_if_fail(converted_obj_arg); + WebCore::TestObj* item = WebKit::core(self); + g_return_if_fail(strArg); + g_return_if_fail(objArg); + WTF::String convertedStrArg = WTF::String::fromUTF8(strArg); + WebCore::TestObj* convertedObjArg = 0; + if (objArg) { + convertedObjArg = WebKit::core(objArg); + g_return_if_fail(convertedObjArg); } - item->voidMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); + item->voidMethodWithArgs(intArg, convertedStrArg, convertedObjArg); } glong @@ -106,27 +920,27 @@ webkit_dom_test_obj_int_method(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->intMethod(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->intMethod(); + return result; } glong -webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg) +webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong intArg, const gchar* strArg, WebKitDOMTestObj* objArg) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - g_return_val_if_fail(str_arg, 0); - g_return_val_if_fail(obj_arg, 0); - WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); - WebCore::TestObj * converted_obj_arg = NULL; - if (obj_arg != NULL) { - converted_obj_arg = WebKit::core(obj_arg); - g_return_val_if_fail(converted_obj_arg, 0); + WebCore::TestObj* item = WebKit::core(self); + g_return_val_if_fail(strArg, 0); + g_return_val_if_fail(objArg, 0); + WTF::String convertedStrArg = WTF::String::fromUTF8(strArg); + WebCore::TestObj* convertedObjArg = 0; + if (objArg) { + convertedObjArg = WebKit::core(objArg); + g_return_val_if_fail(convertedObjArg, 0); } - glong res = item->intMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg); - return res; + glong result = item->intMethodWithArgs(intArg, convertedStrArg, convertedObjArg); + return result; } WebKitDOMTestObj* @@ -134,68 +948,68 @@ webkit_dom_test_obj_obj_method(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethod()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->objMethod()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } WebKitDOMTestObj* -webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg) +webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong intArg, const gchar* strArg, WebKitDOMTestObj* objArg) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - g_return_val_if_fail(str_arg, 0); - g_return_val_if_fail(obj_arg, 0); - WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); - WebCore::TestObj * converted_obj_arg = NULL; - if (obj_arg != NULL) { - converted_obj_arg = WebKit::core(obj_arg); - g_return_val_if_fail(converted_obj_arg, 0); + WebCore::TestObj* item = WebKit::core(self); + g_return_val_if_fail(strArg, 0); + g_return_val_if_fail(objArg, 0); + WTF::String convertedStrArg = WTF::String::fromUTF8(strArg); + WebCore::TestObj* convertedObjArg = 0; + if (objArg) { + convertedObjArg = WebKit::core(objArg); + g_return_val_if_fail(convertedObjArg, 0); } - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, converted_str_arg, converted_obj_arg)); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->objMethodWithArgs(intArg, convertedStrArg, convertedObjArg)); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } WebKitDOMTestObj* -webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error) +webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* self, const gchar* strArg, WebKitDOMTestObj* objArg, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - g_return_val_if_fail(str_arg, 0); - g_return_val_if_fail(obj_arg, 0); - WTF::String converted_str_arg = WTF::String::fromUTF8(str_arg); - WebCore::TestObj * converted_obj_arg = NULL; - if (obj_arg != NULL) { - converted_obj_arg = WebKit::core(obj_arg); - g_return_val_if_fail(converted_obj_arg, 0); + WebCore::TestObj* item = WebKit::core(self); + g_return_val_if_fail(strArg, 0); + g_return_val_if_fail(objArg, 0); + WTF::String convertedStrArg = WTF::String::fromUTF8(strArg); + WebCore::TestObj* convertedObjArg = 0; + if (objArg) { + convertedObjArg = WebKit::core(objArg); + g_return_val_if_fail(convertedObjArg, 0); } WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgsAndThrows(converted_str_arg, converted_obj_arg, ec)); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->methodThatRequiresAllArgsAndThrows(convertedStrArg, convertedObjArg, ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void -webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serialized_arg) +webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serializedArg) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - g_return_if_fail(serialized_arg); - WebCore::SerializedScriptValue * converted_serialized_arg = NULL; - if (serialized_arg != NULL) { - converted_serialized_arg = WebKit::core(serialized_arg); - g_return_if_fail(converted_serialized_arg); + WebCore::TestObj* item = WebKit::core(self); + g_return_if_fail(serializedArg); + WebCore::SerializedScriptValue* convertedSerializedArg = 0; + if (serializedArg) { + convertedSerializedArg = WebKit::core(serializedArg); + g_return_if_fail(convertedSerializedArg); } - item->serializedValue(converted_serialized_arg); + item->serializedValue(convertedSerializedArg); } void @@ -203,43 +1017,43 @@ webkit_dom_test_obj_idb_key(WebKitDOMTestObj* self, WebKitDOMIDBKey* key) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(key); - WebCore::IDBKey * converted_key = NULL; - if (key != NULL) { - converted_key = WebKit::core(key); - g_return_if_fail(converted_key); + WebCore::IDBKey* convertedKey = 0; + if (key) { + convertedKey = WebKit::core(key); + g_return_if_fail(convertedKey); } - item->idbKey(converted_key); + item->idbKey(convertedKey); } void -webkit_dom_test_obj_options_object(WebKitDOMTestObj* self, WebKitDOMOptionsObject* oo, WebKitDOMOptionsObject* ooo) +webkit_dom_test_obj_options_object(WebKitDOMTestObj* self, WebKitDOMDictionary* oo, WebKitDOMDictionary* ooo) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(oo); g_return_if_fail(ooo); - WebCore::OptionsObject * converted_oo = NULL; - if (oo != NULL) { - converted_oo = WebKit::core(oo); - g_return_if_fail(converted_oo); + WebCore::Dictionary* convertedOo = 0; + if (oo) { + convertedOo = WebKit::core(oo); + g_return_if_fail(convertedOo); } - WebCore::OptionsObject * converted_ooo = NULL; - if (ooo != NULL) { - converted_ooo = WebKit::core(ooo); - g_return_if_fail(converted_ooo); + WebCore::Dictionary* convertedOoo = 0; + if (ooo) { + convertedOoo = WebKit::core(ooo); + g_return_if_fail(convertedOoo); } - item->optionsObject(converted_oo, converted_ooo); + item->optionsObject(convertedOo, convertedOoo); } void -webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; item->methodWithException(ec); if (ec) { @@ -253,7 +1067,7 @@ webkit_dom_test_obj_with_script_state_void(WebKitDOMTestObj* self) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->withScriptStateVoid(); } @@ -262,18 +1076,18 @@ webkit_dom_test_obj_with_script_state_obj(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptStateObj()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void -webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; item->withScriptStateVoidException(ec); if (ec) { @@ -283,19 +1097,19 @@ 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) +webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObjException(ec)); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptStateObjException(ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -303,7 +1117,7 @@ webkit_dom_test_obj_with_script_execution_context(WebKitDOMTestObj* self) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->withScriptExecutionContext(); } @@ -312,24 +1126,24 @@ webkit_dom_test_obj_with_script_execution_context_and_script_state(WebKitDOMTest { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->withScriptExecutionContextAndScriptState(); } WebKitDOMTestObj* -webkit_dom_test_obj_with_script_execution_context_and_script_state_obj_exception(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_with_script_execution_context_and_script_state_obj_exception(WebKitDOMTestObj* self, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptExecutionContextAndScriptStateObjException(ec)); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptExecutionContextAndScriptStateObjException(ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } WebKitDOMTestObj* @@ -337,10 +1151,10 @@ webkit_dom_test_obj_with_script_execution_context_and_script_state_with_spaces(W { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptExecutionContextAndScriptStateWithSpaces()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptExecutionContextAndScriptStateWithSpaces()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -348,26 +1162,26 @@ webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->methodWithOptionalArg(opt); } void -webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong non_opt, glong opt) +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong nonOpt, glong opt) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - item->methodWithNonOptionalArgAndOptionalArg(non_opt, opt); + WebCore::TestObj* item = WebKit::core(self); + item->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); } void -webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong non_opt, glong opt1, glong opt2) +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong nonOpt, glong opt1, glong opt2) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2); + WebCore::TestObj* item = WebKit::core(self); + item->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); } void @@ -375,10 +1189,10 @@ webkit_dom_test_obj_method_with_optional_string(WebKitDOMTestObj* self, const gc { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(str); - WTF::String converted_str = WTF::String::fromUTF8(str); - item->methodWithOptionalString(converted_str); + WTF::String convertedStr = WTF::String::fromUTF8(str); + item->methodWithOptionalString(convertedStr); } void @@ -386,10 +1200,10 @@ webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* s { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(str); - WTF::String converted_str = WTF::String::fromUTF8(str); - item->methodWithOptionalStringIsUndefined(converted_str); + WTF::String convertedStr = WTF::String::fromUTF8(str); + item->methodWithOptionalStringIsUndefined(convertedStr); } void @@ -397,10 +1211,10 @@ webkit_dom_test_obj_method_with_optional_string_is_null_string(WebKitDOMTestObj* { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(str); - WTF::String converted_str = WTF::String::fromUTF8(str); - item->methodWithOptionalStringIsNullString(converted_str); + WTF::String convertedStr = WTF::String::fromUTF8(str); + item->methodWithOptionalStringIsNullString(convertedStr); } gchar* @@ -409,11 +1223,12 @@ webkit_dom_test_obj_conditional_method1(WebKitDOMTestObj* self) #if ENABLE(Condition1) g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->conditionalMethod1()); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->conditionalMethod1()); + return result; #else - return NULL; + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + return 0; #endif /* ENABLE(Condition1) */ } @@ -423,8 +1238,15 @@ webkit_dom_test_obj_conditional_method2(WebKitDOMTestObj* self) #if ENABLE(Condition1) && ENABLE(Condition2) g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->conditionalMethod2(); +#else +#if !ENABLE(Condition1) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") +#endif +#if !ENABLE(Condition2) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif #endif /* ENABLE(Condition1) && ENABLE(Condition2) */ } @@ -434,8 +1256,11 @@ webkit_dom_test_obj_conditional_method3(WebKitDOMTestObj* self) #if ENABLE(Condition1) || ENABLE(Condition2) g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->conditionalMethod3(); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") #endif /* ENABLE(Condition1) || ENABLE(Condition2) */ } @@ -444,7 +1269,7 @@ webkit_dom_test_obj_class_method(WebKitDOMTestObj* self) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->classMethod(); } @@ -453,9 +1278,9 @@ webkit_dom_test_obj_class_method_with_optional(WebKitDOMTestObj* self, glong arg { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->classMethodWithOptional(arg); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->classMethodWithOptional(arg); + return result; } void @@ -464,8 +1289,10 @@ webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, glong arg) #if ENABLE(Condition1) g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->overloadedMethod1(arg); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") #endif /* ENABLE(Condition1) */ } @@ -475,10 +1302,12 @@ webkit_dom_test_obj_overloaded_method1(WebKitDOMTestObj* self, const gchar* type #if ENABLE(Condition1) g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(type); - WTF::String converted_type = WTF::String::fromUTF8(type); - item->overloadedMethod1(converted_type); + WTF::String convertedType = WTF::String::fromUTF8(type); + item->overloadedMethod1(convertedType); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") #endif /* ENABLE(Condition1) */ } @@ -487,14 +1316,14 @@ webkit_dom_test_obj_convert1(WebKitDOMTestObj* self, WebKitDOMa* ) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(); - WebCore::a * converted_ = NULL; - if ( != NULL) { - converted_ = WebKit::core(); - g_return_if_fail(converted_); + WebCore::a* converted = 0; + if () { + converted = WebKit::core(); + g_return_if_fail(converted); } - item->convert1(converted_); + item->convert1(converted); } void @@ -502,14 +1331,14 @@ webkit_dom_test_obj_convert2(WebKitDOMTestObj* self, WebKitDOMb* ) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(); - WebCore::b * converted_ = NULL; - if ( != NULL) { - converted_ = WebKit::core(); - g_return_if_fail(converted_); + WebCore::b* converted = 0; + if () { + converted = WebKit::core(); + g_return_if_fail(converted); } - item->convert2(converted_); + item->convert2(converted); } void @@ -517,14 +1346,14 @@ webkit_dom_test_obj_convert3(WebKitDOMTestObj* self, WebKitDOMc* ) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(); - WebCore::c * converted_ = NULL; - if ( != NULL) { - converted_ = WebKit::core(); - g_return_if_fail(converted_); + WebCore::c* converted = 0; + if () { + converted = WebKit::core(); + g_return_if_fail(converted); } - item->convert3(converted_); + item->convert3(converted); } void @@ -532,14 +1361,14 @@ webkit_dom_test_obj_convert4(WebKitDOMTestObj* self, WebKitDOMd* ) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(); - WebCore::d * converted_ = NULL; - if ( != NULL) { - converted_ = WebKit::core(); - g_return_if_fail(converted_); + WebCore::d* converted = 0; + if () { + converted = WebKit::core(); + g_return_if_fail(converted); } - item->convert4(converted_); + item->convert4(converted); } void @@ -547,14 +1376,14 @@ webkit_dom_test_obj_convert5(WebKitDOMTestObj* self, WebKitDOMe* ) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(); - WebCore::e * converted_ = NULL; - if ( != NULL) { - converted_ = WebKit::core(); - g_return_if_fail(converted_); + WebCore::e* converted = 0; + if () { + converted = WebKit::core(); + g_return_if_fail(converted); } - item->convert5(converted_); + item->convert5(converted); } WebKitDOMSVGPoint* @@ -562,10 +1391,10 @@ webkit_dom_test_obj_mutable_point_function(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::SVGPoint> g_res = WTF::getPtr(item->mutablePointFunction()); - WebKitDOMSVGPoint* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::SVGPoint> gobjectResult = WTF::getPtr(item->mutablePointFunction()); + WebKitDOMSVGPoint* result = WebKit::kit(gobjectResult.get()); + return result; } WebKitDOMSVGPoint* @@ -573,10 +1402,10 @@ webkit_dom_test_obj_immutable_point_function(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::SVGPoint> g_res = WTF::getPtr(item->immutablePointFunction()); - WebKitDOMSVGPoint* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::SVGPoint> gobjectResult = WTF::getPtr(item->immutablePointFunction()); + WebKitDOMSVGPoint* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -584,26 +1413,26 @@ webkit_dom_test_obj_orange(WebKitDOMTestObj* self) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->orange(); } WebKitDOMbool* -webkit_dom_test_obj_strict_function(WebKitDOMTestObj* self, const gchar* str, gfloat a, gint b, GError **error) +webkit_dom_test_obj_strict_function(WebKitDOMTestObj* self, const gchar* str, gfloat a, gint b, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_val_if_fail(str, 0); - WTF::String converted_str = WTF::String::fromUTF8(str); + WTF::String convertedStr = WTF::String::fromUTF8(str); WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::bool> g_res = WTF::getPtr(item->strictFunction(converted_str, a, b, ec)); + RefPtr<WebCore::bool> gobjectResult = WTF::getPtr(item->strictFunction(convertedStr, a, b, ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - WebKitDOMbool* res = WebKit::kit(g_res.get()); - return res; + WebKitDOMbool* result = WebKit::kit(gobjectResult.get()); + return result; } glong @@ -611,9 +1440,9 @@ webkit_dom_test_obj_get_read_only_int_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->readOnlyIntAttr(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->readOnlyIntAttr(); + return result; } gchar* @@ -621,9 +1450,9 @@ webkit_dom_test_obj_get_read_only_string_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->readOnlyStringAttr()); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->readOnlyStringAttr()); + return result; } WebKitDOMTestObj* @@ -631,10 +1460,10 @@ webkit_dom_test_obj_get_read_only_test_obj_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->readOnlyTestObjAttr()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->readOnlyTestObjAttr()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } gshort @@ -642,9 +1471,9 @@ webkit_dom_test_obj_get_short_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gshort res = item->shortAttr(); - return res; + WebCore::TestObj* item = WebKit::core(self); + gshort result = item->shortAttr(); + return result; } void @@ -652,7 +1481,7 @@ webkit_dom_test_obj_set_short_attr(WebKitDOMTestObj* self, gshort value) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setShortAttr(value); } @@ -661,9 +1490,9 @@ webkit_dom_test_obj_get_unsigned_short_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gushort res = item->unsignedShortAttr(); - return res; + WebCore::TestObj* item = WebKit::core(self); + gushort result = item->unsignedShortAttr(); + return result; } void @@ -671,7 +1500,7 @@ webkit_dom_test_obj_set_unsigned_short_attr(WebKitDOMTestObj* self, gushort valu { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setUnsignedShortAttr(value); } @@ -680,9 +1509,9 @@ webkit_dom_test_obj_get_int_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->intAttr(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->intAttr(); + return result; } void @@ -690,7 +1519,7 @@ webkit_dom_test_obj_set_int_attr(WebKitDOMTestObj* self, glong value) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setIntAttr(value); } @@ -699,9 +1528,9 @@ webkit_dom_test_obj_get_long_long_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gint64 res = item->longLongAttr(); - return res; + WebCore::TestObj* item = WebKit::core(self); + gint64 result = item->longLongAttr(); + return result; } void @@ -709,7 +1538,7 @@ webkit_dom_test_obj_set_long_long_attr(WebKitDOMTestObj* self, gint64 value) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setLongLongAttr(value); } @@ -718,9 +1547,9 @@ webkit_dom_test_obj_get_unsigned_long_long_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - guint64 res = item->unsignedLongLongAttr(); - return res; + WebCore::TestObj* item = WebKit::core(self); + guint64 result = item->unsignedLongLongAttr(); + return result; } void @@ -728,7 +1557,7 @@ webkit_dom_test_obj_set_unsigned_long_long_attr(WebKitDOMTestObj* self, guint64 { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setUnsignedLongLongAttr(value); } @@ -737,9 +1566,9 @@ webkit_dom_test_obj_get_string_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->stringAttr()); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->stringAttr()); + return result; } void @@ -747,10 +1576,10 @@ webkit_dom_test_obj_set_string_attr(WebKitDOMTestObj* self, const gchar* value) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); - item->setStringAttr(converted_value); + WTF::String convertedValue = WTF::String::fromUTF8(value); + item->setStringAttr(convertedValue); } WebKitDOMTestObj* @@ -758,10 +1587,10 @@ webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->testObjAttr()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->testObjAttr()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -769,14 +1598,14 @@ webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } - item->setTestObjAttr(converted_value); + item->setTestObjAttr(convertedValue); } WebKitDOMTestObj* @@ -784,10 +1613,10 @@ webkit_dom_test_obj_get_xml_obj_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->xmlObjAttr()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->xmlObjAttr()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -795,14 +1624,14 @@ webkit_dom_test_obj_set_xml_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* v { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } - item->setXMLObjAttr(converted_value); + item->setXMLObjAttr(convertedValue); } gboolean @@ -810,9 +1639,9 @@ webkit_dom_test_obj_get_create(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gboolean res = item->isCreate(); - return res; + WebCore::TestObj* item = WebKit::core(self); + gboolean result = item->isCreate(); + return result; } void @@ -820,7 +1649,7 @@ webkit_dom_test_obj_set_create(WebKitDOMTestObj* self, gboolean value) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setCreate(value); } @@ -829,9 +1658,9 @@ webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return result; } void @@ -839,10 +1668,10 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, const gcha { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); - item->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, converted_value); + WTF::String convertedValue = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, convertedValue); } glong @@ -850,9 +1679,9 @@ webkit_dom_test_obj_get_reflected_integral_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr); + return result; } void @@ -860,7 +1689,7 @@ webkit_dom_test_obj_set_reflected_integral_attr(WebKitDOMTestObj* self, glong va { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, value); } @@ -869,9 +1698,9 @@ webkit_dom_test_obj_get_reflected_unsigned_integral_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gulong res = item->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr); - return res; + WebCore::TestObj* item = WebKit::core(self); + gulong result = item->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr); + return result; } void @@ -879,7 +1708,7 @@ webkit_dom_test_obj_set_reflected_unsigned_integral_attr(WebKitDOMTestObj* self, { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, value); } @@ -888,9 +1717,9 @@ webkit_dom_test_obj_get_reflected_boolean_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gboolean res = item->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); - return res; + WebCore::TestObj* item = WebKit::core(self); + gboolean result = item->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr); + return result; } void @@ -898,7 +1727,7 @@ webkit_dom_test_obj_set_reflected_boolean_attr(WebKitDOMTestObj* self, gboolean { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, value); } @@ -907,9 +1736,9 @@ webkit_dom_test_obj_get_reflected_url_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); + return result; } void @@ -917,10 +1746,10 @@ webkit_dom_test_obj_set_reflected_url_attr(WebKitDOMTestObj* self, const gchar* { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); - item->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, converted_value); + WTF::String convertedValue = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, convertedValue); } gchar* @@ -928,9 +1757,9 @@ webkit_dom_test_obj_get_reflected_string_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return result; } void @@ -938,10 +1767,10 @@ webkit_dom_test_obj_set_reflected_string_attr(WebKitDOMTestObj* self, const gcha { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); - item->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, converted_value); + WTF::String convertedValue = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, convertedValue); } glong @@ -949,9 +1778,9 @@ webkit_dom_test_obj_get_reflected_custom_integral_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr); + return result; } void @@ -959,7 +1788,7 @@ webkit_dom_test_obj_set_reflected_custom_integral_attr(WebKitDOMTestObj* self, g { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, value); } @@ -968,9 +1797,9 @@ webkit_dom_test_obj_get_reflected_custom_boolean_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gboolean res = item->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); - return res; + WebCore::TestObj* item = WebKit::core(self); + gboolean result = item->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr); + return result; } void @@ -978,7 +1807,7 @@ webkit_dom_test_obj_set_reflected_custom_boolean_attr(WebKitDOMTestObj* self, gb { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, value); } @@ -987,9 +1816,9 @@ webkit_dom_test_obj_get_reflected_custom_url_attr(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return result; } void @@ -997,33 +1826,33 @@ webkit_dom_test_obj_set_reflected_custom_url_attr(WebKitDOMTestObj* self, const { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); - item->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, converted_value); + WTF::String convertedValue = WTF::String::fromUTF8(value); + item->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, convertedValue); } glong -webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - glong res = item->attrWithGetterException(ec); + glong result = item->attrWithGetterException(ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - return res; + return result; } void -webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error) +webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; item->setAttrWithGetterException(value, ec); if (ec) { @@ -1037,17 +1866,17 @@ webkit_dom_test_obj_get_attr_with_setter_exception(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->attrWithSetterException(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->attrWithSetterException(); + return result; } void -webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError **error) +webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; item->setAttrWithSetterException(value, ec); if (ec) { @@ -1057,26 +1886,26 @@ webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong } gchar* -webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - gchar* res = convertToUTF8String(item->stringAttrWithGetterException(ec)); - return res; + gchar* result = convertToUTF8String(item->stringAttrWithGetterException(ec)); + return result; } void -webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, const gchar* value, GError **error) +webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, const gchar* value, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); + WTF::String convertedValue = WTF::String::fromUTF8(value); WebCore::ExceptionCode ec = 0; - item->setStringAttrWithGetterException(converted_value, ec); + item->setStringAttrWithGetterException(convertedValue, ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); @@ -1088,21 +1917,21 @@ webkit_dom_test_obj_get_string_attr_with_setter_exception(WebKitDOMTestObj* self { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->stringAttrWithSetterException()); - return res; + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->stringAttrWithSetterException()); + return result; } void -webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, const gchar* value, GError **error) +webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, const gchar* value, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WTF::String converted_value = WTF::String::fromUTF8(value); + WTF::String convertedValue = WTF::String::fromUTF8(value); WebCore::ExceptionCode ec = 0; - item->setStringAttrWithSetterException(converted_value, ec); + item->setStringAttrWithSetterException(convertedValue, ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); @@ -1114,9 +1943,9 @@ webkit_dom_test_obj_get_with_script_state_attribute(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->withScriptStateAttribute(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->withScriptStateAttribute(); + return result; } void @@ -1124,7 +1953,7 @@ webkit_dom_test_obj_set_with_script_state_attribute(WebKitDOMTestObj* self, glon { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setWithScriptStateAttribute(value); } @@ -1133,10 +1962,10 @@ webkit_dom_test_obj_get_with_script_execution_context_attribute(WebKitDOMTestObj { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptExecutionContextAttribute()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptExecutionContextAttribute()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -1144,46 +1973,46 @@ webkit_dom_test_obj_set_with_script_execution_context_attribute(WebKitDOMTestObj { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } - item->setWithScriptExecutionContextAttribute(converted_value); + item->setWithScriptExecutionContextAttribute(convertedValue); } WebKitDOMTestObj* -webkit_dom_test_obj_get_with_script_state_attribute_raises(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_get_with_script_state_attribute_raises(WebKitDOMTestObj* self, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateAttributeRaises(ec)); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptStateAttributeRaises(ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void -webkit_dom_test_obj_set_with_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError **error) +webkit_dom_test_obj_set_with_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } WebCore::ExceptionCode ec = 0; - item->setWithScriptStateAttributeRaises(converted_value, ec); + item->setWithScriptStateAttributeRaises(convertedValue, ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); @@ -1191,35 +2020,35 @@ webkit_dom_test_obj_set_with_script_state_attribute_raises(WebKitDOMTestObj* sel } WebKitDOMTestObj* -webkit_dom_test_obj_get_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_get_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptExecutionContextAttributeRaises(ec)); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptExecutionContextAttributeRaises(ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void -webkit_dom_test_obj_set_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError **error) +webkit_dom_test_obj_set_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } WebCore::ExceptionCode ec = 0; - item->setWithScriptExecutionContextAttributeRaises(converted_value, ec); + item->setWithScriptExecutionContextAttributeRaises(convertedValue, ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); @@ -1231,10 +2060,10 @@ webkit_dom_test_obj_get_with_script_execution_context_and_script_state_attribute { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptExecutionContextAndScriptStateAttribute()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptExecutionContextAndScriptStateAttribute()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -1242,46 +2071,46 @@ webkit_dom_test_obj_set_with_script_execution_context_and_script_state_attribute { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } - item->setWithScriptExecutionContextAndScriptStateAttribute(converted_value); + item->setWithScriptExecutionContextAndScriptStateAttribute(convertedValue); } WebKitDOMTestObj* -webkit_dom_test_obj_get_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, GError **error) +webkit_dom_test_obj_get_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, GError** error) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); WebCore::ExceptionCode ec = 0; - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptExecutionContextAndScriptStateAttributeRaises(ec)); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptExecutionContextAndScriptStateAttributeRaises(ec)); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); } - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void -webkit_dom_test_obj_set_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError **error) +webkit_dom_test_obj_set_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError** error) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } WebCore::ExceptionCode ec = 0; - item->setWithScriptExecutionContextAndScriptStateAttributeRaises(converted_value, ec); + item->setWithScriptExecutionContextAndScriptStateAttributeRaises(convertedValue, ec); if (ec) { WebCore::ExceptionCodeDescription ecdesc(ec); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); @@ -1293,10 +2122,10 @@ webkit_dom_test_obj_get_with_script_execution_context_and_script_state_with_spac { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptExecutionContextAndScriptStateWithSpacesAttribute()); - WebKitDOMTestObj* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::TestObj> gobjectResult = WTF::getPtr(item->withScriptExecutionContextAndScriptStateWithSpacesAttribute()); + WebKitDOMTestObj* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -1304,14 +2133,14 @@ webkit_dom_test_obj_set_with_script_execution_context_and_script_state_with_spac { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::TestObj * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::TestObj* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } - item->setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(converted_value); + item->setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(convertedValue); } glong @@ -1320,10 +2149,11 @@ webkit_dom_test_obj_get_conditional_attr1(WebKitDOMTestObj* self) #if ENABLE(Condition1) g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->conditionalAttr1(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->conditionalAttr1(); + return result; #else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") return static_cast<glong>(0); #endif /* ENABLE(Condition1) */ } @@ -1334,8 +2164,10 @@ webkit_dom_test_obj_set_conditional_attr1(WebKitDOMTestObj* self, glong value) #if ENABLE(Condition1) g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setConditionalAttr1(value); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") #endif /* ENABLE(Condition1) */ } @@ -1345,10 +2177,16 @@ webkit_dom_test_obj_get_conditional_attr2(WebKitDOMTestObj* self) #if ENABLE(Condition1) && ENABLE(Condition2) g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->conditionalAttr2(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->conditionalAttr2(); + return result; #else +#if !ENABLE(Condition1) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") +#endif +#if !ENABLE(Condition2) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif return static_cast<glong>(0); #endif /* ENABLE(Condition1) && ENABLE(Condition2) */ } @@ -1359,8 +2197,15 @@ webkit_dom_test_obj_set_conditional_attr2(WebKitDOMTestObj* self, glong value) #if ENABLE(Condition1) && ENABLE(Condition2) g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setConditionalAttr2(value); +#else +#if !ENABLE(Condition1) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") +#endif +#if !ENABLE(Condition2) + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif #endif /* ENABLE(Condition1) && ENABLE(Condition2) */ } @@ -1370,10 +2215,12 @@ webkit_dom_test_obj_get_conditional_attr3(WebKitDOMTestObj* self) #if ENABLE(Condition1) || ENABLE(Condition2) g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->conditionalAttr3(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->conditionalAttr3(); + return result; #else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") return static_cast<glong>(0); #endif /* ENABLE(Condition1) || ENABLE(Condition2) */ } @@ -1384,8 +2231,11 @@ webkit_dom_test_obj_set_conditional_attr3(WebKitDOMTestObj* self, glong value) #if ENABLE(Condition1) || ENABLE(Condition2) g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setConditionalAttr3(value); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") #endif /* ENABLE(Condition1) || ENABLE(Condition2) */ } @@ -1394,10 +2244,10 @@ webkit_dom_test_obj_get_content_document(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::Document> g_res = WTF::getPtr(item->contentDocument()); - WebKitDOMDocument* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::Document> gobjectResult = WTF::getPtr(item->contentDocument()); + WebKitDOMDocument* result = WebKit::kit(gobjectResult.get()); + return result; } WebKitDOMSVGPoint* @@ -1405,10 +2255,10 @@ webkit_dom_test_obj_get_mutable_point(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::SVGPoint> g_res = WTF::getPtr(item->mutablePoint()); - WebKitDOMSVGPoint* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::SVGPoint> gobjectResult = WTF::getPtr(item->mutablePoint()); + WebKitDOMSVGPoint* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -1416,14 +2266,14 @@ webkit_dom_test_obj_set_mutable_point(WebKitDOMTestObj* self, WebKitDOMSVGPoint* { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::SVGPoint * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::SVGPoint* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } - item->setMutablePoint(converted_value); + item->setMutablePoint(convertedValue); } WebKitDOMSVGPoint* @@ -1431,10 +2281,10 @@ webkit_dom_test_obj_get_immutable_point(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - PassRefPtr<WebCore::SVGPoint> g_res = WTF::getPtr(item->immutablePoint()); - WebKitDOMSVGPoint* res = WebKit::kit(g_res.get()); - return res; + WebCore::TestObj* item = WebKit::core(self); + RefPtr<WebCore::SVGPoint> gobjectResult = WTF::getPtr(item->immutablePoint()); + WebKitDOMSVGPoint* result = WebKit::kit(gobjectResult.get()); + return result; } void @@ -1442,14 +2292,33 @@ webkit_dom_test_obj_set_immutable_point(WebKitDOMTestObj* self, WebKitDOMSVGPoin { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); g_return_if_fail(value); - WebCore::SVGPoint * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); + WebCore::SVGPoint* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); } - item->setImmutablePoint(converted_value); + item->setImmutablePoint(convertedValue); +} + +gint +webkit_dom_test_obj_get_strawberry(WebKitDOMTestObj* self) +{ + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestObj* item = WebKit::core(self); + gint result = item->blueberry(); + return result; +} + +void +webkit_dom_test_obj_set_strawberry(WebKitDOMTestObj* self, gint value) +{ + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestObj* item = WebKit::core(self); + item->setBlueberry(value); } gfloat @@ -1457,9 +2326,9 @@ webkit_dom_test_obj_get_strict_float(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gfloat res = item->strictFloat(); - return res; + WebCore::TestObj* item = WebKit::core(self); + gfloat result = item->strictFloat(); + return result; } void @@ -1467,7 +2336,7 @@ webkit_dom_test_obj_set_strict_float(WebKitDOMTestObj* self, gfloat value) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setStrictFloat(value); } @@ -1476,9 +2345,9 @@ webkit_dom_test_obj_get_description(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->description(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->description(); + return result; } glong @@ -1486,9 +2355,9 @@ webkit_dom_test_obj_get_id(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - glong res = item->id(); - return res; + WebCore::TestObj* item = WebKit::core(self); + glong result = item->id(); + return result; } void @@ -1496,7 +2365,7 @@ webkit_dom_test_obj_set_id(WebKitDOMTestObj* self, glong value) { g_return_if_fail(self); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); + WebCore::TestObj* item = WebKit::core(self); item->setId(value); } @@ -1505,870 +2374,8 @@ webkit_dom_test_obj_get_hash(WebKitDOMTestObj* self) { g_return_val_if_fail(self, 0); WebCore::JSMainThreadNullState state; - WebCore::TestObj * item = WebKit::core(self); - gchar* res = convertToUTF8String(item->hash()); - return res; -} - - -G_DEFINE_TYPE(WebKitDOMTestObj, webkit_dom_test_obj, WEBKIT_TYPE_DOM_OBJECT) - -namespace WebKit { - -WebCore::TestObj* core(WebKitDOMTestObj* request) -{ - g_return_val_if_fail(request, 0); - - WebCore::TestObj* coreObject = static_cast<WebCore::TestObj*>(WEBKIT_DOM_OBJECT(request)->coreObject); - g_return_val_if_fail(coreObject, 0); - - return coreObject; -} - -} // namespace WebKit -enum { - PROP_0, - PROP_READ_ONLY_INT_ATTR, - PROP_READ_ONLY_STRING_ATTR, - PROP_READ_ONLY_TEST_OBJ_ATTR, - PROP_SHORT_ATTR, - PROP_UNSIGNED_SHORT_ATTR, - PROP_INT_ATTR, - PROP_LONG_LONG_ATTR, - PROP_UNSIGNED_LONG_LONG_ATTR, - PROP_STRING_ATTR, - PROP_TEST_OBJ_ATTR, - PROP_XML_OBJ_ATTR, - PROP_CREATE, - PROP_REFLECTED_STRING_ATTR, - PROP_REFLECTED_INTEGRAL_ATTR, - PROP_REFLECTED_UNSIGNED_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_CUSTOM_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_WITH_SCRIPT_STATE_ATTRIBUTE, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE, - PROP_WITH_SCRIPT_STATE_ATTRIBUTE_RAISES, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE_RAISES, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE_RAISES, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_WITH_SPACES_ATTRIBUTE, - PROP_WITH_SCRIPT_ARGUMENTS_AND_CALL_STACK_ATTRIBUTE, -#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_CONTENT_DOCUMENT, - PROP_MUTABLE_POINT, - PROP_IMMUTABLE_POINT, - PROP_STRICT_FLOAT, - PROP_DESCRIPTION, - PROP_ID, - PROP_HASH, -}; - - -static void webkit_dom_test_obj_finalize(GObject* object) -{ - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); - - if (dom_object->coreObject) { - WebCore::TestObj* coreObject = static_cast<WebCore::TestObj *>(dom_object->coreObject); - - WebKit::DOMObjectCache::forget(coreObject); - coreObject->deref(); - - dom_object->coreObject = NULL; - } - - G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->finalize(object); -} - -static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) -{ - WebCore::JSMainThreadNullState state; - WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); - WebCore::TestObj* coreSelf = WebKit::core(self); - switch (prop_id) { - case PROP_UNSIGNED_SHORT_ATTR: - { - coreSelf->setUnsignedShortAttr((g_value_get_uint(value))); - break; - } - case PROP_INT_ATTR: - { - coreSelf->setIntAttr((g_value_get_long(value))); - break; - } - case PROP_UNSIGNED_LONG_LONG_ATTR: - { - coreSelf->setUnsignedLongLongAttr((g_value_get_uint64(value))); - break; - } - case PROP_STRING_ATTR: - { - coreSelf->setStringAttr(WTF::String::fromUTF8(g_value_get_string(value))); - break; - } - case PROP_CREATE: - { - coreSelf->setCreate((g_value_get_boolean(value))); - break; - } - case PROP_REFLECTED_STRING_ATTR: - { - coreSelf->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, WTF::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_UNSIGNED_INTEGRAL_ATTR: - { - coreSelf->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, (g_value_get_ulong(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, WTF::String::fromUTF8(g_value_get_string(value))); - break; - } - case PROP_REFLECTED_STRING_ATTR: - { - coreSelf->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, WTF::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->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, (g_value_get_boolean(value))); - break; - } - case PROP_REFLECTED_CUSTOM_URL_ATTR: - { - coreSelf->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, WTF::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: - { - WebCore::ExceptionCode ec = 0; - coreSelf->setAttrWithSetterException((g_value_get_long(value)), ec); - break; - } - case PROP_STRING_ATTR_WITH_GETTER_EXCEPTION: - { - WebCore::ExceptionCode ec = 0; - coreSelf->setStringAttrWithGetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); - break; - } - case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: - { - WebCore::ExceptionCode ec = 0; - coreSelf->setStringAttrWithSetterException(WTF::String::fromUTF8(g_value_get_string(value)), ec); - break; - } - case PROP_WITH_SCRIPT_STATE_ATTRIBUTE: - { - coreSelf->setWithScriptStateAttribute((g_value_get_long(value))); - 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_STRICT_FLOAT: - { - coreSelf->setStrictFloat((g_value_get_float(value))); - break; - } - case PROP_ID: - { - coreSelf->setId((g_value_get_long(value))); - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - - -static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) -{ - WebCore::JSMainThreadNullState state; - WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); - WebCore::TestObj* coreSelf = WebKit::core(self); - switch (prop_id) { - case PROP_READ_ONLY_INT_ATTR: - { - g_value_set_long(value, coreSelf->readOnlyIntAttr()); - break; - } - case PROP_READ_ONLY_STRING_ATTR: - { - g_value_take_string(value, convertToUTF8String(coreSelf->readOnlyStringAttr())); - break; - } - case PROP_READ_ONLY_TEST_OBJ_ATTR: - { - RefPtr<WebCore::TestObj> ptr = coreSelf->readOnlyTestObjAttr(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_SHORT_ATTR: - { - g_value_set_int(value, coreSelf->shortAttr()); - break; - } - case PROP_UNSIGNED_SHORT_ATTR: - { - g_value_set_uint(value, coreSelf->unsignedShortAttr()); - break; - } - case PROP_INT_ATTR: - { - g_value_set_long(value, coreSelf->intAttr()); - break; - } - case PROP_LONG_LONG_ATTR: - { - g_value_set_int64(value, coreSelf->longLongAttr()); - break; - } - case PROP_UNSIGNED_LONG_LONG_ATTR: - { - g_value_set_uint64(value, coreSelf->unsignedLongLongAttr()); - break; - } - case PROP_STRING_ATTR: - { - g_value_take_string(value, convertToUTF8String(coreSelf->stringAttr())); - break; - } - case PROP_TEST_OBJ_ATTR: - { - RefPtr<WebCore::TestObj> ptr = coreSelf->testObjAttr(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_XML_OBJ_ATTR: - { - RefPtr<WebCore::TestObj> ptr = coreSelf->xmlObjAttr(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_CREATE: - { - g_value_set_boolean(value, coreSelf->isCreate()); - break; - } - case PROP_REFLECTED_STRING_ATTR: - { - 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_UNSIGNED_INTEGRAL_ATTR: - { - g_value_set_ulong(value, coreSelf->getUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)); - 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_CUSTOM_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_take_string(value, convertToUTF8String(coreSelf->stringAttrWithGetterException(ec))); - break; - } - case PROP_STRING_ATTR_WITH_SETTER_EXCEPTION: - { - g_value_take_string(value, convertToUTF8String(coreSelf->stringAttrWithSetterException())); - break; - } - case PROP_WITH_SCRIPT_STATE_ATTRIBUTE: - { - g_value_set_long(value, coreSelf->withScriptStateAttribute()); - break; - } - case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE: - { - RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAttribute(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_WITH_SCRIPT_STATE_ATTRIBUTE_RAISES: - { - WebCore::ExceptionCode ec = 0; - RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptStateAttributeRaises(ec); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE_RAISES: - { - WebCore::ExceptionCode ec = 0; - RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAttributeRaises(ec); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE: - { - RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAndScriptStateAttribute(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE_RAISES: - { - WebCore::ExceptionCode ec = 0; - RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAndScriptStateAttributeRaises(ec); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_WITH_SPACES_ATTRIBUTE: - { - RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptExecutionContextAndScriptStateWithSpacesAttribute(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_WITH_SCRIPT_ARGUMENTS_AND_CALL_STACK_ATTRIBUTE: - { - RefPtr<WebCore::TestObj> ptr = coreSelf->withScriptArgumentsAndCallStackAttribute(); - g_value_set_object(value, WebKit::kit(ptr.get())); - 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_CONTENT_DOCUMENT: - { - RefPtr<WebCore::Document> ptr = coreSelf->contentDocument(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_MUTABLE_POINT: - { - RefPtr<WebCore::SVGPoint> ptr = coreSelf->mutablePoint(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_IMMUTABLE_POINT: - { - RefPtr<WebCore::SVGPoint> ptr = coreSelf->immutablePoint(); - g_value_set_object(value, WebKit::kit(ptr.get())); - break; - } - case PROP_STRICT_FLOAT: - { - g_value_set_float(value, coreSelf->strictFloat()); - break; - } - case PROP_DESCRIPTION: - { - g_value_set_long(value, coreSelf->description()); - break; - } - case PROP_ID: - { - g_value_set_long(value, coreSelf->id()); - break; - } - case PROP_HASH: - { - g_value_take_string(value, convertToUTF8String(coreSelf->hash())); - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - - -static void webkit_dom_test_obj_constructed(GObject* object) -{ - - if (G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed) - G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->constructed(object); + WebCore::TestObj* item = WebKit::core(self); + gchar* result = convertToUTF8String(item->hash()); + return result; } -static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass) -{ - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); - gobjectClass->finalize = webkit_dom_test_obj_finalize; - gobjectClass->set_property = webkit_dom_test_obj_set_property; - gobjectClass->get_property = webkit_dom_test_obj_get_property; - gobjectClass->constructed = webkit_dom_test_obj_constructed; - - g_object_class_install_property(gobjectClass, - PROP_READ_ONLY_INT_ATTR, - g_param_spec_long("read-only-int-attr", /* name */ - "test_obj_read-only-int-attr", /* short description */ - "read-only glong TestObj.read-only-int-attr", /* longer - could do with some extra doc stuff here */ - G_MINLONG, /* min */ -G_MAXLONG, /* max */ -0, /* default */ - WEBKIT_PARAM_READABLE)); - g_object_class_install_property(gobjectClass, - PROP_READ_ONLY_STRING_ATTR, - g_param_spec_string("read-only-string-attr", /* name */ - "test_obj_read-only-string-attr", /* short description */ - "read-only gchar* TestObj.read-only-string-attr", /* longer - could do with some extra doc stuff here */ - "", /* default */ - WEBKIT_PARAM_READABLE)); - g_object_class_install_property(gobjectClass, - PROP_READ_ONLY_TEST_OBJ_ATTR, - g_param_spec_object("read-only-test-obj-attr", /* name */ - "test_obj_read-only-test-obj-attr", /* short description */ - "read-only WebKitDOMTestObj* TestObj.read-only-test-obj-attr", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READABLE)); - g_object_class_install_property(gobjectClass, - PROP_SHORT_ATTR, - g_param_spec_int("short-attr", /* name */ - "test_obj_short-attr", /* short description */ - "read-write gshort TestObj.short-attr", /* longer - could do with some extra doc stuff here */ - G_MININT, /* min */ -G_MAXINT, /* max */ -0, /* default */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_UNSIGNED_SHORT_ATTR, - g_param_spec_uint("unsigned-short-attr", /* name */ - "test_obj_unsigned-short-attr", /* short description */ - "read-write gushort TestObj.unsigned-short-attr", /* longer - could do with some extra doc stuff here */ - 0, /* min */ -G_MAXUINT, /* max */ -0, /* default */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_INT_ATTR, - g_param_spec_long("int-attr", /* name */ - "test_obj_int-attr", /* short description */ - "read-write glong TestObj.int-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_LONG_LONG_ATTR, - g_param_spec_int64("long-long-attr", /* name */ - "test_obj_long-long-attr", /* short description */ - "read-write gint64 TestObj.long-long-attr", /* longer - could do with some extra doc stuff here */ - G_MININT64, /* min */ -G_MAXINT64, /* max */ -0, /* default */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_UNSIGNED_LONG_LONG_ATTR, - g_param_spec_uint64("unsigned-long-long-attr", /* name */ - "test_obj_unsigned-long-long-attr", /* short description */ - "read-write guint64 TestObj.unsigned-long-long-attr", /* longer - could do with some extra doc stuff here */ - 0, /* min */ -G_MAXUINT64, /* min */ -0, /* default */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_STRING_ATTR, - g_param_spec_string("string-attr", /* name */ - "test_obj_string-attr", /* short description */ - "read-write gchar* TestObj.string-attr", /* longer - could do with some extra doc stuff here */ - "", /* default */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_TEST_OBJ_ATTR, - g_param_spec_object("test-obj-attr", /* name */ - "test_obj_test-obj-attr", /* short description */ - "read-write WebKitDOMTestObj* TestObj.test-obj-attr", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_XML_OBJ_ATTR, - g_param_spec_object("xml-obj-attr", /* name */ - "test_obj_xml-obj-attr", /* short description */ - "read-write WebKitDOMTestObj* TestObj.xml-obj-attr", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_CREATE, - g_param_spec_boolean("create", /* name */ - "test_obj_create", /* short description */ - "read-write gboolean TestObj.create", /* longer - could do with some extra doc stuff here */ - FALSE, /* 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_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_REFLECTED_UNSIGNED_INTEGRAL_ATTR, - g_param_spec_ulong("reflected-unsigned-integral-attr", /* name */ - "test_obj_reflected-unsigned-integral-attr", /* short description */ - "read-write gulong TestObj.reflected-unsigned-integral-attr", /* longer - could do with some extra doc stuff here */ - 0, /* min */ -G_MAXULONG, /* max */ -0, /* default */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - 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_CUSTOM_URL_ATTR, - g_param_spec_string("reflected-custom-url-attr", /* name */ - "test_obj_reflected-custom-url-attr", /* short description */ - "read-write gchar* TestObj.reflected-custom-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 */ - "read-write glong TestObj.attr-with-getter-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_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_WITH_SCRIPT_STATE_ATTRIBUTE, - g_param_spec_long("with-script-state-attribute", /* name */ - "test_obj_with-script-state-attribute", /* short description */ - "read-write glong TestObj.with-script-state-attribute", /* 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_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE, - g_param_spec_object("with-script-execution-context-attribute", /* name */ - "test_obj_with-script-execution-context-attribute", /* short description */ - "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-attribute", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_WITH_SCRIPT_STATE_ATTRIBUTE_RAISES, - g_param_spec_object("with-script-state-attribute-raises", /* name */ - "test_obj_with-script-state-attribute-raises", /* short description */ - "read-write WebKitDOMTestObj* TestObj.with-script-state-attribute-raises", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_ATTRIBUTE_RAISES, - g_param_spec_object("with-script-execution-context-attribute-raises", /* name */ - "test_obj_with-script-execution-context-attribute-raises", /* short description */ - "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-attribute-raises", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE, - g_param_spec_object("with-script-execution-context-and-script-state-attribute", /* name */ - "test_obj_with-script-execution-context-and-script-state-attribute", /* short description */ - "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-and-script-state-attribute", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_ATTRIBUTE_RAISES, - g_param_spec_object("with-script-execution-context-and-script-state-attribute-raises", /* name */ - "test_obj_with-script-execution-context-and-script-state-attribute-raises", /* short description */ - "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-and-script-state-attribute-raises", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_WITH_SCRIPT_EXECUTION_CONTEXT_AND_SCRIPT_STATE_WITH_SPACES_ATTRIBUTE, - g_param_spec_object("with-script-execution-context-and-script-state-with-spaces-attribute", /* name */ - "test_obj_with-script-execution-context-and-script-state-with-spaces-attribute", /* short description */ - "read-write WebKitDOMTestObj* TestObj.with-script-execution-context-and-script-state-with-spaces-attribute", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_WITH_SCRIPT_ARGUMENTS_AND_CALL_STACK_ATTRIBUTE, - g_param_spec_object("with-script-arguments-and-call-stack-attribute", /* name */ - "test_obj_with-script-arguments-and-call-stack-attribute", /* short description */ - "read-write WebKitDOMTestObj* TestObj.with-script-arguments-and-call-stack-attribute", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ - WEBKIT_PARAM_READWRITE)); -#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_CONTENT_DOCUMENT, - g_param_spec_object("content-document", /* name */ - "test_obj_content-document", /* short description */ - "read-only WebKitDOMDocument* TestObj.content-document", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_DOCUMENT, /* gobject type */ - WEBKIT_PARAM_READABLE)); - g_object_class_install_property(gobjectClass, - PROP_MUTABLE_POINT, - g_param_spec_object("mutable-point", /* name */ - "test_obj_mutable-point", /* short description */ - "read-write WebKitDOMSVGPoint* TestObj.mutable-point", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_SVG_POINT, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_IMMUTABLE_POINT, - g_param_spec_object("immutable-point", /* name */ - "test_obj_immutable-point", /* short description */ - "read-write WebKitDOMSVGPoint* TestObj.immutable-point", /* longer - could do with some extra doc stuff here */ - WEBKIT_TYPE_DOM_SVG_POINT, /* gobject type */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_STRICT_FLOAT, - g_param_spec_float("strict-float", /* name */ - "test_obj_strict-float", /* short description */ - "read-write gfloat TestObj.strict-float", /* longer - could do with some extra doc stuff here */ - -G_MAXFLOAT, /* min */ -G_MAXFLOAT, /* max */ -0.0, /* default */ - WEBKIT_PARAM_READWRITE)); - g_object_class_install_property(gobjectClass, - PROP_DESCRIPTION, - g_param_spec_long("description", /* name */ - "test_obj_description", /* short description */ - "read-only glong TestObj.description", /* longer - could do with some extra doc stuff here */ - G_MINLONG, /* min */ -G_MAXLONG, /* max */ -0, /* default */ - WEBKIT_PARAM_READABLE)); - g_object_class_install_property(gobjectClass, - PROP_ID, - g_param_spec_long("id", /* name */ - "test_obj_id", /* short description */ - "read-write glong TestObj.id", /* 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_HASH, - g_param_spec_string("hash", /* name */ - "test_obj_hash", /* short description */ - "read-only gchar* TestObj.hash", /* longer - could do with some extra doc stuff here */ - "", /* default */ - WEBKIT_PARAM_READABLE)); - - -} - -static void webkit_dom_test_obj_init(WebKitDOMTestObj* request) -{ -} - -namespace WebKit { -WebKitDOMTestObj* wrapTestObj(WebCore::TestObj* coreObject) -{ - g_return_val_if_fail(coreObject, 0); - - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); - - return WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, - "core-object", coreObject, NULL)); -} -} // namespace WebKit diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h index caeb51ffa..9fa9aadee 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestObj_h #define WebKitDOMTestObj_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_OBJ (webkit_dom_test_obj_get_type()) @@ -59,15 +58,15 @@ webkit_dom_test_obj_void_method(WebKitDOMTestObj* self); /** * webkit_dom_test_obj_void_method_with_args: * @self: A #WebKitDOMTestObj - * @int_arg: A #glong - * @str_arg: A #gchar - * @obj_arg: A #WebKitDOMTestObj + * @intArg: A #glong + * @strArg: A #gchar + * @objArg: A #WebKitDOMTestObj * * Returns: * **/ WEBKIT_API void -webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg); +webkit_dom_test_obj_void_method_with_args(WebKitDOMTestObj* self, glong intArg, const gchar* strArg, WebKitDOMTestObj* objArg); /** * webkit_dom_test_obj_int_method: @@ -82,15 +81,15 @@ webkit_dom_test_obj_int_method(WebKitDOMTestObj* self); /** * webkit_dom_test_obj_int_method_with_args: * @self: A #WebKitDOMTestObj - * @int_arg: A #glong - * @str_arg: A #gchar - * @obj_arg: A #WebKitDOMTestObj + * @intArg: A #glong + * @strArg: A #gchar + * @objArg: A #WebKitDOMTestObj * * Returns: * **/ WEBKIT_API glong -webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg); +webkit_dom_test_obj_int_method_with_args(WebKitDOMTestObj* self, glong intArg, const gchar* strArg, WebKitDOMTestObj* objArg); /** * webkit_dom_test_obj_obj_method: @@ -105,39 +104,39 @@ webkit_dom_test_obj_obj_method(WebKitDOMTestObj* self); /** * webkit_dom_test_obj_obj_method_with_args: * @self: A #WebKitDOMTestObj - * @int_arg: A #glong - * @str_arg: A #gchar - * @obj_arg: A #WebKitDOMTestObj + * @intArg: A #glong + * @strArg: A #gchar + * @objArg: A #WebKitDOMTestObj * * Returns: (transfer none): * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong int_arg, const gchar* str_arg, WebKitDOMTestObj* obj_arg); +webkit_dom_test_obj_obj_method_with_args(WebKitDOMTestObj* self, glong intArg, const gchar* strArg, WebKitDOMTestObj* objArg); /** * webkit_dom_test_obj_method_that_requires_all_args_and_throws: * @self: A #WebKitDOMTestObj - * @str_arg: A #gchar - * @obj_arg: A #WebKitDOMTestObj + * @strArg: A #gchar + * @objArg: A #WebKitDOMTestObj * @error: #GError * * Returns: (transfer none): * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* self, const gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error); +webkit_dom_test_obj_method_that_requires_all_args_and_throws(WebKitDOMTestObj* self, const gchar* strArg, WebKitDOMTestObj* objArg, GError** error); /** * webkit_dom_test_obj_serialized_value: * @self: A #WebKitDOMTestObj - * @serialized_arg: A #WebKitDOMSerializedScriptValue + * @serializedArg: A #WebKitDOMSerializedScriptValue * * Returns: * **/ WEBKIT_API void -webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serialized_arg); +webkit_dom_test_obj_serialized_value(WebKitDOMTestObj* self, WebKitDOMSerializedScriptValue* serializedArg); /** * webkit_dom_test_obj_idb_key: @@ -153,14 +152,14 @@ webkit_dom_test_obj_idb_key(WebKitDOMTestObj* self, WebKitDOMIDBKey* key); /** * webkit_dom_test_obj_options_object: * @self: A #WebKitDOMTestObj - * @oo: A #WebKitDOMOptionsObject - * @ooo: A #WebKitDOMOptionsObject + * @oo: A #WebKitDOMDictionary + * @ooo: A #WebKitDOMDictionary * * Returns: * **/ WEBKIT_API void -webkit_dom_test_obj_options_object(WebKitDOMTestObj* self, WebKitDOMOptionsObject* oo, WebKitDOMOptionsObject* ooo); +webkit_dom_test_obj_options_object(WebKitDOMTestObj* self, WebKitDOMDictionary* oo, WebKitDOMDictionary* ooo); /** * webkit_dom_test_obj_method_with_exception: @@ -171,7 +170,7 @@ webkit_dom_test_obj_options_object(WebKitDOMTestObj* self, WebKitDOMOptionsObjec * **/ WEBKIT_API void -webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_method_with_exception(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_with_script_state_void: @@ -202,7 +201,7 @@ webkit_dom_test_obj_with_script_state_obj(WebKitDOMTestObj* self); * **/ WEBKIT_API void -webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_with_script_state_obj_exception: @@ -213,7 +212,7 @@ webkit_dom_test_obj_with_script_state_void_exception(WebKitDOMTestObj* self, GEr * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_with_script_state_obj_exception(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_with_script_execution_context: @@ -244,7 +243,7 @@ webkit_dom_test_obj_with_script_execution_context_and_script_state(WebKitDOMTest * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_obj_with_script_execution_context_and_script_state_obj_exception(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_with_script_execution_context_and_script_state_obj_exception(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_with_script_execution_context_and_script_state_with_spaces: @@ -270,19 +269,19 @@ webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt); /** * webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg: * @self: A #WebKitDOMTestObj - * @non_opt: A #glong + * @nonOpt: A #glong * @opt: A #glong * * Returns: * **/ WEBKIT_API void -webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong non_opt, glong opt); +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong nonOpt, glong opt); /** * webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args: * @self: A #WebKitDOMTestObj - * @non_opt: A #glong + * @nonOpt: A #glong * @opt1: A #glong * @opt2: A #glong * @@ -290,7 +289,7 @@ webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestO * **/ WEBKIT_API void -webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong non_opt, glong opt1, glong opt2); +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong nonOpt, glong opt1, glong opt2); /** * webkit_dom_test_obj_method_with_optional_string: @@ -495,7 +494,7 @@ webkit_dom_test_obj_orange(WebKitDOMTestObj* self); * **/ WEBKIT_API WebKitDOMbool* -webkit_dom_test_obj_strict_function(WebKitDOMTestObj* self, const gchar* str, gfloat a, gint b, GError **error); +webkit_dom_test_obj_strict_function(WebKitDOMTestObj* self, const gchar* str, gfloat a, gint b, GError** error); /** * webkit_dom_test_obj_get_read_only_int_attr: @@ -914,7 +913,7 @@ webkit_dom_test_obj_set_reflected_custom_url_attr(WebKitDOMTestObj* self, const * **/ WEBKIT_API glong -webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_set_attr_with_getter_exception: @@ -926,7 +925,7 @@ webkit_dom_test_obj_get_attr_with_getter_exception(WebKitDOMTestObj* self, GErro * **/ WEBKIT_API void -webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError **error); +webkit_dom_test_obj_set_attr_with_getter_exception(WebKitDOMTestObj* self, glong value, GError** error); /** * webkit_dom_test_obj_get_attr_with_setter_exception: @@ -948,7 +947,7 @@ 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_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong value, GError** error); /** * webkit_dom_test_obj_get_string_attr_with_getter_exception: @@ -959,7 +958,7 @@ webkit_dom_test_obj_set_attr_with_setter_exception(WebKitDOMTestObj* self, glong * **/ WEBKIT_API gchar* -webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_set_string_attr_with_getter_exception: @@ -971,7 +970,7 @@ webkit_dom_test_obj_get_string_attr_with_getter_exception(WebKitDOMTestObj* self * **/ WEBKIT_API void -webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, const gchar* value, GError **error); +webkit_dom_test_obj_set_string_attr_with_getter_exception(WebKitDOMTestObj* self, const gchar* value, GError** error); /** * webkit_dom_test_obj_get_string_attr_with_setter_exception: @@ -993,7 +992,7 @@ 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, const gchar* value, GError **error); +webkit_dom_test_obj_set_string_attr_with_setter_exception(WebKitDOMTestObj* self, const gchar* value, GError** error); /** * webkit_dom_test_obj_get_with_script_state_attribute: @@ -1046,7 +1045,7 @@ webkit_dom_test_obj_set_with_script_execution_context_attribute(WebKitDOMTestObj * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_obj_get_with_script_state_attribute_raises(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_get_with_script_state_attribute_raises(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_set_with_script_state_attribute_raises: @@ -1058,7 +1057,7 @@ webkit_dom_test_obj_get_with_script_state_attribute_raises(WebKitDOMTestObj* sel * **/ WEBKIT_API void -webkit_dom_test_obj_set_with_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError **error); +webkit_dom_test_obj_set_with_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError** error); /** * webkit_dom_test_obj_get_with_script_execution_context_attribute_raises: @@ -1069,7 +1068,7 @@ webkit_dom_test_obj_set_with_script_state_attribute_raises(WebKitDOMTestObj* sel * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_obj_get_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_get_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_set_with_script_execution_context_attribute_raises: @@ -1081,7 +1080,7 @@ webkit_dom_test_obj_get_with_script_execution_context_attribute_raises(WebKitDOM * **/ WEBKIT_API void -webkit_dom_test_obj_set_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError **error); +webkit_dom_test_obj_set_with_script_execution_context_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError** error); /** * webkit_dom_test_obj_get_with_script_execution_context_and_script_state_attribute: @@ -1113,7 +1112,7 @@ webkit_dom_test_obj_set_with_script_execution_context_and_script_state_attribute * **/ WEBKIT_API WebKitDOMTestObj* -webkit_dom_test_obj_get_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, GError **error); +webkit_dom_test_obj_get_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, GError** error); /** * webkit_dom_test_obj_set_with_script_execution_context_and_script_state_attribute_raises: @@ -1125,7 +1124,7 @@ webkit_dom_test_obj_get_with_script_execution_context_and_script_state_attribute * **/ WEBKIT_API void -webkit_dom_test_obj_set_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError **error); +webkit_dom_test_obj_set_with_script_execution_context_and_script_state_attribute_raises(WebKitDOMTestObj* self, WebKitDOMTestObj* value, GError** error); /** * webkit_dom_test_obj_get_with_script_execution_context_and_script_state_with_spaces_attribute: @@ -1264,6 +1263,27 @@ WEBKIT_API void webkit_dom_test_obj_set_immutable_point(WebKitDOMTestObj* self, WebKitDOMSVGPoint* value); /** + * webkit_dom_test_obj_get_strawberry: + * @self: A #WebKitDOMTestObj + * + * Returns: + * +**/ +WEBKIT_API gint +webkit_dom_test_obj_get_strawberry(WebKitDOMTestObj* self); + +/** + * webkit_dom_test_obj_set_strawberry: + * @self: A #WebKitDOMTestObj + * @value: A #gint + * + * Returns: + * +**/ +WEBKIT_API void +webkit_dom_test_obj_set_strawberry(WebKitDOMTestObj* self, gint value); + +/** * webkit_dom_test_obj_get_strict_float: * @self: A #WebKitDOMTestObj * diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h index 96722f797..98e4a3149 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h @@ -18,22 +18,17 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_OBJ_PRIVATE_H -#define WEB_KIT_DOM_TEST_OBJ_PRIVATE_H +#ifndef WebKitDOMTestObjPrivate_h +#define WebKitDOMTestObjPrivate_h +#include "TestObj.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestObj.h" -namespace WebKit { - WebKitDOMTestObj * - wrapTestObj(WebCore::TestObj *coreObject); - - WebCore::TestObj * - core(WebKitDOMTestObj *request); - - WebKitDOMTestObj* - kit(WebCore::TestObj* node); +namespace WebKit { +WebKitDOMTestObj* wrapTestObj(WebCore::TestObj*); +WebCore::TestObj* core(WebKitDOMTestObj* request); +WebKitDOMTestObj* kit(WebCore::TestObj* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_OBJ_PRIVATE_H */ +#endif /* WebKitDOMTestObjPrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.cpp index 961c4b3a5..fe5724e81 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.cpp @@ -18,30 +18,35 @@ Boston, MA 02110-1301, USA. */ -#include <glib-object.h> #include "config.h" +#include "WebKitDOMTestSerializedScriptValueInterface.h" -#if ENABLE(Condition1) || ENABLE(Condition2) - -#include <wtf/GetPtr.h> -#include <wtf/RefPtr.h> #include "DOMObjectCache.h" #include "ExceptionCode.h" #include "JSMainThreadExecState.h" +#include "MessagePortArray.h" #include "SerializedScriptValue.h" #include "TestSerializedScriptValueInterface.h" #include "WebKitDOMBinding.h" #include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMArray.h" +#include "webkit/WebKitDOMArrayPrivate.h" +#include "webkit/WebKitDOMMessagePortArray.h" +#include "webkit/WebKitDOMMessagePortArrayPrivate.h" #include "webkit/WebKitDOMSerializedScriptValue.h" #include "webkit/WebKitDOMSerializedScriptValuePrivate.h" -#include "webkit/WebKitDOMTestSerializedScriptValueInterface.h" #include "webkit/WebKitDOMTestSerializedScriptValueInterfacePrivate.h" #include "webkitdefines.h" #include "webkitglobalsprivate.h" #include "webkitmarshal.h" +#include <glib-object.h> +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +#if ENABLE(Condition1) || ENABLE(Condition2) namespace WebKit { - + WebKitDOMTestSerializedScriptValueInterface* kit(WebCore::TestSerializedScriptValueInterface* obj) { g_return_val_if_fail(obj, 0); @@ -51,167 +56,130 @@ WebKitDOMTestSerializedScriptValueInterface* kit(WebCore::TestSerializedScriptVa return static_cast<WebKitDOMTestSerializedScriptValueInterface*>(DOMObjectCache::put(obj, WebKit::wrapTestSerializedScriptValueInterface(obj))); } - -} // namespace WebKit // -WebKitDOMSerializedScriptValue* -webkit_dom_test_serialized_script_value_interface_get_value(WebKitDOMTestSerializedScriptValueInterface* self) +WebCore::TestSerializedScriptValueInterface* core(WebKitDOMTestSerializedScriptValueInterface* request) { - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestSerializedScriptValueInterface * item = WebKit::core(self); - PassRefPtr<WebCore::SerializedScriptValue> g_res = WTF::getPtr(item->value()); - WebKitDOMSerializedScriptValue* res = WebKit::kit(g_res.get()); - return res; -} + g_return_val_if_fail(request, 0); -void -webkit_dom_test_serialized_script_value_interface_set_value(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* value) -{ - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestSerializedScriptValueInterface * item = WebKit::core(self); - g_return_if_fail(value); - WebCore::SerializedScriptValue * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); - } - item->setValue(converted_value); -} + WebCore::TestSerializedScriptValueInterface* coreObject = static_cast<WebCore::TestSerializedScriptValueInterface*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject, 0); -WebKitDOMSerializedScriptValue* -webkit_dom_test_serialized_script_value_interface_get_readonly_value(WebKitDOMTestSerializedScriptValueInterface* self) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestSerializedScriptValueInterface * item = WebKit::core(self); - PassRefPtr<WebCore::SerializedScriptValue> g_res = WTF::getPtr(item->readonlyValue()); - WebKitDOMSerializedScriptValue* res = WebKit::kit(g_res.get()); - return res; + return coreObject; } -WebKitDOMSerializedScriptValue* -webkit_dom_test_serialized_script_value_interface_get_cached_value(WebKitDOMTestSerializedScriptValueInterface* self) +WebKitDOMTestSerializedScriptValueInterface* wrapTestSerializedScriptValueInterface(WebCore::TestSerializedScriptValueInterface* coreObject) { - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestSerializedScriptValueInterface * item = WebKit::core(self); - PassRefPtr<WebCore::SerializedScriptValue> g_res = WTF::getPtr(item->cachedValue()); - WebKitDOMSerializedScriptValue* res = WebKit::kit(g_res.get()); - return res; -} + g_return_val_if_fail(coreObject, 0); -void -webkit_dom_test_serialized_script_value_interface_set_cached_value(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* value) -{ - g_return_if_fail(self); - WebCore::JSMainThreadNullState state; - WebCore::TestSerializedScriptValueInterface * item = WebKit::core(self); - g_return_if_fail(value); - WebCore::SerializedScriptValue * converted_value = NULL; - if (value != NULL) { - converted_value = WebKit::core(value); - g_return_if_fail(converted_value); - } - item->setCachedValue(converted_value); -} + // We call ref() rather than using a C++ smart pointer because we can't store a C++ object + // in a C-allocated GObject structure. See the finalize() code for the matching deref(). + coreObject->ref(); -WebKitDOMSerializedScriptValue* -webkit_dom_test_serialized_script_value_interface_get_cached_readonly_value(WebKitDOMTestSerializedScriptValueInterface* self) -{ - g_return_val_if_fail(self, 0); - WebCore::JSMainThreadNullState state; - WebCore::TestSerializedScriptValueInterface * item = WebKit::core(self); - PassRefPtr<WebCore::SerializedScriptValue> g_res = WTF::getPtr(item->cachedReadonlyValue()); - WebKitDOMSerializedScriptValue* res = WebKit::kit(g_res.get()); - return res; + return WEBKIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE, "core-object", coreObject, NULL)); } +} // namespace WebKit -G_DEFINE_TYPE(WebKitDOMTestSerializedScriptValueInterface, webkit_dom_test_serialized_script_value_interface, WEBKIT_TYPE_DOM_OBJECT) - -namespace WebKit { - -WebCore::TestSerializedScriptValueInterface* core(WebKitDOMTestSerializedScriptValueInterface* request) -{ - g_return_val_if_fail(request, 0); - - WebCore::TestSerializedScriptValueInterface* coreObject = static_cast<WebCore::TestSerializedScriptValueInterface*>(WEBKIT_DOM_OBJECT(request)->coreObject); - g_return_val_if_fail(coreObject, 0); +#endif // ENABLE(Condition1) || ENABLE(Condition2) - return coreObject; -} +G_DEFINE_TYPE(WebKitDOMTestSerializedScriptValueInterface, webkit_dom_test_serialized_script_value_interface, WEBKIT_TYPE_DOM_OBJECT) -} // namespace WebKit enum { PROP_0, PROP_VALUE, PROP_READONLY_VALUE, PROP_CACHED_VALUE, + PROP_PORTS, PROP_CACHED_READONLY_VALUE, }; - static void webkit_dom_test_serialized_script_value_interface_finalize(GObject* object) { - WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); +#if ENABLE(Condition1) || ENABLE(Condition2) + WebKitDOMObject* domObject = WEBKIT_DOM_OBJECT(object); - if (dom_object->coreObject) { - WebCore::TestSerializedScriptValueInterface* coreObject = static_cast<WebCore::TestSerializedScriptValueInterface *>(dom_object->coreObject); + if (domObject->coreObject) { + WebCore::TestSerializedScriptValueInterface* coreObject = static_cast<WebCore::TestSerializedScriptValueInterface*>(domObject->coreObject); WebKit::DOMObjectCache::forget(coreObject); coreObject->deref(); - dom_object->coreObject = NULL; + domObject->coreObject = 0; } +#endif // ENABLE(Condition1) || ENABLE(Condition2) G_OBJECT_CLASS(webkit_dom_test_serialized_script_value_interface_parent_class)->finalize(object); } -static void webkit_dom_test_serialized_script_value_interface_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +static void webkit_dom_test_serialized_script_value_interface_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; - switch (prop_id) { + switch (propertyId) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } -static void webkit_dom_test_serialized_script_value_interface_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +static void webkit_dom_test_serialized_script_value_interface_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) { WebCore::JSMainThreadNullState state; WebKitDOMTestSerializedScriptValueInterface* self = WEBKIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE(object); WebCore::TestSerializedScriptValueInterface* coreSelf = WebKit::core(self); - switch (prop_id) { - case PROP_VALUE: - { + switch (propertyId) { + case PROP_VALUE: { +#if ENABLE(Condition1) || ENABLE(Condition2) RefPtr<WebCore::SerializedScriptValue> ptr = coreSelf->value(); g_value_set_object(value, WebKit::kit(ptr.get())); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } - case PROP_READONLY_VALUE: - { + case PROP_READONLY_VALUE: { +#if ENABLE(Condition1) || ENABLE(Condition2) RefPtr<WebCore::SerializedScriptValue> ptr = coreSelf->readonlyValue(); g_value_set_object(value, WebKit::kit(ptr.get())); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } - case PROP_CACHED_VALUE: - { + case PROP_CACHED_VALUE: { +#if ENABLE(Condition1) || ENABLE(Condition2) RefPtr<WebCore::SerializedScriptValue> ptr = coreSelf->cachedValue(); g_value_set_object(value, WebKit::kit(ptr.get())); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } - case PROP_CACHED_READONLY_VALUE: - { + case PROP_PORTS: { +#if ENABLE(Condition1) || ENABLE(Condition2) + RefPtr<WebCore::MessagePortArray> ptr = coreSelf->ports(); + g_value_set_object(value, WebKit::kit(ptr.get())); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + break; + } + case PROP_CACHED_READONLY_VALUE: { +#if ENABLE(Condition1) || ENABLE(Condition2) RefPtr<WebCore::SerializedScriptValue> ptr = coreSelf->cachedReadonlyValue(); g_value_set_object(value, WebKit::kit(ptr.get())); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ break; } default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); break; } } @@ -226,7 +194,7 @@ static void webkit_dom_test_serialized_script_value_interface_constructed(GObjec static void webkit_dom_test_serialized_script_value_interface_class_init(WebKitDOMTestSerializedScriptValueInterfaceClass* requestClass) { - GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass); gobjectClass->finalize = webkit_dom_test_serialized_script_value_interface_finalize; gobjectClass->set_property = webkit_dom_test_serialized_script_value_interface_set_property; gobjectClass->get_property = webkit_dom_test_serialized_script_value_interface_get_property; @@ -254,6 +222,13 @@ static void webkit_dom_test_serialized_script_value_interface_class_init(WebKitD WEBKIT_TYPE_DOM_SERIALIZED_SCRIPT_VALUE, /* gobject type */ WEBKIT_PARAM_READWRITE)); g_object_class_install_property(gobjectClass, + PROP_PORTS, + g_param_spec_object("ports", /* name */ + "test_serialized_script_value_interface_ports", /* short description */ + "read-only WebKitDOMMessagePortArray* TestSerializedScriptValueInterface.ports", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_MESSAGE_PORT_ARRAY, /* gobject type */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, PROP_CACHED_READONLY_VALUE, g_param_spec_object("cached-readonly-value", /* name */ "test_serialized_script_value_interface_cached-readonly-value", /* short description */ @@ -268,19 +243,192 @@ static void webkit_dom_test_serialized_script_value_interface_init(WebKitDOMTest { } -namespace WebKit { -WebKitDOMTestSerializedScriptValueInterface* wrapTestSerializedScriptValueInterface(WebCore::TestSerializedScriptValueInterface* coreObject) +void +webkit_dom_test_serialized_script_value_interface_accept_transfer_list(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* data, WebKitDOMArray* transferList) { - g_return_val_if_fail(coreObject, 0); +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + g_return_if_fail(data); + g_return_if_fail(transferList); + WebCore::SerializedScriptValue* convertedData = 0; + if (data) { + convertedData = WebKit::core(data); + g_return_if_fail(convertedData); + } + WebCore::Array* convertedTransferList = 0; + if (transferList) { + convertedTransferList = WebKit::core(transferList); + g_return_if_fail(convertedTransferList); + } + item->acceptTransferList(convertedData, convertedTransferList); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} - /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object - * in a C-allocated GObject structure. See the finalize() code for the - * matching deref(). - */ - coreObject->ref(); +void +webkit_dom_test_serialized_script_value_interface_multi_transfer_list(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* first, WebKitDOMArray* tx, WebKitDOMSerializedScriptValue* second, WebKitDOMArray* txx) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + g_return_if_fail(first); + g_return_if_fail(tx); + g_return_if_fail(second); + g_return_if_fail(txx); + WebCore::SerializedScriptValue* convertedFirst = 0; + if (first) { + convertedFirst = WebKit::core(first); + g_return_if_fail(convertedFirst); + } + WebCore::Array* convertedTx = 0; + if (tx) { + convertedTx = WebKit::core(tx); + g_return_if_fail(convertedTx); + } + WebCore::SerializedScriptValue* convertedSecond = 0; + if (second) { + convertedSecond = WebKit::core(second); + g_return_if_fail(convertedSecond); + } + WebCore::Array* convertedTxx = 0; + if (txx) { + convertedTxx = WebKit::core(txx); + g_return_if_fail(convertedTxx); + } + item->multiTransferList(convertedFirst, convertedTx, convertedSecond, convertedTxx); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} - return WEBKIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE, - "core-object", coreObject, NULL)); +WebKitDOMSerializedScriptValue* +webkit_dom_test_serialized_script_value_interface_get_value(WebKitDOMTestSerializedScriptValueInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + RefPtr<WebCore::SerializedScriptValue> gobjectResult = WTF::getPtr(item->value()); + WebKitDOMSerializedScriptValue* result = WebKit::kit(gobjectResult.get()); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ } -} // namespace WebKit + +void +webkit_dom_test_serialized_script_value_interface_set_value(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* value) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + g_return_if_fail(value); + WebCore::SerializedScriptValue* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); + } + item->setValue(convertedValue); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +WebKitDOMSerializedScriptValue* +webkit_dom_test_serialized_script_value_interface_get_readonly_value(WebKitDOMTestSerializedScriptValueInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + RefPtr<WebCore::SerializedScriptValue> gobjectResult = WTF::getPtr(item->readonlyValue()); + WebKitDOMSerializedScriptValue* result = WebKit::kit(gobjectResult.get()); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +WebKitDOMSerializedScriptValue* +webkit_dom_test_serialized_script_value_interface_get_cached_value(WebKitDOMTestSerializedScriptValueInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + RefPtr<WebCore::SerializedScriptValue> gobjectResult = WTF::getPtr(item->cachedValue()); + WebKitDOMSerializedScriptValue* result = WebKit::kit(gobjectResult.get()); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +void +webkit_dom_test_serialized_script_value_interface_set_cached_value(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* value) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_if_fail(self); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + g_return_if_fail(value); + WebCore::SerializedScriptValue* convertedValue = 0; + if (value) { + convertedValue = WebKit::core(value); + g_return_if_fail(convertedValue); + } + item->setCachedValue(convertedValue); +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +WebKitDOMMessagePortArray* +webkit_dom_test_serialized_script_value_interface_get_ports(WebKitDOMTestSerializedScriptValueInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + RefPtr<WebCore::MessagePortArray> gobjectResult = WTF::getPtr(item->ports()); + WebKitDOMMessagePortArray* result = WebKit::kit(gobjectResult.get()); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; #endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + +WebKitDOMSerializedScriptValue* +webkit_dom_test_serialized_script_value_interface_get_cached_readonly_value(WebKitDOMTestSerializedScriptValueInterface* self) +{ +#if ENABLE(Condition1) || ENABLE(Condition2) + g_return_val_if_fail(self, 0); + WebCore::JSMainThreadNullState state; + WebCore::TestSerializedScriptValueInterface* item = WebKit::core(self); + RefPtr<WebCore::SerializedScriptValue> gobjectResult = WTF::getPtr(item->cachedReadonlyValue()); + WebKitDOMSerializedScriptValue* result = WebKit::kit(gobjectResult.get()); + return result; +#else + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition1") + WEBKIT_WARN_FEATURE_NOT_PRESENT("Condition2") + return 0; +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ +} + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.h index 516141859..7232fe3e7 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.h @@ -21,11 +21,10 @@ #ifndef WebKitDOMTestSerializedScriptValueInterface_h #define WebKitDOMTestSerializedScriptValueInterface_h -#include "webkit/webkitdomdefines.h" #include <glib-object.h> +#include <webkit/WebKitDOMObject.h> #include <webkit/webkitdefines.h> -#include "webkit/WebKitDOMObject.h" - +#include <webkit/webkitdomdefines.h> G_BEGIN_DECLS #define WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE (webkit_dom_test_serialized_script_value_interface_get_type()) @@ -47,6 +46,32 @@ WEBKIT_API GType webkit_dom_test_serialized_script_value_interface_get_type (void); /** + * webkit_dom_test_serialized_script_value_interface_accept_transfer_list: + * @self: A #WebKitDOMTestSerializedScriptValueInterface + * @data: A #WebKitDOMSerializedScriptValue + * @transferList: A #WebKitDOMArray + * + * Returns: + * +**/ +WEBKIT_API void +webkit_dom_test_serialized_script_value_interface_accept_transfer_list(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* data, WebKitDOMArray* transferList); + +/** + * webkit_dom_test_serialized_script_value_interface_multi_transfer_list: + * @self: A #WebKitDOMTestSerializedScriptValueInterface + * @first: A #WebKitDOMSerializedScriptValue + * @tx: A #WebKitDOMArray + * @second: A #WebKitDOMSerializedScriptValue + * @txx: A #WebKitDOMArray + * + * Returns: + * +**/ +WEBKIT_API void +webkit_dom_test_serialized_script_value_interface_multi_transfer_list(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* first, WebKitDOMArray* tx, WebKitDOMSerializedScriptValue* second, WebKitDOMArray* txx); + +/** * webkit_dom_test_serialized_script_value_interface_get_value: * @self: A #WebKitDOMTestSerializedScriptValueInterface * @@ -99,6 +124,16 @@ WEBKIT_API void webkit_dom_test_serialized_script_value_interface_set_cached_value(WebKitDOMTestSerializedScriptValueInterface* self, WebKitDOMSerializedScriptValue* value); /** + * webkit_dom_test_serialized_script_value_interface_get_ports: + * @self: A #WebKitDOMTestSerializedScriptValueInterface + * + * Returns: (transfer none): + * +**/ +WEBKIT_API WebKitDOMMessagePortArray* +webkit_dom_test_serialized_script_value_interface_get_ports(WebKitDOMTestSerializedScriptValueInterface* self); + +/** * webkit_dom_test_serialized_script_value_interface_get_cached_readonly_value: * @self: A #WebKitDOMTestSerializedScriptValueInterface * diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterfacePrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterfacePrivate.h index 82e79a26f..fcbea0761 100644 --- a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterfacePrivate.h +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterfacePrivate.h @@ -18,22 +18,20 @@ Boston, MA 02110-1301, USA. */ -#ifndef WEB_KIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_PRIVATE_H -#define WEB_KIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_PRIVATE_H +#ifndef WebKitDOMTestSerializedScriptValueInterfacePrivate_h +#define WebKitDOMTestSerializedScriptValueInterfacePrivate_h +#include "TestSerializedScriptValueInterface.h" #include <glib-object.h> #include <webkit/WebKitDOMObject.h> -#include "TestSerializedScriptValueInterface.h" -namespace WebKit { - WebKitDOMTestSerializedScriptValueInterface * - wrapTestSerializedScriptValueInterface(WebCore::TestSerializedScriptValueInterface *coreObject); - - WebCore::TestSerializedScriptValueInterface * - core(WebKitDOMTestSerializedScriptValueInterface *request); - - WebKitDOMTestSerializedScriptValueInterface* - kit(WebCore::TestSerializedScriptValueInterface* node); +#if ENABLE(Condition1) || ENABLE(Condition2) +namespace WebKit { +WebKitDOMTestSerializedScriptValueInterface* wrapTestSerializedScriptValueInterface(WebCore::TestSerializedScriptValueInterface*); +WebCore::TestSerializedScriptValueInterface* core(WebKitDOMTestSerializedScriptValueInterface* request); +WebKitDOMTestSerializedScriptValueInterface* kit(WebCore::TestSerializedScriptValueInterface* node); } // namespace WebKit -#endif /* WEB_KIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_PRIVATE_H */ +#endif /* ENABLE(Condition1) || ENABLE(Condition2) */ + +#endif /* WebKitDOMTestSerializedScriptValueInterfacePrivate_h */ diff --git a/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp b/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp index 9ce2b68f3..3b533f59d 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp @@ -70,12 +70,12 @@ void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObjec bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, static_cast<JSFloat64ArrayConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(cell), propertyName, slot); } bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, static_cast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor); } ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -183,7 +183,7 @@ bool JSFloat64Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, un JSValue jsFloat64ArrayConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSFloat64Array* domObject = static_cast<JSFloat64Array*>(asObject(slotBase)); + JSFloat64Array* domObject = jsCast<JSFloat64Array*>(asObject(slotBase)); return JSFloat64Array::getConstructor(exec, domObject->globalObject()); } @@ -219,7 +219,7 @@ void JSFloat64Array::getOwnPropertyNames(JSObject* object, ExecState* exec, Prop JSValue JSFloat64Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSFloat64ArrayConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSFloat64ArrayConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionFoo(ExecState* exec) @@ -227,11 +227,11 @@ EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionFoo(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSFloat64Array::s_info)) return throwVMTypeError(exec); - JSFloat64Array* castedThis = static_cast<JSFloat64Array*>(asObject(thisValue)); + JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info); Float64Array* impl = static_cast<Float64Array*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); Float32Array* array(toFloat32Array(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -252,7 +252,7 @@ JSValue JSFloat64Array::getByIndex(ExecState*, unsigned index) Float64Array* toFloat64Array(JSC::JSValue value) { - return value.inherits(&JSFloat64Array::s_info) ? static_cast<JSFloat64Array*>(asObject(value))->impl() : 0; + return value.inherits(&JSFloat64Array::s_info) ? jsCast<JSFloat64Array*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp index 6e66849f0..ce8e623b9 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp @@ -67,12 +67,12 @@ void JSTestActiveDOMObjectConstructor::finishCreation(ExecState* exec, JSDOMGlob bool JSTestActiveDOMObjectConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, static_cast<JSTestActiveDOMObjectConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, jsCast<JSTestActiveDOMObjectConstructor*>(cell), propertyName, slot); } bool JSTestActiveDOMObjectConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, static_cast<JSTestActiveDOMObjectConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, jsCast<JSTestActiveDOMObjectConstructor*>(object), propertyName, descriptor); } /* Hash table for prototype */ @@ -152,7 +152,7 @@ bool JSTestActiveDOMObject::getOwnPropertyDescriptor(JSObject* object, ExecState JSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestActiveDOMObject* castedThis = static_cast<JSTestActiveDOMObject*>(asObject(slotBase)); + JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(slotBase)); if (!castedThis->allowsAccessFrom(exec)) return jsUndefined(); UNUSED_PARAM(exec); @@ -164,7 +164,7 @@ JSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSValue slotBase, con JSValue jsTestActiveDOMObjectConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestActiveDOMObject* domObject = static_cast<JSTestActiveDOMObject*>(asObject(slotBase)); + JSTestActiveDOMObject* domObject = jsCast<JSTestActiveDOMObject*>(asObject(slotBase)); if (!domObject->allowsAccessFrom(exec)) return jsUndefined(); return JSTestActiveDOMObject::getConstructor(exec, domObject->globalObject()); @@ -172,7 +172,7 @@ JSValue jsTestActiveDOMObjectConstructor(ExecState* exec, JSValue slotBase, cons JSValue JSTestActiveDOMObject::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestActiveDOMObjectConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestActiveDOMObjectConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunction(ExecState* exec) @@ -180,13 +180,13 @@ EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunct JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestActiveDOMObject::s_info)) return throwVMTypeError(exec); - JSTestActiveDOMObject* castedThis = static_cast<JSTestActiveDOMObject*>(asObject(thisValue)); + JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestActiveDOMObject::s_info); if (!castedThis->allowsAccessFrom(exec)) return JSValue::encode(jsUndefined()); TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); Node* nextChild(toNode(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -199,11 +199,11 @@ EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionPostMessage(E JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestActiveDOMObject::s_info)) return throwVMTypeError(exec); - JSTestActiveDOMObject* castedThis = static_cast<JSTestActiveDOMObject*>(asObject(thisValue)); + JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestActiveDOMObject::s_info); TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); const String& message(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -220,7 +220,7 @@ static inline bool isObservable(JSTestActiveDOMObject* jsTestActiveDOMObject) bool JSTestActiveDOMObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestActiveDOMObject* jsTestActiveDOMObject = static_cast<JSTestActiveDOMObject*>(handle.get().asCell()); + JSTestActiveDOMObject* jsTestActiveDOMObject = jsCast<JSTestActiveDOMObject*>(handle.get().asCell()); if (!isObservable(jsTestActiveDOMObject)) return false; UNUSED_PARAM(visitor); @@ -229,7 +229,7 @@ bool JSTestActiveDOMObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unk void JSTestActiveDOMObjectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestActiveDOMObject* jsTestActiveDOMObject = static_cast<JSTestActiveDOMObject*>(handle.get().asCell()); + JSTestActiveDOMObject* jsTestActiveDOMObject = jsCast<JSTestActiveDOMObject*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestActiveDOMObject->impl(), jsTestActiveDOMObject); jsTestActiveDOMObject->releaseImpl(); @@ -242,7 +242,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestAct TestActiveDOMObject* toTestActiveDOMObject(JSC::JSValue value) { - return value.inherits(&JSTestActiveDOMObject::s_info) ? static_cast<JSTestActiveDOMObject*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestActiveDOMObject::s_info) ? jsCast<JSTestActiveDOMObject*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp index fc1461bdd..b23e26115 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -26,7 +26,9 @@ #include "JSClass1.h" #include "JSClass2.h" +#include "JSClass8.h" #include "JSDOMStringList.h" +#include "JSThisClass.h" #include "ScriptExecutionContext.h" #include <runtime/JSLock.h> @@ -128,6 +130,47 @@ bool JSTestCallback::callbackWithStringList(DOMStringList* listParam) return !raisedException; } +bool JSTestCallback::callbackWithBoolean(bool boolParam) +{ + if (!canInvokeCallback()) + return true; + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + ExecState* exec = m_data->globalObject()->globalExec(); + MarkedArgumentBuffer args; + args.append(jsBoolean(boolParam)); + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + +bool JSTestCallback::callbackRequiresThisToPass(Class8* class8Param, ThisClass* thisClassParam) +{ + ASSERT(thisClassParam); + + if (!canInvokeCallback()) + return true; + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + ExecState* exec = m_data->globalObject()->globalExec(); + MarkedArgumentBuffer args; + args.append(toJS(exec, m_data->globalObject(), class8Param)); + args.append(toJS(exec, m_data->globalObject(), thisClassParam)); + + bool raisedException = false; + JSValue jsthisClassParam = toJS(exec, m_data->globalObject(), thisClassParam); + m_data->invokeCallback(jsthisClassParam, args, &raisedException); + + return !raisedException; +} + } #endif // ENABLE(SQL_DATABASE) diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h index a6f3cce1e..0c4638904 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -46,6 +46,8 @@ public: COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); virtual int customCallback(Class5* class5Param, Class6* class6Param); virtual bool callbackWithStringList(DOMStringList* listParam); + virtual bool callbackWithBoolean(bool boolParam); + virtual bool callbackRequiresThisToPass(Class8* class8Param, ThisClass* thisClassParam); private: JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp index aeab46b4c..180f09e85 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp @@ -66,12 +66,12 @@ void JSTestCustomNamedGetterConstructor::finishCreation(ExecState* exec, JSDOMGl bool JSTestCustomNamedGetterConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSTestCustomNamedGetterConstructor, JSDOMWrapper>(exec, &JSTestCustomNamedGetterConstructorTable, static_cast<JSTestCustomNamedGetterConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSTestCustomNamedGetterConstructor, JSDOMWrapper>(exec, &JSTestCustomNamedGetterConstructorTable, jsCast<JSTestCustomNamedGetterConstructor*>(cell), propertyName, slot); } bool JSTestCustomNamedGetterConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSTestCustomNamedGetterConstructor, JSDOMWrapper>(exec, &JSTestCustomNamedGetterConstructorTable, static_cast<JSTestCustomNamedGetterConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSTestCustomNamedGetterConstructor, JSDOMWrapper>(exec, &JSTestCustomNamedGetterConstructorTable, jsCast<JSTestCustomNamedGetterConstructor*>(object), propertyName, descriptor); } /* Hash table for prototype */ @@ -158,13 +158,13 @@ bool JSTestCustomNamedGetter::getOwnPropertyDescriptor(JSObject* object, ExecSta JSValue jsTestCustomNamedGetterConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestCustomNamedGetter* domObject = static_cast<JSTestCustomNamedGetter*>(asObject(slotBase)); + JSTestCustomNamedGetter* domObject = jsCast<JSTestCustomNamedGetter*>(asObject(slotBase)); return JSTestCustomNamedGetter::getConstructor(exec, domObject->globalObject()); } JSValue JSTestCustomNamedGetter::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestCustomNamedGetterConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestCustomNamedGetterConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunction(ExecState* exec) @@ -172,11 +172,11 @@ EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunc JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestCustomNamedGetter::s_info)) return throwVMTypeError(exec); - JSTestCustomNamedGetter* castedThis = static_cast<JSTestCustomNamedGetter*>(asObject(thisValue)); + JSTestCustomNamedGetter* castedThis = jsCast<JSTestCustomNamedGetter*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestCustomNamedGetter::s_info); TestCustomNamedGetter* impl = static_cast<TestCustomNamedGetter*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); const String& str(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -193,7 +193,7 @@ static inline bool isObservable(JSTestCustomNamedGetter* jsTestCustomNamedGetter bool JSTestCustomNamedGetterOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestCustomNamedGetter* jsTestCustomNamedGetter = static_cast<JSTestCustomNamedGetter*>(handle.get().asCell()); + JSTestCustomNamedGetter* jsTestCustomNamedGetter = jsCast<JSTestCustomNamedGetter*>(handle.get().asCell()); if (!isObservable(jsTestCustomNamedGetter)) return false; UNUSED_PARAM(visitor); @@ -202,7 +202,7 @@ bool JSTestCustomNamedGetterOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::U void JSTestCustomNamedGetterOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestCustomNamedGetter* jsTestCustomNamedGetter = static_cast<JSTestCustomNamedGetter*>(handle.get().asCell()); + JSTestCustomNamedGetter* jsTestCustomNamedGetter = jsCast<JSTestCustomNamedGetter*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestCustomNamedGetter->impl(), jsTestCustomNamedGetter); jsTestCustomNamedGetter->releaseImpl(); @@ -215,7 +215,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestCus TestCustomNamedGetter* toTestCustomNamedGetter(JSC::JSValue value) { - return value.inherits(&JSTestCustomNamedGetter::s_info) ? static_cast<JSTestCustomNamedGetter*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestCustomNamedGetter::s_info) ? jsCast<JSTestCustomNamedGetter*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp index bd72745ae..315e157a0 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp @@ -69,17 +69,17 @@ void JSTestEventConstructorConstructor::finishCreation(ExecState* exec, JSDOMGlo bool JSTestEventConstructorConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSTestEventConstructorConstructor, JSDOMWrapper>(exec, &JSTestEventConstructorConstructorTable, static_cast<JSTestEventConstructorConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSTestEventConstructorConstructor, JSDOMWrapper>(exec, &JSTestEventConstructorConstructorTable, jsCast<JSTestEventConstructorConstructor*>(cell), propertyName, slot); } bool JSTestEventConstructorConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSTestEventConstructorConstructor, JSDOMWrapper>(exec, &JSTestEventConstructorConstructorTable, static_cast<JSTestEventConstructorConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSTestEventConstructorConstructor, JSDOMWrapper>(exec, &JSTestEventConstructorConstructorTable, jsCast<JSTestEventConstructorConstructor*>(object), propertyName, descriptor); } EncodedJSValue JSC_HOST_CALL JSTestEventConstructorConstructor::constructJSTestEventConstructor(ExecState* exec) { - JSTestEventConstructorConstructor* jsConstructor = static_cast<JSTestEventConstructorConstructor*>(exec->callee()); + JSTestEventConstructorConstructor* jsConstructor = jsCast<JSTestEventConstructorConstructor*>(exec->callee()); ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext(); if (!executionContext) @@ -182,7 +182,7 @@ bool JSTestEventConstructor::getOwnPropertyDescriptor(JSObject* object, ExecStat JSValue jsTestEventConstructorAttr1(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestEventConstructor* castedThis = static_cast<JSTestEventConstructor*>(asObject(slotBase)); + JSTestEventConstructor* castedThis = jsCast<JSTestEventConstructor*>(asObject(slotBase)); UNUSED_PARAM(exec); TestEventConstructor* impl = static_cast<TestEventConstructor*>(castedThis->impl()); JSValue result = jsString(exec, impl->attr1()); @@ -192,7 +192,7 @@ JSValue jsTestEventConstructorAttr1(ExecState* exec, JSValue slotBase, const Ide JSValue jsTestEventConstructorAttr2(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestEventConstructor* castedThis = static_cast<JSTestEventConstructor*>(asObject(slotBase)); + JSTestEventConstructor* castedThis = jsCast<JSTestEventConstructor*>(asObject(slotBase)); UNUSED_PARAM(exec); TestEventConstructor* impl = static_cast<TestEventConstructor*>(castedThis->impl()); JSValue result = jsString(exec, impl->attr2()); @@ -202,13 +202,13 @@ JSValue jsTestEventConstructorAttr2(ExecState* exec, JSValue slotBase, const Ide JSValue jsTestEventConstructorConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestEventConstructor* domObject = static_cast<JSTestEventConstructor*>(asObject(slotBase)); + JSTestEventConstructor* domObject = jsCast<JSTestEventConstructor*>(asObject(slotBase)); return JSTestEventConstructor::getConstructor(exec, domObject->globalObject()); } JSValue JSTestEventConstructor::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestEventConstructorConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestEventConstructorConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } static inline bool isObservable(JSTestEventConstructor* jsTestEventConstructor) @@ -220,7 +220,7 @@ static inline bool isObservable(JSTestEventConstructor* jsTestEventConstructor) bool JSTestEventConstructorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestEventConstructor* jsTestEventConstructor = static_cast<JSTestEventConstructor*>(handle.get().asCell()); + JSTestEventConstructor* jsTestEventConstructor = jsCast<JSTestEventConstructor*>(handle.get().asCell()); if (!isObservable(jsTestEventConstructor)) return false; UNUSED_PARAM(visitor); @@ -229,7 +229,7 @@ bool JSTestEventConstructorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Un void JSTestEventConstructorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestEventConstructor* jsTestEventConstructor = static_cast<JSTestEventConstructor*>(handle.get().asCell()); + JSTestEventConstructor* jsTestEventConstructor = jsCast<JSTestEventConstructor*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestEventConstructor->impl(), jsTestEventConstructor); jsTestEventConstructor->releaseImpl(); @@ -242,7 +242,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestEve TestEventConstructor* toTestEventConstructor(JSC::JSValue value) { - return value.inherits(&JSTestEventConstructor::s_info) ? static_cast<JSTestEventConstructor*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestEventConstructor::s_info) ? jsCast<JSTestEventConstructor*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp index 157288984..bfa872825 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp @@ -72,12 +72,12 @@ void JSTestEventTargetConstructor::finishCreation(ExecState* exec, JSDOMGlobalOb bool JSTestEventTargetConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSTestEventTargetConstructor, JSDOMWrapper>(exec, &JSTestEventTargetConstructorTable, static_cast<JSTestEventTargetConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSTestEventTargetConstructor, JSDOMWrapper>(exec, &JSTestEventTargetConstructorTable, jsCast<JSTestEventTargetConstructor*>(cell), propertyName, slot); } bool JSTestEventTargetConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSTestEventTargetConstructor, JSDOMWrapper>(exec, &JSTestEventTargetConstructorTable, static_cast<JSTestEventTargetConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSTestEventTargetConstructor, JSDOMWrapper>(exec, &JSTestEventTargetConstructorTable, jsCast<JSTestEventTargetConstructor*>(object), propertyName, descriptor); } /* Hash table for prototype */ @@ -204,7 +204,7 @@ bool JSTestEventTarget::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, JSValue jsTestEventTargetConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestEventTarget* domObject = static_cast<JSTestEventTarget*>(asObject(slotBase)); + JSTestEventTarget* domObject = jsCast<JSTestEventTarget*>(asObject(slotBase)); return JSTestEventTarget::getConstructor(exec, domObject->globalObject()); } @@ -219,7 +219,7 @@ void JSTestEventTarget::getOwnPropertyNames(JSObject* object, ExecState* exec, P JSValue JSTestEventTarget::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestEventTargetConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestEventTargetConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionItem(ExecState* exec) @@ -227,11 +227,11 @@ EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionItem(ExecState* e JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestEventTarget::s_info)) return throwVMTypeError(exec); - JSTestEventTarget* castedThis = static_cast<JSTestEventTarget*>(asObject(thisValue)); + JSTestEventTarget* castedThis = jsCast<JSTestEventTarget*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestEventTarget::s_info); TestEventTarget* impl = static_cast<TestEventTarget*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int index(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toUInt32(exec)); if (index < 0) { setDOMException(exec, INDEX_SIZE_ERR); @@ -249,11 +249,11 @@ EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionAddEventListener( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestEventTarget::s_info)) return throwVMTypeError(exec); - JSTestEventTarget* castedThis = static_cast<JSTestEventTarget*>(asObject(thisValue)); + JSTestEventTarget* castedThis = jsCast<JSTestEventTarget*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestEventTarget::s_info); TestEventTarget* impl = static_cast<TestEventTarget*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); JSValue listener = exec->argument(1); if (!listener.isObject()) return JSValue::encode(jsUndefined()); @@ -266,11 +266,11 @@ EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionRemoveEventListen JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestEventTarget::s_info)) return throwVMTypeError(exec); - JSTestEventTarget* castedThis = static_cast<JSTestEventTarget*>(asObject(thisValue)); + JSTestEventTarget* castedThis = jsCast<JSTestEventTarget*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestEventTarget::s_info); TestEventTarget* impl = static_cast<TestEventTarget*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); JSValue listener = exec->argument(1); if (!listener.isObject()) return JSValue::encode(jsUndefined()); @@ -283,11 +283,11 @@ EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionDispatchEvent(Exe JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestEventTarget::s_info)) return throwVMTypeError(exec); - JSTestEventTarget* castedThis = static_cast<JSTestEventTarget*>(asObject(thisValue)); + JSTestEventTarget* castedThis = jsCast<JSTestEventTarget*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestEventTarget::s_info); TestEventTarget* impl = static_cast<TestEventTarget*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; Event* evt(toEvent(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) @@ -311,7 +311,7 @@ void JSTestEventTarget::visitChildren(JSCell* cell, SlotVisitor& visitor) JSValue JSTestEventTarget::indexGetter(ExecState* exec, JSValue slotBase, unsigned index) { - JSTestEventTarget* thisObj = static_cast<JSTestEventTarget*>(asObject(slotBase)); + JSTestEventTarget* thisObj = jsCast<JSTestEventTarget*>(asObject(slotBase)); ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info); return toJS(exec, thisObj->globalObject(), static_cast<TestEventTarget*>(thisObj->impl())->item(index)); } @@ -327,7 +327,7 @@ static inline bool isObservable(JSTestEventTarget* jsTestEventTarget) bool JSTestEventTargetOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestEventTarget* jsTestEventTarget = static_cast<JSTestEventTarget*>(handle.get().asCell()); + JSTestEventTarget* jsTestEventTarget = jsCast<JSTestEventTarget*>(handle.get().asCell()); if (!isObservable(jsTestEventTarget)) return false; UNUSED_PARAM(visitor); @@ -336,7 +336,7 @@ bool JSTestEventTargetOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown void JSTestEventTargetOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestEventTarget* jsTestEventTarget = static_cast<JSTestEventTarget*>(handle.get().asCell()); + JSTestEventTarget* jsTestEventTarget = jsCast<JSTestEventTarget*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestEventTarget->impl(), jsTestEventTarget); jsTestEventTarget->releaseImpl(); @@ -349,7 +349,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestEve TestEventTarget* toTestEventTarget(JSC::JSValue value) { - return value.inherits(&JSTestEventTarget::s_info) ? static_cast<JSTestEventTarget*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestEventTarget::s_info) ? jsCast<JSTestEventTarget*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp new file mode 100644 index 000000000..f66e6b96d --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp @@ -0,0 +1,190 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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 "JSTestException.h" + +#include "KURL.h" +#include "TestException.h" +#include <runtime/JSString.h> +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestException); +/* Hash table */ + +static const HashTableValue JSTestExceptionTableValues[] = +{ + { "name", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestExceptionName), (intptr_t)0, NoIntrinsic }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestExceptionConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSTestExceptionTable = { 5, 3, JSTestExceptionTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSTestExceptionConstructorTableValues[] = +{ + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSTestExceptionConstructorTable = { 1, 0, JSTestExceptionConstructorTableValues, 0 }; +const ClassInfo JSTestExceptionConstructor::s_info = { "TestExceptionConstructor", &Base::s_info, &JSTestExceptionConstructorTable, 0, CREATE_METHOD_TABLE(JSTestExceptionConstructor) }; + +JSTestExceptionConstructor::JSTestExceptionConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSTestExceptionConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestExceptionPrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + +bool JSTestExceptionConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestExceptionConstructor, JSDOMWrapper>(exec, &JSTestExceptionConstructorTable, jsCast<JSTestExceptionConstructor*>(cell), propertyName, slot); +} + +bool JSTestExceptionConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestExceptionConstructor, JSDOMWrapper>(exec, &JSTestExceptionConstructorTable, jsCast<JSTestExceptionConstructor*>(object), propertyName, descriptor); +} + +/* Hash table for prototype */ + +static const HashTableValue JSTestExceptionPrototypeTableValues[] = +{ + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSTestExceptionPrototypeTable = { 1, 0, JSTestExceptionPrototypeTableValues, 0 }; +const ClassInfo JSTestExceptionPrototype::s_info = { "TestExceptionPrototype", &Base::s_info, &JSTestExceptionPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestExceptionPrototype) }; + +JSObject* JSTestExceptionPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestException>(exec, globalObject); +} + +const ClassInfo JSTestException::s_info = { "TestException", &Base::s_info, &JSTestExceptionTable, 0 , CREATE_METHOD_TABLE(JSTestException) }; + +JSTestException::JSTestException(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestException> impl) + : JSDOMWrapper(structure, globalObject) + , m_impl(impl.leakRef()) +{ +} + +void JSTestException::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + ASSERT(inherits(&s_info)); +} + +JSObject* JSTestException::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSTestExceptionPrototype::create(exec->globalData(), globalObject, JSTestExceptionPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype())); +} + +void JSTestException::destroy(JSC::JSCell* cell) +{ + JSTestException* thisObject = jsCast<JSTestException*>(cell); + thisObject->JSTestException::~JSTestException(); +} + +JSTestException::~JSTestException() +{ + releaseImplIfNotNull(); +} + +bool JSTestException::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSTestException* thisObject = jsCast<JSTestException*>(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueSlot<JSTestException, Base>(exec, &JSTestExceptionTable, thisObject, propertyName, slot); +} + +bool JSTestException::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSTestException* thisObject = jsCast<JSTestException*>(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueDescriptor<JSTestException, Base>(exec, &JSTestExceptionTable, thisObject, propertyName, descriptor); +} + +JSValue jsTestExceptionName(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestException* castedThis = jsCast<JSTestException*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestException* impl = static_cast<TestException*>(castedThis->impl()); + JSValue result = jsString(exec, impl->name()); + return result; +} + + +JSValue jsTestExceptionConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestException* domObject = jsCast<JSTestException*>(asObject(slotBase)); + return JSTestException::getConstructor(exec, domObject->globalObject()); +} + +JSValue JSTestException::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestExceptionConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); +} + +static inline bool isObservable(JSTestException* jsTestException) +{ + if (jsTestException->hasCustomProperties()) + return true; + return false; +} + +bool JSTestExceptionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) +{ + JSTestException* jsTestException = jsCast<JSTestException*>(handle.get().asCell()); + if (!isObservable(jsTestException)) + return false; + UNUSED_PARAM(visitor); + return false; +} + +void JSTestExceptionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) +{ + JSTestException* jsTestException = jsCast<JSTestException*>(handle.get().asCell()); + DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); + uncacheWrapper(world, jsTestException->impl(), jsTestException); + jsTestException->releaseImpl(); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestException* impl) +{ + return wrap<JSTestException>(exec, globalObject, impl); +} + +TestException* toTestException(JSC::JSValue value) +{ + return value.inherits(&JSTestException::s_info) ? jsCast<JSTestException*>(asObject(value))->impl() : 0; +} + +} diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestException.h b/Source/WebCore/bindings/scripts/test/JS/JSTestException.h new file mode 100644 index 000000000..5f1fa8ac1 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestException.h @@ -0,0 +1,142 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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. +*/ + +#ifndef JSTestException_h +#define JSTestException_h + +#include "JSDOMBinding.h" +#include "TestException.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/JSObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class JSTestException : public JSDOMWrapper { +public: + typedef JSDOMWrapper Base; + static JSTestException* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestException> impl) + { + JSTestException* ptr = new (NotNull, JSC::allocateCell<JSTestException>(globalObject->globalData().heap)) JSTestException(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static void destroy(JSC::JSCell*); + ~JSTestException(); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + TestException* impl() const { return m_impl; } + void releaseImpl() { m_impl->deref(); m_impl = 0; } + + void releaseImplIfNotNull() { if (m_impl) { m_impl->deref(); m_impl = 0; } } + +private: + TestException* m_impl; +protected: + JSTestException(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestException>); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +class JSTestExceptionOwner : public JSC::WeakHandleOwner { + virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&); + virtual void finalize(JSC::Handle<JSC::Unknown>, void* context); +}; + +inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld*, TestException*) +{ + DEFINE_STATIC_LOCAL(JSTestExceptionOwner, jsTestExceptionOwner, ()); + return &jsTestExceptionOwner; +} + +inline void* wrapperContext(DOMWrapperWorld* world, TestException*) +{ + return world; +} + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestException*); +TestException* toTestException(JSC::JSValue); + +class JSTestExceptionPrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSTestExceptionPrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSTestExceptionPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestExceptionPrototype>(globalData.heap)) JSTestExceptionPrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSTestExceptionPrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = Base::StructureFlags; +}; + +class JSTestExceptionConstructor : public DOMConstructorObject { +private: + JSTestExceptionConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSTestExceptionConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSTestExceptionConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestExceptionConstructor>(*exec->heap())) JSTestExceptionConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +// Attributes + +JSC::JSValue jsTestExceptionName(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestExceptionConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp index c3888e8e8..ea2efa707 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -112,19 +112,19 @@ void JSTestInterfaceConstructor::finishCreation(ExecState* exec, JSDOMGlobalObje bool JSTestInterfaceConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticPropertySlot<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, static_cast<JSTestInterfaceConstructor*>(cell), propertyName, slot); + return getStaticPropertySlot<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(cell), propertyName, slot); } bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticPropertyDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, static_cast<JSTestInterfaceConstructor*>(object), propertyName, descriptor); + return getStaticPropertyDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(object), propertyName, descriptor); } EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterface(ExecState* exec) { - JSTestInterfaceConstructor* jsConstructor = static_cast<JSTestInterfaceConstructor*>(exec->callee()); + JSTestInterfaceConstructor* castedThis = jsCast<JSTestInterfaceConstructor*>(exec->callee()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; const String& str1(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) @@ -132,7 +132,7 @@ EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterfac const String& str2(ustringToString(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); + ScriptExecutionContext* context = castedThis->scriptExecutionContext(); if (!context) return throwVMError(exec, createReferenceError(exec, "TestInterface constructor associated document is unavailable")); RefPtr<TestInterface> object = TestInterface::create(context, str1, str2, ec); @@ -140,7 +140,7 @@ EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterfac setDOMException(exec, ec); return JSValue::encode(JSValue()); } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get()))); + return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get()))); } ConstructType JSTestInterfaceConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -238,7 +238,7 @@ bool JSTestInterface::getOwnPropertyDescriptor(JSObject* object, ExecState* exec #if ENABLE(Condition11) || ENABLE(Condition12) JSValue jsTestInterfaceSupplementalStr1(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase)); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(asObject(slotBase)); UNUSED_PARAM(exec); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); JSValue result = jsString(exec, TestSupplemental::supplementalStr1(impl)); @@ -250,7 +250,7 @@ JSValue jsTestInterfaceSupplementalStr1(ExecState* exec, JSValue slotBase, const #if ENABLE(Condition11) || ENABLE(Condition12) JSValue jsTestInterfaceSupplementalStr2(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase)); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(asObject(slotBase)); UNUSED_PARAM(exec); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); JSValue result = jsString(exec, TestSupplemental::supplementalStr2(impl)); @@ -262,7 +262,7 @@ JSValue jsTestInterfaceSupplementalStr2(ExecState* exec, JSValue slotBase, const #if ENABLE(Condition11) || ENABLE(Condition12) JSValue jsTestInterfaceSupplementalStr3(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase)); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(asObject(slotBase)); return castedThis->supplementalStr3(exec); } @@ -271,7 +271,7 @@ JSValue jsTestInterfaceSupplementalStr3(ExecState* exec, JSValue slotBase, const #if ENABLE(Condition11) || ENABLE(Condition12) JSValue jsTestInterfaceSupplementalNode(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase)); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(asObject(slotBase)); UNUSED_PARAM(exec); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(TestSupplemental::supplementalNode(impl))); @@ -282,7 +282,7 @@ JSValue jsTestInterfaceSupplementalNode(ExecState* exec, JSValue slotBase, const JSValue jsTestInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestInterface* domObject = static_cast<JSTestInterface*>(asObject(slotBase)); + JSTestInterface* domObject = jsCast<JSTestInterface*>(asObject(slotBase)); return JSTestInterface::getConstructor(exec, domObject->globalObject()); } @@ -298,7 +298,7 @@ void JSTestInterface::put(JSCell* cell, ExecState* exec, const Identifier& prope #if ENABLE(Condition11) || ENABLE(Condition12) void setJSTestInterfaceSupplementalStr2(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestInterface* castedThis = static_cast<JSTestInterface*>(thisObject); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(thisObject); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); TestSupplemental::setSupplementalStr2(impl, ustringToString(value.isEmpty() ? UString() : value.toString(exec)->value(exec))); } @@ -308,7 +308,7 @@ void setJSTestInterfaceSupplementalStr2(ExecState* exec, JSObject* thisObject, J #if ENABLE(Condition11) || ENABLE(Condition12) void setJSTestInterfaceSupplementalStr3(ExecState* exec, JSObject* thisObject, JSValue value) { - static_cast<JSTestInterface*>(thisObject)->setSupplementalStr3(exec, value); + jsCast<JSTestInterface*>(thisObject)->setSupplementalStr3(exec, value); } #endif @@ -316,7 +316,7 @@ void setJSTestInterfaceSupplementalStr3(ExecState* exec, JSObject* thisObject, J #if ENABLE(Condition11) || ENABLE(Condition12) void setJSTestInterfaceSupplementalNode(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestInterface* castedThis = static_cast<JSTestInterface*>(thisObject); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(thisObject); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); TestSupplemental::setSupplementalNode(impl, toNode(value)); } @@ -325,7 +325,7 @@ void setJSTestInterfaceSupplementalNode(ExecState* exec, JSObject* thisObject, J JSValue JSTestInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestInterfaceConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } #if ENABLE(Condition11) || ENABLE(Condition12) @@ -334,7 +334,7 @@ EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod1 JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestInterface::s_info)) return throwVMTypeError(exec); - JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(thisValue)); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestInterface::s_info); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); TestSupplemental::supplementalMethod1(impl); @@ -349,13 +349,13 @@ EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod2 JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestInterface::s_info)) return throwVMTypeError(exec); - JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(thisValue)); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestInterface::s_info); TestInterface* impl = static_cast<TestInterface*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return JSValue::encode(jsUndefined()); const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); @@ -378,7 +378,7 @@ EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod3 JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestInterface::s_info)) return throwVMTypeError(exec); - JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(thisValue)); + JSTestInterface* castedThis = jsCast<JSTestInterface*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestInterface::s_info); return JSValue::encode(castedThis->supplementalMethod3(exec)); } @@ -421,7 +421,7 @@ static inline bool isObservable(JSTestInterface* jsTestInterface) bool JSTestInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestInterface* jsTestInterface = static_cast<JSTestInterface*>(handle.get().asCell()); + JSTestInterface* jsTestInterface = jsCast<JSTestInterface*>(handle.get().asCell()); if (jsTestInterface->impl()->hasPendingActivity()) return true; if (!isObservable(jsTestInterface)) @@ -432,7 +432,7 @@ bool JSTestInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> void JSTestInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestInterface* jsTestInterface = static_cast<JSTestInterface*>(handle.get().asCell()); + JSTestInterface* jsTestInterface = jsCast<JSTestInterface*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestInterface->impl(), jsTestInterface); jsTestInterface->releaseImpl(); @@ -445,7 +445,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestInt TestInterface* toTestInterface(JSC::JSValue value) { - return value.inherits(&JSTestInterface::s_info) ? static_cast<JSTestInterface*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestInterface::s_info) ? jsCast<JSTestInterface*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp index 4237cbd3b..75121f192 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp @@ -66,12 +66,12 @@ void JSTestMediaQueryListListenerConstructor::finishCreation(ExecState* exec, JS bool JSTestMediaQueryListListenerConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSTestMediaQueryListListenerConstructor, JSDOMWrapper>(exec, &JSTestMediaQueryListListenerConstructorTable, static_cast<JSTestMediaQueryListListenerConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSTestMediaQueryListListenerConstructor, JSDOMWrapper>(exec, &JSTestMediaQueryListListenerConstructorTable, jsCast<JSTestMediaQueryListListenerConstructor*>(cell), propertyName, slot); } bool JSTestMediaQueryListListenerConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSTestMediaQueryListListenerConstructor, JSDOMWrapper>(exec, &JSTestMediaQueryListListenerConstructorTable, static_cast<JSTestMediaQueryListListenerConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSTestMediaQueryListListenerConstructor, JSDOMWrapper>(exec, &JSTestMediaQueryListListenerConstructorTable, jsCast<JSTestMediaQueryListListenerConstructor*>(object), propertyName, descriptor); } /* Hash table for prototype */ @@ -148,13 +148,13 @@ bool JSTestMediaQueryListListener::getOwnPropertyDescriptor(JSObject* object, Ex JSValue jsTestMediaQueryListListenerConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestMediaQueryListListener* domObject = static_cast<JSTestMediaQueryListListener*>(asObject(slotBase)); + JSTestMediaQueryListListener* domObject = jsCast<JSTestMediaQueryListListener*>(asObject(slotBase)); return JSTestMediaQueryListListener::getConstructor(exec, domObject->globalObject()); } JSValue JSTestMediaQueryListListener::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestMediaQueryListListenerConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestMediaQueryListListenerConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } EncodedJSValue JSC_HOST_CALL jsTestMediaQueryListListenerPrototypeFunctionMethod(ExecState* exec) @@ -162,11 +162,11 @@ EncodedJSValue JSC_HOST_CALL jsTestMediaQueryListListenerPrototypeFunctionMethod JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestMediaQueryListListener::s_info)) return throwVMTypeError(exec); - JSTestMediaQueryListListener* castedThis = static_cast<JSTestMediaQueryListListener*>(asObject(thisValue)); + JSTestMediaQueryListListener* castedThis = jsCast<JSTestMediaQueryListListener*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestMediaQueryListListener::s_info); TestMediaQueryListListener* impl = static_cast<TestMediaQueryListListener*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); RefPtr<MediaQueryListListener> listener(MediaQueryListListener::create(ScriptValue(exec->globalData(), MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -183,7 +183,7 @@ static inline bool isObservable(JSTestMediaQueryListListener* jsTestMediaQueryLi bool JSTestMediaQueryListListenerOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestMediaQueryListListener* jsTestMediaQueryListListener = static_cast<JSTestMediaQueryListListener*>(handle.get().asCell()); + JSTestMediaQueryListListener* jsTestMediaQueryListListener = jsCast<JSTestMediaQueryListListener*>(handle.get().asCell()); if (!isObservable(jsTestMediaQueryListListener)) return false; UNUSED_PARAM(visitor); @@ -192,7 +192,7 @@ bool JSTestMediaQueryListListenerOwner::isReachableFromOpaqueRoots(JSC::Handle<J void JSTestMediaQueryListListenerOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestMediaQueryListListener* jsTestMediaQueryListListener = static_cast<JSTestMediaQueryListListener*>(handle.get().asCell()); + JSTestMediaQueryListListener* jsTestMediaQueryListListener = jsCast<JSTestMediaQueryListListener*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestMediaQueryListListener->impl(), jsTestMediaQueryListListener); jsTestMediaQueryListListener->releaseImpl(); @@ -205,7 +205,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestMed TestMediaQueryListListener* toTestMediaQueryListListener(JSC::JSValue value) { - return value.inherits(&JSTestMediaQueryListListener::s_info) ? static_cast<JSTestMediaQueryListListener*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestMediaQueryListListener::s_info) ? jsCast<JSTestMediaQueryListListener*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp index 225208dc2..4b654e0e2 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp @@ -65,12 +65,12 @@ void JSTestNamedConstructorConstructor::finishCreation(ExecState* exec, JSDOMGlo bool JSTestNamedConstructorConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSTestNamedConstructorConstructor, JSDOMWrapper>(exec, &JSTestNamedConstructorConstructorTable, static_cast<JSTestNamedConstructorConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSTestNamedConstructorConstructor, JSDOMWrapper>(exec, &JSTestNamedConstructorConstructorTable, jsCast<JSTestNamedConstructorConstructor*>(cell), propertyName, slot); } bool JSTestNamedConstructorConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSTestNamedConstructorConstructor, JSDOMWrapper>(exec, &JSTestNamedConstructorConstructorTable, static_cast<JSTestNamedConstructorConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSTestNamedConstructorConstructor, JSDOMWrapper>(exec, &JSTestNamedConstructorConstructorTable, jsCast<JSTestNamedConstructorConstructor*>(object), propertyName, descriptor); } const ClassInfo JSTestNamedConstructorNamedConstructor::s_info = { "AudioConstructor", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSTestNamedConstructorNamedConstructor) }; @@ -89,9 +89,9 @@ void JSTestNamedConstructorNamedConstructor::finishCreation(ExecState* exec, JSD EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor(ExecState* exec) { - JSTestNamedConstructorNamedConstructor* jsConstructor = static_cast<JSTestNamedConstructorNamedConstructor*>(exec->callee()); + JSTestNamedConstructorNamedConstructor* castedThis = jsCast<JSTestNamedConstructorNamedConstructor*>(exec->callee()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; const String& str1(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) @@ -102,12 +102,12 @@ EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::constructJS const String& str3(ustringToString(MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsNullString).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsNullString).toString(exec)->value(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - RefPtr<TestNamedConstructor> object = TestNamedConstructor::createForJSConstructor(jsConstructor->document(), str1, str2, str3, ec); + RefPtr<TestNamedConstructor> object = TestNamedConstructor::createForJSConstructor(castedThis->document(), str1, str2, str3, ec); if (ec) { setDOMException(exec, ec); return JSValue::encode(JSValue()); } - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get()))); + return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get()))); } ConstructType JSTestNamedConstructorNamedConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -177,13 +177,13 @@ bool JSTestNamedConstructor::getOwnPropertyDescriptor(JSObject* object, ExecStat JSValue jsTestNamedConstructorConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestNamedConstructor* domObject = static_cast<JSTestNamedConstructor*>(asObject(slotBase)); + JSTestNamedConstructor* domObject = jsCast<JSTestNamedConstructor*>(asObject(slotBase)); return JSTestNamedConstructor::getConstructor(exec, domObject->globalObject()); } JSValue JSTestNamedConstructor::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestNamedConstructorConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestNamedConstructorConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } static inline bool isObservable(JSTestNamedConstructor* jsTestNamedConstructor) @@ -195,7 +195,7 @@ static inline bool isObservable(JSTestNamedConstructor* jsTestNamedConstructor) bool JSTestNamedConstructorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestNamedConstructor* jsTestNamedConstructor = static_cast<JSTestNamedConstructor*>(handle.get().asCell()); + JSTestNamedConstructor* jsTestNamedConstructor = jsCast<JSTestNamedConstructor*>(handle.get().asCell()); if (jsTestNamedConstructor->impl()->hasPendingActivity()) return true; if (!isObservable(jsTestNamedConstructor)) @@ -206,7 +206,7 @@ bool JSTestNamedConstructorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Un void JSTestNamedConstructorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestNamedConstructor* jsTestNamedConstructor = static_cast<JSTestNamedConstructor*>(handle.get().asCell()); + JSTestNamedConstructor* jsTestNamedConstructor = jsCast<JSTestNamedConstructor*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestNamedConstructor->impl(), jsTestNamedConstructor); jsTestNamedConstructor->releaseImpl(); @@ -219,7 +219,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestNam TestNamedConstructor* toTestNamedConstructor(JSC::JSValue value) { - return value.inherits(&JSTestNamedConstructor::s_info) ? static_cast<JSTestNamedConstructor*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestNamedConstructor::s_info) ? jsCast<JSTestNamedConstructor*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp new file mode 100644 index 000000000..4399661c5 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp @@ -0,0 +1,149 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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 "JSTestNode.h" + +#include "ExceptionCode.h" +#include "JSDOMBinding.h" +#include "TestNode.h" +#include <runtime/Error.h> +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestNode); +/* Hash table */ + +static const HashTableValue JSTestNodeTableValues[] = +{ + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t)0, NoIntrinsic }, + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSTestNodeTable = { 2, 1, JSTestNodeTableValues, 0 }; +/* Hash table for constructor */ + +static const HashTableValue JSTestNodeConstructorTableValues[] = +{ + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSTestNodeConstructorTable = { 1, 0, JSTestNodeConstructorTableValues, 0 }; +const ClassInfo JSTestNodeConstructor::s_info = { "TestNodeConstructor", &Base::s_info, &JSTestNodeConstructorTable, 0, CREATE_METHOD_TABLE(JSTestNodeConstructor) }; + +JSTestNodeConstructor::JSTestNodeConstructor(Structure* structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) +{ +} + +void JSTestNodeConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) +{ + Base::finishCreation(exec->globalData()); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestNodePrototype::self(exec, globalObject), DontDelete | ReadOnly); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(0), ReadOnly | DontDelete | DontEnum); +} + +bool JSTestNodeConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestNodeConstructor, JSDOMWrapper>(exec, &JSTestNodeConstructorTable, jsCast<JSTestNodeConstructor*>(cell), propertyName, slot); +} + +bool JSTestNodeConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestNodeConstructor, JSDOMWrapper>(exec, &JSTestNodeConstructorTable, jsCast<JSTestNodeConstructor*>(object), propertyName, descriptor); +} + +EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::constructJSTestNode(ExecState* exec) +{ + JSTestNodeConstructor* castedThis = jsCast<JSTestNodeConstructor*>(exec->callee()); + RefPtr<TestNode> object = TestNode::create(); + return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get()))); +} + +ConstructType JSTestNodeConstructor::getConstructData(JSCell*, ConstructData& constructData) +{ + constructData.native.function = constructJSTestNode; + return ConstructTypeHost; +} + +/* Hash table for prototype */ + +static const HashTableValue JSTestNodePrototypeTableValues[] = +{ + { 0, 0, 0, 0, NoIntrinsic } +}; + +static const HashTable JSTestNodePrototypeTable = { 1, 0, JSTestNodePrototypeTableValues, 0 }; +const ClassInfo JSTestNodePrototype::s_info = { "TestNodePrototype", &Base::s_info, &JSTestNodePrototypeTable, 0, CREATE_METHOD_TABLE(JSTestNodePrototype) }; + +JSObject* JSTestNodePrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestNode>(exec, globalObject); +} + +const ClassInfo JSTestNode::s_info = { "TestNode", &Base::s_info, &JSTestNodeTable, 0 , CREATE_METHOD_TABLE(JSTestNode) }; + +JSTestNode::JSTestNode(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestNode> impl) + : JSNode(structure, globalObject, impl) +{ +} + +void JSTestNode::finishCreation(JSGlobalData& globalData) +{ + Base::finishCreation(globalData); + ASSERT(inherits(&s_info)); +} + +JSObject* JSTestNode::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return JSTestNodePrototype::create(exec->globalData(), globalObject, JSTestNodePrototype::createStructure(exec->globalData(), globalObject, JSNodePrototype::self(exec, globalObject))); +} + +bool JSTestNode::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSTestNode* thisObject = jsCast<JSTestNode*>(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueSlot<JSTestNode, Base>(exec, &JSTestNodeTable, thisObject, propertyName, slot); +} + +bool JSTestNode::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSTestNode* thisObject = jsCast<JSTestNode*>(object); + ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); + return getStaticValueDescriptor<JSTestNode, Base>(exec, &JSTestNodeTable, thisObject, propertyName, descriptor); +} + +JSValue jsTestNodeConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestNode* domObject = jsCast<JSTestNode*>(asObject(slotBase)); + return JSTestNode::getConstructor(exec, domObject->globalObject()); +} + +JSValue JSTestNode::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestNodeConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); +} + + +} diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestNode.h b/Source/WebCore/bindings/scripts/test/JS/JSTestNode.h new file mode 100644 index 000000000..5f8706fd3 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestNode.h @@ -0,0 +1,117 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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. +*/ + +#ifndef JSTestNode_h +#define JSTestNode_h + +#include "JSDOMBinding.h" +#include "JSNode.h" +#include "TestNode.h" +#include <runtime/JSObject.h> + +namespace WebCore { + +class JSTestNode : public JSNode { +public: + typedef JSNode Base; + static JSTestNode* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestNode> impl) + { + JSTestNode* ptr = new (NotNull, JSC::allocateCell<JSTestNode>(globalObject->globalData().heap)) JSTestNode(structure, globalObject, impl); + ptr->finishCreation(globalObject->globalData()); + return ptr; + } + + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + static void visitChildren(JSCell*, JSC::SlotVisitor&); + +protected: + JSTestNode(JSC::Structure*, JSDOMGlobalObject*, PassRefPtr<TestNode>); + void finishCreation(JSC::JSGlobalData&); + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesVisitChildren | Base::StructureFlags; +}; + + +class JSTestNodePrototype : public JSC::JSNonFinalObject { +public: + typedef JSC::JSNonFinalObject Base; + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static JSTestNodePrototype* create(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) + { + JSTestNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNodePrototype>(globalData.heap)) JSTestNodePrototype(globalData, globalObject, structure); + ptr->finishCreation(globalData); + return ptr; + } + + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } + +private: + JSTestNodePrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesVisitChildren | Base::StructureFlags; +}; + +class JSTestNodeConstructor : public DOMConstructorObject { +private: + JSTestNodeConstructor(JSC::Structure*, JSDOMGlobalObject*); + void finishCreation(JSC::ExecState*, JSDOMGlobalObject*); + +public: + typedef DOMConstructorObject Base; + static JSTestNodeConstructor* create(JSC::ExecState* exec, JSC::Structure* structure, JSDOMGlobalObject* globalObject) + { + JSTestNodeConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestNodeConstructor>(*exec->heap())) JSTestNodeConstructor(structure, globalObject); + ptr->finishCreation(exec, globalObject); + return ptr; + } + + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) + { + return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestNode(JSC::ExecState*); + static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); +}; + +// Attributes + +JSC::JSValue jsTestNodeConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 11a20df92..06828a48a 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -21,6 +21,7 @@ #include "config.h" #include "JSTestObj.h" +#include "Dictionary.h" #include "Document.h" #include "ExceptionCode.h" #include "HTMLNames.h" @@ -30,9 +31,9 @@ #include "JSDOMStringList.h" #include "JSDocument.h" #include "JSEventListener.h" -#include "JSOptionsObject.h" #include "JSSVGDocument.h" #include "JSSVGPoint.h" +#include "JSScriptProfile.h" #include "JSTestCallback.h" #include "JSTestObj.h" #include "JSa.h" @@ -48,10 +49,12 @@ #include "ScriptArguments.h" #include "ScriptCallStack.h" #include "ScriptCallStackFactory.h" +#include "ScriptProfile.h" #include "SerializedScriptValue.h" #include "TestObj.h" #include "bool.h" #include <runtime/Error.h> +#include <runtime/JSArray.h> #include <runtime/JSString.h> #include <wtf/GetPtr.h> @@ -86,6 +89,20 @@ static const HashTableValue JSTestObjTableValues[] = { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t)setJSTestObjUnsignedLongLongAttr, NoIntrinsic }, { "stringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttr), (intptr_t)setJSTestObjStringAttr, NoIntrinsic }, { "testObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestObjAttr), (intptr_t)setJSTestObjTestObjAttr, NoIntrinsic }, + { "sequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjSequenceAttr), (intptr_t)setJSTestObjSequenceAttr, NoIntrinsic }, + { "intSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjIntSequenceAttr), (intptr_t)setJSTestObjIntSequenceAttr, NoIntrinsic }, + { "shortSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjShortSequenceAttr), (intptr_t)setJSTestObjShortSequenceAttr, NoIntrinsic }, + { "longSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLongSequenceAttr), (intptr_t)setJSTestObjLongSequenceAttr, NoIntrinsic }, + { "longLongSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLongLongSequenceAttr), (intptr_t)setJSTestObjLongLongSequenceAttr, NoIntrinsic }, + { "unsignedIntSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedIntSequenceAttr), (intptr_t)setJSTestObjUnsignedIntSequenceAttr, NoIntrinsic }, + { "unsignedShortSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedShortSequenceAttr), (intptr_t)setJSTestObjUnsignedShortSequenceAttr, NoIntrinsic }, + { "unsignedLongSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongSequenceAttr), (intptr_t)setJSTestObjUnsignedLongSequenceAttr, NoIntrinsic }, + { "unsignedLongLongSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongSequenceAttr), (intptr_t)setJSTestObjUnsignedLongLongSequenceAttr, NoIntrinsic }, + { "floatSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjFloatSequenceAttr), (intptr_t)setJSTestObjFloatSequenceAttr, NoIntrinsic }, + { "doubleSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjDoubleSequenceAttr), (intptr_t)setJSTestObjDoubleSequenceAttr, NoIntrinsic }, + { "booleanSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjBooleanSequenceAttr), (intptr_t)setJSTestObjBooleanSequenceAttr, NoIntrinsic }, + { "voidSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjVoidSequenceAttr), (intptr_t)setJSTestObjVoidSequenceAttr, NoIntrinsic }, + { "dateSequenceAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjDateSequenceAttr), (intptr_t)setJSTestObjDateSequenceAttr, NoIntrinsic }, { "XMLObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjXMLObjAttr), (intptr_t)setJSTestObjXMLObjAttr, NoIntrinsic }, { "create", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCreate), (intptr_t)setJSTestObjCreate, NoIntrinsic }, { "reflectedStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReflectedStringAttr), (intptr_t)setJSTestObjReflectedStringAttr, NoIntrinsic }, @@ -133,6 +150,7 @@ static const HashTableValue JSTestObjTableValues[] = { "contentDocument", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjContentDocument), (intptr_t)0, NoIntrinsic }, { "mutablePoint", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjMutablePoint), (intptr_t)setJSTestObjMutablePoint, NoIntrinsic }, { "immutablePoint", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjImmutablePoint), (intptr_t)setJSTestObjImmutablePoint, NoIntrinsic }, + { "strawberry", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStrawberry), (intptr_t)setJSTestObjStrawberry, NoIntrinsic }, { "strictFloat", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStrictFloat), (intptr_t)setJSTestObjStrictFloat, NoIntrinsic }, { "description", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjDescription), (intptr_t)0, NoIntrinsic }, { "id", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjId), (intptr_t)setJSTestObjId, NoIntrinsic }, @@ -141,7 +159,7 @@ static const HashTableValue JSTestObjTableValues[] = { 0, 0, 0, 0, NoIntrinsic } }; -static const HashTable JSTestObjTable = { 137, 127, JSTestObjTableValues, 0 }; +static const HashTable JSTestObjTable = { 265, 255, JSTestObjTableValues, 0 }; /* Hash table for constructor */ static const HashTableValue JSTestObjConstructorTableValues[] = @@ -200,24 +218,31 @@ void JSTestObjConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* gl Base::finishCreation(exec->globalData()); ASSERT(inherits(&s_info)); putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), DontDelete | ReadOnly); - putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(0), ReadOnly | DontDelete | DontEnum); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } bool JSTestObjConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticPropertySlot<JSTestObjConstructor, JSDOMWrapper>(exec, &JSTestObjConstructorTable, static_cast<JSTestObjConstructor*>(cell), propertyName, slot); + return getStaticPropertySlot<JSTestObjConstructor, JSDOMWrapper>(exec, &JSTestObjConstructorTable, jsCast<JSTestObjConstructor*>(cell), propertyName, slot); } bool JSTestObjConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticPropertyDescriptor<JSTestObjConstructor, JSDOMWrapper>(exec, &JSTestObjConstructorTable, static_cast<JSTestObjConstructor*>(object), propertyName, descriptor); + return getStaticPropertyDescriptor<JSTestObjConstructor, JSDOMWrapper>(exec, &JSTestObjConstructorTable, jsCast<JSTestObjConstructor*>(object), propertyName, descriptor); } EncodedJSValue JSC_HOST_CALL JSTestObjConstructor::constructJSTestObj(ExecState* exec) { - JSTestObjConstructor* jsConstructor = static_cast<JSTestObjConstructor*>(exec->callee()); - RefPtr<TestObj> object = TestObj::create(); - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get()))); + JSTestObjConstructor* castedThis = jsCast<JSTestObjConstructor*>(exec->callee()); + if (exec->argumentCount() < 1) + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return JSValue::encode(jsUndefined()); + } + RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(exec->argument(0)), castedThis->globalObject()); + RefPtr<TestObj> object = TestObj::create(testCallback); + return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get()))); } ConstructType JSTestObjConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -251,6 +276,8 @@ static const HashTableValue JSTestObjPrototypeTableValues[] = { "intMethodWithArgs", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3, NoIntrinsic }, { "objMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0, NoIntrinsic }, { "objMethodWithArgs", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3, NoIntrinsic }, + { "methodWithSequenceArg", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithSequenceArg), (intptr_t)1, NoIntrinsic }, + { "methodReturningSequence", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodReturningSequence), (intptr_t)1, NoIntrinsic }, { "methodThatRequiresAllArgsAndThrows", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows), (intptr_t)2, NoIntrinsic }, { "serializedValue", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1, NoIntrinsic }, { "idbKey", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIdbKey), (intptr_t)1, NoIntrinsic }, @@ -368,7 +395,7 @@ bool JSTestObj::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, cons JSValue jsTestObjReadOnlyIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->readOnlyIntAttr()); @@ -378,7 +405,7 @@ JSValue jsTestObjReadOnlyIntAttr(ExecState* exec, JSValue slotBase, const Identi JSValue jsTestObjReadOnlyStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->readOnlyStringAttr()); @@ -388,7 +415,7 @@ JSValue jsTestObjReadOnlyStringAttr(ExecState* exec, JSValue slotBase, const Ide JSValue jsTestObjReadOnlyTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->readOnlyTestObjAttr())); @@ -398,7 +425,7 @@ JSValue jsTestObjReadOnlyTestObjAttr(ExecState* exec, JSValue slotBase, const Id JSValue jsTestObjShortAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->shortAttr()); @@ -408,7 +435,7 @@ JSValue jsTestObjShortAttr(ExecState* exec, JSValue slotBase, const Identifier&) JSValue jsTestObjUnsignedShortAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->unsignedShortAttr()); @@ -418,7 +445,7 @@ JSValue jsTestObjUnsignedShortAttr(ExecState* exec, JSValue slotBase, const Iden JSValue jsTestObjIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->intAttr()); @@ -428,7 +455,7 @@ JSValue jsTestObjIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) JSValue jsTestObjLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->longLongAttr()); @@ -438,7 +465,7 @@ JSValue jsTestObjLongLongAttr(ExecState* exec, JSValue slotBase, const Identifie JSValue jsTestObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->unsignedLongLongAttr()); @@ -448,7 +475,7 @@ JSValue jsTestObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const I JSValue jsTestObjStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->stringAttr()); @@ -458,7 +485,7 @@ JSValue jsTestObjStringAttr(ExecState* exec, JSValue slotBase, const Identifier& JSValue jsTestObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->testObjAttr())); @@ -466,9 +493,149 @@ JSValue jsTestObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier } +JSValue jsTestObjSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->sequenceAttr()); + return result; +} + + +JSValue jsTestObjIntSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->intSequenceAttr()); + return result; +} + + +JSValue jsTestObjShortSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->shortSequenceAttr()); + return result; +} + + +JSValue jsTestObjLongSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->longSequenceAttr()); + return result; +} + + +JSValue jsTestObjLongLongSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->longLongSequenceAttr()); + return result; +} + + +JSValue jsTestObjUnsignedIntSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->unsignedIntSequenceAttr()); + return result; +} + + +JSValue jsTestObjUnsignedShortSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->unsignedShortSequenceAttr()); + return result; +} + + +JSValue jsTestObjUnsignedLongSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->unsignedLongSequenceAttr()); + return result; +} + + +JSValue jsTestObjUnsignedLongLongSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->unsignedLongLongSequenceAttr()); + return result; +} + + +JSValue jsTestObjFloatSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->floatSequenceAttr()); + return result; +} + + +JSValue jsTestObjDoubleSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->doubleSequenceAttr()); + return result; +} + + +JSValue jsTestObjBooleanSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->booleanSequenceAttr()); + return result; +} + + +JSValue jsTestObjVoidSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->voidSequenceAttr()); + return result; +} + + +JSValue jsTestObjDateSequenceAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsArray(exec, castedThis->globalObject(), impl->dateSequenceAttr()); + return result; +} + + JSValue jsTestObjXMLObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->xmlObjAttr())); @@ -478,7 +645,7 @@ JSValue jsTestObjXMLObjAttr(ExecState* exec, JSValue slotBase, const Identifier& JSValue jsTestObjCreate(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsBoolean(impl->isCreate()); @@ -488,7 +655,7 @@ JSValue jsTestObjCreate(ExecState* exec, JSValue slotBase, const Identifier&) JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); @@ -498,7 +665,7 @@ JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Id JSValue jsTestObjReflectedIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); @@ -508,7 +675,7 @@ JSValue jsTestObjReflectedIntegralAttr(ExecState* exec, JSValue slotBase, const JSValue jsTestObjReflectedUnsignedIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(std::max(0, impl->getIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr))); @@ -518,7 +685,7 @@ JSValue jsTestObjReflectedUnsignedIntegralAttr(ExecState* exec, JSValue slotBase JSValue jsTestObjReflectedBooleanAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsBoolean(impl->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr)); @@ -528,7 +695,7 @@ JSValue jsTestObjReflectedBooleanAttr(ExecState* exec, JSValue slotBase, const I JSValue jsTestObjReflectedURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); @@ -538,7 +705,7 @@ JSValue jsTestObjReflectedURLAttr(ExecState* exec, JSValue slotBase, const Ident JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); @@ -548,7 +715,7 @@ JSValue jsTestObjReflectedStringAttr(ExecState* exec, JSValue slotBase, const Id JSValue jsTestObjReflectedCustomIntegralAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); @@ -558,7 +725,7 @@ JSValue jsTestObjReflectedCustomIntegralAttr(ExecState* exec, JSValue slotBase, JSValue jsTestObjReflectedCustomBooleanAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsBoolean(impl->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr)); @@ -568,7 +735,7 @@ JSValue jsTestObjReflectedCustomBooleanAttr(ExecState* exec, JSValue slotBase, c JSValue jsTestObjReflectedCustomURLAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); @@ -578,7 +745,7 @@ JSValue jsTestObjReflectedCustomURLAttr(ExecState* exec, JSValue slotBase, const JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); ExceptionCode ec = 0; TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSC::JSValue result = jsNumber(impl->attrWithGetterException(ec)); @@ -589,7 +756,7 @@ JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, cons JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->attrWithSetterException()); @@ -599,7 +766,7 @@ JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, cons JSValue jsTestObjStringAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); ExceptionCode ec = 0; TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSC::JSValue result = jsString(exec, impl->stringAttrWithGetterException(ec)); @@ -610,7 +777,7 @@ JSValue jsTestObjStringAttrWithGetterException(ExecState* exec, JSValue slotBase JSValue jsTestObjStringAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->stringAttrWithSetterException()); @@ -620,14 +787,14 @@ JSValue jsTestObjStringAttrWithSetterException(ExecState* exec, JSValue slotBase JSValue jsTestObjCustomAttr(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); return castedThis->customAttr(exec); } JSValue jsTestObjWithScriptStateAttribute(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->withScriptStateAttribute(exec)); return result; @@ -636,8 +803,8 @@ JSValue jsTestObjWithScriptStateAttribute(ExecState* exec, JSValue slotBase, con JSValue jsTestObjWithScriptExecutionContextAttribute(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return jsUndefined(); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -648,7 +815,7 @@ JSValue jsTestObjWithScriptExecutionContextAttribute(ExecState* exec, JSValue sl JSValue jsTestObjWithScriptStateAttributeRaises(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); ExceptionCode ec = 0; TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->withScriptStateAttributeRaises(exec, ec))); @@ -659,9 +826,9 @@ JSValue jsTestObjWithScriptStateAttributeRaises(ExecState* exec, JSValue slotBas JSValue jsTestObjWithScriptExecutionContextAttributeRaises(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); ExceptionCode ec = 0; - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return jsUndefined(); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -673,8 +840,8 @@ JSValue jsTestObjWithScriptExecutionContextAttributeRaises(ExecState* exec, JSVa JSValue jsTestObjWithScriptExecutionContextAndScriptStateAttribute(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return jsUndefined(); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -685,9 +852,9 @@ JSValue jsTestObjWithScriptExecutionContextAndScriptStateAttribute(ExecState* ex JSValue jsTestObjWithScriptExecutionContextAndScriptStateAttributeRaises(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); ExceptionCode ec = 0; - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return jsUndefined(); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -699,8 +866,8 @@ JSValue jsTestObjWithScriptExecutionContextAndScriptStateAttributeRaises(ExecSta JSValue jsTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return jsUndefined(); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -711,7 +878,7 @@ JSValue jsTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute(Exe JSValue jsTestObjWithScriptArgumentsAndCallStackAttribute(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); RefPtr<ScriptCallStack> callStack(createScriptCallStackForInspector(exec)); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->withScriptArgumentsAndCallStackAttribute(callStack))); @@ -722,7 +889,7 @@ JSValue jsTestObjWithScriptArgumentsAndCallStackAttribute(ExecState* exec, JSVal #if ENABLE(Condition1) JSValue jsTestObjConditionalAttr1(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->conditionalAttr1()); @@ -734,7 +901,7 @@ JSValue jsTestObjConditionalAttr1(ExecState* exec, JSValue slotBase, const Ident #if ENABLE(Condition1) && ENABLE(Condition2) JSValue jsTestObjConditionalAttr2(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->conditionalAttr2()); @@ -746,7 +913,7 @@ JSValue jsTestObjConditionalAttr2(ExecState* exec, JSValue slotBase, const Ident #if ENABLE(Condition1) || ENABLE(Condition2) JSValue jsTestObjConditionalAttr3(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->conditionalAttr3()); @@ -758,7 +925,7 @@ JSValue jsTestObjConditionalAttr3(ExecState* exec, JSValue slotBase, const Ident #if ENABLE(Condition1) JSValue jsTestObjConditionalAttr4Constructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); return JSTestObjectA::getConstructor(exec, castedThis); } @@ -767,7 +934,7 @@ JSValue jsTestObjConditionalAttr4Constructor(ExecState* exec, JSValue slotBase, #if ENABLE(Condition1) && ENABLE(Condition2) JSValue jsTestObjConditionalAttr5Constructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); return JSTestObjectB::getConstructor(exec, castedThis); } @@ -776,7 +943,7 @@ JSValue jsTestObjConditionalAttr5Constructor(ExecState* exec, JSValue slotBase, #if ENABLE(Condition1) || ENABLE(Condition2) JSValue jsTestObjConditionalAttr6Constructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); return JSTestObjectC::getConstructor(exec, castedThis); } @@ -784,7 +951,7 @@ JSValue jsTestObjConditionalAttr6Constructor(ExecState* exec, JSValue slotBase, JSValue jsTestObjCachedAttribute1(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); if (JSValue cachedValue = castedThis->m_cachedAttribute1.get()) return cachedValue; @@ -797,7 +964,7 @@ JSValue jsTestObjCachedAttribute1(ExecState* exec, JSValue slotBase, const Ident JSValue jsTestObjCachedAttribute2(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); if (JSValue cachedValue = castedThis->m_cachedAttribute2.get()) return cachedValue; @@ -810,15 +977,15 @@ JSValue jsTestObjCachedAttribute2(ExecState* exec, JSValue slotBase, const Ident JSValue jsTestObjContentDocument(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); - return shouldAllowAccessToNode(exec, impl->contentDocument()) ? toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->contentDocument())) : jsUndefined(); + return shouldAllowAccessToNode(exec, impl->contentDocument()) ? toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->contentDocument())) : jsNull(); } JSValue jsTestObjMutablePoint(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(SVGStaticPropertyTearOff<TestObj, FloatPoint>::create(impl, impl->mutablePoint(), &TestObj::updateMutablePoint))); @@ -828,7 +995,7 @@ JSValue jsTestObjMutablePoint(ExecState* exec, JSValue slotBase, const Identifie JSValue jsTestObjImmutablePoint(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(impl->immutablePoint()))); @@ -836,9 +1003,19 @@ JSValue jsTestObjImmutablePoint(ExecState* exec, JSValue slotBase, const Identif } +JSValue jsTestObjStrawberry(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(impl->blueberry()); + return result; +} + + JSValue jsTestObjStrictFloat(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->strictFloat()); @@ -848,7 +1025,7 @@ JSValue jsTestObjStrictFloat(ExecState* exec, JSValue slotBase, const Identifier JSValue jsTestObjDescription(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->description()); @@ -858,7 +1035,7 @@ JSValue jsTestObjDescription(ExecState* exec, JSValue slotBase, const Identifier JSValue jsTestObjId(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsNumber(impl->id()); @@ -868,7 +1045,7 @@ JSValue jsTestObjId(ExecState* exec, JSValue slotBase, const Identifier&) JSValue jsTestObjHash(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase)); UNUSED_PARAM(exec); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); JSValue result = jsString(exec, impl->hash()); @@ -878,7 +1055,7 @@ JSValue jsTestObjHash(ExecState* exec, JSValue slotBase, const Identifier&) JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase)); + JSTestObj* domObject = jsCast<JSTestObj*>(asObject(slotBase)); return JSTestObj::getConstructor(exec, domObject->globalObject()); } @@ -891,7 +1068,7 @@ void JSTestObj::put(JSCell* cell, ExecState* exec, const Identifier& propertyNam void setJSTestObjShortAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setShortAttr(value.toInt32(exec)); } @@ -899,7 +1076,7 @@ void setJSTestObjShortAttr(ExecState* exec, JSObject* thisObject, JSValue value) void setJSTestObjUnsignedShortAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setUnsignedShortAttr(value.toUInt32(exec)); } @@ -907,7 +1084,7 @@ void setJSTestObjUnsignedShortAttr(ExecState* exec, JSObject* thisObject, JSValu void setJSTestObjIntAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setIntAttr(value.toInt32(exec)); } @@ -915,7 +1092,7 @@ void setJSTestObjIntAttr(ExecState* exec, JSObject* thisObject, JSValue value) void setJSTestObjLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setLongLongAttr(static_cast<long long>(value.toInteger(exec))); } @@ -923,7 +1100,7 @@ void setJSTestObjLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue val void setJSTestObjUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setUnsignedLongLongAttr(static_cast<unsigned long long>(value.toInteger(exec))); } @@ -931,7 +1108,7 @@ void setJSTestObjUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSV void setJSTestObjStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setStringAttr(ustringToString(value.isEmpty() ? UString() : value.toString(exec)->value(exec))); } @@ -939,15 +1116,127 @@ void setJSTestObjStringAttr(ExecState* exec, JSObject* thisObject, JSValue value void setJSTestObjTestObjAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setTestObjAttr(toTestObj(value)); } +void setJSTestObjSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setSequenceAttr(toNativeArray<ScriptProfile>(exec, value)); +} + + +void setJSTestObjIntSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setIntSequenceAttr(toNativeArray<int>(exec, value)); +} + + +void setJSTestObjShortSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setShortSequenceAttr(toNativeArray<short>(exec, value)); +} + + +void setJSTestObjLongSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setLongSequenceAttr(toNativeArray<long>(exec, value)); +} + + +void setJSTestObjLongLongSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setLongLongSequenceAttr(toNativeArray<long long>(exec, value)); +} + + +void setJSTestObjUnsignedIntSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setUnsignedIntSequenceAttr(toNativeArray<unsigned int>(exec, value)); +} + + +void setJSTestObjUnsignedShortSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setUnsignedShortSequenceAttr(toNativeArray<unsigned short>(exec, value)); +} + + +void setJSTestObjUnsignedLongSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setUnsignedLongSequenceAttr(toNativeArray<unsigned long>(exec, value)); +} + + +void setJSTestObjUnsignedLongLongSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setUnsignedLongLongSequenceAttr(toNativeArray<unsigned long long>(exec, value)); +} + + +void setJSTestObjFloatSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setFloatSequenceAttr(toNativeArray<float>(exec, value)); +} + + +void setJSTestObjDoubleSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setDoubleSequenceAttr(toNativeArray<double>(exec, value)); +} + + +void setJSTestObjBooleanSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setBooleanSequenceAttr(toNativeArray<boolean>(exec, value)); +} + + +void setJSTestObjVoidSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setVoidSequenceAttr(toNativeArray<void>(exec, value)); +} + + +void setJSTestObjDateSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setDateSequenceAttr(toNativeArray<Date>(exec, value)); +} + + void setJSTestObjXMLObjAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setXMLObjAttr(toTestObj(value)); } @@ -955,7 +1244,7 @@ void setJSTestObjXMLObjAttr(ExecState* exec, JSObject* thisObject, JSValue value void setJSTestObjCreate(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setCreate(value.toBoolean(exec)); } @@ -963,7 +1252,7 @@ void setJSTestObjCreate(ExecState* exec, JSObject* thisObject, JSValue value) void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, valueToStringWithNullCheck(exec, value)); } @@ -971,7 +1260,7 @@ void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSVa void setJSTestObjReflectedIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, value.toInt32(exec)); } @@ -979,7 +1268,7 @@ void setJSTestObjReflectedIntegralAttr(ExecState* exec, JSObject* thisObject, JS void setJSTestObjReflectedUnsignedIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setUnsignedIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr, value.toUInt32(exec)); } @@ -987,7 +1276,7 @@ void setJSTestObjReflectedUnsignedIntegralAttr(ExecState* exec, JSObject* thisOb void setJSTestObjReflectedBooleanAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, value.toBoolean(exec)); } @@ -995,7 +1284,7 @@ void setJSTestObjReflectedBooleanAttr(ExecState* exec, JSObject* thisObject, JSV void setJSTestObjReflectedURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, valueToStringWithNullCheck(exec, value)); } @@ -1003,7 +1292,7 @@ void setJSTestObjReflectedURLAttr(ExecState* exec, JSObject* thisObject, JSValue void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, valueToStringWithNullCheck(exec, value)); } @@ -1011,7 +1300,7 @@ void setJSTestObjReflectedStringAttr(ExecState* exec, JSObject* thisObject, JSVa void setJSTestObjReflectedCustomIntegralAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, value.toInt32(exec)); } @@ -1019,7 +1308,7 @@ void setJSTestObjReflectedCustomIntegralAttr(ExecState* exec, JSObject* thisObje void setJSTestObjReflectedCustomBooleanAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, value.toBoolean(exec)); } @@ -1027,7 +1316,7 @@ void setJSTestObjReflectedCustomBooleanAttr(ExecState* exec, JSObject* thisObjec void setJSTestObjReflectedCustomURLAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, valueToStringWithNullCheck(exec, value)); } @@ -1035,7 +1324,7 @@ void setJSTestObjReflectedCustomURLAttr(ExecState* exec, JSObject* thisObject, J void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; impl->setAttrWithGetterException(value.toInt32(exec), ec); @@ -1045,7 +1334,7 @@ void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; impl->setAttrWithSetterException(value.toInt32(exec), ec); @@ -1055,7 +1344,7 @@ void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, void setJSTestObjStringAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; impl->setStringAttrWithGetterException(ustringToString(value.isEmpty() ? UString() : value.toString(exec)->value(exec)), ec); @@ -1065,7 +1354,7 @@ void setJSTestObjStringAttrWithGetterException(ExecState* exec, JSObject* thisOb void setJSTestObjStringAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; impl->setStringAttrWithSetterException(ustringToString(value.isEmpty() ? UString() : value.toString(exec)->value(exec)), ec); @@ -1075,13 +1364,13 @@ void setJSTestObjStringAttrWithSetterException(ExecState* exec, JSObject* thisOb void setJSTestObjCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value) { - static_cast<JSTestObj*>(thisObject)->setCustomAttr(exec, value); + jsCast<JSTestObj*>(thisObject)->setCustomAttr(exec, value); } void setJSTestObjWithScriptStateAttribute(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setWithScriptStateAttribute(exec, value.toInt32(exec)); } @@ -1089,9 +1378,9 @@ void setJSTestObjWithScriptStateAttribute(ExecState* exec, JSObject* thisObject, void setJSTestObjWithScriptExecutionContextAttribute(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return; impl->setWithScriptExecutionContextAttribute(scriptContext, toTestObj(value)); @@ -1100,7 +1389,7 @@ void setJSTestObjWithScriptExecutionContextAttribute(ExecState* exec, JSObject* void setJSTestObjWithScriptStateAttributeRaises(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; impl->setWithScriptStateAttributeRaises(exec, toTestObj(value), ec); @@ -1110,10 +1399,10 @@ void setJSTestObjWithScriptStateAttributeRaises(ExecState* exec, JSObject* thisO void setJSTestObjWithScriptExecutionContextAttributeRaises(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return; impl->setWithScriptExecutionContextAttributeRaises(scriptContext, toTestObj(value), ec); @@ -1123,9 +1412,9 @@ void setJSTestObjWithScriptExecutionContextAttributeRaises(ExecState* exec, JSOb void setJSTestObjWithScriptExecutionContextAndScriptStateAttribute(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return; impl->setWithScriptExecutionContextAndScriptStateAttribute(exec, scriptContext, toTestObj(value)); @@ -1134,10 +1423,10 @@ void setJSTestObjWithScriptExecutionContextAndScriptStateAttribute(ExecState* ex void setJSTestObjWithScriptExecutionContextAndScriptStateAttributeRaises(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return; impl->setWithScriptExecutionContextAndScriptStateAttributeRaises(exec, scriptContext, toTestObj(value), ec); @@ -1147,9 +1436,9 @@ void setJSTestObjWithScriptExecutionContextAndScriptStateAttributeRaises(ExecSta void setJSTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return; impl->setWithScriptExecutionContextAndScriptStateWithSpacesAttribute(exec, scriptContext, toTestObj(value)); @@ -1158,7 +1447,7 @@ void setJSTestObjWithScriptExecutionContextAndScriptStateWithSpacesAttribute(Exe void setJSTestObjWithScriptArgumentsAndCallStackAttribute(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); RefPtr<ScriptCallStack> callStack(createScriptCallStackForInspector(exec)); impl->setWithScriptArgumentsAndCallStackAttribute(callStack, toTestObj(value)); @@ -1168,7 +1457,7 @@ void setJSTestObjWithScriptArgumentsAndCallStackAttribute(ExecState* exec, JSObj #if ENABLE(Condition1) void setJSTestObjConditionalAttr1(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setConditionalAttr1(value.toInt32(exec)); } @@ -1178,7 +1467,7 @@ void setJSTestObjConditionalAttr1(ExecState* exec, JSObject* thisObject, JSValue #if ENABLE(Condition1) && ENABLE(Condition2) void setJSTestObjConditionalAttr2(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setConditionalAttr2(value.toInt32(exec)); } @@ -1188,7 +1477,7 @@ void setJSTestObjConditionalAttr2(ExecState* exec, JSObject* thisObject, JSValue #if ENABLE(Condition1) || ENABLE(Condition2) void setJSTestObjConditionalAttr3(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setConditionalAttr3(value.toInt32(exec)); } @@ -1199,7 +1488,7 @@ void setJSTestObjConditionalAttr3(ExecState* exec, JSObject* thisObject, JSValue void setJSTestObjConditionalAttr4Constructor(ExecState* exec, JSObject* thisObject, JSValue value) { // Shadowing a built-in constructor - static_cast<JSTestObj*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, "conditionalAttr4"), value); + jsCast<JSTestObj*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, "conditionalAttr4"), value); } #endif @@ -1208,7 +1497,7 @@ void setJSTestObjConditionalAttr4Constructor(ExecState* exec, JSObject* thisObje void setJSTestObjConditionalAttr5Constructor(ExecState* exec, JSObject* thisObject, JSValue value) { // Shadowing a built-in constructor - static_cast<JSTestObj*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, "conditionalAttr5"), value); + jsCast<JSTestObj*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, "conditionalAttr5"), value); } #endif @@ -1217,14 +1506,14 @@ void setJSTestObjConditionalAttr5Constructor(ExecState* exec, JSObject* thisObje void setJSTestObjConditionalAttr6Constructor(ExecState* exec, JSObject* thisObject, JSValue value) { // Shadowing a built-in constructor - static_cast<JSTestObj*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, "conditionalAttr6"), value); + jsCast<JSTestObj*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, "conditionalAttr6"), value); } #endif void setJSTestObjMutablePoint(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setMutablePoint(toSVGPoint(value)); } @@ -1232,15 +1521,23 @@ void setJSTestObjMutablePoint(ExecState* exec, JSObject* thisObject, JSValue val void setJSTestObjImmutablePoint(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setImmutablePoint(toSVGPoint(value)); } +void setJSTestObjStrawberry(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + impl->setBlueberry(toint(value)); +} + + void setJSTestObjStrictFloat(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setStrictFloat(value.toFloat(exec)); } @@ -1248,7 +1545,7 @@ void setJSTestObjStrictFloat(ExecState* exec, JSObject* thisObject, JSValue valu void setJSTestObjId(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->setId(value.toInt32(exec)); } @@ -1256,7 +1553,7 @@ void setJSTestObjId(ExecState* exec, JSObject* thisObject, JSValue value) JSValue JSTestObj::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestObjConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestObjConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); } EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* exec) @@ -1264,7 +1561,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* exe JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->voidMethod(); @@ -1276,11 +1573,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecSt JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 3) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1299,7 +1596,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(ExecState* exec JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -1312,11 +1609,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecSta JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 3) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1336,7 +1633,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(ExecState* exec JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -1349,11 +1646,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecSta JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 3) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1368,16 +1665,51 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecSta return JSValue::encode(result); } +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithSequenceArg(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + if (exec->argumentCount() < 1) + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + sequence<ScriptProfile>* sequenceArg(toNativeArray<ScriptProfile>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + impl->methodWithSequenceArg(sequenceArg); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodReturningSequence(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwVMTypeError(exec); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); + TestObj* impl = static_cast<TestObj*>(castedThis->impl()); + if (exec->argumentCount() < 1) + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl->methodReturningSequence(intArg)); + return JSValue::encode(result); +} + EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) @@ -1396,11 +1728,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); RefPtr<SerializedScriptValue> serializedArg(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1413,12 +1745,12 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); - RefPtr<IDBKey> key(createIDBKeyFromValue(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + PassRefPtr<IDBKey> key(createIDBKeyFromValue(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); impl->idbKey(key); @@ -1430,12 +1762,12 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(ExecState* JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); - OptionsObject* oo(toOptionsObject(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + Dictionary oo(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1445,7 +1777,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(ExecState* return JSValue::encode(jsUndefined()); } - OptionsObject* ooo(toOptionsObject(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined))); + Dictionary ooo(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)); if (exec->hadException()) return JSValue::encode(jsUndefined()); impl->optionsObject(oo, ooo); @@ -1457,7 +1789,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecS JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; @@ -1471,7 +1803,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(ExecState* e JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); return JSValue::encode(castedThis->customMethod(exec)); } @@ -1481,7 +1813,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(Exec JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); return JSValue::encode(castedThis->customMethodWithArgs(exec)); } @@ -1491,11 +1823,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(ExecStat JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); JSValue listener = exec->argument(1); if (!listener.isObject()) return JSValue::encode(jsUndefined()); @@ -1508,11 +1840,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(ExecS JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); JSValue listener = exec->argument(1); if (!listener.isObject()) return JSValue::encode(jsUndefined()); @@ -1525,7 +1857,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(ExecS JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->withScriptStateVoid(exec); @@ -1537,7 +1869,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(ExecSt JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -1552,7 +1884,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidExcept JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; @@ -1566,7 +1898,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjExcepti JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; @@ -1583,10 +1915,10 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContex JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return JSValue::encode(jsUndefined()); impl->withScriptExecutionContext(scriptContext); @@ -1598,10 +1930,10 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContex JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return JSValue::encode(jsUndefined()); impl->withScriptExecutionContextAndScriptState(exec, scriptContext); @@ -1613,11 +1945,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContex JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return JSValue::encode(jsUndefined()); @@ -1633,10 +1965,10 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContex JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); - ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return JSValue::encode(jsUndefined()); @@ -1651,7 +1983,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptArgumentsAndCal JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 0)); @@ -1665,7 +1997,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(Exe JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -1687,11 +2019,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int nonOpt(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1714,11 +2046,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int nonOpt(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1749,7 +2081,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalString( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -1771,7 +2103,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringI JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); const String& str(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); @@ -1786,7 +2118,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringI JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); const String& str(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsNullString).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsNullString).toString(exec)->value(exec))); @@ -1801,12 +2133,12 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(Exe JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); - if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) { setDOMException(exec, TYPE_MISMATCH_ERR); return JSValue::encode(jsUndefined()); } @@ -1820,15 +2152,15 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgA JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int nonCallback(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); - if (exec->argumentCount() <= 1 || !exec->argument(1).isObject()) { + if (exec->argumentCount() <= 1 || !exec->argument(1).isFunction()) { setDOMException(exec, TYPE_MISMATCH_ERR); return JSValue::encode(jsUndefined()); } @@ -1842,12 +2174,12 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackAndOpti JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); RefPtr<TestCallback> callback; if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull()) { - if (!exec->argument(0).isObject()) { + if (!exec->argument(0).isFunction()) { setDOMException(exec, TYPE_MISMATCH_ERR); return JSValue::encode(jsUndefined()); } @@ -1863,7 +2195,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod1(ExecSt JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -1879,7 +2211,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod2(ExecSt JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->conditionalMethod2(); @@ -1894,7 +2226,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConditionalMethod3(ExecSt JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->conditionalMethod3(); @@ -1908,11 +2240,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1928,11 +2260,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1955,11 +2287,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1972,11 +2304,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int intArg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1989,12 +2321,12 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod5( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); - if (exec->argumentCount() <= 0 || !exec->argument(0).isObject()) { + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + if (exec->argumentCount() <= 0 || !exec->argument(0).isFunction()) { setDOMException(exec, TYPE_MISMATCH_ERR); return JSValue::encode(jsUndefined()); } @@ -2008,11 +2340,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod6( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); DOMStringList* listArg(toDOMStringList(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2025,11 +2357,11 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod7( JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); DOMStringList* arrayArg(toDOMStringList(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2050,7 +2382,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecStat return jsTestObjPrototypeFunctionOverloadedMethod3(exec); if (argsCount == 1) return jsTestObjPrototypeFunctionOverloadedMethod4(exec); - if ((argsCount == 1 && (arg0.isNull() || arg0.isObject()))) + if ((argsCount == 1 && (arg0.isNull() || arg0.isFunction()))) return jsTestObjPrototypeFunctionOverloadedMethod5(exec); if ((argsCount == 1 && (arg0.isNull() || (arg0.isObject() && asObject(arg0)->inherits(&JSDOMStringList::s_info))))) return jsTestObjPrototypeFunctionOverloadedMethod6(exec); @@ -2086,7 +2418,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethodWithOptional EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod2(ExecState* exec) { if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); return JSValue::encode(JSTestObj::classMethod2(exec)); } @@ -2094,7 +2426,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionClassMethod2(ExecState* static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod11(ExecState* exec) { if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); int arg(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2108,7 +2440,7 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod static EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod12(ExecState* exec) { if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); const String& type(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2134,11 +2466,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongArr JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); Vector<unsigned long> unsignedLongArray(jsUnsignedLongArrayToVector(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2151,12 +2483,12 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(ExecState* JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; if (!shouldAllowAccessToNode(exec, impl->getSVGDocument(ec))) - return JSValue::encode(jsUndefined()); + return JSValue::encode(jsNull()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->getSVGDocument(ec))); setDOMException(exec, ec); @@ -2168,11 +2500,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert1(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); a* (toa(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2185,11 +2517,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert2(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); b* (tob(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2202,11 +2534,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert3(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); c* (toc(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2219,11 +2551,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert4(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); d* (tod(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2236,11 +2568,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert5(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 1) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); e* (toe(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -2253,7 +2585,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMutablePointFunction(Exec JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -2266,7 +2598,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionImmutablePointFunction(Ex JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); @@ -2279,7 +2611,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOrange(ExecState* exec) JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); impl->banana(); @@ -2291,11 +2623,11 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStrictFunction(ExecState* JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); - JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 3) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; const String& str(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) @@ -2417,7 +2749,7 @@ static inline bool isObservable(JSTestObj* jsTestObj) bool JSTestObjOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestObj* jsTestObj = static_cast<JSTestObj*>(handle.get().asCell()); + JSTestObj* jsTestObj = jsCast<JSTestObj*>(handle.get().asCell()); if (!isObservable(jsTestObj)) return false; UNUSED_PARAM(visitor); @@ -2426,7 +2758,7 @@ bool JSTestObjOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle void JSTestObjOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestObj* jsTestObj = static_cast<JSTestObj*>(handle.get().asCell()); + JSTestObj* jsTestObj = jsCast<JSTestObj*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestObj->impl(), jsTestObj); jsTestObj->releaseImpl(); @@ -2439,7 +2771,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj TestObj* toTestObj(JSC::JSValue value) { - return value.inherits(&JSTestObj::s_info) ? static_cast<JSTestObj*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestObj::s_info) ? jsCast<JSTestObj*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h index 28419eca1..b8dca2e02 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -158,6 +158,8 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(JSC::ExecS JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithSequenceArg(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodReturningSequence(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*); JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(JSC::ExecState*); @@ -231,6 +233,34 @@ 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 jsTestObjSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjIntSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjIntSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjShortSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjShortSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjLongSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjLongSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjLongLongSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjLongLongSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedIntSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedIntSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedShortSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedShortSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedLongSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedLongSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedLongLongSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedLongLongSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjFloatSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjFloatSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjDoubleSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjDoubleSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjBooleanSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjBooleanSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjVoidSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjVoidSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjDateSequenceAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjDateSequenceAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjXMLObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestObjXMLObjAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjCreate(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); @@ -310,6 +340,8 @@ JSC::JSValue jsTestObjMutablePoint(JSC::ExecState*, JSC::JSValue, const JSC::Ide void setJSTestObjMutablePoint(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjImmutablePoint(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestObjImmutablePoint(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStrawberry(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStrawberry(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjStrictFloat(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestObjStrictFloat(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); JSC::JSValue jsTestObjDescription(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp index c0ea6eaad..db5304973 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp @@ -25,7 +25,10 @@ #include "JSTestSerializedScriptValueInterface.h" #include "ExceptionCode.h" +#include "JSArray.h" #include "JSDOMBinding.h" +#include "JSMessagePortArray.h" +#include "MessagePortArray.h" #include "SerializedScriptValue.h" #include "TestSerializedScriptValueInterface.h" #include <runtime/Error.h> @@ -43,6 +46,7 @@ static const HashTableValue JSTestSerializedScriptValueInterfaceTableValues[] = { "value", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t)setJSTestSerializedScriptValueInterfaceValue, NoIntrinsic }, { "readonlyValue", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t)0, NoIntrinsic }, { "cachedValue", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t)setJSTestSerializedScriptValueInterfaceCachedValue, NoIntrinsic }, + { "ports", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t)0, NoIntrinsic }, { "cachedReadonlyValue", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t)0, NoIntrinsic }, { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t)0, NoIntrinsic }, { 0, 0, 0, 0, NoIntrinsic } @@ -69,32 +73,35 @@ void JSTestSerializedScriptValueInterfaceConstructor::finishCreation(ExecState* Base::finishCreation(exec->globalData()); ASSERT(inherits(&s_info)); putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestSerializedScriptValueInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly); - putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum); + putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(3), ReadOnly | DontDelete | DontEnum); } bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, static_cast<JSTestSerializedScriptValueInterfaceConstructor*>(cell), propertyName, slot); + return getStaticValueSlot<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(cell), propertyName, slot); } bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { - return getStaticValueDescriptor<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, static_cast<JSTestSerializedScriptValueInterfaceConstructor*>(object), propertyName, descriptor); + return getStaticValueDescriptor<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(object), propertyName, descriptor); } EncodedJSValue JSC_HOST_CALL JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface(ExecState* exec) { - JSTestSerializedScriptValueInterfaceConstructor* jsConstructor = static_cast<JSTestSerializedScriptValueInterfaceConstructor*>(exec->callee()); + JSTestSerializedScriptValueInterfaceConstructor* castedThis = jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(exec->callee()); if (exec->argumentCount() < 2) - return throwVMError(exec, createTypeError(exec, "Not enough arguments")); + return throwVMError(exec, createNotEnoughArgumentsError(exec)); const String& hello(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - RefPtr<SerializedScriptValue> value(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined))); + RefPtr<SerializedScriptValue> data(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - RefPtr<TestSerializedScriptValueInterface> object = TestSerializedScriptValueInterface::create(hello, value); - return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), object.get()))); + Array* transferList(toArray(MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + RefPtr<TestSerializedScriptValueInterface> object = TestSerializedScriptValueInterface::create(hello, data, transferList); + return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get()))); } ConstructType JSTestSerializedScriptValueInterfaceConstructor::getConstructData(JSCell*, ConstructData& constructData) @@ -107,10 +114,12 @@ ConstructType JSTestSerializedScriptValueInterfaceConstructor::getConstructData( static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] = { + { "acceptTransferList", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList), (intptr_t)2, NoIntrinsic }, + { "multiTransferList", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionMultiTransferList), (intptr_t)4, NoIntrinsic }, { 0, 0, 0, 0, NoIntrinsic } }; -static const HashTable JSTestSerializedScriptValueInterfacePrototypeTable = { 1, 0, JSTestSerializedScriptValueInterfacePrototypeTableValues, 0 }; +static const HashTable JSTestSerializedScriptValueInterfacePrototypeTable = { 5, 3, JSTestSerializedScriptValueInterfacePrototypeTableValues, 0 }; const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, &JSTestSerializedScriptValueInterfacePrototypeTable, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) }; JSObject* JSTestSerializedScriptValueInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject) @@ -118,6 +127,18 @@ JSObject* JSTestSerializedScriptValueInterfacePrototype::self(ExecState* exec, J return getDOMPrototype<JSTestSerializedScriptValueInterface>(exec, globalObject); } +bool JSTestSerializedScriptValueInterfacePrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSTestSerializedScriptValueInterfacePrototype* thisObject = jsCast<JSTestSerializedScriptValueInterfacePrototype*>(cell); + return getStaticFunctionSlot<JSObject>(exec, &JSTestSerializedScriptValueInterfacePrototypeTable, thisObject, propertyName, slot); +} + +bool JSTestSerializedScriptValueInterfacePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + JSTestSerializedScriptValueInterfacePrototype* thisObject = jsCast<JSTestSerializedScriptValueInterfacePrototype*>(object); + return getStaticFunctionDescriptor<JSObject>(exec, &JSTestSerializedScriptValueInterfacePrototypeTable, thisObject, propertyName, descriptor); +} + const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, &JSTestSerializedScriptValueInterfaceTable, 0 , CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) }; JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestSerializedScriptValueInterface> impl) @@ -164,7 +185,7 @@ bool JSTestSerializedScriptValueInterface::getOwnPropertyDescriptor(JSObject* ob JSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); UNUSED_PARAM(exec); TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); JSValue result = impl->value() ? impl->value()->deserialize(exec, castedThis->globalObject(), 0) : jsNull(); @@ -174,7 +195,7 @@ JSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSValue slotB JSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); UNUSED_PARAM(exec); TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); JSValue result = impl->readonlyValue() ? impl->readonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull(); @@ -184,7 +205,7 @@ JSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* exec, JSVal JSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); UNUSED_PARAM(exec); if (JSValue cachedValue = castedThis->m_cachedValue.get()) return cachedValue; @@ -195,9 +216,19 @@ JSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSValue } +JSValue jsTestSerializedScriptValueInterfacePorts(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->ports())); + return result; +} + + JSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); UNUSED_PARAM(exec); if (JSValue cachedValue = castedThis->m_cachedReadonlyValue.get()) return cachedValue; @@ -210,7 +241,7 @@ JSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* exec, JSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { - JSTestSerializedScriptValueInterface* domObject = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + JSTestSerializedScriptValueInterface* domObject = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); return JSTestSerializedScriptValueInterface::getConstructor(exec, domObject->globalObject()); } @@ -223,7 +254,7 @@ void JSTestSerializedScriptValueInterface::put(JSCell* cell, ExecState* exec, co void setJSTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(thisObject); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(thisObject); TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); impl->setValue(SerializedScriptValue::create(exec, value)); } @@ -231,7 +262,7 @@ void setJSTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* thi void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* thisObject, JSValue value) { - JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(thisObject); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(thisObject); TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); impl->setCachedValue(SerializedScriptValue::create(exec, value)); } @@ -239,7 +270,80 @@ void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObjec JSValue JSTestSerializedScriptValueInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { - return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); + return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); +} + +EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestSerializedScriptValueInterface::s_info)) + return throwVMTypeError(exec); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestSerializedScriptValueInterface::s_info); + TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); + if (exec->argumentCount() < 1) + return throwVMError(exec, createNotEnoughArgumentsError(exec)); + RefPtr<SerializedScriptValue> data(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 1) { + impl->acceptTransferList(data); + return JSValue::encode(jsUndefined()); + } + + Array* transferList(toArray(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + impl->acceptTransferList(data, transferList); + return JSValue::encode(jsUndefined()); +} + +EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionMultiTransferList(ExecState* exec) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSTestSerializedScriptValueInterface::s_info)) + return throwVMTypeError(exec); + JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(thisValue)); + ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestSerializedScriptValueInterface::s_info); + TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); + + size_t argsCount = exec->argumentCount(); + if (argsCount <= 0) { + impl->multiTransferList(); + return JSValue::encode(jsUndefined()); + } + + RefPtr<SerializedScriptValue> first(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + if (argsCount <= 1) { + impl->multiTransferList(first); + return JSValue::encode(jsUndefined()); + } + + Array* tx(toArray(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + if (argsCount <= 2) { + impl->multiTransferList(first, tx); + return JSValue::encode(jsUndefined()); + } + + RefPtr<SerializedScriptValue> second(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + if (argsCount <= 3) { + impl->multiTransferList(first, tx, second); + return JSValue::encode(jsUndefined()); + } + + Array* txx(toArray(MAYBE_MISSING_PARAMETER(exec, 3, DefaultIsUndefined))); + if (exec->hadException()) + return JSValue::encode(jsUndefined()); + impl->multiTransferList(first, tx, second, txx); + return JSValue::encode(jsUndefined()); } void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor) @@ -264,7 +368,7 @@ static inline bool isObservable(JSTestSerializedScriptValueInterface* jsTestSeri bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { - JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = static_cast<JSTestSerializedScriptValueInterface*>(handle.get().asCell()); + JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.get().asCell()); if (!isObservable(jsTestSerializedScriptValueInterface)) return false; UNUSED_PARAM(visitor); @@ -273,7 +377,7 @@ bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC:: void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { - JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = static_cast<JSTestSerializedScriptValueInterface*>(handle.get().asCell()); + JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsTestSerializedScriptValueInterface->impl(), jsTestSerializedScriptValueInterface); jsTestSerializedScriptValueInterface->releaseImpl(); @@ -286,7 +390,7 @@ JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestSer TestSerializedScriptValueInterface* toTestSerializedScriptValueInterface(JSC::JSValue value) { - return value.inherits(&JSTestSerializedScriptValueInterface::s_info) ? static_cast<JSTestSerializedScriptValueInterface*>(asObject(value))->impl() : 0; + return value.inherits(&JSTestSerializedScriptValueInterface::s_info) ? jsCast<JSTestSerializedScriptValueInterface*>(asObject(value))->impl() : 0; } } diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h index c944e42a3..80df1e0b7 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h @@ -103,6 +103,8 @@ public: } static const JSC::ClassInfo s_info; + static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) { return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info); @@ -111,7 +113,7 @@ public: private: JSTestSerializedScriptValueInterfacePrototype(JSC::JSGlobalData& globalData, JSC::JSGlobalObject*, JSC::Structure* structure) : JSC::JSNonFinalObject(globalData, structure) { } protected: - static const unsigned StructureFlags = JSC::OverridesVisitChildren | Base::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesVisitChildren | Base::StructureFlags; }; class JSTestSerializedScriptValueInterfaceConstructor : public DOMConstructorObject { @@ -141,6 +143,10 @@ protected: static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&); }; +// Functions + +JSC::EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList(JSC::ExecState*); +JSC::EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionMultiTransferList(JSC::ExecState*); // Attributes JSC::JSValue jsTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); @@ -148,6 +154,7 @@ void setJSTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::JSObject JSC::JSValue jsTestSerializedScriptValueInterfaceReadonlyValue(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); JSC::JSValue jsTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); void setJSTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestSerializedScriptValueInterfacePorts(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); JSC::JSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); JSC::JSValue jsTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h index 3d6f7bd93..7d53b3026 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h @@ -33,7 +33,9 @@ @class DOMClass3; @class DOMClass5; @class DOMClass6; +@class DOMClass8; @class DOMDOMStringList; +@class DOMThisClass; @class NSString; @interface DOMTestCallback : DOMObject @@ -43,6 +45,8 @@ - (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param; - (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param; - (BOOL)callbackWithStringList:(DOMDOMStringList *)listParam; +- (BOOL)callbackWithBoolean:(BOOL)boolParam; +- (BOOL)callbackRequiresThisToPass:(DOMClass8 *)class8Param thisClassParam:(DOMThisClass *)thisClassParam; @end #endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm index 9b0866c9a..f2f389c8f 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm @@ -37,6 +37,7 @@ #import "Class3.h" #import "Class5.h" #import "Class6.h" +#import "Class8.h" #import "DOMBlobInternal.h" #import "DOMCSSRuleInternal.h" #import "DOMCSSValueInternal.h" @@ -45,16 +46,19 @@ #import "DOMClass3Internal.h" #import "DOMClass5Internal.h" #import "DOMClass6Internal.h" +#import "DOMClass8Internal.h" #import "DOMDOMStringListInternal.h" #import "DOMEventInternal.h" #import "DOMNodeInternal.h" #import "DOMStringList.h" #import "DOMStyleSheetInternal.h" #import "DOMTestCallbackInternal.h" +#import "DOMThisClassInternal.h" #import "ExceptionHandlers.h" #import "JSMainThreadExecState.h" #import "KURL.h" #import "TestCallback.h" +#import "ThisClass.h" #import "ThreadCheck.h" #import "WebCoreObjCExtras.h" #import "WebScriptObjectPrivate.h" @@ -117,6 +121,18 @@ return IMPL->callbackWithStringList(core(listParam)); } +- (BOOL)callbackWithBoolean:(BOOL)boolParam +{ + WebCore::JSMainThreadNullState state; + return IMPL->callbackWithBoolean(boolParam); +} + +- (BOOL)callbackRequiresThisToPass:(DOMClass8 *)class8Param thisClassParam:(DOMThisClass *)thisClassParam +{ + WebCore::JSMainThreadNullState state; + return IMPL->callbackRequiresThisToPass(core(class8Param), core(thisClassParam)); +} + @end WebCore::TestCallback* core(DOMTestCallback *wrapper) diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestException.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestException.h new file mode 100644 index 000000000..08e044dee --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestException.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class NSString; + +@interface DOMTestException : DOMObject +- (NSString *)name; +@end + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestException.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestException.mm new file mode 100644 index 000000000..5ba346081 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestException.mm @@ -0,0 +1,94 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * 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. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestException.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestExceptionInternal.h" +#import "ExceptionHandlers.h" +#import "JSMainThreadExecState.h" +#import "KURL.h" +#import "TestException.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestException*>(_internal) + +@implementation DOMTestException + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestException class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (NSString *)name +{ + WebCore::JSMainThreadNullState state; + return IMPL->name(); +} + +@end + +WebCore::TestException* core(DOMTestException *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestException*>(wrapper->_internal) : 0; +} + +DOMTestException *kit(WebCore::TestException* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestException *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestException *wrapper = [[DOMTestException alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestExceptionInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestExceptionInternal.h new file mode 100644 index 000000000..54f38bc99 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestExceptionInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * 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. + */ + +#import <WebCore/DOMTestException.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestException; +} + +WebCore::TestException* core(DOMTestException *); +DOMTestException *kit(WebCore::TestException*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNode.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNode.h new file mode 100644 index 000000000..d298c78b4 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNode.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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. + */ + +#import <WebCore/DOMNode.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@interface DOMTestNode : DOMNode +@end + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNode.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNode.mm new file mode 100644 index 000000000..1a657d85e --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNode.mm @@ -0,0 +1,61 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * 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. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestNode.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestNodeInternal.h" +#import "ExceptionHandlers.h" +#import "JSMainThreadExecState.h" +#import "TestNode.h" +#import "ThreadCheck.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL static_cast<WebCore::TestNode*>(reinterpret_cast<WebCore::Node*>(_internal)) + +@implementation DOMTestNode + +@end + +WebCore::TestNode* core(DOMTestNode *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestNode*>(wrapper->_internal) : 0; +} + +DOMTestNode *kit(WebCore::TestNode* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + return static_cast<DOMTestNode*>(kit(static_cast<WebCore::Node*>(value))); +} diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNodeInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNodeInternal.h new file mode 100644 index 000000000..fef27570e --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestNodeInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * 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. + */ + +#import <WebCore/DOMTestNode.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestNode; +} + +WebCore::TestNode* core(DOMTestNode *); +DOMTestNode *kit(WebCore::TestNode*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h index aebc39fb3..831a50fe9 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h @@ -28,9 +28,9 @@ #if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST +@class DOMDictionary; @class DOMDocument; @class DOMIDBKey; -@class DOMOptionsObject; @class DOMSVGDocument; @class DOMSVGPoint; @class DOMTestObj; @@ -159,6 +159,8 @@ enum { - (void)setMutablePoint:(DOMSVGPoint *)newMutablePoint; - (DOMSVGPoint *)immutablePoint; - (void)setImmutablePoint:(DOMSVGPoint *)newImmutablePoint; +- (int)strawberry; +- (void)setStrawberry:(int)newStrawberry; - (float)strictFloat; - (void)setStrictFloat:(float)newStrictFloat; - (int)descriptionName; @@ -174,7 +176,7 @@ enum { - (DOMTestObj *)methodThatRequiresAllArgsAndThrows:(NSString *)strArg objArg:(DOMTestObj *)objArg; - (void)serializedValue:(NSString *)serializedArg; - (void)idbKey:(DOMIDBKey *)key; -- (void)optionsObject:(DOMOptionsObject *)oo ooo:(DOMOptionsObject *)ooo; +- (void)optionsObject:(DOMDictionary *)oo ooo:(DOMDictionary *)ooo; - (void)methodWithException; - (void)customMethod; - (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm index abd3b9cc5..53e459643 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -32,11 +32,11 @@ #import "DOMBlobInternal.h" #import "DOMCSSRuleInternal.h" #import "DOMCSSValueInternal.h" +#import "DOMDictionaryInternal.h" #import "DOMDocumentInternal.h" #import "DOMEventInternal.h" #import "DOMIDBKeyInternal.h" #import "DOMNodeInternal.h" -#import "DOMOptionsObjectInternal.h" #import "DOMSVGDocumentInternal.h" #import "DOMSVGPointInternal.h" #import "DOMStyleSheetInternal.h" @@ -50,6 +50,7 @@ #import "DOMcInternal.h" #import "DOMdInternal.h" #import "DOMeInternal.h" +#import "Dictionary.h" #import "Document.h" #import "EventListener.h" #import "ExceptionHandlers.h" @@ -58,7 +59,6 @@ #import "JSMainThreadExecState.h" #import "KURL.h" #import "ObjCEventListener.h" -#import "OptionsObject.h" #import "SVGDocument.h" #import "SVGStaticPropertyTearOff.h" #import "SerializedScriptValue.h" @@ -659,6 +659,18 @@ IMPL->setImmutablePoint(core(newImmutablePoint)); } +- (int)strawberry +{ + WebCore::JSMainThreadNullState state; + return IMPL->blueberry(); +} + +- (void)setStrawberry:(int)newStrawberry +{ + WebCore::JSMainThreadNullState state; + IMPL->setBlueberry(newStrawberry); +} + - (float)strictFloat { WebCore::JSMainThreadNullState state; @@ -752,7 +764,7 @@ IMPL->idbKey(core(key)); } -- (void)optionsObject:(DOMOptionsObject *)oo ooo:(DOMOptionsObject *)ooo +- (void)optionsObject:(DOMDictionary *)oo ooo:(DOMDictionary *)ooo { WebCore::JSMainThreadNullState state; IMPL->optionsObject(core(oo), core(ooo)); diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.h index b5f3a17c9..01c68d9e9 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.h +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.h @@ -28,6 +28,8 @@ #if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST +@class DOMArray; +@class DOMMessagePortArray; @class NSString; @interface DOMTestSerializedScriptValueInterface : DOMObject @@ -36,7 +38,10 @@ - (NSString *)readonlyValue; - (NSString *)cachedValue; - (void)setCachedValue:(NSString *)newCachedValue; +- (DOMMessagePortArray *)ports; - (NSString *)cachedReadonlyValue; +- (void)acceptTransferList:(NSString *)data transferList:(DOMArray *)transferList; +- (void)multiTransferList:(NSString *)first tx:(DOMArray *)tx second:(NSString *)second txx:(DOMArray *)txx; @end #endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.mm index 388f1c56d..3b9fb73af 100644 --- a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.mm +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.mm @@ -32,15 +32,19 @@ #import "DOMTestSerializedScriptValueInterface.h" +#import "Array.h" +#import "DOMArrayInternal.h" #import "DOMBlobInternal.h" #import "DOMCSSRuleInternal.h" #import "DOMCSSValueInternal.h" #import "DOMEventInternal.h" +#import "DOMMessagePortArrayInternal.h" #import "DOMNodeInternal.h" #import "DOMStyleSheetInternal.h" #import "DOMTestSerializedScriptValueInterfaceInternal.h" #import "ExceptionHandlers.h" #import "JSMainThreadExecState.h" +#import "MessagePortArray.h" #import "SerializedScriptValue.h" #import "TestSerializedScriptValueInterface.h" #import "ThreadCheck.h" @@ -103,12 +107,30 @@ IMPL->setCachedValue(WebCore::SerializedScriptValue::create(WTF::String(newCachedValue))); } +- (DOMMessagePortArray *)ports +{ + WebCore::JSMainThreadNullState state; + return kit(WTF::getPtr(IMPL->ports())); +} + - (NSString *)cachedReadonlyValue { WebCore::JSMainThreadNullState state; return IMPL->cachedReadonlyValue()->toString(); } +- (void)acceptTransferList:(NSString *)data transferList:(DOMArray *)transferList +{ + WebCore::JSMainThreadNullState state; + IMPL->acceptTransferList(WebCore::SerializedScriptValue::create(WTF::String(data)), core(transferList)); +} + +- (void)multiTransferList:(NSString *)first tx:(DOMArray *)tx second:(NSString *)second txx:(DOMArray *)txx +{ + WebCore::JSMainThreadNullState state; + IMPL->multiTransferList(WebCore::SerializedScriptValue::create(WTF::String(first)), core(tx), WebCore::SerializedScriptValue::create(WTF::String(second)), core(txx)); +} + @end WebCore::TestSerializedScriptValueInterface* core(DOMTestSerializedScriptValueInterface *wrapper) diff --git a/Source/WebCore/bindings/scripts/test/TestCallback.idl b/Source/WebCore/bindings/scripts/test/TestCallback.idl index 9e1f06e40..354859a37 100644 --- a/Source/WebCore/bindings/scripts/test/TestCallback.idl +++ b/Source/WebCore/bindings/scripts/test/TestCallback.idl @@ -39,5 +39,7 @@ module test { long callbackWithNonBoolReturnType(in Class3 class3Param); [Custom] long customCallback(in Class5 class5Param, in Class6 class6Param); boolean callbackWithStringList(in DOMStringList listParam); + boolean callbackWithBoolean(in boolean boolParam); + [PassThisToCallback=ThisClass] boolean callbackRequiresThisToPass(in Class8 class8Param, in ThisClass thisClassParam); }; } diff --git a/Source/WebCore/bindings/js/OptionsObject.h b/Source/WebCore/bindings/scripts/test/TestException.idl index 34910c032..f34af0035 100644 --- a/Source/WebCore/bindings/js/OptionsObject.h +++ b/Source/WebCore/bindings/scripts/test/TestException.idl @@ -1,7 +1,7 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2012 Google Inc. All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary formstrArg, with or without * modification, are permitted provided that the following conditions * are met: * @@ -10,9 +10,12 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * EXPRESS OR IMPLIED WARRANTIEstrArg, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES @@ -22,10 +25,8 @@ * (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 OptionsObject_h -#define OptionsObject_h - -// FIXME: Implement. - -#endif // OptionsObject_h +module test { + exception TestException { + readonly attribute DOMString name; + }; +} diff --git a/Source/WebCore/bindings/scripts/test/TestNode.idl b/Source/WebCore/bindings/scripts/test/TestNode.idl new file mode 100644 index 000000000..321621cdc --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/TestNode.idl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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. + */ + +module test { + + interface [ + EventTarget, + Constructor, + V8DependentLifetime + ] TestNode : Node { + }; + +} diff --git a/Source/WebCore/bindings/scripts/test/TestObj.idl b/Source/WebCore/bindings/scripts/test/TestObj.idl index fd5dbf930..488c99ab8 100644 --- a/Source/WebCore/bindings/scripts/test/TestObj.idl +++ b/Source/WebCore/bindings/scripts/test/TestObj.idl @@ -31,7 +31,7 @@ // changes in its ouput. module test { interface [ - Constructor, + Constructor(in [Callback] TestCallback testCallback), InterfaceName=TestObject ] TestObj { // Attributes @@ -46,6 +46,22 @@ module test { attribute DOMString stringAttr; attribute TestObj testObjAttr; + // Sequence Attributes + attribute sequence<ScriptProfile> sequenceAttr; + attribute sequence<int> intSequenceAttr; + attribute sequence<short> shortSequenceAttr; + attribute sequence<long> longSequenceAttr; + attribute sequence<long long> longLongSequenceAttr; + attribute sequence<unsigned int> unsignedIntSequenceAttr; + attribute sequence<unsigned short> unsignedShortSequenceAttr; + attribute sequence<unsigned long> unsignedLongSequenceAttr; + attribute sequence<unsigned long long> unsignedLongLongSequenceAttr; + attribute sequence<float> floatSequenceAttr; + attribute sequence<double> doubleSequenceAttr; + attribute sequence<boolean> booleanSequenceAttr; + attribute sequence<void> voidSequenceAttr; + attribute sequence<Date> dateSequenceAttr; + JS, V8 // WK_ucfirst, WK_lcfirst exceptional cases. attribute TestObj XMLObjAttr; @@ -70,12 +86,15 @@ module test { TestObj objMethod(); TestObj objMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + void methodWithSequenceArg(in sequence<ScriptProfile> sequenceArg); + sequence<ScriptProfile> methodReturningSequence(in long intArg); + TestObj methodThatRequiresAllArgsAndThrows(in DOMString strArg, in TestObj objArg) raises(DOMException); void serializedValue(in SerializedScriptValue serializedArg); void idbKey(in IDBKey key); - void optionsObject(in OptionsObject oo, in [Optional] OptionsObject ooo); + void optionsObject(in Dictionary oo, in [Optional] Dictionary ooo); // Exceptions void methodWithException() raises(DOMException); @@ -212,6 +231,7 @@ module test { [Immutable] SVGPoint immutablePointFunction(); [ImplementedAs=banana] void orange(); + attribute [ImplementedAs=blueberry] int strawberry; attribute [StrictTypeChecking] float strictFloat; [StrictTypeChecking] bool strictFunction(in DOMString str, in float a, in int b) diff --git a/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl b/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl index dddee9fae..facf7cba8 100644 --- a/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl +++ b/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl @@ -29,10 +29,14 @@ module test { interface [ Conditional=Condition1|Condition2, Constructor(in DOMString hello, in SerializedScriptValue value), + Constructor(in DOMString hello, in [TransferList=transferList] SerializedScriptValue data, in [Optional=DefaultIsUndefined] Array transferList), ] TestSerializedScriptValueInterface { attribute SerializedScriptValue value; readonly attribute SerializedScriptValue readonlyValue; attribute [CachedAttribute] SerializedScriptValue cachedValue; + readonly attribute MessagePortArray ports; readonly attribute [CachedAttribute] SerializedScriptValue cachedReadonlyValue; + void acceptTransferList(in [TransferList=transferList] SerializedScriptValue data, in [Optional] Array transferList); + void multiTransferList(in [Optional, TransferList=tx] SerializedScriptValue first, in [Optional] Array tx, in [Optional, TransferList=txx] SerializedScriptValue second, in [Optional] Array txx); }; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp b/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp index bdc6028be..8581a8d68 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp @@ -44,7 +44,7 @@ namespace WebCore { WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, &V8ArrayBufferView::info }; -namespace Float64ArrayInternal { +namespace Float64ArrayV8Internal { template <typename T> void V8_USE(T) { } @@ -52,13 +52,13 @@ static v8::Handle<v8::Value> fooCallback(const v8::Arguments& args) { INC_STATS("DOM.Float64Array.foo"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); Float64Array* imp = V8Float64Array::toNative(args.Holder()); EXCEPTION_BLOCK(Float32Array*, array, V8Float32Array::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8Float32Array::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); - return toV8(imp->foo(array)); + return toV8(imp->foo(array), args.GetIsolate()); } -} // namespace Float64ArrayInternal +} // namespace Float64ArrayV8Internal static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float64ArrayTemplate(v8::Persistent<v8::FunctionTemplate> desc) { @@ -80,7 +80,7 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float64ArrayTemplate(v8:: const int fooArgc = 1; v8::Handle<v8::FunctionTemplate> fooArgv[fooArgc] = { V8Float32Array::GetRawTemplate() }; v8::Handle<v8::Signature> fooSignature = v8::Signature::New(desc, fooArgc, fooArgv); - proto->Set(v8::String::New("foo"), v8::FunctionTemplate::New(Float64ArrayInternal::fooCallback, v8::Handle<v8::Value>(), fooSignature)); + proto->Set(v8::String::New("foo"), v8::FunctionTemplate::New(Float64ArrayV8Internal::fooCallback, v8::Handle<v8::Value>(), fooSignature)); // Custom toString template desc->Set(getToStringName(), getToStringTemplate()); @@ -120,20 +120,19 @@ bool V8Float64Array::HasInstance(v8::Handle<v8::Value> value) } -v8::Handle<v8::Object> V8Float64Array::wrapSlow(Float64Array* impl) +v8::Handle<v8::Object> V8Float64Array::wrapSlow(PassRefPtr<Float64Array> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.h b/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.h index b1cdbe743..368fceba8 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.h @@ -41,34 +41,27 @@ public: { return reinterpret_cast<Float64Array*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(Float64Array*); + inline static v8::Handle<v8::Object> wrap(Float64Array*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(Float64Array*); - private: - static v8::Handle<v8::Object> wrapSlow(Float64Array*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<Float64Array>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8Float64Array::existingWrapper(Float64Array* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8Float64Array::wrap(Float64Array* impl) +v8::Handle<v8::Object> V8Float64Array::wrap(Float64Array* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8Float64Array::wrapSlow(impl); + return V8Float64Array::wrapSlow(impl, isolate); } -v8::Handle<v8::Value> toV8(Float64Array*); -inline v8::Handle<v8::Value> toV8(PassRefPtr< Float64Array > impl) +v8::Handle<v8::Value> toV8(Float64Array*, v8::Isolate* = 0); +inline v8::Handle<v8::Value> toV8(PassRefPtr< Float64Array > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp index ffc97e462..749000017 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp @@ -36,7 +36,7 @@ namespace WebCore { WrapperTypeInfo V8TestActiveDOMObject::info = { V8TestActiveDOMObject::GetTemplate, V8TestActiveDOMObject::derefObject, 0, 0 }; -namespace TestActiveDOMObjectInternal { +namespace TestActiveDOMObjectV8Internal { template <typename T> void V8_USE(T) { } @@ -51,7 +51,7 @@ static v8::Handle<v8::Value> excitingFunctionCallback(const v8::Arguments& args) { INC_STATS("DOM.TestActiveDOMObject.excitingFunction"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(args.Holder()); if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true)) return v8::Handle<v8::Value>(); @@ -64,7 +64,7 @@ static v8::Handle<v8::Value> postMessageCallback(const v8::Arguments& args) { INC_STATS("DOM.TestActiveDOMObject.postMessage"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(args.Holder()); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, message, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); imp->postMessage(message); @@ -74,7 +74,7 @@ static v8::Handle<v8::Value> postMessageCallback(const v8::Arguments& args) static v8::Handle<v8::Value> postMessageAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestActiveDOMObject.postMessage._get"); - static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(TestActiveDOMObjectInternal::postMessageCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate()))); + static v8::Persistent<v8::FunctionTemplate> privateTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(TestActiveDOMObjectV8Internal::postMessageCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate()))); v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8TestActiveDOMObject::GetTemplate(), info.This()); if (holder.IsEmpty()) { // can only reach here by 'object.__proto__.func', and it should passed @@ -83,17 +83,17 @@ static v8::Handle<v8::Value> postMessageAttrGetter(v8::Local<v8::String> name, c } TestActiveDOMObject* imp = V8TestActiveDOMObject::toNative(holder); if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), false)) { - static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(TestActiveDOMObjectInternal::postMessageCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate()))); + static v8::Persistent<v8::FunctionTemplate> sharedTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(TestActiveDOMObjectV8Internal::postMessageCallback, v8::Handle<v8::Value>(), v8::Signature::New(V8TestActiveDOMObject::GetRawTemplate()))); return sharedTemplate->GetFunction(); } return privateTemplate->GetFunction(); } -} // namespace TestActiveDOMObjectInternal +} // namespace TestActiveDOMObjectV8Internal static const BatchedAttribute TestActiveDOMObjectAttrs[] = { // Attribute 'excitingAttr' (Type: 'readonly attribute' ExtAttr: '') - {"excitingAttr", TestActiveDOMObjectInternal::excitingAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"excitingAttr", TestActiveDOMObjectV8Internal::excitingAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, }; static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestActiveDOMObjectTemplate(v8::Persistent<v8::FunctionTemplate> desc) @@ -115,10 +115,10 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestActiveDOMObjectTempla const int excitingFunctionArgc = 1; v8::Handle<v8::FunctionTemplate> excitingFunctionArgv[excitingFunctionArgc] = { V8Node::GetRawTemplate() }; v8::Handle<v8::Signature> excitingFunctionSignature = v8::Signature::New(desc, excitingFunctionArgc, excitingFunctionArgv); - proto->Set(v8::String::New("excitingFunction"), v8::FunctionTemplate::New(TestActiveDOMObjectInternal::excitingFunctionCallback, v8::Handle<v8::Value>(), excitingFunctionSignature)); + proto->Set(v8::String::New("excitingFunction"), v8::FunctionTemplate::New(TestActiveDOMObjectV8Internal::excitingFunctionCallback, v8::Handle<v8::Value>(), excitingFunctionSignature)); // Function 'postMessage' (ExtAttr: 'DoNotCheckSecurity') - proto->SetAccessor(v8::String::New("postMessage"), TestActiveDOMObjectInternal::postMessageAttrGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); + proto->SetAccessor(v8::String::New("postMessage"), TestActiveDOMObjectV8Internal::postMessageAttrGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly)); // Custom toString template desc->Set(getToStringName(), getToStringTemplate()); @@ -158,7 +158,7 @@ bool V8TestActiveDOMObject::HasInstance(v8::Handle<v8::Value> value) } -v8::Handle<v8::Object> V8TestActiveDOMObject::wrapSlow(TestActiveDOMObject* impl) +v8::Handle<v8::Object> V8TestActiveDOMObject::wrapSlow(PassRefPtr<TestActiveDOMObject> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; @@ -168,26 +168,27 @@ v8::Handle<v8::Object> V8TestActiveDOMObject::wrapSlow(TestActiveDOMObject* impl proxy->windowShell()->initContextIfNeeded(); } + // Enter the node's context and create the wrapper in that context. v8::Handle<v8::Context> context; - if (proxy) + if (proxy && !proxy->matchesCurrentContext()) { + // For performance, we enter the context only if the currently running context + // is different from the context that we are about to enter. context = proxy->context(); - - // Enter the node's context and create the wrapper in that context. - if (!context.IsEmpty()) - context->Enter(); - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (!context.IsEmpty()) + context->Enter(); + } + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); // Exit the node's context if it was entered. if (!context.IsEmpty()) context->Exit(); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.h b/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.h index e163b3dd6..c55202831 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.h @@ -40,40 +40,33 @@ public: { return reinterpret_cast<TestActiveDOMObject*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestActiveDOMObject*); + inline static v8::Handle<v8::Object> wrap(TestActiveDOMObject*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; static bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data); static bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType, v8::Local<v8::Value> data); - static v8::Handle<v8::Object> existingWrapper(TestActiveDOMObject*); - private: - static v8::Handle<v8::Object> wrapSlow(TestActiveDOMObject*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestActiveDOMObject>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestActiveDOMObject::existingWrapper(TestActiveDOMObject* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestActiveDOMObject::wrap(TestActiveDOMObject* impl) +v8::Handle<v8::Object> V8TestActiveDOMObject::wrap(TestActiveDOMObject* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestActiveDOMObject::wrapSlow(impl); + return V8TestActiveDOMObject::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestActiveDOMObject* impl) +inline v8::Handle<v8::Value> toV8(TestActiveDOMObject* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestActiveDOMObject::wrap(impl); + return V8TestActiveDOMObject::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestActiveDOMObject > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestActiveDOMObject > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp index 3a17f7a3b..628d5a8b7 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -27,9 +27,11 @@ #include "V8Binding.h" #include "V8Class1.h" #include "V8Class2.h" +#include "V8Class8.h" #include "V8CustomVoidCallback.h" #include "V8DOMStringList.h" #include "V8Proxy.h" +#include "V8ThisClass.h" #include <wtf/GetPtr.h> #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> @@ -85,7 +87,7 @@ bool V8TestCallback::callbackWithClass1Param(Class1* class1Param) v8::Context::Scope scope(v8Context); - v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param); + v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param, 0); if (class1ParamHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); @@ -113,13 +115,13 @@ bool V8TestCallback::callbackWithClass2Param(Class2* class2Param, const String& v8::Context::Scope scope(v8Context); - v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param); + v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, 0); if (class2ParamHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } - v8::Handle<v8::Value> strArgHandle = v8String(strArg); + v8::Handle<v8::Value> strArgHandle = v8String(strArg, 0); if (strArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); @@ -148,7 +150,7 @@ bool V8TestCallback::callbackWithStringList(RefPtr<DOMStringList> listParam) v8::Context::Scope scope(v8Context); - v8::Handle<v8::Value> listParamHandle = toV8(listParam); + v8::Handle<v8::Value> listParamHandle = toV8(listParam, 0); if (listParamHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); @@ -163,6 +165,71 @@ bool V8TestCallback::callbackWithStringList(RefPtr<DOMStringList> listParam) return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext()); } +bool V8TestCallback::callbackWithBoolean(bool boolParam) +{ + if (!canInvokeCallback()) + return true; + + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> boolParamHandle = v8Boolean(boolParam); + if (boolParamHandle.IsEmpty()) { + if (!isScriptControllerTerminating()) + CRASH(); + return true; + } + + v8::Handle<v8::Value> argv[] = { + boolParamHandle + }; + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext()); +} + +bool V8TestCallback::callbackRequiresThisToPass(Class8* class8Param, ThisClass* thisClassParam) +{ + ASSERT(thisClassParam); + + if (!canInvokeCallback()) + return true; + + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> class8ParamHandle = toV8(class8Param, 0); + if (class8ParamHandle.IsEmpty()) { + if (!isScriptControllerTerminating()) + CRASH(); + return true; + } + v8::Handle<v8::Value> thisClassParamHandle = toV8(thisClassParam, 0); + if (thisClassParamHandle.IsEmpty()) { + if (!isScriptControllerTerminating()) + CRASH(); + return true; + } + + v8::Handle<v8::Value> argv[] = { + class8ParamHandle, + thisClassParamHandle + }; + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(thisClassParamHandle), 2, argv, callbackReturnValue, scriptExecutionContext()); +} + } // namespace WebCore #endif // ENABLE(SQL_DATABASE) diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h index 72980f2ce..31ca7e177 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -51,6 +51,8 @@ public: COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(Class3* class3Param); virtual int customCallback(Class5* class5Param, Class6* class6Param); virtual bool callbackWithStringList(RefPtr<DOMStringList> listParam); + virtual bool callbackWithBoolean(bool boolParam); + virtual bool callbackRequiresThisToPass(Class8* class8Param, ThisClass* thisClassParam); private: V8TestCallback(v8::Local<v8::Object>, ScriptExecutionContext*); diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp index cbff6d4e7..20eb5a11a 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp @@ -35,7 +35,7 @@ namespace WebCore { WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTemplate, V8TestCustomNamedGetter::derefObject, 0, 0 }; -namespace TestCustomNamedGetterInternal { +namespace TestCustomNamedGetterV8Internal { template <typename T> void V8_USE(T) { } @@ -43,17 +43,17 @@ static v8::Handle<v8::Value> anotherFunctionCallback(const v8::Arguments& args) { INC_STATS("DOM.TestCustomNamedGetter.anotherFunction"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestCustomNamedGetter* imp = V8TestCustomNamedGetter::toNative(args.Holder()); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); imp->anotherFunction(str); return v8::Handle<v8::Value>(); } -} // namespace TestCustomNamedGetterInternal +} // namespace TestCustomNamedGetterV8Internal static const BatchedCallback TestCustomNamedGetterCallbacks[] = { - {"anotherFunction", TestCustomNamedGetterInternal::anotherFunctionCallback}, + {"anotherFunction", TestCustomNamedGetterV8Internal::anotherFunctionCallback}, }; static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestCustomNamedGetterTemplate(v8::Persistent<v8::FunctionTemplate> desc) @@ -110,20 +110,19 @@ bool V8TestCustomNamedGetter::HasInstance(v8::Handle<v8::Value> value) } -v8::Handle<v8::Object> V8TestCustomNamedGetter::wrapSlow(TestCustomNamedGetter* impl) +v8::Handle<v8::Object> V8TestCustomNamedGetter::wrapSlow(PassRefPtr<TestCustomNamedGetter> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.h b/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.h index 264791d84..99472b755 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.h @@ -40,39 +40,32 @@ public: { return reinterpret_cast<TestCustomNamedGetter*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestCustomNamedGetter*); + inline static v8::Handle<v8::Object> wrap(TestCustomNamedGetter*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, const v8::AccessorInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(TestCustomNamedGetter*); - private: - static v8::Handle<v8::Object> wrapSlow(TestCustomNamedGetter*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestCustomNamedGetter>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestCustomNamedGetter::existingWrapper(TestCustomNamedGetter* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestCustomNamedGetter::wrap(TestCustomNamedGetter* impl) +v8::Handle<v8::Object> V8TestCustomNamedGetter::wrap(TestCustomNamedGetter* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestCustomNamedGetter::wrapSlow(impl); + return V8TestCustomNamedGetter::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestCustomNamedGetter* impl) +inline v8::Handle<v8::Value> toV8(TestCustomNamedGetter* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestCustomNamedGetter::wrap(impl); + return V8TestCustomNamedGetter::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestCustomNamedGetter > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestCustomNamedGetter > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp index 7c06e34e6..feb22aee9 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp @@ -21,7 +21,7 @@ #include "config.h" #include "V8TestEventConstructor.h" -#include "OptionsObject.h" +#include "Dictionary.h" #include "RuntimeEnabledFeatures.h" #include "V8Binding.h" #include "V8BindingMacros.h" @@ -35,7 +35,7 @@ namespace WebCore { WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0 }; -namespace TestEventConstructorInternal { +namespace TestEventConstructorV8Internal { template <typename T> void V8_USE(T) { } @@ -43,23 +43,23 @@ static v8::Handle<v8::Value> attr1AttrGetter(v8::Local<v8::String> name, const v { INC_STATS("DOM.TestEventConstructor.attr1._get"); TestEventConstructor* imp = V8TestEventConstructor::toNative(info.Holder()); - return v8String(imp->attr1()); + return v8String(imp->attr1(), info.GetIsolate()); } static v8::Handle<v8::Value> attr2AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestEventConstructor.attr2._get"); TestEventConstructor* imp = V8TestEventConstructor::toNative(info.Holder()); - return v8String(imp->attr2()); + return v8String(imp->attr2(), info.GetIsolate()); } -} // namespace TestEventConstructorInternal +} // namespace TestEventConstructorV8Internal static const BatchedAttribute TestEventConstructorAttrs[] = { // Attribute 'attr1' (Type: 'readonly attribute' ExtAttr: '') - {"attr1", TestEventConstructorInternal::attr1AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"attr1", TestEventConstructorV8Internal::attr1AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'attr2' (Type: 'readonly attribute' ExtAttr: 'InitializedByEventConstructor') - {"attr2", TestEventConstructorInternal::attr2AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"attr2", TestEventConstructorV8Internal::attr2AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, }; v8::Handle<v8::Value> V8TestEventConstructor::constructorCallback(const v8::Arguments& args) @@ -73,12 +73,12 @@ v8::Handle<v8::Value> V8TestEventConstructor::constructorCallback(const v8::Argu return args.Holder(); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, args[0]); TestEventConstructorInit eventInit; if (args.Length() >= 2) { - EXCEPTION_BLOCK(OptionsObject, options, args[1]); + EXCEPTION_BLOCK(Dictionary, options, args[1]); if (!fillTestEventConstructorInit(eventInit, options)) return v8::Undefined(); } @@ -86,10 +86,11 @@ v8::Handle<v8::Value> V8TestEventConstructor::constructorCallback(const v8::Argu RefPtr<TestEventConstructor> event = TestEventConstructor::create(type, eventInit); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, event.get()); - return toV8(event.release(), args.Holder()); + V8DOMWrapper::setJSWrapperForDOMObject(event.release(), v8::Persistent<v8::Object>::New(args.Holder()), args.GetIsolate()); + return args.Holder(); } -bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, const OptionsObject& options) +bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, const Dictionary& options) { options.get("attr2", eventInit.attr2); return true; @@ -145,20 +146,19 @@ bool V8TestEventConstructor::HasInstance(v8::Handle<v8::Value> value) } -v8::Handle<v8::Object> V8TestEventConstructor::wrapSlow(TestEventConstructor* impl) +v8::Handle<v8::Object> V8TestEventConstructor::wrapSlow(PassRefPtr<TestEventConstructor> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.h b/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.h index 520e1ce58..119310be3 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.h @@ -30,7 +30,7 @@ namespace WebCore { -class OptionsObject; +class Dictionary; class V8TestEventConstructor { public: static const bool hasDependentLifetime = false; @@ -41,42 +41,35 @@ public: { return reinterpret_cast<TestEventConstructor*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestEventConstructor*); + inline static v8::Handle<v8::Object> wrap(TestEventConstructor*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(TestEventConstructor*); - private: - static v8::Handle<v8::Object> wrapSlow(TestEventConstructor*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestEventConstructor>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestEventConstructor::existingWrapper(TestEventConstructor* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestEventConstructor::wrap(TestEventConstructor* impl) +v8::Handle<v8::Object> V8TestEventConstructor::wrap(TestEventConstructor* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestEventConstructor::wrapSlow(impl); + return V8TestEventConstructor::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestEventConstructor* impl) +inline v8::Handle<v8::Value> toV8(TestEventConstructor* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestEventConstructor::wrap(impl); + return V8TestEventConstructor::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestEventConstructor > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestEventConstructor > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } -bool fillTestEventConstructorInit(TestEventConstructorInit&, const OptionsObject&); +bool fillTestEventConstructorInit(TestEventConstructorInit&, const Dictionary&); } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp index 1e6fbfa53..33c5065f0 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp @@ -38,7 +38,7 @@ namespace WebCore { WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, 0 }; -namespace TestEventTargetInternal { +namespace TestEventTargetV8Internal { template <typename T> void V8_USE(T) { } @@ -46,7 +46,7 @@ static v8::Handle<v8::Value> itemCallback(const v8::Arguments& args) { INC_STATS("DOM.TestEventTarget.item"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestEventTarget* imp = V8TestEventTarget::toNative(args.Holder()); ExceptionCode ec = 0; { @@ -55,10 +55,10 @@ static v8::Handle<v8::Value> itemCallback(const v8::Arguments& args) ec = INDEX_SIZE_ERR; goto fail; } - return toV8(imp->item(index)); + return toV8(imp->item(index), args.GetIsolate()); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -88,7 +88,7 @@ static v8::Handle<v8::Value> dispatchEventCallback(const v8::Arguments& args) { INC_STATS("DOM.TestEventTarget.dispatchEvent"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestEventTarget* imp = V8TestEventTarget::toNative(args.Holder()); ExceptionCode ec = 0; { @@ -99,16 +99,16 @@ static v8::Handle<v8::Value> dispatchEventCallback(const v8::Arguments& args) return v8Boolean(result); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } -} // namespace TestEventTargetInternal +} // namespace TestEventTargetV8Internal static const BatchedCallback TestEventTargetCallbacks[] = { - {"item", TestEventTargetInternal::itemCallback}, - {"addEventListener", TestEventTargetInternal::addEventListenerCallback}, - {"removeEventListener", TestEventTargetInternal::removeEventListenerCallback}, + {"item", TestEventTargetV8Internal::itemCallback}, + {"addEventListener", TestEventTargetV8Internal::addEventListenerCallback}, + {"removeEventListener", TestEventTargetV8Internal::removeEventListenerCallback}, }; static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestEventTargetTemplate(v8::Persistent<v8::FunctionTemplate> desc) @@ -133,7 +133,7 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestEventTargetTemplate(v const int dispatchEventArgc = 1; v8::Handle<v8::FunctionTemplate> dispatchEventArgv[dispatchEventArgc] = { V8Event::GetRawTemplate() }; v8::Handle<v8::Signature> dispatchEventSignature = v8::Signature::New(desc, dispatchEventArgc, dispatchEventArgv); - proto->Set(v8::String::New("dispatchEvent"), v8::FunctionTemplate::New(TestEventTargetInternal::dispatchEventCallback, v8::Handle<v8::Value>(), dispatchEventSignature)); + proto->Set(v8::String::New("dispatchEvent"), v8::FunctionTemplate::New(TestEventTargetV8Internal::dispatchEventCallback, v8::Handle<v8::Value>(), dispatchEventSignature)); // Custom toString template desc->Set(getToStringName(), getToStringTemplate()); @@ -173,20 +173,19 @@ bool V8TestEventTarget::HasInstance(v8::Handle<v8::Value> value) } -v8::Handle<v8::Object> V8TestEventTarget::wrapSlow(TestEventTarget* impl) +v8::Handle<v8::Object> V8TestEventTarget::wrapSlow(PassRefPtr<TestEventTarget> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.h b/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.h index 073412f80..d577c98d8 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.h @@ -40,41 +40,34 @@ public: { return reinterpret_cast<TestEventTarget*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestEventTarget*); + inline static v8::Handle<v8::Object> wrap(TestEventTarget*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::AccessorInfo&); static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String>, const v8::AccessorInfo&); static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + 0; static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 1; - static v8::Handle<v8::Object> existingWrapper(TestEventTarget*); - private: - static v8::Handle<v8::Object> wrapSlow(TestEventTarget*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestEventTarget>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestEventTarget::existingWrapper(TestEventTarget* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestEventTarget::wrap(TestEventTarget* impl) +v8::Handle<v8::Object> V8TestEventTarget::wrap(TestEventTarget* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestEventTarget::wrapSlow(impl); + return V8TestEventTarget::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestEventTarget* impl) +inline v8::Handle<v8::Value> toV8(TestEventTarget* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestEventTarget::wrap(impl); + return V8TestEventTarget::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestEventTarget > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestEventTarget > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp new file mode 100644 index 000000000..5d1777f01 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp @@ -0,0 +1,124 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "config.h" +#include "V8TestException.h" + +#include "RuntimeEnabledFeatures.h" +#include "V8Binding.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" +#include <wtf/UnusedParam.h> + +namespace WebCore { + +WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestException::derefObject, 0, 0 }; + +namespace TestExceptionV8Internal { + +template <typename T> void V8_USE(T) { } + +static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestException.name._get"); + TestException* imp = V8TestException::toNative(info.Holder()); + return v8String(imp->name(), info.GetIsolate()); +} + +} // namespace TestExceptionV8Internal + +static const BatchedAttribute TestExceptionAttrs[] = { + // Attribute 'name' (Type: 'readonly attribute' ExtAttr: '') + {"name", TestExceptionV8Internal::nameAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +}; + +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestExceptionTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + desc->ReadOnlyPrototype(); + + v8::Local<v8::Signature> defaultSignature; + defaultSignature = configureTemplate(desc, "TestException", v8::Persistent<v8::FunctionTemplate>(), V8TestException::internalFieldCount, + TestExceptionAttrs, WTF_ARRAY_LENGTH(TestExceptionAttrs), + 0, 0); + UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. + + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestException::GetRawTemplate() +{ + V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); + V8BindingPerIsolateData::TemplateMap::iterator result = data->rawTemplateMap().find(&info); + if (result != data->rawTemplateMap().end()) + return result->second; + + v8::HandleScope handleScope; + v8::Persistent<v8::FunctionTemplate> templ = createRawTemplate(); + data->rawTemplateMap().add(&info, templ); + return templ; +} + +v8::Persistent<v8::FunctionTemplate> V8TestException::GetTemplate() +{ + V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); + V8BindingPerIsolateData::TemplateMap::iterator result = data->templateMap().find(&info); + if (result != data->templateMap().end()) + return result->second; + + v8::HandleScope handleScope; + v8::Persistent<v8::FunctionTemplate> templ = + ConfigureV8TestExceptionTemplate(GetRawTemplate()); + data->templateMap().add(&info, templ); + return templ; +} + +bool V8TestException::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestException::wrapSlow(PassRefPtr<TestException> impl, v8::Isolate* isolate) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); + if (UNLIKELY(wrapper.IsEmpty())) + return wrapper; + + v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); + + if (!hasDependentLifetime) + wrapperHandle.MarkIndependent(); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle); + return wrapper; +} + +void V8TestException::derefObject(void* object) +{ + static_cast<TestException*>(object)->deref(); +} + +} // namespace WebCore diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestException.h b/Source/WebCore/bindings/scripts/test/V8/V8TestException.h new file mode 100644 index 000000000..86d4a4ff2 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestException.h @@ -0,0 +1,72 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8TestException_h +#define V8TestException_h + +#include "TestException.h" +#include "V8DOMWrapper.h" +#include "WrapperTypeInfo.h" +#include <v8.h> +#include <wtf/HashMap.h> +#include <wtf/text/StringHash.h> + +namespace WebCore { + +class V8TestException { +public: + static const bool hasDependentLifetime = false; + static bool HasInstance(v8::Handle<v8::Value>); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestException* toNative(v8::Handle<v8::Object> object) + { + return reinterpret_cast<TestException*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); + } + inline static v8::Handle<v8::Object> wrap(TestException*, v8::Isolate* = 0); + static void derefObject(void*); + static WrapperTypeInfo info; + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +private: + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestException>, v8::Isolate*); +}; + +v8::Handle<v8::Object> V8TestException::wrap(TestException* impl, v8::Isolate* isolate) +{ + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return V8TestException::wrapSlow(impl, isolate); +} + +inline v8::Handle<v8::Value> toV8(TestException* impl, v8::Isolate* isolate = 0) +{ + if (!impl) + return v8::Null(); + return V8TestException::wrap(impl, isolate); +} +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestException > impl, v8::Isolate* isolate = 0) +{ + return toV8(impl.get(), isolate); +} + +} + +#endif // V8TestException_h diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp index a2c551860..263b425eb 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp @@ -43,7 +43,7 @@ namespace WebCore { WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0 }; -namespace TestInterfaceInternal { +namespace TestInterfaceV8Internal { template <typename T> void V8_USE(T) { } @@ -53,7 +53,7 @@ static v8::Handle<v8::Value> supplementalStr1AttrGetter(v8::Local<v8::String> na { INC_STATS("DOM.TestInterface.supplementalStr1._get"); TestInterface* imp = V8TestInterface::toNative(info.Holder()); - return v8String(TestSupplemental::supplementalStr1(imp)); + return v8String(TestSupplemental::supplementalStr1(imp), info.GetIsolate()); } #endif // ENABLE(Condition11) || ENABLE(Condition12) @@ -64,7 +64,7 @@ static v8::Handle<v8::Value> supplementalStr2AttrGetter(v8::Local<v8::String> na { INC_STATS("DOM.TestInterface.supplementalStr2._get"); TestInterface* imp = V8TestInterface::toNative(info.Holder()); - return v8String(TestSupplemental::supplementalStr2(imp)); + return v8String(TestSupplemental::supplementalStr2(imp), info.GetIsolate()); } #endif // ENABLE(Condition11) || ENABLE(Condition12) @@ -88,7 +88,7 @@ static v8::Handle<v8::Value> supplementalNodeAttrGetter(v8::Local<v8::String> na { INC_STATS("DOM.TestInterface.supplementalNode._get"); TestInterface* imp = V8TestInterface::toNative(info.Holder()); - return toV8(TestSupplemental::supplementalNode(imp)); + return toV8(TestSupplemental::supplementalNode(imp), info.GetIsolate()); } #endif // ENABLE(Condition11) || ENABLE(Condition12) @@ -124,7 +124,7 @@ static v8::Handle<v8::Value> supplementalMethod2Callback(const v8::Arguments& ar { INC_STATS("DOM.TestInterface.supplementalMethod2"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestInterface* imp = V8TestInterface::toNative(args.Holder()); ExceptionCode ec = 0; { @@ -136,10 +136,10 @@ static v8::Handle<v8::Value> supplementalMethod2Callback(const v8::Arguments& ar RefPtr<TestObj> result = TestSupplemental::supplementalMethod2(imp, scriptContext, strArg, objArg, ec); if (UNLIKELY(ec)) goto fail; - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -156,16 +156,16 @@ static v8::Handle<v8::Value> supplementalMethod4Callback(const v8::Arguments& ar #endif // ENABLE(Condition11) || ENABLE(Condition12) -} // namespace TestInterfaceInternal +} // namespace TestInterfaceV8Internal static const BatchedAttribute TestInterfaceAttrs[] = { #if ENABLE(Condition11) || ENABLE(Condition12) // Attribute 'supplementalStr1' (Type: 'readonly attribute' ExtAttr: 'Conditional ImplementedBy') - {"supplementalStr1", TestInterfaceInternal::supplementalStr1AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"supplementalStr1", TestInterfaceV8Internal::supplementalStr1AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, #endif // ENABLE(Condition11) || ENABLE(Condition12) #if ENABLE(Condition11) || ENABLE(Condition12) // Attribute 'supplementalStr2' (Type: 'attribute' ExtAttr: 'Conditional ImplementedBy') - {"supplementalStr2", TestInterfaceInternal::supplementalStr2AttrGetter, TestInterfaceInternal::supplementalStr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"supplementalStr2", TestInterfaceV8Internal::supplementalStr2AttrGetter, TestInterfaceV8Internal::supplementalStr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, #endif // ENABLE(Condition11) || ENABLE(Condition12) #if ENABLE(Condition11) || ENABLE(Condition12) // Attribute 'supplementalStr3' (Type: 'attribute' ExtAttr: 'CustomSetter CustomGetter Conditional ImplementedBy') @@ -173,13 +173,13 @@ static const BatchedAttribute TestInterfaceAttrs[] = { #endif // ENABLE(Condition11) || ENABLE(Condition12) #if ENABLE(Condition11) || ENABLE(Condition12) // Attribute 'supplementalNode' (Type: 'attribute' ExtAttr: 'Conditional ImplementedBy') - {"supplementalNode", TestInterfaceInternal::supplementalNodeAttrGetter, TestInterfaceInternal::supplementalNodeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"supplementalNode", TestInterfaceV8Internal::supplementalNodeAttrGetter, TestInterfaceV8Internal::supplementalNodeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, #endif // ENABLE(Condition11) || ENABLE(Condition12) }; static const BatchedCallback TestInterfaceCallbacks[] = { #if ENABLE(Condition11) || ENABLE(Condition12) - {"supplementalMethod1", TestInterfaceInternal::supplementalMethod1Callback}, + {"supplementalMethod1", TestInterfaceV8Internal::supplementalMethod1Callback}, #endif #if ENABLE(Condition11) || ENABLE(Condition12) {"supplementalMethod3", V8TestInterface::supplementalMethod3Callback}, @@ -213,7 +213,7 @@ v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) return args.Holder(); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str1, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); @@ -229,8 +229,7 @@ v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& goto fail; V8DOMWrapper::setDOMWrapper(wrapper, &info, impl.get()); - impl->ref(); - V8DOMWrapper::setJSWrapperForActiveDOMObject(impl.get(), v8::Persistent<v8::Object>::New(wrapper)); + V8DOMWrapper::setJSWrapperForActiveDOMObject(impl.release(), v8::Persistent<v8::Object>::New(wrapper), args.GetIsolate()); return args.Holder(); fail: return throwError(ec); @@ -257,10 +256,10 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8: v8::Handle<v8::FunctionTemplate> supplementalMethod2Argv[supplementalMethod2Argc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; v8::Handle<v8::Signature> supplementalMethod2Signature = v8::Signature::New(desc, supplementalMethod2Argc, supplementalMethod2Argv); #if ENABLE(Condition11) || ENABLE(Condition12) - proto->Set(v8::String::New("supplementalMethod2"), v8::FunctionTemplate::New(TestInterfaceInternal::supplementalMethod2Callback, v8::Handle<v8::Value>(), supplementalMethod2Signature)); + proto->Set(v8::String::New("supplementalMethod2"), v8::FunctionTemplate::New(TestInterfaceV8Internal::supplementalMethod2Callback, v8::Handle<v8::Value>(), supplementalMethod2Signature)); #endif // ENABLE(Condition11) || ENABLE(Condition12) #if ENABLE(Condition11) || ENABLE(Condition12) - desc->Set(v8::String::New("supplementalMethod4"), v8::FunctionTemplate::New(TestInterfaceInternal::supplementalMethod4Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); + desc->Set(v8::String::New("supplementalMethod4"), v8::FunctionTemplate::New(TestInterfaceV8Internal::supplementalMethod4Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); #endif // ENABLE(Condition11) || ENABLE(Condition12) batchConfigureConstants(desc, proto, TestInterfaceConsts, WTF_ARRAY_LENGTH(TestInterfaceConsts)); @@ -306,20 +305,19 @@ ActiveDOMObject* V8TestInterface::toActiveDOMObject(v8::Handle<v8::Object> objec return toNative(object); } -v8::Handle<v8::Object> V8TestInterface::wrapSlow(TestInterface* impl) +v8::Handle<v8::Object> V8TestInterface::wrapSlow(PassRefPtr<TestInterface> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getActiveDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForActiveDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h index 7216c0278..82064154c 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h @@ -42,41 +42,34 @@ public: { return reinterpret_cast<TestInterface*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestInterface*); + inline static v8::Handle<v8::Object> wrap(TestInterface*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>); static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&); static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(TestInterface*); - private: - static v8::Handle<v8::Object> wrapSlow(TestInterface*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestInterface>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestInterface::existingWrapper(TestInterface* impl) -{ - return getActiveDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestInterface::wrap(TestInterface* impl) +v8::Handle<v8::Object> V8TestInterface::wrap(TestInterface* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestInterface::wrapSlow(impl); + return V8TestInterface::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestInterface* impl) +inline v8::Handle<v8::Value> toV8(TestInterface* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestInterface::wrap(impl); + return V8TestInterface::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestInterface > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestInterface > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp index 934f66839..b515b4346 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp @@ -36,7 +36,7 @@ namespace WebCore { WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0 }; -namespace TestMediaQueryListListenerInternal { +namespace TestMediaQueryListListenerV8Internal { template <typename T> void V8_USE(T) { } @@ -44,17 +44,17 @@ static v8::Handle<v8::Value> methodCallback(const v8::Arguments& args) { INC_STATS("DOM.TestMediaQueryListListener.method"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(args.Holder()); EXCEPTION_BLOCK(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); imp->method(listener); return v8::Handle<v8::Value>(); } -} // namespace TestMediaQueryListListenerInternal +} // namespace TestMediaQueryListListenerV8Internal static const BatchedCallback TestMediaQueryListListenerCallbacks[] = { - {"method", TestMediaQueryListListenerInternal::methodCallback}, + {"method", TestMediaQueryListListenerV8Internal::methodCallback}, }; static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestMediaQueryListListenerTemplate(v8::Persistent<v8::FunctionTemplate> desc) @@ -110,20 +110,19 @@ bool V8TestMediaQueryListListener::HasInstance(v8::Handle<v8::Value> value) } -v8::Handle<v8::Object> V8TestMediaQueryListListener::wrapSlow(TestMediaQueryListListener* impl) +v8::Handle<v8::Object> V8TestMediaQueryListListener::wrapSlow(PassRefPtr<TestMediaQueryListListener> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h index acde0ea49..0fe71799d 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h @@ -40,38 +40,31 @@ public: { return reinterpret_cast<TestMediaQueryListListener*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestMediaQueryListListener*); + inline static v8::Handle<v8::Object> wrap(TestMediaQueryListListener*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(TestMediaQueryListListener*); - private: - static v8::Handle<v8::Object> wrapSlow(TestMediaQueryListListener*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestMediaQueryListListener>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestMediaQueryListListener::existingWrapper(TestMediaQueryListListener* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestMediaQueryListListener::wrap(TestMediaQueryListListener* impl) +v8::Handle<v8::Object> V8TestMediaQueryListListener::wrap(TestMediaQueryListListener* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestMediaQueryListListener::wrapSlow(impl); + return V8TestMediaQueryListListener::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestMediaQueryListListener* impl) +inline v8::Handle<v8::Value> toV8(TestMediaQueryListListener* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestMediaQueryListListener::wrap(impl); + return V8TestMediaQueryListListener::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestMediaQueryListListener > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestMediaQueryListListener > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp index 5abce0e7d..53c3c4b64 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp @@ -35,11 +35,11 @@ namespace WebCore { WrapperTypeInfo V8TestNamedConstructor::info = { V8TestNamedConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0 }; -namespace TestNamedConstructorInternal { +namespace TestNamedConstructorV8Internal { template <typename T> void V8_USE(T) { } -} // namespace TestNamedConstructorInternal +} // namespace TestNamedConstructorV8Internal WrapperTypeInfo V8TestNamedConstructorConstructor::info = { V8TestNamedConstructorConstructor::GetTemplate, V8TestNamedConstructor::derefObject, V8TestNamedConstructor::toActiveDOMObject, 0 }; @@ -61,10 +61,10 @@ static v8::Handle<v8::Value> V8TestNamedConstructorConstructorCallback(const v8: // Make sure the document is added to the DOM Node map. Otherwise, the TestNamedConstructor instance // may end up being the only node in the map and get garbage-collected prematurely. - toV8(document); + toV8(document, args.GetIsolate()); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, str1, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); @@ -77,8 +77,7 @@ static v8::Handle<v8::Value> V8TestNamedConstructorConstructorCallback(const v8: goto fail; V8DOMWrapper::setDOMWrapper(wrapper, &V8TestNamedConstructorConstructor::info, impl.get()); - impl->ref(); - V8DOMWrapper::setJSWrapperForActiveDOMObject(impl.get(), v8::Persistent<v8::Object>::New(wrapper)); + V8DOMWrapper::setJSWrapperForActiveDOMObject(impl.release(), v8::Persistent<v8::Object>::New(wrapper), args.GetIsolate()); return args.Holder(); fail: return throwError(ec); @@ -155,20 +154,19 @@ ActiveDOMObject* V8TestNamedConstructor::toActiveDOMObject(v8::Handle<v8::Object return toNative(object); } -v8::Handle<v8::Object> V8TestNamedConstructor::wrapSlow(TestNamedConstructor* impl) +v8::Handle<v8::Object> V8TestNamedConstructor::wrapSlow(PassRefPtr<TestNamedConstructor> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getActiveDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForActiveDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.h b/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.h index ade600e59..c6e2625bf 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.h @@ -46,39 +46,32 @@ public: { return reinterpret_cast<TestNamedConstructor*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestNamedConstructor*); + inline static v8::Handle<v8::Object> wrap(TestNamedConstructor*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(TestNamedConstructor*); - private: - static v8::Handle<v8::Object> wrapSlow(TestNamedConstructor*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestNamedConstructor>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestNamedConstructor::existingWrapper(TestNamedConstructor* impl) -{ - return getActiveDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestNamedConstructor::wrap(TestNamedConstructor* impl) +v8::Handle<v8::Object> V8TestNamedConstructor::wrap(TestNamedConstructor* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestNamedConstructor::wrapSlow(impl); + return V8TestNamedConstructor::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestNamedConstructor* impl) +inline v8::Handle<v8::Value> toV8(TestNamedConstructor* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestNamedConstructor::wrap(impl); + return V8TestNamedConstructor::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestNamedConstructor > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestNamedConstructor > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp new file mode 100644 index 000000000..dc4943c41 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp @@ -0,0 +1,146 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "config.h" +#include "V8TestNode.h" + +#include "RuntimeEnabledFeatures.h" +#include "V8Binding.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Node.h" +#include "V8Proxy.h" +#include <wtf/UnusedParam.h> + +namespace WebCore { + +WrapperTypeInfo V8TestNode::info = { V8TestNode::GetTemplate, V8TestNode::derefObject, 0, &V8Node::info }; + +namespace TestNodeV8Internal { + +template <typename T> void V8_USE(T) { } + +} // namespace TestNodeV8Internal + +v8::Handle<v8::Value> V8TestNode::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestNode.Constructor"); + + if (!args.IsConstructCall()) + return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError); + + if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) + return args.Holder(); + + RefPtr<TestNode> impl = TestNode::create(); + v8::Handle<v8::Object> wrapper = args.Holder(); + + V8DOMWrapper::setDOMWrapper(wrapper, &info, impl.get()); + V8DOMWrapper::setJSWrapperForDOMNode(impl.release(), v8::Persistent<v8::Object>::New(wrapper), args.GetIsolate()); + return args.Holder(); +} + +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestNodeTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + desc->ReadOnlyPrototype(); + + v8::Local<v8::Signature> defaultSignature; + defaultSignature = configureTemplate(desc, "TestNode", V8Node::GetTemplate(), V8TestNode::internalFieldCount, + 0, 0, + 0, 0); + UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. + desc->SetCallHandler(V8TestNode::constructorCallback); + + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestNode::GetRawTemplate() +{ + V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); + V8BindingPerIsolateData::TemplateMap::iterator result = data->rawTemplateMap().find(&info); + if (result != data->rawTemplateMap().end()) + return result->second; + + v8::HandleScope handleScope; + v8::Persistent<v8::FunctionTemplate> templ = createRawTemplate(); + data->rawTemplateMap().add(&info, templ); + return templ; +} + +v8::Persistent<v8::FunctionTemplate> V8TestNode::GetTemplate() +{ + V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); + V8BindingPerIsolateData::TemplateMap::iterator result = data->templateMap().find(&info); + if (result != data->templateMap().end()) + return result->second; + + v8::HandleScope handleScope; + v8::Persistent<v8::FunctionTemplate> templ = + ConfigureV8TestNodeTemplate(GetRawTemplate()); + data->templateMap().add(&info, templ); + return templ; +} + +bool V8TestNode::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestNode::wrapSlow(PassRefPtr<TestNode> impl, v8::Isolate* isolate) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = V8Proxy::retrieve(impl->document()->frame()); + + // Enter the node's context and create the wrapper in that context. + v8::Handle<v8::Context> context; + if (proxy && !proxy->matchesCurrentContext()) { + // For performance, we enter the context only if the currently running context + // is different from the context that we are about to enter. + context = proxy->context(); + if (!context.IsEmpty()) + context->Enter(); + } + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); + // Exit the node's context if it was entered. + if (!context.IsEmpty()) + context->Exit(); + if (UNLIKELY(wrapper.IsEmpty())) + return wrapper; + + v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); + + if (!hasDependentLifetime) + wrapperHandle.MarkIndependent(); + wrapperHandle.SetWrapperClassId(v8DOMSubtreeClassId); + V8DOMWrapper::setJSWrapperForDOMNode(impl, wrapperHandle, isolate); + return wrapper; +} + +void V8TestNode::derefObject(void* object) +{ + static_cast<TestNode*>(object)->deref(); +} + +} // namespace WebCore diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestNode.h b/Source/WebCore/bindings/scripts/test/V8/V8TestNode.h new file mode 100644 index 000000000..57e5026dc --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestNode.h @@ -0,0 +1,73 @@ +/* + This file is part of the WebKit open source project. + This file has been generated by generate-bindings.pl. DO NOT MODIFY! + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8TestNode_h +#define V8TestNode_h + +#include "TestNode.h" +#include "V8DOMWrapper.h" +#include "WrapperTypeInfo.h" +#include <v8.h> +#include <wtf/HashMap.h> +#include <wtf/text/StringHash.h> + +namespace WebCore { + +class V8TestNode { +public: + static const bool hasDependentLifetime = true; + static bool HasInstance(v8::Handle<v8::Value>); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestNode* toNative(v8::Handle<v8::Object> object) + { + return reinterpret_cast<TestNode*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); + } + inline static v8::Handle<v8::Object> wrap(TestNode*, v8::Isolate* = 0); + static void derefObject(void*); + static WrapperTypeInfo info; + static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&); + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +private: + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestNode>, v8::Isolate*); +}; + +v8::Handle<v8::Object> V8TestNode::wrap(TestNode* impl, v8::Isolate* isolate) +{ + v8::Handle<v8::Object> wrapper = V8DOMWrapper::getCachedWrapper(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return V8TestNode::wrapSlow(impl, isolate); +} + +inline v8::Handle<v8::Value> toV8(TestNode* impl, v8::Isolate* isolate = 0) +{ + if (!impl) + return v8::Null(); + return V8TestNode::wrap(impl, isolate); +} +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestNode > impl, v8::Isolate* isolate = 0) +{ + return toV8(impl.get(), isolate); +} + +} + +#endif // V8TestNode_h diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 530bbedc4..39c13b6f2 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -21,17 +21,18 @@ #include "config.h" #include "V8TestObj.h" +#include "Dictionary.h" #include "ExceptionCode.h" #include "HTMLNames.h" #include "IDBBindingUtilities.h" #include "IDBKey.h" -#include "OptionsObject.h" #include "RuntimeEnabledFeatures.h" #include "SVGPropertyTearOff.h" #include "SVGStaticPropertyTearOff.h" #include "ScriptArguments.h" #include "ScriptCallStack.h" #include "ScriptCallStackFactory.h" +#include "ScriptProfile.h" #include "SerializedScriptValue.h" #include "V8Binding.h" #include "V8BindingMacros.h" @@ -42,6 +43,7 @@ #include "V8Proxy.h" #include "V8SVGDocument.h" #include "V8SVGPoint.h" +#include "V8ScriptProfile.h" #include "V8TestCallback.h" #include "V8a.h" #include "V8any.h" @@ -73,7 +75,7 @@ namespace WebCore { WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0, 0 }; -namespace TestObjInternal { +namespace TestObjV8Internal { template <typename T> void V8_USE(T) { } @@ -88,7 +90,7 @@ static v8::Handle<v8::Value> readOnlyStringAttrAttrGetter(v8::Local<v8::String> { INC_STATS("DOM.TestObj.readOnlyStringAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->readOnlyStringAttr()); + return v8String(imp->readOnlyStringAttr(), info.GetIsolate()); } static v8::Handle<v8::Value> readOnlyTestObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -96,9 +98,9 @@ static v8::Handle<v8::Value> readOnlyTestObjAttrAttrGetter(v8::Local<v8::String> INC_STATS("DOM.TestObj.readOnlyTestObjAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); RefPtr<TestObj> result = imp->readOnlyTestObjAttr(); - v8::Handle<v8::Value> wrapper = result.get() ? V8TestObj::existingWrapper(result.get()) : v8::Handle<v8::Object>(); + v8::Handle<v8::Value> wrapper = result.get() ? getDOMObjectMap(info.GetIsolate()).get(result.get()) : v8::Handle<v8::Object>(); if (wrapper.IsEmpty()) { - wrapper = toV8(result.get()); + wrapper = toV8(result.get(), info.GetIsolate()); if (!wrapper.IsEmpty()) V8DOMWrapper::setNamedHiddenReference(info.Holder(), "readOnlyTestObjAttr", wrapper); } @@ -189,7 +191,7 @@ static v8::Handle<v8::Value> stringAttrAttrGetter(v8::Local<v8::String> name, co { INC_STATS("DOM.TestObj.stringAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->stringAttr()); + return v8String(imp->stringAttr(), info.GetIsolate()); } static void stringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -205,7 +207,7 @@ static v8::Handle<v8::Value> testObjAttrAttrGetter(v8::Local<v8::String> name, c { INC_STATS("DOM.TestObj.testObjAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return toV8(imp->testObjAttr()); + return toV8(imp->testObjAttr(), info.GetIsolate()); } static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -217,11 +219,235 @@ static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Valu return; } +static v8::Handle<v8::Value> sequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.sequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->sequenceAttr(), info.GetIsolate()); +} + +static void sequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.sequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<ScriptProfile> v = toNativeArray<ScriptProfile>(value); + imp->setSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> intSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.intSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->intSequenceAttr(), info.GetIsolate()); +} + +static void intSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.intSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<int> v = toNativeArray<int>(value); + imp->setIntSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> shortSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.shortSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->shortSequenceAttr(), info.GetIsolate()); +} + +static void shortSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.shortSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<short> v = toNativeArray<short>(value); + imp->setShortSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> longSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->longSequenceAttr(), info.GetIsolate()); +} + +static void longSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<long> v = toNativeArray<long>(value); + imp->setLongSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> longLongSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->longLongSequenceAttr(), info.GetIsolate()); +} + +static void longLongSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<long long> v = toNativeArray<long long>(value); + imp->setLongLongSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> unsignedIntSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedIntSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->unsignedIntSequenceAttr(), info.GetIsolate()); +} + +static void unsignedIntSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedIntSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<unsigned int> v = toNativeArray<unsigned int>(value); + imp->setUnsignedIntSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> unsignedShortSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedShortSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->unsignedShortSequenceAttr(), info.GetIsolate()); +} + +static void unsignedShortSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedShortSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<unsigned short> v = toNativeArray<unsigned short>(value); + imp->setUnsignedShortSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> unsignedLongSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->unsignedLongSequenceAttr(), info.GetIsolate()); +} + +static void unsignedLongSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<unsigned long> v = toNativeArray<unsigned long>(value); + imp->setUnsignedLongSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> unsignedLongLongSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->unsignedLongLongSequenceAttr(), info.GetIsolate()); +} + +static void unsignedLongLongSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<unsigned long long> v = toNativeArray<unsigned long long>(value); + imp->setUnsignedLongLongSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> floatSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.floatSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->floatSequenceAttr(), info.GetIsolate()); +} + +static void floatSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.floatSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<float> v = toNativeArray<float>(value); + imp->setFloatSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> doubleSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.doubleSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->doubleSequenceAttr(), info.GetIsolate()); +} + +static void doubleSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.doubleSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<double> v = toNativeArray<double>(value); + imp->setDoubleSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> booleanSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.booleanSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->booleanSequenceAttr(), info.GetIsolate()); +} + +static void booleanSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.booleanSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<boolean> v = toNativeArray<boolean>(value); + imp->setBooleanSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> voidSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.voidSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->voidSequenceAttr(), info.GetIsolate()); +} + +static void voidSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.voidSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<void> v = toNativeArray<void>(value); + imp->setVoidSequenceAttr(v); + return; +} + +static v8::Handle<v8::Value> dateSequenceAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.dateSequenceAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8Array(imp->dateSequenceAttr(), info.GetIsolate()); +} + +static void dateSequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.dateSequenceAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + Vector<Date> v = toNativeArray<Date>(value); + imp->setDateSequenceAttr(v); + return; +} + static v8::Handle<v8::Value> XMLObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestObj.XMLObjAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return toV8(imp->xmlObjAttr()); + return toV8(imp->xmlObjAttr(), info.GetIsolate()); } static void XMLObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -253,7 +479,7 @@ static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> { INC_STATS("DOM.TestObj.reflectedStringAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr)); + return v8String(imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr), info.GetIsolate()); } static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -317,7 +543,7 @@ static v8::Handle<v8::Value> reflectedURLAttrAttrGetter(v8::Local<v8::String> na { INC_STATS("DOM.TestObj.reflectedURLAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr)); + return v8String(imp->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr), info.GetIsolate()); } static void reflectedURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -333,7 +559,7 @@ static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> { INC_STATS("DOM.TestObj.reflectedStringAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr)); + return v8String(imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr), info.GetIsolate()); } static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -381,7 +607,7 @@ static v8::Handle<v8::Value> reflectedCustomURLAttrAttrGetter(v8::Local<v8::Stri { INC_STATS("DOM.TestObj.reflectedCustomURLAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr)); + return v8String(imp->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr), info.GetIsolate()); } static void reflectedCustomURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -400,7 +626,7 @@ static v8::Handle<v8::Value> attrWithGetterExceptionAttrGetter(v8::Local<v8::Str ExceptionCode ec = 0; int v = imp->attrWithGetterException(ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Handle<v8::Value>(); } return v8::Integer::New(v); @@ -414,7 +640,7 @@ static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Lo ExceptionCode ec = 0; imp->setAttrWithGetterException(v, ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return; } @@ -433,7 +659,7 @@ static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Lo ExceptionCode ec = 0; imp->setAttrWithSetterException(v, ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return; } @@ -444,10 +670,10 @@ static v8::Handle<v8::Value> stringAttrWithGetterExceptionAttrGetter(v8::Local<v ExceptionCode ec = 0; String v = imp->stringAttrWithGetterException(ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Handle<v8::Value>(); } - return v8String(v); + return v8String(v, info.GetIsolate()); } static void stringAttrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -458,7 +684,7 @@ static void stringAttrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, ExceptionCode ec = 0; imp->setStringAttrWithGetterException(v, ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return; } @@ -466,7 +692,7 @@ static v8::Handle<v8::Value> stringAttrWithSetterExceptionAttrGetter(v8::Local<v { INC_STATS("DOM.TestObj.stringAttrWithSetterException._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->stringAttrWithSetterException()); + return v8String(imp->stringAttrWithSetterException(), info.GetIsolate()); } static void stringAttrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -477,7 +703,7 @@ static void stringAttrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, ExceptionCode ec = 0; imp->setStringAttrWithSetterException(v, ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return; } @@ -512,7 +738,7 @@ static v8::Handle<v8::Value> withScriptExecutionContextAttributeAttrGetter(v8::L ScriptExecutionContext* scriptContext = getScriptExecutionContext(); if (!scriptContext) return v8::Undefined(); - return toV8(imp->withScriptExecutionContextAttribute(scriptContext)); + return toV8(imp->withScriptExecutionContextAttribute(scriptContext), info.GetIsolate()); } static void withScriptExecutionContextAttributeAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -537,12 +763,12 @@ static v8::Handle<v8::Value> withScriptStateAttributeRaisesAttrGetter(v8::Local< return v8::Undefined(); RefPtr<TestObj> v = imp->withScriptStateAttributeRaises(state, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Handle<v8::Value>(); } if (state.hadException()) return throwError(state.exception()); - return toV8(v.release()); + return toV8(v.release(), info.GetIsolate()); } static void withScriptStateAttributeRaisesAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -556,7 +782,7 @@ static void withScriptStateAttributeRaisesAttrSetter(v8::Local<v8::String> name, return; imp->setWithScriptStateAttributeRaises(state, WTF::getPtr(v), ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); if (state.hadException()) throwError(state.exception()); return; @@ -572,10 +798,10 @@ static v8::Handle<v8::Value> withScriptExecutionContextAttributeRaisesAttrGetter return v8::Undefined(); RefPtr<TestObj> v = imp->withScriptExecutionContextAttributeRaises(scriptContext, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Handle<v8::Value>(); } - return toV8(v.release()); + return toV8(v.release(), info.GetIsolate()); } static void withScriptExecutionContextAttributeRaisesAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -589,7 +815,7 @@ static void withScriptExecutionContextAttributeRaisesAttrSetter(v8::Local<v8::St return; imp->setWithScriptExecutionContextAttributeRaises(scriptContext, WTF::getPtr(v), ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return; } @@ -603,7 +829,7 @@ static v8::Handle<v8::Value> withScriptExecutionContextAndScriptStateAttributeAt ScriptExecutionContext* scriptContext = getScriptExecutionContext(); if (!scriptContext) return v8::Undefined(); - return toV8(imp->withScriptExecutionContextAndScriptStateAttribute(state, scriptContext)); + return toV8(imp->withScriptExecutionContextAndScriptStateAttribute(state, scriptContext), info.GetIsolate()); } static void withScriptExecutionContextAndScriptStateAttributeAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -636,12 +862,12 @@ static v8::Handle<v8::Value> withScriptExecutionContextAndScriptStateAttributeRa return v8::Undefined(); RefPtr<TestObj> v = imp->withScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Handle<v8::Value>(); } if (state.hadException()) return throwError(state.exception()); - return toV8(v.release()); + return toV8(v.release(), info.GetIsolate()); } static void withScriptExecutionContextAndScriptStateAttributeRaisesAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -658,7 +884,7 @@ static void withScriptExecutionContextAndScriptStateAttributeRaisesAttrSetter(v8 return; imp->setWithScriptExecutionContextAndScriptStateAttributeRaises(state, scriptContext, WTF::getPtr(v), ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); if (state.hadException()) throwError(state.exception()); return; @@ -674,7 +900,7 @@ static v8::Handle<v8::Value> withScriptExecutionContextAndScriptStateWithSpacesA ScriptExecutionContext* scriptContext = getScriptExecutionContext(); if (!scriptContext) return v8::Undefined(); - return toV8(imp->withScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext)); + return toV8(imp->withScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext), info.GetIsolate()); } static void withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -701,7 +927,7 @@ static v8::Handle<v8::Value> withScriptArgumentsAndCallStackAttributeAttrGetter( RefPtr<ScriptCallStack> callStack(createScriptCallStackForInspector()); if (!callStack) return v8::Undefined(); - return toV8(imp->withScriptArgumentsAndCallStackAttribute(callStack)); + return toV8(imp->withScriptArgumentsAndCallStackAttribute(callStack), info.GetIsolate()); } static void withScriptArgumentsAndCallStackAttributeAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -793,9 +1019,9 @@ static v8::Handle<v8::Value> cachedAttribute1AttrGetter(v8::Local<v8::String> na INC_STATS("DOM.TestObj.cachedAttribute1._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); RefPtr<any> result = imp->cachedAttribute1(); - v8::Handle<v8::Value> wrapper = result.get() ? V8any::existingWrapper(result.get()) : v8::Handle<v8::Object>(); + v8::Handle<v8::Value> wrapper = result.get() ? getDOMObjectMap(info.GetIsolate()).get(result.get()) : v8::Handle<v8::Object>(); if (wrapper.IsEmpty()) { - wrapper = toV8(result.get()); + wrapper = toV8(result.get(), info.GetIsolate()); if (!wrapper.IsEmpty()) V8DOMWrapper::setNamedHiddenReference(info.Holder(), "cachedAttribute1", wrapper); } @@ -807,9 +1033,9 @@ static v8::Handle<v8::Value> cachedAttribute2AttrGetter(v8::Local<v8::String> na INC_STATS("DOM.TestObj.cachedAttribute2._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); RefPtr<any> result = imp->cachedAttribute2(); - v8::Handle<v8::Value> wrapper = result.get() ? V8any::existingWrapper(result.get()) : v8::Handle<v8::Object>(); + v8::Handle<v8::Value> wrapper = result.get() ? getDOMObjectMap(info.GetIsolate()).get(result.get()) : v8::Handle<v8::Object>(); if (wrapper.IsEmpty()) { - wrapper = toV8(result.get()); + wrapper = toV8(result.get(), info.GetIsolate()); if (!wrapper.IsEmpty()) V8DOMWrapper::setNamedHiddenReference(info.Holder(), "cachedAttribute2", wrapper); } @@ -885,16 +1111,16 @@ static v8::Handle<v8::Value> contentDocumentAttrGetter(v8::Local<v8::String> nam INC_STATS("DOM.TestObj.contentDocument._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->contentDocument())) - return v8::Handle<v8::Value>(); + return v8::Handle<v8::Value>(v8::Null()); - return toV8(imp->contentDocument()); + return toV8(imp->contentDocument(), info.GetIsolate()); } static v8::Handle<v8::Value> mutablePointAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestObj.mutablePoint._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return toV8(WTF::getPtr(SVGStaticPropertyTearOff<TestObj, FloatPoint>::create(imp, imp->mutablePoint(), &TestObj::updateMutablePoint))); + return toV8(WTF::getPtr(SVGStaticPropertyTearOff<TestObj, FloatPoint>::create(imp, imp->mutablePoint(), &TestObj::updateMutablePoint)), info.GetIsolate()); } static void mutablePointAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -910,7 +1136,7 @@ static v8::Handle<v8::Value> immutablePointAttrGetter(v8::Local<v8::String> name { INC_STATS("DOM.TestObj.immutablePoint._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return toV8(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->immutablePoint()))); + return toV8(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->immutablePoint())), info.GetIsolate()); } static void immutablePointAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -922,6 +1148,22 @@ static void immutablePointAttrSetter(v8::Local<v8::String> name, v8::Local<v8::V return; } +static v8::Handle<v8::Value> strawberryAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.strawberry._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->blueberry()); +} + +static void strawberryAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.strawberry._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = V8int::HasInstance(value) ? V8int::toNative(v8::Handle<v8::Object>::Cast(value)) : 0; + imp->setBlueberry(v); + return; +} + static v8::Handle<v8::Value> strictFloatAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestObj.strictFloat._get"); @@ -965,7 +1207,7 @@ static v8::Handle<v8::Value> hashAttrGetter(v8::Local<v8::String> name, const v8 { INC_STATS("DOM.TestObj.hash._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8String(imp->hash()); + return v8String(imp->hash(), info.GetIsolate()); } static v8::Handle<v8::Value> TestObjConstructorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -988,7 +1230,7 @@ static v8::Handle<v8::Value> voidMethodWithArgsCallback(const v8::Arguments& arg { INC_STATS("DOM.TestObj.voidMethodWithArgs"); if (args.Length() < 3) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); @@ -1008,7 +1250,7 @@ static v8::Handle<v8::Value> intMethodWithArgsCallback(const v8::Arguments& args { INC_STATS("DOM.TestObj.intMethodWithArgs"); if (args.Length() < 3) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); @@ -1020,26 +1262,47 @@ static v8::Handle<v8::Value> objMethodCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.objMethod"); TestObj* imp = V8TestObj::toNative(args.Holder()); - return toV8(imp->objMethod()); + return toV8(imp->objMethod(), args.GetIsolate()); } static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.objMethodWithArgs"); if (args.Length() < 3) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined))) : 0); - return toV8(imp->objMethodWithArgs(intArg, strArg, objArg)); + return toV8(imp->objMethodWithArgs(intArg, strArg, objArg), args.GetIsolate()); +} + +static v8::Handle<v8::Value> methodWithSequenceArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithSequenceArg"); + if (args.Length() < 1) + return V8Proxy::throwNotEnoughArgumentsError(); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(sequence<ScriptProfile>*, sequenceArg, toNativeArray<ScriptProfile>(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); + imp->methodWithSequenceArg(sequenceArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodReturningSequenceCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodReturningSequence"); + if (args.Length() < 1) + return V8Proxy::throwNotEnoughArgumentsError(); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); + return v8Array(imp->methodReturningSequence(intArg), args.GetIsolate()); } static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.methodThatRequiresAllArgsAndThrows"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); ExceptionCode ec = 0; { @@ -1048,10 +1311,10 @@ static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8 RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec); if (UNLIKELY(ec)) goto fail; - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -1059,10 +1322,10 @@ static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.serializedValue"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); bool serializedArgDidThrow = false; - RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], 0, 0, serializedArgDidThrow); + RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], 0, 0, serializedArgDidThrow, args.GetIsolate()); if (serializedArgDidThrow) return v8::Undefined(); imp->serializedValue(serializedArg); @@ -1073,7 +1336,7 @@ static v8::Handle<v8::Value> idbKeyCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.idbKey"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(RefPtr<IDBKey>, key, createIDBKeyFromValue(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); imp->idbKey(key.get()); @@ -1084,22 +1347,18 @@ static v8::Handle<v8::Value> optionsObjectCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.optionsObject"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); - EXCEPTION_BLOCK(OptionsObject, oo, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); + EXCEPTION_BLOCK(Dictionary, oo, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); if (args.Length() > 0 && !oo.isUndefinedOrNull() && !oo.isObject()) { - ec = TYPE_MISMATCH_ERR; - V8Proxy::setDOMException(ec); return throwError("Not an object.", V8Proxy::TypeError); } if (args.Length() <= 1) { imp->optionsObject(oo); return v8::Handle<v8::Value>(); } - EXCEPTION_BLOCK(OptionsObject, ooo, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); + EXCEPTION_BLOCK(Dictionary, ooo, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); if (args.Length() > 1 && !ooo.isUndefinedOrNull() && !ooo.isObject()) { - ec = TYPE_MISMATCH_ERR; - V8Proxy::setDOMException(ec); return throwError("Not an object.", V8Proxy::TypeError); } imp->optionsObject(oo, ooo); @@ -1118,7 +1377,7 @@ static v8::Handle<v8::Value> methodWithExceptionCallback(const v8::Arguments& ar return v8::Handle<v8::Value>(); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -1163,7 +1422,7 @@ static v8::Handle<v8::Value> withScriptStateObjCallback(const v8::Arguments& arg RefPtr<TestObj> result = imp->withScriptStateObj(&state); if (state.hadException()) return throwError(state.exception()); - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Arguments& args) @@ -1181,7 +1440,7 @@ static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Argu return v8::Handle<v8::Value>(); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -1197,10 +1456,10 @@ static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Argum goto fail; if (state.hadException()) return throwError(state.exception()); - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -1244,10 +1503,10 @@ static v8::Handle<v8::Value> withScriptExecutionContextAndScriptStateObjExceptio goto fail; if (state.hadException()) return throwError(state.exception()); - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -1262,7 +1521,7 @@ static v8::Handle<v8::Value> withScriptExecutionContextAndScriptStateWithSpacesC RefPtr<TestObj> result = imp->withScriptExecutionContextAndScriptStateWithSpaces(&state, scriptContext); if (state.hadException()) return throwError(state.exception()); - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } static v8::Handle<v8::Value> withScriptArgumentsAndCallStackCallback(const v8::Arguments& args) @@ -1294,7 +1553,7 @@ static v8::Handle<v8::Value> methodWithNonOptionalArgAndOptionalArgCallback(cons { INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, nonOpt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); if (args.Length() <= 1) { @@ -1310,7 +1569,7 @@ static v8::Handle<v8::Value> methodWithNonOptionalArgAndTwoOptionalArgsCallback( { INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, nonOpt, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); if (args.Length() <= 1) { @@ -1362,9 +1621,9 @@ static v8::Handle<v8::Value> methodWithCallbackArgCallback(const v8::Arguments& { INC_STATS("DOM.TestObj.methodWithCallbackArg"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); - if (args.Length() <= 0 || !args[0]->IsObject()) + if (args.Length() <= 0 || !args[0]->IsFunction()) return throwError(TYPE_MISMATCH_ERR); RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); imp->methodWithCallbackArg(callback); @@ -1375,10 +1634,10 @@ static v8::Handle<v8::Value> methodWithNonCallbackArgAndCallbackArgCallback(cons { INC_STATS("DOM.TestObj.methodWithNonCallbackArgAndCallbackArg"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, nonCallback, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); - if (args.Length() <= 1 || !args[1]->IsObject()) + if (args.Length() <= 1 || !args[1]->IsFunction()) return throwError(TYPE_MISMATCH_ERR); RefPtr<TestCallback> callback = V8TestCallback::create(args[1], getScriptExecutionContext()); imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback); @@ -1391,7 +1650,7 @@ static v8::Handle<v8::Value> methodWithCallbackAndOptionalArgCallback(const v8:: TestObj* imp = V8TestObj::toNative(args.Holder()); RefPtr<TestCallback> callback; if (args.Length() > 0 && !args[0]->IsNull() && !args[0]->IsUndefined()) { - if (!args[0]->IsObject()) + if (!args[0]->IsFunction()) return throwError(TYPE_MISMATCH_ERR); callback = V8TestCallback::create(args[0], getScriptExecutionContext()); } @@ -1405,7 +1664,7 @@ static v8::Handle<v8::Value> conditionalMethod1Callback(const v8::Arguments& arg { INC_STATS("DOM.TestObj.conditionalMethod1"); TestObj* imp = V8TestObj::toNative(args.Holder()); - return v8String(imp->conditionalMethod1()); + return v8String(imp->conditionalMethod1(), args.GetIsolate()); } #endif // ENABLE(Condition1) @@ -1438,7 +1697,7 @@ static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod1"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); @@ -1450,7 +1709,7 @@ static v8::Handle<v8::Value> overloadedMethod2Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod2"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); if (args.Length() <= 1) { @@ -1466,7 +1725,7 @@ static v8::Handle<v8::Value> overloadedMethod3Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod3"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); imp->overloadedMethod(strArg); @@ -1477,7 +1736,7 @@ static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod4"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); imp->overloadedMethod(intArg); @@ -1488,9 +1747,9 @@ static v8::Handle<v8::Value> overloadedMethod5Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod5"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); - if (args.Length() <= 0 || !args[0]->IsObject()) + if (args.Length() <= 0 || !args[0]->IsFunction()) return throwError(TYPE_MISMATCH_ERR); RefPtr<TestCallback> callback = V8TestCallback::create(args[0], getScriptExecutionContext()); imp->overloadedMethod(callback); @@ -1501,7 +1760,7 @@ static v8::Handle<v8::Value> overloadedMethod6Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod6"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(RefPtr<DOMStringList>, listArg, v8ValueToWebCoreDOMStringList(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); imp->overloadedMethod(listArg); @@ -1512,7 +1771,7 @@ static v8::Handle<v8::Value> overloadedMethod7Callback(const v8::Arguments& args { INC_STATS("DOM.TestObj.overloadedMethod7"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(RefPtr<DOMStringList>, arrayArg, v8ValueToWebCoreDOMStringList(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); imp->overloadedMethod(arrayArg); @@ -1530,7 +1789,7 @@ static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args) return overloadedMethod3Callback(args); if (args.Length() == 1) return overloadedMethod4Callback(args); - if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsObject()))) + if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsFunction()))) return overloadedMethod5Callback(args); if ((args.Length() == 1 && (args[0]->IsNull() || V8DOMStringList::HasInstance(args[0])))) return overloadedMethod6Callback(args); @@ -1563,7 +1822,7 @@ static v8::Handle<v8::Value> overloadedMethod11Callback(const v8::Arguments& arg { INC_STATS("DOM.TestObj.overloadedMethod11"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); EXCEPTION_BLOCK(int, arg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); TestObj::overloadedMethod1(arg); return v8::Handle<v8::Value>(); @@ -1577,7 +1836,7 @@ static v8::Handle<v8::Value> overloadedMethod12Callback(const v8::Arguments& arg { INC_STATS("DOM.TestObj.overloadedMethod12"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); TestObj::overloadedMethod1(type); return v8::Handle<v8::Value>(); @@ -1604,7 +1863,7 @@ static v8::Handle<v8::Value> enabledAtRuntimeMethod1Callback(const v8::Arguments { INC_STATS("DOM.TestObj.enabledAtRuntimeMethod1"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8int::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); imp->enabledAtRuntimeMethod1(intArg); @@ -1615,7 +1874,7 @@ static v8::Handle<v8::Value> enabledAtRuntimeMethod2Callback(const v8::Arguments { INC_STATS("DOM.TestObj.enabledAtRuntimeMethod2"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(int, intArg, V8int::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8int::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); imp->enabledAtRuntimeMethod2(intArg); @@ -1629,14 +1888,14 @@ static v8::Handle<v8::Value> getSVGDocumentCallback(const v8::Arguments& args) ExceptionCode ec = 0; { if (!V8BindingSecurity::shouldAllowAccessToNode(V8BindingState::Only(), imp->getSVGDocument(ec))) - return v8::Handle<v8::Value>(); + return v8::Handle<v8::Value>(v8::Null()); RefPtr<SVGDocument> result = imp->getSVGDocument(ec); if (UNLIKELY(ec)) goto fail; - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -1644,7 +1903,7 @@ static v8::Handle<v8::Value> convert1Callback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.convert1"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(a*, , V8a::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8a::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); imp->convert1(); @@ -1655,7 +1914,7 @@ static v8::Handle<v8::Value> convert2Callback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.convert2"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(b*, , V8b::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8b::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); imp->convert2(); @@ -1666,7 +1925,7 @@ static v8::Handle<v8::Value> convert3Callback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.convert3"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(c*, , V8c::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8c::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); imp->convert3(); @@ -1677,7 +1936,7 @@ static v8::Handle<v8::Value> convert4Callback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.convert4"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(d*, , V8d::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8d::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); imp->convert4(); @@ -1688,7 +1947,7 @@ static v8::Handle<v8::Value> convert5Callback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.convert5"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); EXCEPTION_BLOCK(e*, , V8e::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8e::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0); imp->convert5(); @@ -1699,14 +1958,14 @@ static v8::Handle<v8::Value> mutablePointFunctionCallback(const v8::Arguments& a { INC_STATS("DOM.TestObj.mutablePointFunction"); TestObj* imp = V8TestObj::toNative(args.Holder()); - return toV8(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->mutablePointFunction()))); + return toV8(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->mutablePointFunction())), args.GetIsolate()); } static v8::Handle<v8::Value> immutablePointFunctionCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.immutablePointFunction"); TestObj* imp = V8TestObj::toNative(args.Holder()); - return toV8(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->immutablePointFunction()))); + return toV8(WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(imp->immutablePointFunction())), args.GetIsolate()); } static v8::Handle<v8::Value> orangeCallback(const v8::Arguments& args) @@ -1721,7 +1980,7 @@ static v8::Handle<v8::Value> strictFunctionCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.strictFunction"); if (args.Length() < 3) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); TestObj* imp = V8TestObj::toNative(args.Holder()); ExceptionCode ec = 0; { @@ -1731,177 +1990,208 @@ static v8::Handle<v8::Value> strictFunctionCallback(const v8::Arguments& args) RefPtr<bool> result = imp->strictFunction(str, a, b, ec); if (UNLIKELY(ec)) goto fail; - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } fail: - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } -} // namespace TestObjInternal +} // namespace TestObjV8Internal static const BatchedAttribute TestObjAttrs[] = { // Attribute 'readOnlyIntAttr' (Type: 'readonly attribute' ExtAttr: '') - {"readOnlyIntAttr", TestObjInternal::readOnlyIntAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"readOnlyIntAttr", TestObjV8Internal::readOnlyIntAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'readOnlyStringAttr' (Type: 'readonly attribute' ExtAttr: '') - {"readOnlyStringAttr", TestObjInternal::readOnlyStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"readOnlyStringAttr", TestObjV8Internal::readOnlyStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'readOnlyTestObjAttr' (Type: 'readonly attribute' ExtAttr: '') - {"readOnlyTestObjAttr", TestObjInternal::readOnlyTestObjAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"readOnlyTestObjAttr", TestObjV8Internal::readOnlyTestObjAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'shortAttr' (Type: 'attribute' ExtAttr: '') - {"shortAttr", TestObjInternal::shortAttrAttrGetter, TestObjInternal::shortAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"shortAttr", TestObjV8Internal::shortAttrAttrGetter, TestObjV8Internal::shortAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'unsignedShortAttr' (Type: 'attribute' ExtAttr: '') - {"unsignedShortAttr", TestObjInternal::unsignedShortAttrAttrGetter, TestObjInternal::unsignedShortAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"unsignedShortAttr", TestObjV8Internal::unsignedShortAttrAttrGetter, TestObjV8Internal::unsignedShortAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'intAttr' (Type: 'attribute' ExtAttr: '') - {"intAttr", TestObjInternal::intAttrAttrGetter, TestObjInternal::intAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"intAttr", TestObjV8Internal::intAttrAttrGetter, TestObjV8Internal::intAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'longLongAttr' (Type: 'attribute' ExtAttr: '') - {"longLongAttr", TestObjInternal::longLongAttrAttrGetter, TestObjInternal::longLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"longLongAttr", TestObjV8Internal::longLongAttrAttrGetter, TestObjV8Internal::longLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'unsignedLongLongAttr' (Type: 'attribute' ExtAttr: '') - {"unsignedLongLongAttr", TestObjInternal::unsignedLongLongAttrAttrGetter, TestObjInternal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"unsignedLongLongAttr", TestObjV8Internal::unsignedLongLongAttrAttrGetter, TestObjV8Internal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'stringAttr' (Type: 'attribute' ExtAttr: '') - {"stringAttr", TestObjInternal::stringAttrAttrGetter, TestObjInternal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"stringAttr", TestObjV8Internal::stringAttrAttrGetter, TestObjV8Internal::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 */}, + {"testObjAttr", TestObjV8Internal::testObjAttrAttrGetter, TestObjV8Internal::testObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'sequenceAttr' (Type: 'attribute' ExtAttr: '') + {"sequenceAttr", TestObjV8Internal::sequenceAttrAttrGetter, TestObjV8Internal::sequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'intSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"intSequenceAttr", TestObjV8Internal::intSequenceAttrAttrGetter, TestObjV8Internal::intSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'shortSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"shortSequenceAttr", TestObjV8Internal::shortSequenceAttrAttrGetter, TestObjV8Internal::shortSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'longSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"longSequenceAttr", TestObjV8Internal::longSequenceAttrAttrGetter, TestObjV8Internal::longSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'longLongSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"longLongSequenceAttr", TestObjV8Internal::longLongSequenceAttrAttrGetter, TestObjV8Internal::longLongSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedIntSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedIntSequenceAttr", TestObjV8Internal::unsignedIntSequenceAttrAttrGetter, TestObjV8Internal::unsignedIntSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedShortSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedShortSequenceAttr", TestObjV8Internal::unsignedShortSequenceAttrAttrGetter, TestObjV8Internal::unsignedShortSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedLongSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedLongSequenceAttr", TestObjV8Internal::unsignedLongSequenceAttrAttrGetter, TestObjV8Internal::unsignedLongSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedLongLongSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedLongLongSequenceAttr", TestObjV8Internal::unsignedLongLongSequenceAttrAttrGetter, TestObjV8Internal::unsignedLongLongSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'floatSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"floatSequenceAttr", TestObjV8Internal::floatSequenceAttrAttrGetter, TestObjV8Internal::floatSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'doubleSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"doubleSequenceAttr", TestObjV8Internal::doubleSequenceAttrAttrGetter, TestObjV8Internal::doubleSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'booleanSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"booleanSequenceAttr", TestObjV8Internal::booleanSequenceAttrAttrGetter, TestObjV8Internal::booleanSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'voidSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"voidSequenceAttr", TestObjV8Internal::voidSequenceAttrAttrGetter, TestObjV8Internal::voidSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'dateSequenceAttr' (Type: 'attribute' ExtAttr: '') + {"dateSequenceAttr", TestObjV8Internal::dateSequenceAttrAttrGetter, TestObjV8Internal::dateSequenceAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'XMLObjAttr' (Type: 'attribute' ExtAttr: '') - {"XMLObjAttr", TestObjInternal::XMLObjAttrAttrGetter, TestObjInternal::XMLObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"XMLObjAttr", TestObjV8Internal::XMLObjAttrAttrGetter, TestObjV8Internal::XMLObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'create' (Type: 'attribute' ExtAttr: '') - {"create", TestObjInternal::createAttrGetter, TestObjInternal::createAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"create", TestObjV8Internal::createAttrGetter, TestObjV8Internal::createAttrSetter, 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 */}, + {"reflectedStringAttr", TestObjV8Internal::reflectedStringAttrAttrGetter, TestObjV8Internal::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 */}, + {"reflectedIntegralAttr", TestObjV8Internal::reflectedIntegralAttrAttrGetter, TestObjV8Internal::reflectedIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'reflectedUnsignedIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect') - {"reflectedUnsignedIntegralAttr", TestObjInternal::reflectedUnsignedIntegralAttrAttrGetter, TestObjInternal::reflectedUnsignedIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"reflectedUnsignedIntegralAttr", TestObjV8Internal::reflectedUnsignedIntegralAttrAttrGetter, TestObjV8Internal::reflectedUnsignedIntegralAttrAttrSetter, 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 */}, + {"reflectedBooleanAttr", TestObjV8Internal::reflectedBooleanAttrAttrGetter, TestObjV8Internal::reflectedBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'reflectedURLAttr' (Type: 'attribute' ExtAttr: 'URL Reflect') - {"reflectedURLAttr", TestObjInternal::reflectedURLAttrAttrGetter, TestObjInternal::reflectedURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"reflectedURLAttr", TestObjV8Internal::reflectedURLAttrAttrGetter, TestObjV8Internal::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 */}, + {"reflectedStringAttr", TestObjV8Internal::reflectedStringAttrAttrGetter, TestObjV8Internal::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 */}, + {"reflectedCustomIntegralAttr", TestObjV8Internal::reflectedCustomIntegralAttrAttrGetter, TestObjV8Internal::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 */}, + {"reflectedCustomBooleanAttr", TestObjV8Internal::reflectedCustomBooleanAttrAttrGetter, TestObjV8Internal::reflectedCustomBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'reflectedCustomURLAttr' (Type: 'attribute' ExtAttr: 'URL Reflect') - {"reflectedCustomURLAttr", TestObjInternal::reflectedCustomURLAttrAttrGetter, TestObjInternal::reflectedCustomURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"reflectedCustomURLAttr", TestObjV8Internal::reflectedCustomURLAttrAttrGetter, TestObjV8Internal::reflectedCustomURLAttrAttrSetter, 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 */}, + {"attrWithGetterException", TestObjV8Internal::attrWithGetterExceptionAttrGetter, TestObjV8Internal::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 */}, + {"attrWithSetterException", TestObjV8Internal::attrWithSetterExceptionAttrGetter, TestObjV8Internal::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 */}, + {"stringAttrWithGetterException", TestObjV8Internal::stringAttrWithGetterExceptionAttrGetter, TestObjV8Internal::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 */}, + {"stringAttrWithSetterException", TestObjV8Internal::stringAttrWithSetterExceptionAttrGetter, TestObjV8Internal::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 'withScriptStateAttribute' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptStateAttribute", TestObjInternal::withScriptStateAttributeAttrGetter, TestObjInternal::withScriptStateAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptStateAttribute", TestObjV8Internal::withScriptStateAttributeAttrGetter, TestObjV8Internal::withScriptStateAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'withScriptExecutionContextAttribute' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptExecutionContextAttribute", TestObjInternal::withScriptExecutionContextAttributeAttrGetter, TestObjInternal::withScriptExecutionContextAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptExecutionContextAttribute", TestObjV8Internal::withScriptExecutionContextAttributeAttrGetter, TestObjV8Internal::withScriptExecutionContextAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'withScriptStateAttributeRaises' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptStateAttributeRaises", TestObjInternal::withScriptStateAttributeRaisesAttrGetter, TestObjInternal::withScriptStateAttributeRaisesAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptStateAttributeRaises", TestObjV8Internal::withScriptStateAttributeRaisesAttrGetter, TestObjV8Internal::withScriptStateAttributeRaisesAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'withScriptExecutionContextAttributeRaises' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptExecutionContextAttributeRaises", TestObjInternal::withScriptExecutionContextAttributeRaisesAttrGetter, TestObjInternal::withScriptExecutionContextAttributeRaisesAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptExecutionContextAttributeRaises", TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrGetter, TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'withScriptExecutionContextAndScriptStateAttribute' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptExecutionContextAndScriptStateAttribute", TestObjInternal::withScriptExecutionContextAndScriptStateAttributeAttrGetter, TestObjInternal::withScriptExecutionContextAndScriptStateAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptExecutionContextAndScriptStateAttribute", TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrGetter, TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'withScriptExecutionContextAndScriptStateAttributeRaises' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptExecutionContextAndScriptStateAttributeRaises", TestObjInternal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter, TestObjInternal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptExecutionContextAndScriptStateAttributeRaises", TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter, TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'withScriptExecutionContextAndScriptStateWithSpacesAttribute' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptExecutionContextAndScriptStateWithSpacesAttribute", TestObjInternal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrGetter, TestObjInternal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptExecutionContextAndScriptStateWithSpacesAttribute", TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrGetter, TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'withScriptArgumentsAndCallStackAttribute' (Type: 'attribute' ExtAttr: 'CallWith') - {"withScriptArgumentsAndCallStackAttribute", TestObjInternal::withScriptArgumentsAndCallStackAttributeAttrGetter, TestObjInternal::withScriptArgumentsAndCallStackAttributeAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"withScriptArgumentsAndCallStackAttribute", TestObjV8Internal::withScriptArgumentsAndCallStackAttributeAttrGetter, TestObjV8Internal::withScriptArgumentsAndCallStackAttributeAttrSetter, 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 */}, + {"conditionalAttr1", TestObjV8Internal::conditionalAttr1AttrGetter, TestObjV8Internal::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 */}, + {"conditionalAttr2", TestObjV8Internal::conditionalAttr2AttrGetter, TestObjV8Internal::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 */}, + {"conditionalAttr3", TestObjV8Internal::conditionalAttr3AttrGetter, TestObjV8Internal::conditionalAttr3AttrSetter, 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) // Attribute 'conditionalAttr4' (Type: 'attribute' ExtAttr: 'Conditional') - {"conditionalAttr4", TestObjInternal::TestObjConstructorGetter, 0, &V8TestObjectA::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::ReadOnly), 0 /* on instance */}, + {"conditionalAttr4", TestObjV8Internal::TestObjConstructorGetter, 0, &V8TestObjectA::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::ReadOnly), 0 /* on instance */}, #endif // ENABLE(Condition1) #if ENABLE(Condition1) && ENABLE(Condition2) // Attribute 'conditionalAttr5' (Type: 'attribute' ExtAttr: 'Conditional') - {"conditionalAttr5", TestObjInternal::TestObjConstructorGetter, 0, &V8TestObjectB::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::ReadOnly), 0 /* on instance */}, + {"conditionalAttr5", TestObjV8Internal::TestObjConstructorGetter, 0, &V8TestObjectB::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::ReadOnly), 0 /* on instance */}, #endif // ENABLE(Condition1) && ENABLE(Condition2) #if ENABLE(Condition1) || ENABLE(Condition2) // Attribute 'conditionalAttr6' (Type: 'attribute' ExtAttr: 'Conditional') - {"conditionalAttr6", TestObjInternal::TestObjConstructorGetter, 0, &V8TestObjectC::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::ReadOnly), 0 /* on instance */}, + {"conditionalAttr6", TestObjV8Internal::TestObjConstructorGetter, 0, &V8TestObjectC::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::ReadOnly), 0 /* on instance */}, #endif // ENABLE(Condition1) || ENABLE(Condition2) // Attribute 'cachedAttribute1' (Type: 'readonly attribute' ExtAttr: 'CachedAttribute') - {"cachedAttribute1", TestObjInternal::cachedAttribute1AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"cachedAttribute1", TestObjV8Internal::cachedAttribute1AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'cachedAttribute2' (Type: 'readonly attribute' ExtAttr: 'CachedAttribute') - {"cachedAttribute2", TestObjInternal::cachedAttribute2AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"cachedAttribute2", TestObjV8Internal::cachedAttribute2AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'floatArray' (Type: 'attribute' ExtAttr: '') - {"floatArray", TestObjInternal::floatArrayAttrGetter, TestObjInternal::floatArrayAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"floatArray", TestObjV8Internal::floatArrayAttrGetter, TestObjV8Internal::floatArrayAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'doubleArray' (Type: 'attribute' ExtAttr: '') - {"doubleArray", TestObjInternal::doubleArrayAttrGetter, TestObjInternal::doubleArrayAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"doubleArray", TestObjV8Internal::doubleArrayAttrGetter, TestObjV8Internal::doubleArrayAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'contentDocument' (Type: 'readonly attribute' ExtAttr: 'CheckSecurityForNode') - {"contentDocument", TestObjInternal::contentDocumentAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"contentDocument", TestObjV8Internal::contentDocumentAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'mutablePoint' (Type: 'attribute' ExtAttr: '') - {"mutablePoint", TestObjInternal::mutablePointAttrGetter, TestObjInternal::mutablePointAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"mutablePoint", TestObjV8Internal::mutablePointAttrGetter, TestObjV8Internal::mutablePointAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'immutablePoint' (Type: 'attribute' ExtAttr: 'Immutable') - {"immutablePoint", TestObjInternal::immutablePointAttrGetter, TestObjInternal::immutablePointAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"immutablePoint", TestObjV8Internal::immutablePointAttrGetter, TestObjV8Internal::immutablePointAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'strawberry' (Type: 'attribute' ExtAttr: 'ImplementedAs') + {"strawberry", TestObjV8Internal::strawberryAttrGetter, TestObjV8Internal::strawberryAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'strictFloat' (Type: 'attribute' ExtAttr: 'StrictTypeChecking') - {"strictFloat", TestObjInternal::strictFloatAttrGetter, TestObjInternal::strictFloatAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"strictFloat", TestObjV8Internal::strictFloatAttrGetter, TestObjV8Internal::strictFloatAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // 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 */}, + {"description", TestObjV8Internal::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: '') - {"id", TestObjInternal::idAttrGetter, TestObjInternal::idAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"id", TestObjV8Internal::idAttrGetter, TestObjV8Internal::idAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'hash' (Type: 'readonly attribute' ExtAttr: '') - {"hash", TestObjInternal::hashAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"hash", TestObjV8Internal::hashAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, }; static const BatchedCallback TestObjCallbacks[] = { - {"voidMethod", TestObjInternal::voidMethodCallback}, - {"intMethod", TestObjInternal::intMethodCallback}, - {"objMethod", TestObjInternal::objMethodCallback}, - {"serializedValue", TestObjInternal::serializedValueCallback}, - {"idbKey", TestObjInternal::idbKeyCallback}, - {"optionsObject", TestObjInternal::optionsObjectCallback}, - {"methodWithException", TestObjInternal::methodWithExceptionCallback}, + {"voidMethod", TestObjV8Internal::voidMethodCallback}, + {"intMethod", TestObjV8Internal::intMethodCallback}, + {"objMethod", TestObjV8Internal::objMethodCallback}, + {"methodReturningSequence", TestObjV8Internal::methodReturningSequenceCallback}, + {"serializedValue", TestObjV8Internal::serializedValueCallback}, + {"idbKey", TestObjV8Internal::idbKeyCallback}, + {"optionsObject", TestObjV8Internal::optionsObjectCallback}, + {"methodWithException", TestObjV8Internal::methodWithExceptionCallback}, {"customMethod", V8TestObj::customMethodCallback}, {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback}, - {"addEventListener", TestObjInternal::addEventListenerCallback}, - {"removeEventListener", TestObjInternal::removeEventListenerCallback}, - {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback}, - {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback}, - {"withScriptStateVoidException", TestObjInternal::withScriptStateVoidExceptionCallback}, - {"withScriptStateObjException", TestObjInternal::withScriptStateObjExceptionCallback}, - {"withScriptExecutionContext", TestObjInternal::withScriptExecutionContextCallback}, - {"withScriptExecutionContextAndScriptState", TestObjInternal::withScriptExecutionContextAndScriptStateCallback}, - {"withScriptExecutionContextAndScriptStateObjException", TestObjInternal::withScriptExecutionContextAndScriptStateObjExceptionCallback}, - {"withScriptExecutionContextAndScriptStateWithSpaces", TestObjInternal::withScriptExecutionContextAndScriptStateWithSpacesCallback}, - {"withScriptArgumentsAndCallStack", TestObjInternal::withScriptArgumentsAndCallStackCallback}, - {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback}, - {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback}, - {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback}, - {"methodWithOptionalString", TestObjInternal::methodWithOptionalStringCallback}, - {"methodWithOptionalStringIsUndefined", TestObjInternal::methodWithOptionalStringIsUndefinedCallback}, - {"methodWithOptionalStringIsNullString", TestObjInternal::methodWithOptionalStringIsNullStringCallback}, - {"methodWithCallbackArg", TestObjInternal::methodWithCallbackArgCallback}, - {"methodWithNonCallbackArgAndCallbackArg", TestObjInternal::methodWithNonCallbackArgAndCallbackArgCallback}, - {"methodWithCallbackAndOptionalArg", TestObjInternal::methodWithCallbackAndOptionalArgCallback}, + {"addEventListener", TestObjV8Internal::addEventListenerCallback}, + {"removeEventListener", TestObjV8Internal::removeEventListenerCallback}, + {"withScriptStateVoid", TestObjV8Internal::withScriptStateVoidCallback}, + {"withScriptStateObj", TestObjV8Internal::withScriptStateObjCallback}, + {"withScriptStateVoidException", TestObjV8Internal::withScriptStateVoidExceptionCallback}, + {"withScriptStateObjException", TestObjV8Internal::withScriptStateObjExceptionCallback}, + {"withScriptExecutionContext", TestObjV8Internal::withScriptExecutionContextCallback}, + {"withScriptExecutionContextAndScriptState", TestObjV8Internal::withScriptExecutionContextAndScriptStateCallback}, + {"withScriptExecutionContextAndScriptStateObjException", TestObjV8Internal::withScriptExecutionContextAndScriptStateObjExceptionCallback}, + {"withScriptExecutionContextAndScriptStateWithSpaces", TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesCallback}, + {"withScriptArgumentsAndCallStack", TestObjV8Internal::withScriptArgumentsAndCallStackCallback}, + {"methodWithOptionalArg", TestObjV8Internal::methodWithOptionalArgCallback}, + {"methodWithNonOptionalArgAndOptionalArg", TestObjV8Internal::methodWithNonOptionalArgAndOptionalArgCallback}, + {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjV8Internal::methodWithNonOptionalArgAndTwoOptionalArgsCallback}, + {"methodWithOptionalString", TestObjV8Internal::methodWithOptionalStringCallback}, + {"methodWithOptionalStringIsUndefined", TestObjV8Internal::methodWithOptionalStringIsUndefinedCallback}, + {"methodWithOptionalStringIsNullString", TestObjV8Internal::methodWithOptionalStringIsNullStringCallback}, + {"methodWithCallbackArg", TestObjV8Internal::methodWithCallbackArgCallback}, + {"methodWithNonCallbackArgAndCallbackArg", TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgCallback}, + {"methodWithCallbackAndOptionalArg", TestObjV8Internal::methodWithCallbackAndOptionalArgCallback}, #if ENABLE(Condition1) - {"conditionalMethod1", TestObjInternal::conditionalMethod1Callback}, + {"conditionalMethod1", TestObjV8Internal::conditionalMethod1Callback}, #endif #if ENABLE(Condition1) && ENABLE(Condition2) - {"conditionalMethod2", TestObjInternal::conditionalMethod2Callback}, + {"conditionalMethod2", TestObjV8Internal::conditionalMethod2Callback}, #endif #if ENABLE(Condition1) || ENABLE(Condition2) - {"conditionalMethod3", TestObjInternal::conditionalMethod3Callback}, + {"conditionalMethod3", TestObjV8Internal::conditionalMethod3Callback}, #endif - {"overloadedMethod", TestObjInternal::overloadedMethodCallback}, - {"getSVGDocument", TestObjInternal::getSVGDocumentCallback}, - {"mutablePointFunction", TestObjInternal::mutablePointFunctionCallback}, - {"immutablePointFunction", TestObjInternal::immutablePointFunctionCallback}, - {"orange", TestObjInternal::orangeCallback}, - {"strictFunction", TestObjInternal::strictFunctionCallback}, + {"overloadedMethod", TestObjV8Internal::overloadedMethodCallback}, + {"getSVGDocument", TestObjV8Internal::getSVGDocumentCallback}, + {"mutablePointFunction", TestObjV8Internal::mutablePointFunctionCallback}, + {"immutablePointFunction", TestObjV8Internal::immutablePointFunctionCallback}, + {"orange", TestObjV8Internal::orangeCallback}, + {"strictFunction", TestObjV8Internal::strictFunctionCallback}, }; static const BatchedConstant TestObjConsts[] = { @@ -1948,13 +2238,17 @@ v8::Handle<v8::Value> V8TestObj::constructorCallback(const v8::Arguments& args) if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) return args.Holder(); + if (args.Length() < 1) + return V8Proxy::throwNotEnoughArgumentsError(); + if (args.Length() <= 0 || !args[0]->IsFunction()) + return throwError(TYPE_MISMATCH_ERR); + RefPtr<TestCallback> testCallback = V8TestCallback::create(args[0], getScriptExecutionContext()); - RefPtr<TestObj> impl = TestObj::create(); + RefPtr<TestObj> impl = TestObj::create(testCallback); v8::Handle<v8::Object> wrapper = args.Holder(); V8DOMWrapper::setDOMWrapper(wrapper, &info, impl.get()); - impl->ref(); - V8DOMWrapper::setJSWrapperForDOMObject(impl.get(), v8::Persistent<v8::Object>::New(wrapper)); + V8DOMWrapper::setJSWrapperForDOMObject(impl.release(), v8::Persistent<v8::Object>::New(wrapper), args.GetIsolate()); return args.Holder(); } @@ -1976,13 +2270,13 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi if (RuntimeEnabledFeatures::enabledAtRuntimeAttr1Enabled()) { static const BatchedAttribute attrData =\ // Attribute 'enabledAtRuntimeAttr1' (Type: 'attribute' ExtAttr: 'V8EnabledAtRuntime') - {"enabledAtRuntimeAttr1", TestObjInternal::enabledAtRuntimeAttr1AttrGetter, TestObjInternal::enabledAtRuntimeAttr1AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; + {"enabledAtRuntimeAttr1", TestObjV8Internal::enabledAtRuntimeAttr1AttrGetter, TestObjV8Internal::enabledAtRuntimeAttr1AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; configureAttribute(instance, proto, attrData); } if (RuntimeEnabledFeatures::featureNameEnabled()) { static const BatchedAttribute attrData =\ // Attribute 'enabledAtRuntimeAttr2' (Type: 'attribute' ExtAttr: 'V8EnabledAtRuntime') - {"enabledAtRuntimeAttr2", TestObjInternal::enabledAtRuntimeAttr2AttrGetter, TestObjInternal::enabledAtRuntimeAttr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; + {"enabledAtRuntimeAttr2", TestObjV8Internal::enabledAtRuntimeAttr2AttrGetter, TestObjV8Internal::enabledAtRuntimeAttr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; configureAttribute(instance, proto, attrData); } @@ -1990,65 +2284,71 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi const int voidMethodWithArgsArgc = 3; v8::Handle<v8::FunctionTemplate> voidMethodWithArgsArgv[voidMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; v8::Handle<v8::Signature> voidMethodWithArgsSignature = v8::Signature::New(desc, voidMethodWithArgsArgc, voidMethodWithArgsArgv); - proto->Set(v8::String::New("voidMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::voidMethodWithArgsCallback, v8::Handle<v8::Value>(), voidMethodWithArgsSignature)); + proto->Set(v8::String::New("voidMethodWithArgs"), v8::FunctionTemplate::New(TestObjV8Internal::voidMethodWithArgsCallback, v8::Handle<v8::Value>(), voidMethodWithArgsSignature)); // Custom Signature 'intMethodWithArgs' const int intMethodWithArgsArgc = 3; v8::Handle<v8::FunctionTemplate> intMethodWithArgsArgv[intMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; v8::Handle<v8::Signature> intMethodWithArgsSignature = v8::Signature::New(desc, intMethodWithArgsArgc, intMethodWithArgsArgv); - proto->Set(v8::String::New("intMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::intMethodWithArgsCallback, v8::Handle<v8::Value>(), intMethodWithArgsSignature)); + proto->Set(v8::String::New("intMethodWithArgs"), v8::FunctionTemplate::New(TestObjV8Internal::intMethodWithArgsCallback, v8::Handle<v8::Value>(), intMethodWithArgsSignature)); // Custom Signature 'objMethodWithArgs' const int objMethodWithArgsArgc = 3; v8::Handle<v8::FunctionTemplate> objMethodWithArgsArgv[objMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; v8::Handle<v8::Signature> objMethodWithArgsSignature = v8::Signature::New(desc, objMethodWithArgsArgc, objMethodWithArgsArgv); - proto->Set(v8::String::New("objMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::objMethodWithArgsCallback, v8::Handle<v8::Value>(), objMethodWithArgsSignature)); + proto->Set(v8::String::New("objMethodWithArgs"), v8::FunctionTemplate::New(TestObjV8Internal::objMethodWithArgsCallback, v8::Handle<v8::Value>(), objMethodWithArgsSignature)); + + // Custom Signature 'methodWithSequenceArg' + const int methodWithSequenceArgArgc = 1; + v8::Handle<v8::FunctionTemplate> methodWithSequenceArgArgv[methodWithSequenceArgArgc] = { V8sequence<ScriptProfile>::GetRawTemplate() }; + v8::Handle<v8::Signature> methodWithSequenceArgSignature = v8::Signature::New(desc, methodWithSequenceArgArgc, methodWithSequenceArgArgv); + proto->Set(v8::String::New("methodWithSequenceArg"), v8::FunctionTemplate::New(TestObjV8Internal::methodWithSequenceArgCallback, v8::Handle<v8::Value>(), methodWithSequenceArgSignature)); // Custom Signature 'methodThatRequiresAllArgsAndThrows' const int methodThatRequiresAllArgsAndThrowsArgc = 2; v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsAndThrowsArgv[methodThatRequiresAllArgsAndThrowsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; v8::Handle<v8::Signature> methodThatRequiresAllArgsAndThrowsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsAndThrowsArgc, methodThatRequiresAllArgsAndThrowsArgv); - proto->Set(v8::String::New("methodThatRequiresAllArgsAndThrows"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsAndThrowsSignature)); - desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjInternal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); - desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjInternal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); + proto->Set(v8::String::New("methodThatRequiresAllArgsAndThrows"), v8::FunctionTemplate::New(TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsAndThrowsSignature)); + desc->Set(v8::String::New("classMethod"), v8::FunctionTemplate::New(TestObjV8Internal::classMethodCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); + desc->Set(v8::String::New("classMethodWithOptional"), v8::FunctionTemplate::New(TestObjV8Internal::classMethodWithOptionalCallback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); desc->Set(v8::String::New("classMethod2"), v8::FunctionTemplate::New(V8TestObj::classMethod2Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); #if ENABLE(Condition1) - desc->Set(v8::String::New("overloadedMethod1"), v8::FunctionTemplate::New(TestObjInternal::overloadedMethod1Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); + desc->Set(v8::String::New("overloadedMethod1"), v8::FunctionTemplate::New(TestObjV8Internal::overloadedMethod1Callback, v8::Handle<v8::Value>(), v8::Local<v8::Signature>())); #endif // ENABLE(Condition1) if (RuntimeEnabledFeatures::enabledAtRuntimeMethod1Enabled()) - proto->Set(v8::String::New("enabledAtRuntimeMethod1"), v8::FunctionTemplate::New(TestObjInternal::enabledAtRuntimeMethod1Callback, v8::Handle<v8::Value>(), defaultSignature)); + proto->Set(v8::String::New("enabledAtRuntimeMethod1"), v8::FunctionTemplate::New(TestObjV8Internal::enabledAtRuntimeMethod1Callback, v8::Handle<v8::Value>(), defaultSignature)); if (RuntimeEnabledFeatures::featureNameEnabled()) - proto->Set(v8::String::New("enabledAtRuntimeMethod2"), v8::FunctionTemplate::New(TestObjInternal::enabledAtRuntimeMethod2Callback, v8::Handle<v8::Value>(), defaultSignature)); + proto->Set(v8::String::New("enabledAtRuntimeMethod2"), v8::FunctionTemplate::New(TestObjV8Internal::enabledAtRuntimeMethod2Callback, v8::Handle<v8::Value>(), defaultSignature)); // Custom Signature 'convert1' const int convert1Argc = 1; v8::Handle<v8::FunctionTemplate> convert1Argv[convert1Argc] = { V8a::GetRawTemplate() }; v8::Handle<v8::Signature> convert1Signature = v8::Signature::New(desc, convert1Argc, convert1Argv); - proto->Set(v8::String::New("convert1"), v8::FunctionTemplate::New(TestObjInternal::convert1Callback, v8::Handle<v8::Value>(), convert1Signature)); + proto->Set(v8::String::New("convert1"), v8::FunctionTemplate::New(TestObjV8Internal::convert1Callback, v8::Handle<v8::Value>(), convert1Signature)); // Custom Signature 'convert2' const int convert2Argc = 1; v8::Handle<v8::FunctionTemplate> convert2Argv[convert2Argc] = { V8b::GetRawTemplate() }; v8::Handle<v8::Signature> convert2Signature = v8::Signature::New(desc, convert2Argc, convert2Argv); - proto->Set(v8::String::New("convert2"), v8::FunctionTemplate::New(TestObjInternal::convert2Callback, v8::Handle<v8::Value>(), convert2Signature)); + proto->Set(v8::String::New("convert2"), v8::FunctionTemplate::New(TestObjV8Internal::convert2Callback, v8::Handle<v8::Value>(), convert2Signature)); // Custom Signature 'convert3' const int convert3Argc = 1; v8::Handle<v8::FunctionTemplate> convert3Argv[convert3Argc] = { V8c::GetRawTemplate() }; v8::Handle<v8::Signature> convert3Signature = v8::Signature::New(desc, convert3Argc, convert3Argv); - proto->Set(v8::String::New("convert3"), v8::FunctionTemplate::New(TestObjInternal::convert3Callback, v8::Handle<v8::Value>(), convert3Signature)); + proto->Set(v8::String::New("convert3"), v8::FunctionTemplate::New(TestObjV8Internal::convert3Callback, v8::Handle<v8::Value>(), convert3Signature)); // Custom Signature 'convert4' const int convert4Argc = 1; v8::Handle<v8::FunctionTemplate> convert4Argv[convert4Argc] = { V8d::GetRawTemplate() }; v8::Handle<v8::Signature> convert4Signature = v8::Signature::New(desc, convert4Argc, convert4Argv); - proto->Set(v8::String::New("convert4"), v8::FunctionTemplate::New(TestObjInternal::convert4Callback, v8::Handle<v8::Value>(), convert4Signature)); + proto->Set(v8::String::New("convert4"), v8::FunctionTemplate::New(TestObjV8Internal::convert4Callback, v8::Handle<v8::Value>(), convert4Signature)); // Custom Signature 'convert5' const int convert5Argc = 1; v8::Handle<v8::FunctionTemplate> convert5Argv[convert5Argc] = { V8e::GetRawTemplate() }; v8::Handle<v8::Signature> convert5Signature = v8::Signature::New(desc, convert5Argc, convert5Argv); - proto->Set(v8::String::New("convert5"), v8::FunctionTemplate::New(TestObjInternal::convert5Callback, v8::Handle<v8::Value>(), convert5Signature)); + proto->Set(v8::String::New("convert5"), v8::FunctionTemplate::New(TestObjV8Internal::convert5Callback, v8::Handle<v8::Value>(), convert5Signature)); batchConfigureConstants(desc, proto, TestObjConsts, WTF_ARRAY_LENGTH(TestObjConsts)); // Custom toString template @@ -2089,20 +2389,19 @@ bool V8TestObj::HasInstance(v8::Handle<v8::Value> value) } -v8::Handle<v8::Object> V8TestObj::wrapSlow(TestObj* impl) +v8::Handle<v8::Object> V8TestObj::wrapSlow(PassRefPtr<TestObj> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h index e59dab8c9..78f718d55 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h @@ -40,7 +40,7 @@ public: { return reinterpret_cast<TestObj*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestObj*); + inline static v8::Handle<v8::Object> wrap(TestObj*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static v8::Handle<v8::Value> customMethodCallback(const v8::Arguments&); @@ -50,34 +50,27 @@ public: static v8::Handle<v8::Value> customAttrAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo&); static void customAttrAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(TestObj*); - private: - static v8::Handle<v8::Object> wrapSlow(TestObj*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestObj>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestObj::existingWrapper(TestObj* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestObj::wrap(TestObj* impl) +v8::Handle<v8::Object> V8TestObj::wrap(TestObj* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestObj::wrapSlow(impl); + return V8TestObj::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestObj* impl) +inline v8::Handle<v8::Value> toV8(TestObj* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestObj::wrap(impl); + return V8TestObj::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestObj > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestObj > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp index f329ab0f3..a99a0cf54 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp @@ -24,21 +24,24 @@ #if ENABLE(Condition1) || ENABLE(Condition2) #include "ExceptionCode.h" +#include "MessagePort.h" #include "RuntimeEnabledFeatures.h" #include "SerializedScriptValue.h" +#include "V8Array.h" #include "V8Binding.h" #include "V8BindingMacros.h" #include "V8BindingState.h" #include "V8DOMWrapper.h" #include "V8IsolatedContext.h" #include "V8Proxy.h" +#include <wtf/ArrayBuffer.h> #include <wtf/UnusedParam.h> namespace WebCore { WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0, 0 }; -namespace TestSerializedScriptValueInterfaceInternal { +namespace TestSerializedScriptValueInterfaceV8Internal { template <typename T> void V8_USE(T) { } @@ -53,7 +56,7 @@ static void valueAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> val { INC_STATS("DOM.TestSerializedScriptValueInterface.value._set"); TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder()); - RefPtr<SerializedScriptValue> v = SerializedScriptValue::create(value); + RefPtr<SerializedScriptValue> v = SerializedScriptValue::create(value, info.GetIsolate()); imp->setValue(WTF::getPtr(v)); return; } @@ -83,12 +86,26 @@ static void cachedValueAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Valu { INC_STATS("DOM.TestSerializedScriptValueInterface.cachedValue._set"); TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder()); - RefPtr<SerializedScriptValue> v = SerializedScriptValue::create(value); + RefPtr<SerializedScriptValue> v = SerializedScriptValue::create(value, info.GetIsolate()); imp->setCachedValue(WTF::getPtr(v)); info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("cachedValue")); // Invalidate the cached value. return; } +static v8::Handle<v8::Value> portsAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestSerializedScriptValueInterface.ports._get"); + TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(info.Holder()); + MessagePortArray* ports = imp->ports(); + if (!ports) + return v8::Array::New(0); + MessagePortArray portsCopy(*ports); + v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); + for (size_t i = 0; i < portsCopy.size(); ++i) + portArray->Set(v8::Integer::New(i), toV8(portsCopy[i].get(), info.GetIsolate())); + return portArray; +} + static v8::Handle<v8::Value> cachedReadonlyValueAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestSerializedScriptValueInterface.cachedReadonlyValue._get"); @@ -103,17 +120,92 @@ static v8::Handle<v8::Value> cachedReadonlyValueAttrGetter(v8::Local<v8::String> return value; } -} // namespace TestSerializedScriptValueInterfaceInternal +static v8::Handle<v8::Value> acceptTransferListCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestSerializedScriptValueInterface.acceptTransferList"); + if (args.Length() < 1) + return V8Proxy::throwNotEnoughArgumentsError(); + TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(args.Holder()); + MessagePortArray messagePortArrayTransferList; + ArrayBufferArray arrayBufferArrayTransferList; + if (args.Length() > 1) { + if (!extractTransferables(args[1], messagePortArrayTransferList, arrayBufferArrayTransferList)) + return throwError("Could not extract transferables", V8Proxy::TypeError); + } + bool dataDidThrow = false; + RefPtr<SerializedScriptValue> data = SerializedScriptValue::create(args[0], &messagePortArrayTransferList, &arrayBufferArrayTransferList, dataDidThrow, args.GetIsolate()); + if (dataDidThrow) + return v8::Undefined(); + if (args.Length() <= 1) { + imp->acceptTransferList(data); + return v8::Handle<v8::Value>(); + } + imp->acceptTransferList(data, messagePortArrayTransferList); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> multiTransferListCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestSerializedScriptValueInterface.multiTransferList"); + TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterface::toNative(args.Holder()); + if (args.Length() <= 0) { + imp->multiTransferList(); + return v8::Handle<v8::Value>(); + } + MessagePortArray messagePortArrayTx; + ArrayBufferArray arrayBufferArrayTx; + if (args.Length() > 1) { + if (!extractTransferables(args[1], messagePortArrayTx, arrayBufferArrayTx)) + return throwError("Could not extract transferables", V8Proxy::TypeError); + } + bool firstDidThrow = false; + RefPtr<SerializedScriptValue> first = SerializedScriptValue::create(args[0], &messagePortArrayTx, &arrayBufferArrayTx, firstDidThrow, args.GetIsolate()); + if (firstDidThrow) + return v8::Undefined(); + if (args.Length() <= 1) { + imp->multiTransferList(first); + return v8::Handle<v8::Value>(); + } + if (args.Length() <= 2) { + imp->multiTransferList(first, messagePortArrayTx); + return v8::Handle<v8::Value>(); + } + MessagePortArray messagePortArrayTxx; + ArrayBufferArray arrayBufferArrayTxx; + if (args.Length() > 3) { + if (!extractTransferables(args[3], messagePortArrayTxx, arrayBufferArrayTxx)) + return throwError("Could not extract transferables", V8Proxy::TypeError); + } + bool secondDidThrow = false; + RefPtr<SerializedScriptValue> second = SerializedScriptValue::create(args[2], &messagePortArrayTxx, &arrayBufferArrayTxx, secondDidThrow, args.GetIsolate()); + if (secondDidThrow) + return v8::Undefined(); + if (args.Length() <= 3) { + imp->multiTransferList(first, messagePortArrayTx, second); + return v8::Handle<v8::Value>(); + } + imp->multiTransferList(first, messagePortArrayTx, second, messagePortArrayTxx); + return v8::Handle<v8::Value>(); +} + +} // namespace TestSerializedScriptValueInterfaceV8Internal static const BatchedAttribute TestSerializedScriptValueInterfaceAttrs[] = { // Attribute 'value' (Type: 'attribute' ExtAttr: '') - {"value", TestSerializedScriptValueInterfaceInternal::valueAttrGetter, TestSerializedScriptValueInterfaceInternal::valueAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"value", TestSerializedScriptValueInterfaceV8Internal::valueAttrGetter, TestSerializedScriptValueInterfaceV8Internal::valueAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'readonlyValue' (Type: 'readonly attribute' ExtAttr: '') - {"readonlyValue", TestSerializedScriptValueInterfaceInternal::readonlyValueAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"readonlyValue", TestSerializedScriptValueInterfaceV8Internal::readonlyValueAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'cachedValue' (Type: 'attribute' ExtAttr: 'CachedAttribute') - {"cachedValue", TestSerializedScriptValueInterfaceInternal::cachedValueAttrGetter, TestSerializedScriptValueInterfaceInternal::cachedValueAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"cachedValue", TestSerializedScriptValueInterfaceV8Internal::cachedValueAttrGetter, TestSerializedScriptValueInterfaceV8Internal::cachedValueAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'ports' (Type: 'readonly attribute' ExtAttr: '') + {"ports", TestSerializedScriptValueInterfaceV8Internal::portsAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'cachedReadonlyValue' (Type: 'readonly attribute' ExtAttr: 'CachedAttribute') - {"cachedReadonlyValue", TestSerializedScriptValueInterfaceInternal::cachedReadonlyValueAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + {"cachedReadonlyValue", TestSerializedScriptValueInterfaceV8Internal::cachedReadonlyValueAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +}; + +static const BatchedCallback TestSerializedScriptValueInterfaceCallbacks[] = { + {"acceptTransferList", TestSerializedScriptValueInterfaceV8Internal::acceptTransferListCallback}, + {"multiTransferList", TestSerializedScriptValueInterfaceV8Internal::multiTransferListCallback}, }; v8::Handle<v8::Value> V8TestSerializedScriptValueInterface::constructorCallback(const v8::Arguments& args) @@ -126,19 +218,24 @@ v8::Handle<v8::Value> V8TestSerializedScriptValueInterface::constructorCallback( if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) return args.Holder(); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, hello, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); - bool valueDidThrow = false; - RefPtr<SerializedScriptValue> value = SerializedScriptValue::create(args[1], 0, 0, valueDidThrow); - if (valueDidThrow) + MessagePortArray messagePortArrayTransferList; + ArrayBufferArray arrayBufferArrayTransferList; + if (args.Length() > 2) { + if (!extractTransferables(args[2], messagePortArrayTransferList, arrayBufferArrayTransferList)) + return throwError("Could not extract transferables", V8Proxy::TypeError); + } + bool dataDidThrow = false; + RefPtr<SerializedScriptValue> data = SerializedScriptValue::create(args[1], &messagePortArrayTransferList, &arrayBufferArrayTransferList, dataDidThrow, args.GetIsolate()); + if (dataDidThrow) return v8::Undefined(); - RefPtr<TestSerializedScriptValueInterface> impl = TestSerializedScriptValueInterface::create(hello, value); + RefPtr<TestSerializedScriptValueInterface> impl = TestSerializedScriptValueInterface::create(hello, data, messagePortArrayTransferList); v8::Handle<v8::Object> wrapper = args.Holder(); V8DOMWrapper::setDOMWrapper(wrapper, &info, impl.get()); - impl->ref(); - V8DOMWrapper::setJSWrapperForDOMObject(impl.get(), v8::Persistent<v8::Object>::New(wrapper)); + V8DOMWrapper::setJSWrapperForDOMObject(impl.release(), v8::Persistent<v8::Object>::New(wrapper), args.GetIsolate()); return args.Holder(); } @@ -149,9 +246,13 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestSerializedScriptValue v8::Local<v8::Signature> defaultSignature; defaultSignature = configureTemplate(desc, "TestSerializedScriptValueInterface", v8::Persistent<v8::FunctionTemplate>(), V8TestSerializedScriptValueInterface::internalFieldCount, TestSerializedScriptValueInterfaceAttrs, WTF_ARRAY_LENGTH(TestSerializedScriptValueInterfaceAttrs), - 0, 0); + TestSerializedScriptValueInterfaceCallbacks, WTF_ARRAY_LENGTH(TestSerializedScriptValueInterfaceCallbacks)); UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. desc->SetCallHandler(V8TestSerializedScriptValueInterface::constructorCallback); + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); + UNUSED_PARAM(instance); // In some cases, it will not be used. + UNUSED_PARAM(proto); // In some cases, it will not be used. // Custom toString template @@ -192,20 +293,19 @@ bool V8TestSerializedScriptValueInterface::HasInstance(v8::Handle<v8::Value> val } -v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::wrapSlow(TestSerializedScriptValueInterface* impl) +v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::wrapSlow(PassRefPtr<TestSerializedScriptValueInterface> impl, v8::Isolate* isolate) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; - wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get()); if (UNLIKELY(wrapper.IsEmpty())) return wrapper; - impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); - getDOMObjectMap().set(impl, wrapperHandle); + V8DOMWrapper::setJSWrapperForDOMObject(impl, wrapperHandle, isolate); return wrapper; } diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h index abd5ddf6d..bd6d9e612 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h @@ -42,39 +42,32 @@ public: { return reinterpret_cast<TestSerializedScriptValueInterface*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } - inline static v8::Handle<v8::Object> wrap(TestSerializedScriptValueInterface*); + inline static v8::Handle<v8::Object> wrap(TestSerializedScriptValueInterface*, v8::Isolate* = 0); static void derefObject(void*); static WrapperTypeInfo info; static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&); static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; - static v8::Handle<v8::Object> existingWrapper(TestSerializedScriptValueInterface*); - private: - static v8::Handle<v8::Object> wrapSlow(TestSerializedScriptValueInterface*); + static v8::Handle<v8::Object> wrapSlow(PassRefPtr<TestSerializedScriptValueInterface>, v8::Isolate*); }; -ALWAYS_INLINE v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::existingWrapper(TestSerializedScriptValueInterface* impl) -{ - return getDOMObjectMap().get(impl); -} - -v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::wrap(TestSerializedScriptValueInterface* impl) +v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::wrap(TestSerializedScriptValueInterface* impl, v8::Isolate* isolate) { - v8::Handle<v8::Object> wrapper = existingWrapper(impl); + v8::Handle<v8::Object> wrapper = getDOMObjectMap(isolate).get(impl); if (!wrapper.IsEmpty()) return wrapper; - return V8TestSerializedScriptValueInterface::wrapSlow(impl); + return V8TestSerializedScriptValueInterface::wrapSlow(impl, isolate); } -inline v8::Handle<v8::Value> toV8(TestSerializedScriptValueInterface* impl) +inline v8::Handle<v8::Value> toV8(TestSerializedScriptValueInterface* impl, v8::Isolate* isolate = 0) { if (!impl) return v8::Null(); - return V8TestSerializedScriptValueInterface::wrap(impl); + return V8TestSerializedScriptValueInterface::wrap(impl, isolate); } -inline v8::Handle<v8::Value> toV8(PassRefPtr< TestSerializedScriptValueInterface > impl) +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestSerializedScriptValueInterface > impl, v8::Isolate* isolate = 0) { - return toV8(impl.get()); + return toV8(impl.get(), isolate); } } diff --git a/Source/WebCore/bindings/v8/DOMData.cpp b/Source/WebCore/bindings/v8/DOMData.cpp index ab5c2123d..9c84b5386 100644 --- a/Source/WebCore/bindings/v8/DOMData.cpp +++ b/Source/WebCore/bindings/v8/DOMData.cpp @@ -37,21 +37,16 @@ namespace WebCore { -static StaticDOMDataStore& getDefaultStore() +DOMDataStore& DOMData::getCurrentStore(v8::Isolate* isolate) { DEFINE_STATIC_LOCAL(StaticDOMDataStore, defaultStore, ()); - return defaultStore; -} - -DOMDataStore& DOMData::getCurrentStore() -{ - V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); + V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(isolate); if (UNLIKELY(data->domDataStore() != 0)) return *data->domDataStore(); V8IsolatedContext* context = V8IsolatedContext::getEntered(); if (UNLIKELY(context != 0)) return *context->world()->domDataStore(); - return getDefaultStore(); + return defaultStore; } void DOMData::derefObject(WrapperTypeInfo* type, void* domObject) diff --git a/Source/WebCore/bindings/v8/DOMData.h b/Source/WebCore/bindings/v8/DOMData.h index 71e7e58ac..7df9dfdba 100644 --- a/Source/WebCore/bindings/v8/DOMData.h +++ b/Source/WebCore/bindings/v8/DOMData.h @@ -53,7 +53,7 @@ namespace WebCore { static void removeObjectsFromWrapperMap(DOMDataStore* store, AbstractWeakReferenceMap<T, v8::Object>& domMap); - static DOMDataStore& getCurrentStore(); + static DOMDataStore& getCurrentStore(v8::Isolate* = 0); private: DOMData(); static void derefObject(WrapperTypeInfo* type, void* domObject); diff --git a/Source/WebCore/bindings/v8/DOMDataStore.cpp b/Source/WebCore/bindings/v8/DOMDataStore.cpp index f421f6905..2d5b5e633 100644 --- a/Source/WebCore/bindings/v8/DOMDataStore.cpp +++ b/Source/WebCore/bindings/v8/DOMDataStore.cpp @@ -89,9 +89,6 @@ DOMDataStore::DOMDataStore() , m_activeDomNodeMap(0) , m_domObjectMap(0) , m_activeDomObjectMap(0) -#if ENABLE(SVG) - , m_domSvgElementInstanceMap(0) -#endif { } @@ -115,10 +112,6 @@ void* DOMDataStore::getDOMWrapperMap(DOMWrapperMapType type) return m_domObjectMap; case ActiveDOMObjectMap: return m_activeDomObjectMap; -#if ENABLE(SVG) - case DOMSVGElementInstanceMap: - return m_domSvgElementInstanceMap; -#endif } ASSERT_NOT_REACHED(); @@ -165,15 +158,4 @@ void DOMDataStore::weakNodeCallback(v8::Persistent<v8::Value> value, void* domOb node->deref(); // Nobody overrides Node::deref so it's safe } -#if ENABLE(SVG) - -void DOMDataStore::weakSVGElementInstanceCallback(v8::Persistent<v8::Value> v8Object, void* domObject) -{ - v8::HandleScope scope; - ASSERT(v8Object->IsObject()); - DOMData::handleWeakObject(DOMDataStore::DOMSVGElementInstanceMap, v8::Persistent<v8::Object>::Cast(v8Object), static_cast<SVGElementInstance*>(domObject)); -} - -#endif // ENABLE(SVG) - } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/DOMDataStore.h b/Source/WebCore/bindings/v8/DOMDataStore.h index c57f8b729..089d86d4f 100644 --- a/Source/WebCore/bindings/v8/DOMDataStore.h +++ b/Source/WebCore/bindings/v8/DOMDataStore.h @@ -32,7 +32,6 @@ #define DOMDataStore_h #include "V8DOMMap.h" -#include "V8Node.h" #include <v8.h> #include <wtf/HashMap.h> @@ -68,9 +67,6 @@ namespace WebCore { ActiveDOMNodeMap, DOMObjectMap, ActiveDOMObjectMap, -#if ENABLE(SVG) - DOMSVGElementInstanceMap -#endif }; DOMDataStore(); @@ -85,9 +81,6 @@ namespace WebCore { DOMNodeMapping& activeDomNodeMap() { return *m_activeDomNodeMap; } DOMWrapperMap<void>& domObjectMap() { return *m_domObjectMap; } DOMWrapperMap<void>& activeDomObjectMap() { return *m_activeDomObjectMap; } -#if ENABLE(SVG) - DOMWrapperMap<SVGElementInstance>& domSvgElementInstanceMap() { return *m_domSvgElementInstanceMap; } -#endif // Need by V8GCController. static void weakActiveDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject); @@ -95,17 +88,11 @@ namespace WebCore { protected: static void weakDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject); -#if ENABLE(SVG) - static void weakSVGElementInstanceCallback(v8::Persistent<v8::Value> v8Object, void* domObject); -#endif - + DOMNodeMapping* m_domNodeMap; DOMNodeMapping* m_activeDomNodeMap; DOMWrapperMap<void>* m_domObjectMap; DOMWrapperMap<void>* m_activeDomObjectMap; -#if ENABLE(SVG) - DOMWrapperMap<SVGElementInstance>* m_domSvgElementInstanceMap; -#endif }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/DateExtension.cpp b/Source/WebCore/bindings/v8/DateExtension.cpp index 332828b22..ca363c2ef 100644 --- a/Source/WebCore/bindings/v8/DateExtension.cpp +++ b/Source/WebCore/bindings/v8/DateExtension.cpp @@ -31,8 +31,9 @@ #include "config.h" #include "DateExtension.h" -#include "V8Proxy.h" #include "V8HiddenPropertyName.h" +#include "V8Proxy.h" +#include "V8RecursionScope.h" namespace WebCore { @@ -89,6 +90,7 @@ void DateExtension::setAllowSleep(bool allow) v8::Handle<v8::Value> argv[1]; argv[0] = v8::Boolean::New(!allow); + V8RecursionScope::MicrotaskSuppression scope; v8::Handle<v8::Function>::Cast(sleepFunctionHandle)->Call(v8::Object::New(), 1, argv); } diff --git a/Source/WebCore/bindings/v8/OptionsObject.cpp b/Source/WebCore/bindings/v8/Dictionary.cpp index e8c7dd9cc..10aafe8dc 100644 --- a/Source/WebCore/bindings/v8/OptionsObject.cpp +++ b/Source/WebCore/bindings/v8/Dictionary.cpp @@ -24,12 +24,13 @@ */ #include "config.h" -#include "OptionsObject.h" +#include "Dictionary.h" #include "DOMStringList.h" #include "V8Binding.h" #include "V8DOMWindow.h" #include "V8Storage.h" +#include "V8Uint8Array.h" #include "V8Utilities.h" #include <wtf/MathExtras.h> @@ -38,6 +39,10 @@ #include "V8IDBKeyRange.h" #endif +#if ENABLE(ENCRYPTED_MEDIA) +#include "V8MediaKeyError.h" +#endif + #if ENABLE(VIDEO_TRACK) #include "TrackBase.h" #include "V8TextTrack.h" @@ -54,38 +59,38 @@ namespace WebCore { -OptionsObject::OptionsObject() +Dictionary::Dictionary() { } -OptionsObject::OptionsObject(const v8::Local<v8::Value>& options) +Dictionary::Dictionary(const v8::Local<v8::Value>& options) : m_options(options) { } -OptionsObject::~OptionsObject() +Dictionary::~Dictionary() { } -OptionsObject& OptionsObject::operator=(const OptionsObject& optionsObject) +Dictionary& Dictionary::operator=(const Dictionary& optionsObject) { m_options = optionsObject.m_options; return *this; } -bool OptionsObject::isObject() const +bool Dictionary::isObject() const { return !isUndefinedOrNull() && m_options->IsObject(); } -bool OptionsObject::isUndefinedOrNull() const +bool Dictionary::isUndefinedOrNull() const { if (m_options.IsEmpty()) return true; return WebCore::isUndefinedOrNull(m_options); } -bool OptionsObject::getKey(const String& key, v8::Local<v8::Value>& value) const +bool Dictionary::getKey(const String& key, v8::Local<v8::Value>& value) const { if (isUndefinedOrNull()) return false; @@ -101,7 +106,7 @@ bool OptionsObject::getKey(const String& key, v8::Local<v8::Value>& value) const return true; } -bool OptionsObject::get(const String& key, bool& value) const +bool Dictionary::get(const String& key, bool& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -114,7 +119,7 @@ bool OptionsObject::get(const String& key, bool& value) const return true; } -bool OptionsObject::get(const String& key, int32_t& value) const +bool Dictionary::get(const String& key, int32_t& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -127,7 +132,7 @@ bool OptionsObject::get(const String& key, int32_t& value) const return true; } -bool OptionsObject::get(const String& key, double& value) const +bool Dictionary::get(const String& key, double& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -140,7 +145,7 @@ bool OptionsObject::get(const String& key, double& value) const return true; } -bool OptionsObject::get(const String& key, String& value) const +bool Dictionary::get(const String& key, String& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -154,7 +159,7 @@ bool OptionsObject::get(const String& key, String& value) const return true; } -bool OptionsObject::get(const String& key, ScriptValue& value) const +bool Dictionary::get(const String& key, ScriptValue& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -164,7 +169,7 @@ bool OptionsObject::get(const String& key, ScriptValue& value) const return true; } -bool OptionsObject::get(const String& key, unsigned short& value) const +bool Dictionary::get(const String& key, unsigned short& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -177,7 +182,7 @@ bool OptionsObject::get(const String& key, unsigned short& value) const return true; } -bool OptionsObject::get(const String& key, short& value) const +bool Dictionary::get(const String& key, short& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -190,7 +195,7 @@ bool OptionsObject::get(const String& key, short& value) const return true; } -bool OptionsObject::get(const String& key, unsigned& value) const +bool Dictionary::get(const String& key, unsigned& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -203,7 +208,7 @@ bool OptionsObject::get(const String& key, unsigned& value) const return true; } -bool OptionsObject::get(const String& key, unsigned long long& value) const +bool Dictionary::get(const String& key, unsigned long long& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -217,7 +222,7 @@ bool OptionsObject::get(const String& key, unsigned long long& value) const return true; } -bool OptionsObject::get(const String& key, RefPtr<DOMWindow>& value) const +bool Dictionary::get(const String& key, RefPtr<DOMWindow>& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -234,7 +239,7 @@ bool OptionsObject::get(const String& key, RefPtr<DOMWindow>& value) const return true; } -bool OptionsObject::get(const String& key, RefPtr<Storage>& value) const +bool Dictionary::get(const String& key, RefPtr<Storage>& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -251,7 +256,7 @@ bool OptionsObject::get(const String& key, RefPtr<Storage>& value) const return true; } -bool OptionsObject::get(const String& key, MessagePortArray& value) const +bool Dictionary::get(const String& key, MessagePortArray& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -260,7 +265,7 @@ bool OptionsObject::get(const String& key, MessagePortArray& value) const return getMessagePortArray(v8Value, value); } -bool OptionsObject::get(const String& key, HashSet<AtomicString>& value) const +bool Dictionary::get(const String& key, HashSet<AtomicString>& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -279,7 +284,7 @@ bool OptionsObject::get(const String& key, HashSet<AtomicString>& value) const return true; } -bool OptionsObject::getWithUndefinedOrNullCheck(const String& key, String& value) const +bool Dictionary::getWithUndefinedOrNullCheck(const String& key, String& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value) || v8Value->IsNull() || v8Value->IsUndefined()) @@ -293,8 +298,46 @@ bool OptionsObject::getWithUndefinedOrNullCheck(const String& key, String& value return true; } +bool Dictionary::get(const String& key, RefPtr<Uint8Array>& value) const +{ + v8::Local<v8::Value> v8Value; + if (!getKey(key, v8Value)) + return false; + + Uint8Array* source = 0; + if (v8Value->IsObject()) { + v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); + + v8::Handle<v8::Object> array = V8DOMWrapper::lookupDOMWrapper(V8Uint8Array::GetTemplate(), wrapper); + if (!array.IsEmpty()) + source = V8Uint8Array::toNative(array); + } + value = source; + return true; +} + +#if ENABLE(ENCRYPTED_MEDIA) +bool Dictionary::get(const String& key, RefPtr<MediaKeyError>& value) const +{ + v8::Local<v8::Value> v8Value; + if (!getKey(key, v8Value)) + return false; + + MediaKeyError* source = 0; + if (v8Value->IsObject()) { + v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); + + v8::Handle<v8::Object> error = V8DOMWrapper::lookupDOMWrapper(V8MediaKeyError::GetTemplate(), wrapper); + if (!error.IsEmpty()) + source = V8MediaKeyError::toNative(error); + } + value = source; + return true; +} +#endif + #if ENABLE(VIDEO_TRACK) -bool OptionsObject::get(const String& key, RefPtr<TrackBase>& value) const +bool Dictionary::get(const String& key, RefPtr<TrackBase>& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -316,7 +359,7 @@ bool OptionsObject::get(const String& key, RefPtr<TrackBase>& value) const #endif #if ENABLE(SCRIPTED_SPEECH) -bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionError>& value) const +bool Dictionary::get(const String& key, RefPtr<SpeechRecognitionError>& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -333,7 +376,7 @@ bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionError>& value return true; } -bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionResult>& value) const +bool Dictionary::get(const String& key, RefPtr<SpeechRecognitionResult>& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -350,7 +393,7 @@ bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionResult>& valu return true; } -bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionResultList>& value) const +bool Dictionary::get(const String& key, RefPtr<SpeechRecognitionResultList>& value) const { v8::Local<v8::Value> v8Value; if (!getKey(key, v8Value)) @@ -369,4 +412,44 @@ bool OptionsObject::get(const String& key, RefPtr<SpeechRecognitionResultList>& #endif +bool Dictionary::get(const String& key, Dictionary& value) const +{ + v8::Local<v8::Value> v8Value; + if (!getKey(key, v8Value)) + return false; + + if (v8Value->IsObject()) + value = Dictionary(v8Value); + + return true; +} + + +bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& hashMap) const +{ + if (!isObject()) + return false; + + v8::Handle<v8::Object> options = m_options->ToObject(); + if (options.IsEmpty()) + return false; + + v8::Local<v8::Array> properties = options->GetOwnPropertyNames(); + if (properties.IsEmpty()) + return true; + for (uint32_t i = 0; i < properties->Length(); ++i) { + v8::Local<v8::String> key = properties->Get(i)->ToString(); + if (!options->Has(key)) + continue; + + v8::Local<v8::Value> value = options->Get(key); + String stringKey = v8ValueToWebCoreString(key); + String stringValue = v8ValueToWebCoreString(value); + if (!stringKey.isEmpty()) + hashMap.set(stringKey, stringValue); + } + + return true; +} + } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/OptionsObject.h b/Source/WebCore/bindings/v8/Dictionary.h index 326037816..c4c33b1bb 100644 --- a/Source/WebCore/bindings/v8/OptionsObject.h +++ b/Source/WebCore/bindings/v8/Dictionary.h @@ -23,13 +23,15 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef OptionsObject_h -#define OptionsObject_h +#ifndef Dictionary_h +#define Dictionary_h +#include "EventListener.h" #include "MessagePort.h" #include "PlatformString.h" #include "ScriptValue.h" #include <v8.h> +#include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/text/AtomicString.h> @@ -38,19 +40,21 @@ namespace WebCore { class DOMStringList; class DOMWindow; class IDBKeyRange; -class Storage; -class TrackBase; +class MediaKeyError; +class Notification; class SpeechRecognitionError; class SpeechRecognitionResult; class SpeechRecognitionResultList; +class Storage; +class TrackBase; -class OptionsObject { +class Dictionary { public: - OptionsObject(); - OptionsObject(const v8::Local<v8::Value>& options); - ~OptionsObject(); + Dictionary(); + Dictionary(const v8::Local<v8::Value>& options); + ~Dictionary(); - OptionsObject& operator=(const OptionsObject&); + Dictionary& operator=(const Dictionary&); bool isObject() const; bool isUndefinedOrNull() const; @@ -67,6 +71,10 @@ public: bool get(const String&, RefPtr<DOMWindow>&) const; bool get(const String&, RefPtr<Storage>&) const; bool get(const String&, MessagePortArray&) const; + bool get(const String&, RefPtr<Uint8Array>&) const; +#if ENABLE(ENCRYPTED_MEDIA) + bool get(const String&, RefPtr<MediaKeyError>&) const; +#endif #if ENABLE(VIDEO_TRACK) bool get(const String&, RefPtr<TrackBase>&) const; #endif @@ -76,9 +84,13 @@ public: bool get(const String&, RefPtr<SpeechRecognitionResultList>&) const; #endif bool get(const String&, HashSet<AtomicString>&) const; + bool get(const String&, Dictionary&) const; + bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const; bool getWithUndefinedOrNullCheck(const String&, String&) const; + PassRefPtr<EventListener> getEventListener(const String&, Notification*) const { return 0; } + private: bool getKey(const String& key, v8::Local<v8::Value>&) const; @@ -92,4 +104,4 @@ private: } -#endif // OptionsObject_h +#endif // Dictionary_h diff --git a/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp b/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp index 9e6b12848..df6778030 100644 --- a/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp +++ b/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp @@ -106,6 +106,11 @@ bool setValue(v8::Handle<v8::Value>& v8Object, T indexOrName, const v8::Handle<v bool get(v8::Handle<v8::Value>& object, const String& keyPathElement) { + if (object->IsString() && keyPathElement == "length") { + int32_t length = v8::Handle<v8::String>::Cast(object)->Length(); + object = v8::Number::New(length); + return true; + } return object->IsObject() && getValueFrom(v8String(keyPathElement), object); } diff --git a/Source/WebCore/bindings/v8/NPV8Object.cpp b/Source/WebCore/bindings/v8/NPV8Object.cpp index dfb98ce39..5c3359377 100644 --- a/Source/WebCore/bindings/v8/NPV8Object.cpp +++ b/Source/WebCore/bindings/v8/NPV8Object.cpp @@ -32,7 +32,7 @@ #include "DOMWindow.h" #include "Frame.h" #include "NPObjectWrapper.h" -#include "OwnArrayPtr.h" +#include <wtf/OwnArrayPtr.h> #include "PlatformString.h" #include "ScriptSourceCode.h" #include "UserGestureIndicator.h" @@ -163,7 +163,7 @@ NPObject* npCreateV8ScriptObject(NPP npp, v8::Handle<v8::Object> object, DOMWind } } } else { - iter = staticV8NPObjectMap()->set(v8ObjectHash, V8NPObjectVector()).first; + iter = staticV8NPObjectMap()->set(v8ObjectHash, V8NPObjectVector()).iterator; } V8NPObject* v8npObject = reinterpret_cast<V8NPObject*>(_NPN_CreateObject(npp, &V8NPObjectClass)); diff --git a/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp b/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp index 18f7df7ee..d9d97e7b6 100755 --- a/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp +++ b/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp @@ -39,6 +39,7 @@ #include "V8Binding.h" #include "V8DOMWindow.h" #include "V8Proxy.h" +#include "V8RecursionScope.h" #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/StdLibExtras.h> @@ -100,7 +101,11 @@ void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag v8::Handle<v8::Context> context = shell->context(); v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts"))); v8::Handle<v8::Value> argv[] = { context->GetData() }; - v8::Handle<v8::Value> value = getScriptsFunction->Call(m_debuggerScript.get(), 1, argv); + v8::Handle<v8::Value> value; + { + V8RecursionScope::MicrotaskSuppression scope; + value = getScriptsFunction->Call(m_debuggerScript.get(), 1, argv); + } if (value.IsEmpty()) return; ASSERT(!value->IsUndefined() && value->IsArray()); diff --git a/Source/WebCore/bindings/v8/SafeAllocation.h b/Source/WebCore/bindings/v8/SafeAllocation.h new file mode 100644 index 000000000..c3b34aebf --- /dev/null +++ b/Source/WebCore/bindings/v8/SafeAllocation.h @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2012 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 SafeAllocation_h +#define SafeAllocation_h + +#include "V8Binding.h" +#include "V8RecursionScope.h" + +#include <v8.h> + +namespace WebCore { + +class SafeAllocation { +public: + static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>); + static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::ObjectTemplate>); + static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]); +}; + +v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::Function> function) +{ + if (function.IsEmpty()) + return v8::Local<v8::Object>(); + ConstructorMode constructorMode; + V8RecursionScope::MicrotaskSuppression scope; + return function->NewInstance(); +} + +v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::ObjectTemplate> objectTemplate) +{ + if (objectTemplate.IsEmpty()) + return v8::Local<v8::Object>(); + ConstructorMode constructorMode; + V8RecursionScope::MicrotaskSuppression scope; + return objectTemplate->NewInstance(); +} + +v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[]) +{ + if (function.IsEmpty()) + return v8::Local<v8::Object>(); + ConstructorMode constructorMode; + V8RecursionScope::MicrotaskSuppression scope; + return function->NewInstance(argc, argv); +} + +} // namespace WebCore + +#endif // SafeAllocation_h diff --git a/Source/WebCore/bindings/v8/ScopedDOMDataStore.cpp b/Source/WebCore/bindings/v8/ScopedDOMDataStore.cpp index 666d0f7b7..38fe42983 100644 --- a/Source/WebCore/bindings/v8/ScopedDOMDataStore.cpp +++ b/Source/WebCore/bindings/v8/ScopedDOMDataStore.cpp @@ -40,9 +40,6 @@ ScopedDOMDataStore::ScopedDOMDataStore() m_activeDomNodeMap = new DOMWrapperMap<Node>(&DOMDataStore::weakNodeCallback); m_domObjectMap = new DOMWrapperMap<void>(&DOMDataStore::weakDOMObjectCallback); m_activeDomObjectMap = new DOMWrapperMap<void>(&DOMDataStore::weakActiveDOMObjectCallback); -#if ENABLE(SVG) - m_domSvgElementInstanceMap = new DOMWrapperMap<SVGElementInstance>(&DOMDataStore::weakSVGElementInstanceCallback); -#endif } ScopedDOMDataStore::~ScopedDOMDataStore() @@ -51,9 +48,6 @@ ScopedDOMDataStore::~ScopedDOMDataStore() delete m_activeDomNodeMap; delete m_domObjectMap; delete m_activeDomObjectMap; -#if ENABLE(SVG) - delete m_domSvgElementInstanceMap; -#endif } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/ScriptController.cpp b/Source/WebCore/bindings/v8/ScriptController.cpp index 8de95537a..e80e6c7a6 100644 --- a/Source/WebCore/bindings/v8/ScriptController.cpp +++ b/Source/WebCore/bindings/v8/ScriptController.cpp @@ -38,6 +38,7 @@ #include "ScriptCallStackFactory.h" #include "ScriptableDocumentParser.h" #include "DOMWindow.h" +#include "DOMWindowPagePopup.h" #include "Event.h" #include "EventListener.h" #include "EventNames.h" @@ -54,6 +55,7 @@ #include "Settings.h" #include "UserGestureIndicator.h" #include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8BindingState.h" #include "V8DOMWindow.h" #include "V8Event.h" @@ -62,12 +64,13 @@ #include "V8IsolatedContext.h" #include "V8NPObject.h" #include "V8Proxy.h" +#include "V8RecursionScope.h" #include "Widget.h" #include <wtf/StdLibExtras.h> #include <wtf/text/CString.h> #if PLATFORM(QT) -#include <QJSEngine> +#include <QtQml/QJSEngine> #endif namespace WebCore { @@ -161,14 +164,28 @@ bool ScriptController::processingUserGesture() return UserGestureIndicator::processingUserGesture(); } -void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources) +ScriptValue ScriptController::callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> argv[]) { - m_proxy->evaluateInIsolatedWorld(worldID, sources, 0); + // FIXME: This should probably perform the same isPaused check that happens in ScriptController::executeScript. + return ScriptValue(m_proxy->callFunction(function, receiver, argc, argv)); } -void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup) +void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, Vector<ScriptValue>* results) { - m_proxy->evaluateInIsolatedWorld(worldID, sources, extensionGroup); + evaluateInIsolatedWorld(worldID, sources, 0, results); +} + +void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, Vector<ScriptValue>* results) +{ + v8::HandleScope handleScope; + if (results) { + Vector<v8::Local<v8::Value> > v8Results; + m_proxy->evaluateInIsolatedWorld(worldID, sources, extensionGroup, &v8Results); + Vector<v8::Local<v8::Value> >::iterator itr; + for (itr = v8Results.begin(); itr != v8Results.end(); ++itr) + results->append(ScriptValue(*itr)); + } else + m_proxy->evaluateInIsolatedWorld(worldID, sources, extensionGroup, 0); } void ScriptController::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin> securityOrigin) @@ -233,6 +250,36 @@ void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObj global->Set(v8String(key), value); } +#if ENABLE(PAGE_POPUP) +static v8::Handle<v8::Value> setValueAndClosePopupCallback(const v8::Arguments& args) +{ + if (args.Length() < 2) + return V8Proxy::throwNotEnoughArgumentsError(); + DOMWindow* imp = V8DOMWindow::toNative(args.Data()->ToObject()); + EXCEPTION_BLOCK(int, intValue, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, stringValue, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); + DOMWindowPagePopup::setValueAndClosePopup(imp, intValue, stringValue); + // setValueAndClosePopup() deletes the window. Do not access it. + return v8::Undefined(); +} + +void ScriptController::installFunctionsForPagePopup(Frame* frame, PagePopupClient* popupClient) +{ + ASSERT(frame); + ASSERT(popupClient); + v8::HandleScope handleScope; + v8::Handle<v8::Context> context = V8Proxy::mainWorldContext(frame); + if (context.IsEmpty()) { + ASSERT_NOT_REACHED(); + return; + } + v8::Context::Scope scope(context); + DOMWindowPagePopup::install(frame->existingDOMWindow(), popupClient); + v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(setValueAndClosePopupCallback, V8DOMWindow::wrap(frame->existingDOMWindow())); + context->Global()->Set(v8::String::New("setValueAndClosePopup"), v8::Handle<v8::Function>(templ->GetFunction())); +} +#endif + void ScriptController::collectGarbage() { v8::HandleScope handleScope; @@ -245,8 +292,10 @@ void ScriptController::collectGarbage() v8::Local<v8::String> source = v8::String::New("if (gc) gc();"); v8::Local<v8::String> name = v8::String::New("gc"); v8::Handle<v8::Script> script = v8::Script::Compile(source, name); - if (!script.IsEmpty()) + if (!script.IsEmpty()) { + V8RecursionScope::MicrotaskSuppression scope; script->Run(); + } } v8Context.Dispose(); } @@ -328,7 +377,7 @@ void ScriptController::cleanupScriptObjectsForPlugin(Widget* nativeHandle) m_pluginObjects.remove(it); } -void ScriptController::getAllWorlds(Vector<DOMWrapperWorld*>& worlds) +void ScriptController::getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds) { worlds.append(mainThreadNormalWorld()); } @@ -339,7 +388,7 @@ void ScriptController::evaluateInWorld(const ScriptSourceCode& source, Vector<ScriptSourceCode> sources; sources.append(source); // FIXME: Get an ID from the world param. - evaluateInIsolatedWorld(0, sources); + evaluateInIsolatedWorld(0, sources, 0); } static NPObject* createNoScriptObject() diff --git a/Source/WebCore/bindings/v8/ScriptController.h b/Source/WebCore/bindings/v8/ScriptController.h index 9d2efdeb1..e8477ce29 100644 --- a/Source/WebCore/bindings/v8/ScriptController.h +++ b/Source/WebCore/bindings/v8/ScriptController.h @@ -59,6 +59,7 @@ class DOMWrapperWorld; class Event; class Frame; class HTMLPlugInElement; +class PagePopupClient; class ScriptSourceCode; class Widget; @@ -73,6 +74,7 @@ public: ScriptValue executeScript(const ScriptSourceCode&); ScriptValue executeScript(const String& script, bool forceUserGesture = false); + ScriptValue callFunctionEvenIfScriptDisabled(v8::Handle<v8::Function>, v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> argv[]); // Returns true if argument is a JavaScript URL. bool executeIfJavaScriptURL(const KURL&, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL); @@ -85,7 +87,7 @@ public: // as a string. ScriptValue evaluate(const ScriptSourceCode&); - void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&); + void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, Vector<ScriptValue>* results); // Executes JavaScript in an isolated world. The script gets its own global scope, // its own prototypes for intrinsic JavaScript objects (String, Array, and so-on), @@ -97,7 +99,7 @@ public: // If the worldID is 0, a new world is always created. // // FIXME: Get rid of extensionGroup here. - void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&, int extensionGroup); + void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, Vector<ScriptValue>* results); // Associates an isolated world (see above for description) with a security // origin. XMLHttpRequest instances used in that world will be considered @@ -119,6 +121,9 @@ public: void bindToWindowObject(Frame*, const String& key, NPObject*); PassScriptInstance createScriptInstanceForWidget(Widget*); +#if ENABLE(PAGE_POPUP) + void installFunctionsForPagePopup(Frame*, PagePopupClient*); +#endif // Check if the javascript engine has been initialized. bool haveInterpreter() const; @@ -181,7 +186,7 @@ public: // Dummy method to avoid a bunch of ifdef's in WebCore. void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*); - static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds); + static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds); private: Frame* m_frame; diff --git a/Source/WebCore/bindings/v8/ScriptControllerQt.cpp b/Source/WebCore/bindings/v8/ScriptControllerQt.cpp index 508d7a214..1d7f79476 100644 --- a/Source/WebCore/bindings/v8/ScriptControllerQt.cpp +++ b/Source/WebCore/bindings/v8/ScriptControllerQt.cpp @@ -28,7 +28,7 @@ #include "config.h" #include "ScriptController.h" -#include <QJSEngine> +#include <QtQml/QJSEngine> namespace WebCore { diff --git a/Source/WebCore/bindings/v8/ScriptDebugServer.cpp b/Source/WebCore/bindings/v8/ScriptDebugServer.cpp index b705523b7..cd30c64ae 100644 --- a/Source/WebCore/bindings/v8/ScriptDebugServer.cpp +++ b/Source/WebCore/bindings/v8/ScriptDebugServer.cpp @@ -39,6 +39,7 @@ #include "ScriptObject.h" #include "V8Binding.h" #include "V8JavaScriptCallFrame.h" +#include "V8RecursionScope.h" #include <wtf/StdLibExtras.h> #include <wtf/Vector.h> @@ -57,6 +58,13 @@ private: } +v8::Local<v8::Value> ScriptDebugServer::callDebuggerMethod(const char* functionName, int argc, v8::Handle<v8::Value> argv[]) +{ + v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New(functionName))); + V8RecursionScope::MicrotaskSuppression scope; + return function->Call(m_debuggerScript.get(), argc, argv); +} + ScriptDebugServer::ScriptDebugServer() : m_pauseOnExceptionsState(DontPauseOnExceptions) , m_breakpointsActivated(true) @@ -129,9 +137,8 @@ ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsSt v8::HandleScope scope; v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); - v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("pauseOnExceptionsState"))); v8::Handle<v8::Value> argv[] = { v8::Handle<v8::Value>() }; - v8::Handle<v8::Value> result = function->Call(m_debuggerScript.get(), 0, argv); + v8::Handle<v8::Value> result = callDebuggerMethod("pauseOnExceptionsState", 0, argv); return static_cast<ScriptDebugServer::PauseOnExceptionsState>(result->Int32Value()); } @@ -141,9 +148,8 @@ void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOn v8::HandleScope scope; v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); - v8::Handle<v8::Function> setPauseOnExceptionsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setPauseOnExceptionsState"))); v8::Handle<v8::Value> argv[] = { v8::Int32::New(pauseOnExceptionsState) }; - setPauseOnExceptionsFunction->Call(m_debuggerScript.get(), 1, argv); + callDebuggerMethod("setPauseOnExceptionsState", 1, argv); } void ScriptDebugServer::setPauseOnNextStatement(bool pause) @@ -190,27 +196,24 @@ void ScriptDebugServer::continueProgram() void ScriptDebugServer::stepIntoStatement() { ASSERT(isPaused()); - v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("stepIntoStatement"))); v8::Handle<v8::Value> argv[] = { m_executionState.get() }; - function->Call(m_debuggerScript.get(), 1, argv); + callDebuggerMethod("stepIntoStatement", 1, argv); continueProgram(); } void ScriptDebugServer::stepOverStatement() { ASSERT(isPaused()); - v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("stepOverStatement"))); v8::Handle<v8::Value> argv[] = { m_executionState.get() }; - function->Call(m_debuggerScript.get(), 1, argv); + callDebuggerMethod("stepOverStatement", 1, argv); continueProgram(); } void ScriptDebugServer::stepOutOfFunction() { ASSERT(isPaused()); - v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("stepOutOfFunction"))); v8::Handle<v8::Value> argv[] = { m_executionState.get() }; - function->Call(m_debuggerScript.get(), 1, argv); + callDebuggerMethod("stepOutOfFunction", 1, argv); continueProgram(); } @@ -228,12 +231,11 @@ bool ScriptDebugServer::setScriptSource(const String& sourceID, const String& ne if (!isPaused()) contextScope = adoptPtr(new v8::Context::Scope(v8::Debug::GetDebugContext())); - v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource"))); v8::Handle<v8::Value> argv[] = { v8String(sourceID), v8String(newContent), v8Boolean(preview) }; v8::TryCatch tryCatch; tryCatch.SetVerbose(false); - v8::Handle<v8::Value> v8result = function->Call(m_debuggerScript.get(), 3, argv); + v8::Local<v8::Value> v8result = callDebuggerMethod("setScriptSource", 3, argv); if (tryCatch.HasCaught()) { v8::Local<v8::Message> message = tryCatch.Message(); if (!message.IsEmpty()) @@ -255,9 +257,8 @@ bool ScriptDebugServer::setScriptSource(const String& sourceID, const String& ne ScriptValue ScriptDebugServer::currentCallFrame() { ASSERT(isPaused()); - v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame"))); v8::Handle<v8::Value> argv[] = { m_executionState.get() }; - v8::Handle<v8::Value> currentCallFrameV8 = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); + v8::Handle<v8::Value> currentCallFrameV8 = callDebuggerMethod("currentCallFrame", 1, argv); ASSERT(!currentCallFrameV8.IsEmpty()); if (!currentCallFrameV8->IsObject()) @@ -355,6 +356,7 @@ void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD v8::Handle<v8::Value> exceptionGetterValue = eventData->Get(v8::String::New("exception")); ASSERT(!exceptionGetterValue.IsEmpty() && exceptionGetterValue->IsFunction()); v8::Handle<v8::Value> argv[] = { v8::Handle<v8::Value>() }; + V8RecursionScope::MicrotaskSuppression scope; exception = v8::Handle<v8::Function>::Cast(exceptionGetterValue)->Call(eventData, 0, argv); } @@ -389,6 +391,7 @@ void ScriptDebugServer::ensureDebuggerScriptCompiled() v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); v8::Context::Scope contextScope(debuggerContext); String debuggerScriptSource(reinterpret_cast<const char*>(DebuggerScriptSource_js), sizeof(DebuggerScriptSource_js)); + V8RecursionScope::MicrotaskSuppression recursionScope; m_debuggerScript.set(v8::Handle<v8::Object>::Cast(v8::Script::Compile(v8String(debuggerScriptSource))->Run())); } } diff --git a/Source/WebCore/bindings/v8/ScriptDebugServer.h b/Source/WebCore/bindings/v8/ScriptDebugServer.h index de8465140..a4fb6129d 100644 --- a/Source/WebCore/bindings/v8/ScriptDebugServer.h +++ b/Source/WebCore/bindings/v8/ScriptDebugServer.h @@ -113,7 +113,9 @@ protected: void dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> sourceObject); void ensureDebuggerScriptCompiled(); - + + v8::Local<v8::Value> callDebuggerMethod(const char* functionName, int argc, v8::Handle<v8::Value> argv[]); + PauseOnExceptionsState m_pauseOnExceptionsState; OwnHandle<v8::Object> m_debuggerScript; OwnHandle<v8::Object> m_executionState; diff --git a/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp b/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp index 5c96b564e..06f55a993 100644 --- a/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp +++ b/Source/WebCore/bindings/v8/ScriptFunctionCall.cpp @@ -31,12 +31,13 @@ #include "config.h" #include "ScriptFunctionCall.h" +#include "SafeAllocation.h" #include "ScriptScope.h" #include "ScriptState.h" #include "ScriptValue.h" - #include "V8Binding.h" #include "V8Proxy.h" +#include "V8RecursionScope.h" #include "V8Utilities.h" #include <v8.h> @@ -130,7 +131,11 @@ ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) for (size_t i = 0; i < m_arguments.size(); ++i) args[i] = m_arguments[i].v8Value(); - v8::Local<v8::Value> result = function->Call(thisObject, m_arguments.size(), args.get()); + v8::Local<v8::Value> result; + { + V8RecursionScope scope(getScriptExecutionContext()); + result = function->Call(thisObject, m_arguments.size(), args.get()); + } if (!scope.success()) { hadException = true; return ScriptValue(); diff --git a/Source/WebCore/bindings/v8/ScriptGCEvent.cpp b/Source/WebCore/bindings/v8/ScriptGCEvent.cpp index 539eae6d1..622f22bcd 100644 --- a/Source/WebCore/bindings/v8/ScriptGCEvent.cpp +++ b/Source/WebCore/bindings/v8/ScriptGCEvent.cpp @@ -34,39 +34,38 @@ #include "ScriptGCEvent.h" #include "ScriptGCEventListener.h" +#include "V8Binding.h" #include <wtf/CurrentTime.h> namespace WebCore { -typedef Vector<ScriptGCEventListener*> GCEventListeners; -static GCEventListeners& eventListeners() +static GCEventData& isolateGCEventData() { - DEFINE_STATIC_LOCAL(GCEventListeners, listeners, ()); - return listeners; + V8BindingPerIsolateData* isolateData = V8BindingPerIsolateData::current(); + ASSERT(isolateData); + return isolateData->gcEventData(); } -double ScriptGCEvent::s_startTime = 0.0; -size_t ScriptGCEvent::s_usedHeapSize = 0; - void ScriptGCEvent::addEventListener(ScriptGCEventListener* eventListener) { - ASSERT(eventListener); - if (eventListeners().isEmpty()) { + GCEventData::GCEventListeners& listeners = isolateGCEventData().listeners(); + if (listeners.isEmpty()) { v8::V8::AddGCPrologueCallback(ScriptGCEvent::gcPrologueCallback); v8::V8::AddGCEpilogueCallback(ScriptGCEvent::gcEpilogueCallback); } - eventListeners().append(eventListener); + listeners.append(eventListener); } void ScriptGCEvent::removeEventListener(ScriptGCEventListener* eventListener) { ASSERT(eventListener); - ASSERT(!eventListeners().isEmpty()); - size_t i = eventListeners().find(eventListener); + GCEventData::GCEventListeners& listeners = isolateGCEventData().listeners(); + ASSERT(!listeners.isEmpty()); + size_t i = listeners.find(eventListener); ASSERT(i != notFound); - eventListeners().remove(i); - if (eventListeners().isEmpty()) { + listeners.remove(i); + if (listeners.isEmpty()) { v8::V8::RemoveGCPrologueCallback(ScriptGCEvent::gcPrologueCallback); v8::V8::RemoveGCEpilogueCallback(ScriptGCEvent::gcEpilogueCallback); } @@ -90,17 +89,23 @@ size_t ScriptGCEvent::getUsedHeapSize() void ScriptGCEvent::gcPrologueCallback(v8::GCType type, v8::GCCallbackFlags flags) { - s_startTime = WTF::monotonicallyIncreasingTime(); - s_usedHeapSize = getUsedHeapSize(); + GCEventData& gcEventData = isolateGCEventData(); + gcEventData.startTime = WTF::monotonicallyIncreasingTime(); + gcEventData.usedHeapSize = getUsedHeapSize(); } void ScriptGCEvent::gcEpilogueCallback(v8::GCType type, v8::GCCallbackFlags flags) { + GCEventData& gcEventData = isolateGCEventData(); + if (!gcEventData.usedHeapSize) + return; double endTime = WTF::monotonicallyIncreasingTime(); - size_t collectedBytes = s_usedHeapSize - getUsedHeapSize(); - GCEventListeners listeners(eventListeners()); - for (GCEventListeners::iterator i = listeners.begin(); i != listeners.end(); ++i) - (*i)->didGC(s_startTime, endTime, collectedBytes); + size_t usedHeapSize = getUsedHeapSize(); + size_t collectedBytes = usedHeapSize > gcEventData.usedHeapSize ? 0 : gcEventData.usedHeapSize - usedHeapSize; + GCEventData::GCEventListeners& listeners = gcEventData.listeners(); + for (GCEventData::GCEventListeners::iterator i = listeners.begin(); i != listeners.end(); ++i) + (*i)->didGC(gcEventData.startTime, endTime, collectedBytes); + gcEventData.clear(); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/ScriptGCEvent.h b/Source/WebCore/bindings/v8/ScriptGCEvent.h index 0644a850b..f2ba49525 100644 --- a/Source/WebCore/bindings/v8/ScriptGCEvent.h +++ b/Source/WebCore/bindings/v8/ScriptGCEvent.h @@ -47,9 +47,6 @@ public: static void removeEventListener(ScriptGCEventListener*); static void getHeapSize(size_t&, size_t&, size_t&); private: - static double s_startTime; - static size_t s_usedHeapSize; - static void gcEpilogueCallback(v8::GCType type, v8::GCCallbackFlags flags); static void gcPrologueCallback(v8::GCType type, v8::GCCallbackFlags flags); static size_t getUsedHeapSize(); diff --git a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp index 68ed8daba..769764e82 100644 --- a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp +++ b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp @@ -56,6 +56,11 @@ unsigned int ScriptHeapSnapshot::uid() const return m_snapshot->GetUid(); } +SnapshotObjectId ScriptHeapSnapshot::maxSnapshotJSObjectId() const +{ + return m_snapshot->GetMaxSnapshotJSObjectId(); +} + namespace { class OutputStreamAdapter : public v8::OutputStream { diff --git a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h index 157149607..036bf25a2 100644 --- a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h +++ b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h @@ -41,6 +41,7 @@ class HeapSnapshot; namespace WebCore { class InspectorObject; +typedef uint32_t SnapshotObjectId; class ScriptHeapSnapshot : public RefCounted<ScriptHeapSnapshot> { public: @@ -60,6 +61,7 @@ public: String title() const; unsigned int uid() const; void writeJSON(OutputStream* stream); + SnapshotObjectId maxSnapshotJSObjectId() const; private: ScriptHeapSnapshot(const v8::HeapSnapshot* snapshot) diff --git a/Source/WebCore/bindings/v8/ScriptProfiler.cpp b/Source/WebCore/bindings/v8/ScriptProfiler.cpp index 567693742..056d92e30 100644 --- a/Source/WebCore/bindings/v8/ScriptProfiler.cpp +++ b/Source/WebCore/bindings/v8/ScriptProfiler.cpp @@ -29,6 +29,7 @@ */ #include "config.h" +#if ENABLE(INSPECTOR) #include "ScriptProfiler.h" #include "DOMWrapperVisitor.h" @@ -37,12 +38,12 @@ #include "V8Binding.h" #include "V8DOMMap.h" #include "V8Node.h" +#include "WrapperTypeInfo.h" #include <v8-profiler.h> namespace WebCore { -#if ENABLE(INSPECTOR) void ScriptProfiler::start(ScriptState* state, const String& title) { v8::HandleScope hs; @@ -109,6 +110,13 @@ ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned id) return ScriptObject(); v8::Handle<v8::Object> object = value.As<v8::Object>(); + if (object->InternalFieldCount() >= v8DefaultWrapperInternalFieldCount) { + v8::Handle<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIndex); + // Skip wrapper boilerplates which are like regular wrappers but don't have + // native object. + if (!wrapper.IsEmpty() && wrapper->IsUndefined()) + return ScriptObject(); + } ScriptState* scriptState = ScriptState::forContext(object->CreationContext()); return ScriptObject(scriptState, object); } @@ -155,13 +163,10 @@ static v8::RetainedObjectInfo* retainedDOMInfo(uint16_t classId, v8::Handle<v8:: Node* node = V8Node::toNative(wrapper.As<v8::Object>()); return node ? new RetainedDOMInfo(node) : 0; } -#endif // ENABLE(INSPECTOR) void ScriptProfiler::initialize() { -#if ENABLE(INSPECTOR) v8::HeapProfiler::DefineWrapperClass(v8DOMSubtreeClassId, &retainedDOMInfo); -#endif // ENABLE(INSPECTOR) } void ScriptProfiler::visitJSDOMWrappers(DOMWrapperVisitor* visitor) @@ -186,3 +191,5 @@ void ScriptProfiler::visitExternalJSStrings(DOMWrapperVisitor* visitor) } } // namespace WebCore + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/bindings/v8/ScriptValue.cpp b/Source/WebCore/bindings/v8/ScriptValue.cpp index ecc367362..31bcd23ee 100644 --- a/Source/WebCore/bindings/v8/ScriptValue.cpp +++ b/Source/WebCore/bindings/v8/ScriptValue.cpp @@ -32,9 +32,11 @@ #include "ScriptValue.h" #include "InspectorValues.h" +#include "MessagePort.h" #include "ScriptScope.h" #include "SerializedScriptValue.h" #include "V8Binding.h" +#include <wtf/ArrayBuffer.h> namespace WebCore { @@ -44,6 +46,13 @@ PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptStat return SerializedScriptValue::create(v8Value()); } +PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState, + MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, bool& didThrow) +{ + ScriptScope scope(scriptState); + return SerializedScriptValue::create(v8Value(), messagePorts, arrayBuffers, didThrow); +} + ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value) { ScriptScope scope(scriptState); diff --git a/Source/WebCore/bindings/v8/ScriptValue.h b/Source/WebCore/bindings/v8/ScriptValue.h index d412901fd..5aa202b00 100644 --- a/Source/WebCore/bindings/v8/ScriptValue.h +++ b/Source/WebCore/bindings/v8/ScriptValue.h @@ -36,15 +36,24 @@ #include <v8.h> #include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> #ifndef NDEBUG -#include "V8Proxy.h" // for register and unregister global handles. +#include "V8GCController.h" #endif +namespace WTF { +class ArrayBuffer; +} + namespace WebCore { class InspectorValue; +class MessagePort; class SerializedScriptValue; +typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; +typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray; class ScriptValue { public: @@ -131,10 +140,9 @@ public: } PassRefPtr<SerializedScriptValue> serialize(ScriptState*); + PassRefPtr<SerializedScriptValue> serialize(ScriptState*, MessagePortArray*, ArrayBufferArray*, bool&); static ScriptValue deserialize(ScriptState*, SerializedScriptValue*); - static ScriptValue undefined() { return ScriptValue(v8::Undefined()); } - void clear() { if (m_value.IsEmpty()) diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp index c6738cdc4..1023abd18 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp @@ -31,27 +31,25 @@ #include "config.h" #include "SerializedScriptValue.h" -#include "ArrayBuffer.h" -#include "ArrayBufferView.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/ArrayBufferView.h> #include "Blob.h" -#include "ByteArray.h" -#include "CanvasPixelArray.h" #include "DataView.h" #include "ExceptionCode.h" #include "File.h" #include "FileList.h" -#include "Float32Array.h" -#include "Float64Array.h" +#include <wtf/Float32Array.h> +#include <wtf/Float64Array.h> #include "ImageData.h" -#include "Int16Array.h" -#include "Int32Array.h" -#include "Int8Array.h" +#include <wtf/Int16Array.h> +#include <wtf/Int32Array.h> +#include <wtf/Int8Array.h> #include "MessagePort.h" #include "SharedBuffer.h" -#include "Uint16Array.h" -#include "Uint32Array.h" -#include "Uint8Array.h" -#include "Uint8ClampedArray.h" +#include <wtf/Uint16Array.h> +#include <wtf/Uint32Array.h> +#include <wtf/Uint8Array.h> +#include <wtf/Uint8ClampedArray.h> #include "V8ArrayBuffer.h" #include "V8ArrayBufferView.h" #include "V8Binding.h" @@ -275,8 +273,9 @@ private: class Writer { WTF_MAKE_NONCOPYABLE(Writer); public: - Writer() + Writer(v8::Isolate* isolate) : m_position(0) + , m_isolate(isolate) { } @@ -505,6 +504,7 @@ public: doWriteUint32(length); } + v8::Isolate* getIsolate() { return m_isolate; } private: void doWriteArrayBuffer(const ArrayBuffer& arrayBuffer) @@ -592,6 +592,7 @@ private: Vector<BufferValueType> m_buffer; unsigned m_position; + v8::Isolate* m_isolate; }; class Serializer { @@ -606,22 +607,23 @@ public: JSFailure }; - Serializer(Writer& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, v8::TryCatch& tryCatch) + Serializer(Writer& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, Vector<String>& blobURLs, v8::TryCatch& tryCatch) : m_writer(writer) , m_tryCatch(tryCatch) , m_depth(0) , m_execDepth(0) , m_status(Success) , m_nextObjectReference(0) + , m_blobURLs(blobURLs) { ASSERT(!tryCatch.HasCaught()); if (messagePorts) { for (size_t i = 0; i < messagePorts->size(); i++) - m_transferredMessagePorts.set(V8MessagePort::wrap(messagePorts->at(i).get()), i); + m_transferredMessagePorts.set(V8MessagePort::wrap(messagePorts->at(i).get(), m_writer.getIsolate()), i); } if (arrayBuffers) { for (size_t i = 0; i < arrayBuffers->size(); i++) { - v8::Handle<v8::Object> v8ArrayBuffer = V8ArrayBuffer::wrap(arrayBuffers->at(i).get()); + v8::Handle<v8::Object> v8ArrayBuffer = V8ArrayBuffer::wrap(arrayBuffers->at(i).get(), m_writer.getIsolate()); // Coalesce multiple occurences of the same buffer to the first index. if (!m_transferredArrayBuffers.contains(v8ArrayBuffer)) m_transferredArrayBuffers.set(v8ArrayBuffer, i); @@ -977,6 +979,7 @@ private: if (!blob) return; m_writer.writeBlob(blob->url().string(), blob->type(), blob->size()); + m_blobURLs.append(blob->url().string()); } void writeFile(v8::Handle<v8::Value> value) @@ -985,6 +988,7 @@ private: if (!file) return; m_writer.writeFile(file->path(), file->url().string(), file->type()); + m_blobURLs.append(file->url().string()); } void writeFileList(v8::Handle<v8::Value> value) @@ -993,6 +997,9 @@ private: if (!fileList) return; m_writer.writeFileList(*fileList); + unsigned length = fileList->length(); + for (unsigned i = 0; i < length; ++i) + m_blobURLs.append(fileList->item(i)->url().string()); } void writeImageData(v8::Handle<v8::Value> value) @@ -1000,7 +1007,7 @@ private: ImageData* imageData = V8ImageData::toNative(value.As<v8::Object>()); if (!imageData) return; - WTF::ByteArray* pixelArray = imageData->data()->data(); + Uint8ClampedArray* pixelArray = imageData->data(); m_writer.writeImageData(imageData->width(), imageData->height(), pixelArray->data(), pixelArray->length()); } @@ -1018,7 +1025,7 @@ private: return 0; if (!arrayBufferView->buffer()) return handleError(DataCloneError, next); - v8::Handle<v8::Value> underlyingBuffer = toV8(arrayBufferView->buffer()); + v8::Handle<v8::Value> underlyingBuffer = toV8(arrayBufferView->buffer(), m_writer.getIsolate()); if (underlyingBuffer.IsEmpty()) return handleError(DataCloneError, next); StateBase* stateOut = doSerialize(underlyingBuffer, 0); @@ -1111,6 +1118,7 @@ private: ObjectPool m_transferredMessagePorts; ObjectPool m_transferredArrayBuffers; uint32_t m_nextObjectReference; + Vector<String>& m_blobURLs; }; Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, StateBase* next) @@ -1216,11 +1224,12 @@ public: // restoring information about saved objects of composite types. class Reader { public: - Reader(const uint8_t* buffer, int length) + Reader(const uint8_t* buffer, int length, v8::Isolate* isolate) : m_buffer(buffer) , m_length(length) , m_position(0) , m_version(0) + , m_isolate(isolate) { ASSERT(length >= 0); } @@ -1460,6 +1469,8 @@ public: m_version = version; } + v8::Isolate* getIsolate() { return m_isolate; } + private: bool readTag(SerializationTag* tag) { @@ -1575,12 +1586,12 @@ private: if (m_position + pixelDataLength > m_length) return false; RefPtr<ImageData> imageData = ImageData::create(IntSize(width, height)); - WTF::ByteArray* pixelArray = imageData->data()->data(); + Uint8ClampedArray* pixelArray = imageData->data(); ASSERT(pixelArray); ASSERT(pixelArray->length() >= pixelDataLength); memcpy(pixelArray->data(), m_buffer + m_position, pixelDataLength); m_position += pixelDataLength; - *value = toV8(imageData.release()); + *value = toV8(imageData.release(), m_isolate); return true; } @@ -1602,7 +1613,7 @@ private: RefPtr<ArrayBuffer> arrayBuffer = doReadArrayBuffer(); if (!arrayBuffer) return false; - *value = toV8(arrayBuffer.release()); + *value = toV8(arrayBuffer.release(), m_isolate); return true; } @@ -1628,58 +1639,58 @@ private: return false; switch (subTag) { case ByteArrayTag: - *value = toV8(Int8Array::create(arrayBuffer.release(), byteOffset, byteLength)); + *value = toV8(Int8Array::create(arrayBuffer.release(), byteOffset, byteLength), m_isolate); break; case UnsignedByteArrayTag: - *value = toV8(Uint8Array::create(arrayBuffer.release(), byteOffset, byteLength)); + *value = toV8(Uint8Array::create(arrayBuffer.release(), byteOffset, byteLength), m_isolate); break; case UnsignedByteClampedArrayTag: - *value = toV8(Uint8ClampedArray::create(arrayBuffer.release(), byteOffset, byteLength)); + *value = toV8(Uint8ClampedArray::create(arrayBuffer.release(), byteOffset, byteLength), m_isolate); break; case ShortArrayTag: { uint32_t shortLength = byteLength / sizeof(int16_t); if (shortLength * sizeof(int16_t) != byteLength) return false; - *value = toV8(Int16Array::create(arrayBuffer.release(), byteOffset, shortLength)); + *value = toV8(Int16Array::create(arrayBuffer.release(), byteOffset, shortLength), m_isolate); break; } case UnsignedShortArrayTag: { uint32_t shortLength = byteLength / sizeof(uint16_t); if (shortLength * sizeof(uint16_t) != byteLength) return false; - *value = toV8(Uint16Array::create(arrayBuffer.release(), byteOffset, shortLength)); + *value = toV8(Uint16Array::create(arrayBuffer.release(), byteOffset, shortLength), m_isolate); break; } case IntArrayTag: { uint32_t intLength = byteLength / sizeof(int32_t); if (intLength * sizeof(int32_t) != byteLength) return false; - *value = toV8(Int32Array::create(arrayBuffer.release(), byteOffset, intLength)); + *value = toV8(Int32Array::create(arrayBuffer.release(), byteOffset, intLength), m_isolate); break; } case UnsignedIntArrayTag: { uint32_t intLength = byteLength / sizeof(uint32_t); if (intLength * sizeof(uint32_t) != byteLength) return false; - *value = toV8(Uint32Array::create(arrayBuffer.release(), byteOffset, intLength)); + *value = toV8(Uint32Array::create(arrayBuffer.release(), byteOffset, intLength), m_isolate); break; } case FloatArrayTag: { uint32_t floatLength = byteLength / sizeof(float); if (floatLength * sizeof(float) != byteLength) return false; - *value = toV8(Float32Array::create(arrayBuffer.release(), byteOffset, floatLength)); + *value = toV8(Float32Array::create(arrayBuffer.release(), byteOffset, floatLength), m_isolate); break; } case DoubleArrayTag: { uint32_t floatLength = byteLength / sizeof(double); if (floatLength * sizeof(double) != byteLength) return false; - *value = toV8(Float64Array::create(arrayBuffer.release(), byteOffset, floatLength)); + *value = toV8(Float64Array::create(arrayBuffer.release(), byteOffset, floatLength), m_isolate); break; } case DataViewTag: - *value = toV8(DataView::create(arrayBuffer.release(), byteOffset, byteLength)); + *value = toV8(DataView::create(arrayBuffer.release(), byteOffset, byteLength), m_isolate); break; default: return false; @@ -1714,7 +1725,7 @@ private: if (!doReadUint64(&size)) return false; PassRefPtr<Blob> blob = Blob::create(KURL(ParsedURLString, url), type, size); - *value = toV8(blob); + *value = toV8(blob, m_isolate); return true; } @@ -1730,7 +1741,7 @@ private: if (!readWebCoreString(&type)) return false; PassRefPtr<File> file = File::create(path, KURL(ParsedURLString, url), type); - *value = toV8(file); + *value = toV8(file, m_isolate); return true; } @@ -1752,7 +1763,7 @@ private: return false; fileList->append(File::create(path, KURL(ParsedURLString, urlString), type)); } - *value = toV8(fileList); + *value = toV8(fileList, m_isolate); return true; } @@ -1796,6 +1807,7 @@ private: const unsigned m_length; unsigned m_position; uint32_t m_version; + v8::Isolate* m_isolate; }; @@ -1949,7 +1961,7 @@ public: return false; if (index >= m_transferredMessagePorts->size()) return false; - *object = V8MessagePort::wrap(m_transferredMessagePorts->at(index).get()); + *object = V8MessagePort::wrap(m_transferredMessagePorts->at(index).get(), m_reader.getIsolate()); return true; } @@ -1961,7 +1973,7 @@ public: return false; v8::Handle<v8::Object> result = m_arrayBuffers.at(index); if (result.IsEmpty()) { - result = V8ArrayBuffer::wrap(ArrayBuffer::create(m_arrayBufferContents->at(index)).get()); + result = V8ArrayBuffer::wrap(ArrayBuffer::create(m_arrayBufferContents->at(index)).get(), m_reader.getIsolate()); m_arrayBuffers[index] = result; } *object = result; @@ -2053,32 +2065,19 @@ private: }; } // namespace -void SerializedScriptValue::deserializeAndSetProperty(v8::Handle<v8::Object> object, const char* propertyName, - v8::PropertyAttribute attribute, SerializedScriptValue* value) -{ - if (!value) - return; - v8::Handle<v8::Value> deserialized = value->deserialize(); - object->ForceSet(v8::String::NewSymbol(propertyName), deserialized, attribute); -} - -void SerializedScriptValue::deserializeAndSetProperty(v8::Handle<v8::Object> object, const char* propertyName, - v8::PropertyAttribute attribute, PassRefPtr<SerializedScriptValue> value) -{ - deserializeAndSetProperty(object, propertyName, attribute, value.get()); -} PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, - bool& didThrow) + bool& didThrow, + v8::Isolate* isolate) { - return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, didThrow)); + return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, didThrow, isolate)); } -PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value) +PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value, v8::Isolate* isolate) { bool didThrow; - return adoptRef(new SerializedScriptValue(value, 0, 0, didThrow)); + return adoptRef(new SerializedScriptValue(value, 0, 0, didThrow, isolate)); } PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const String& data) @@ -2086,9 +2085,9 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const St return adoptRef(new SerializedScriptValue(data)); } -PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& data) +PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& data, v8::Isolate* isolate) { - Writer writer; + Writer writer(isolate); writer.writeWebCoreString(data); String wireData = StringImpl::adopt(writer.data()); return adoptRef(new SerializedScriptValue(wireData)); @@ -2099,13 +2098,13 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() return adoptRef(new SerializedScriptValue()); } -SerializedScriptValue* SerializedScriptValue::nullValue() +SerializedScriptValue* SerializedScriptValue::nullValue(v8::Isolate* isolate) { // FIXME: This is not thread-safe. Move caching to callers. // https://bugs.webkit.org/show_bug.cgi?id=70833 DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (0)); if (!nullValue) { - Writer writer; + Writer writer(isolate); writer.writeNull(); String wireData = StringImpl::adopt(writer.data()); nullValue = adoptRef(new SerializedScriptValue(wireData)); @@ -2113,17 +2112,17 @@ SerializedScriptValue* SerializedScriptValue::nullValue() return nullValue.get(); } -PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue() +PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue(v8::Isolate* isolate) { - Writer writer; + Writer writer(isolate); writer.writeUndefined(); String wireData = StringImpl::adopt(writer.data()); return adoptRef(new SerializedScriptValue(wireData)); } -PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value) +PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value, v8::Isolate* isolate) { - Writer writer; + Writer writer(isolate); if (value) writer.writeTrue(); else @@ -2132,9 +2131,9 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value return adoptRef(new SerializedScriptValue(wireData)); } -PassRefPtr<SerializedScriptValue> SerializedScriptValue::numberValue(double value) +PassRefPtr<SerializedScriptValue> SerializedScriptValue::numberValue(double value, v8::Isolate* isolate) { - Writer writer; + Writer writer(isolate); writer.writeNumber(value); String wireData = StringImpl::adopt(writer.data()); return adoptRef(new SerializedScriptValue(wireData)); @@ -2197,14 +2196,15 @@ PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, - bool& didThrow) + bool& didThrow, + v8::Isolate* isolate) { didThrow = false; - Writer writer; + Writer writer(isolate); Serializer::Status status; { v8::TryCatch tryCatch; - Serializer serializer(writer, messagePorts, arrayBuffers, tryCatch); + Serializer serializer(writer, messagePorts, arrayBuffers, m_blobURLs, tryCatch); status = serializer.serialize(value); if (status == Serializer::JSException) { // If there was a JS exception thrown, re-throw it. @@ -2248,23 +2248,23 @@ SerializedScriptValue::SerializedScriptValue(const String& wireData) m_data = wireData.isolatedCopy(); } -v8::Handle<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messagePorts) +v8::Handle<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messagePorts, v8::Isolate* isolate) { if (!m_data.impl()) return v8::Null(); COMPILE_ASSERT(sizeof(BufferValueType) == 2, BufferValueTypeIsTwoBytes); - Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters()), 2 * m_data.length()); + Reader reader(reinterpret_cast<const uint8_t*>(m_data.impl()->characters()), 2 * m_data.length(), isolate); Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.get()); return deserializer.deserialize(); } #if ENABLE(INSPECTOR) -ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptState) +ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptState, v8::Isolate* isolate) { v8::HandleScope handleScope; v8::Context::Scope contextScope(scriptState->context()); - return ScriptValue(deserialize()); + return ScriptValue(deserialize(0, isolate)); } #endif diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.h b/Source/WebCore/bindings/v8/SerializedScriptValue.h index 68b1954d5..1fa99e8a4 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.h +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.h @@ -31,9 +31,9 @@ #ifndef SerializedScriptValue_h #define SerializedScriptValue_h -#include "ArrayBuffer.h" #include "ScriptValue.h" #include <v8.h> +#include <wtf/ArrayBuffer.h> #include <wtf/Threading.h> namespace WebCore { @@ -45,11 +45,6 @@ typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray; class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue> { public: - static void deserializeAndSetProperty(v8::Handle<v8::Object>, const char* propertyName, - v8::PropertyAttribute, SerializedScriptValue*); - static void deserializeAndSetProperty(v8::Handle<v8::Object>, const char* propertyName, - v8::PropertyAttribute, PassRefPtr<SerializedScriptValue>); - // If a serialization error occurs (e.g., cyclic input value) this // function returns an empty representation, schedules a V8 exception to // be thrown using v8::ThrowException(), and sets |didThrow|. In this case @@ -57,16 +52,16 @@ public: // V8. When serialization is successful, |didThrow| is false. static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferArray*, - bool& didThrow); - static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>); + bool& didThrow, v8::Isolate* = 0); + static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, v8::Isolate* = 0); static PassRefPtr<SerializedScriptValue> createFromWire(const String& data); - static PassRefPtr<SerializedScriptValue> create(const String& data); + static PassRefPtr<SerializedScriptValue> create(const String& data, v8::Isolate* = 0); static PassRefPtr<SerializedScriptValue> create(); - static SerializedScriptValue* nullValue(); - static PassRefPtr<SerializedScriptValue> undefinedValue(); - static PassRefPtr<SerializedScriptValue> booleanValue(bool value); - static PassRefPtr<SerializedScriptValue> numberValue(double value); + static SerializedScriptValue* nullValue(v8::Isolate* = 0); + static PassRefPtr<SerializedScriptValue> undefinedValue(v8::Isolate* = 0); + static PassRefPtr<SerializedScriptValue> booleanValue(bool value, v8::Isolate* = 0); + static PassRefPtr<SerializedScriptValue> numberValue(double value, v8::Isolate* = 0); PassRefPtr<SerializedScriptValue> release(); @@ -74,12 +69,14 @@ public: // Deserializes the value (in the current context). Returns a null value in // case of failure. - v8::Handle<v8::Value> deserialize(MessagePortArray* = 0); + v8::Handle<v8::Value> deserialize(MessagePortArray* = 0, v8::Isolate* = 0); #if ENABLE(INSPECTOR) - ScriptValue deserializeForInspector(ScriptState*); + ScriptValue deserializeForInspector(ScriptState*, v8::Isolate* = 0); #endif + const Vector<String>& blobURLs() const { return m_blobURLs; } + private: enum StringDataMode { StringValue, @@ -88,13 +85,14 @@ private: typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; SerializedScriptValue(); - SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferArray*, bool& didThrow); + SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferArray*, bool& didThrow, v8::Isolate*); explicit SerializedScriptValue(const String& wireData); static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBufferArray&, bool& didThrow); String m_data; OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; + Vector<String> m_blobURLs; }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/StaticDOMDataStore.cpp b/Source/WebCore/bindings/v8/StaticDOMDataStore.cpp index 8eb630d88..996c9c87c 100644 --- a/Source/WebCore/bindings/v8/StaticDOMDataStore.cpp +++ b/Source/WebCore/bindings/v8/StaticDOMDataStore.cpp @@ -40,17 +40,11 @@ StaticDOMDataStore::StaticDOMDataStore() , m_staticActiveDomNodeMap(&DOMDataStore::weakNodeCallback) , m_staticDomObjectMap(&DOMDataStore::weakDOMObjectCallback) , m_staticActiveDomObjectMap(&DOMDataStore::weakActiveDOMObjectCallback) -#if ENABLE(SVG) - , m_staticDomSvgElementInstanceMap(&DOMDataStore::weakSVGElementInstanceCallback) -#endif { m_domNodeMap = &m_staticDomNodeMap; m_activeDomNodeMap = &m_staticActiveDomNodeMap; m_domObjectMap = &m_staticDomObjectMap; m_activeDomObjectMap = &m_staticActiveDomObjectMap; -#if ENABLE(SVG) - m_domSvgElementInstanceMap = &m_staticDomSvgElementInstanceMap; -#endif V8BindingPerIsolateData::current()->registerDOMDataStore(this); } diff --git a/Source/WebCore/bindings/v8/StaticDOMDataStore.h b/Source/WebCore/bindings/v8/StaticDOMDataStore.h index 6c65d44fd..2d00b27d9 100644 --- a/Source/WebCore/bindings/v8/StaticDOMDataStore.h +++ b/Source/WebCore/bindings/v8/StaticDOMDataStore.h @@ -54,9 +54,6 @@ private: IntrusiveDOMWrapperMap m_staticActiveDomNodeMap; DOMWrapperMap<void> m_staticDomObjectMap; DOMWrapperMap<void> m_staticActiveDomObjectMap; -#if ENABLE(SVG) - DOMWrapperMap<SVGElementInstance> m_staticDomSvgElementInstanceMap; -#endif }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8Binding.cpp b/Source/WebCore/bindings/v8/V8Binding.cpp index 2ae94e4c1..2db76a8b8 100644 --- a/Source/WebCore/bindings/v8/V8Binding.cpp +++ b/Source/WebCore/bindings/v8/V8Binding.cpp @@ -34,15 +34,16 @@ #include "DOMStringList.h" #include "DOMWrapperVisitor.h" #include "Element.h" -#include "MathExtras.h" #include "PlatformString.h" #include "QualifiedName.h" -#include "StdLibExtras.h" -#include "Threading.h" #include "V8DOMStringList.h" #include "V8Element.h" #include "V8Proxy.h" + +#include <wtf/MathExtras.h> #include <wtf/MainThread.h> +#include <wtf/StdLibExtras.h> +#include <wtf/Threading.h> #include <wtf/text/AtomicString.h> #include <wtf/text/CString.h> #include <wtf/text/StringBuffer.h> @@ -55,6 +56,9 @@ V8BindingPerIsolateData::V8BindingPerIsolateData(v8::Isolate* isolate) : m_domDataStore(0) , m_constructorMode(ConstructorMode::CreateNewObject) , m_recursionLevel(0) +#ifndef NDEBUG + , m_internalScriptRecursionLevel(0) +#endif { } @@ -173,6 +177,7 @@ private: #endif }; +#if ENABLE(INSPECTOR) void V8BindingPerIsolateData::visitJSExternalStrings(DOMWrapperVisitor* visitor) { v8::HandleScope handleScope; @@ -191,6 +196,7 @@ void V8BindingPerIsolateData::visitJSExternalStrings(DOMWrapperVisitor* visitor) } v8Visitor(visitor); v8::V8::VisitExternalResources(&v8Visitor); } +#endif String v8ValueToWebCoreString(v8::Handle<v8::Value> value) { @@ -545,7 +551,7 @@ v8::Handle<v8::Value> getElementStringAttr(const v8::AccessorInfo& info, const QualifiedName& name) { Element* imp = V8Element::toNative(info.Holder()); - return v8ExternalString(imp->getAttribute(name)); + return v8ExternalString(imp->getAttribute(name), info.GetIsolate()); } void setElementStringAttr(const v8::AccessorInfo& info, diff --git a/Source/WebCore/bindings/v8/V8Binding.h b/Source/WebCore/bindings/v8/V8Binding.h index d0092f980..3ee692da0 100644 --- a/Source/WebCore/bindings/v8/V8Binding.h +++ b/Source/WebCore/bindings/v8/V8Binding.h @@ -33,11 +33,11 @@ #include "BindingSecurity.h" #include "DOMDataStore.h" -#include "MathExtras.h" #include "PlatformString.h" #include "V8DOMWrapper.h" #include "V8GCController.h" #include "V8HiddenPropertyName.h" +#include <wtf/MathExtras.h> #include <wtf/Noncopyable.h> #include <wtf/text/AtomicString.h> @@ -89,6 +89,27 @@ namespace WebCore { RefPtr<StringImpl> m_lastStringImpl; }; + class ScriptGCEventListener; + + class GCEventData { + public: + typedef Vector<ScriptGCEventListener*> GCEventListeners; + + GCEventData() : startTime(0.0), usedHeapSize(0) { } + void clear() + { + startTime = 0.0; + usedHeapSize = 0; + } + GCEventListeners& listeners() { return m_listeners; } + + double startTime; + size_t usedHeapSize; + + private: + GCEventListeners m_listeners; + }; + class ConstructorMode; #ifndef NDEBUG @@ -105,9 +126,9 @@ namespace WebCore { return static_cast<V8BindingPerIsolateData*>(isolate->GetData()); } - static V8BindingPerIsolateData* current() + static V8BindingPerIsolateData* current(v8::Isolate* isolate = 0) { - return get(v8::Isolate::GetCurrent()); + return isolate ? static_cast<V8BindingPerIsolateData*>(isolate->GetData()) : get(v8::Isolate::GetCurrent()); } static void dispose(v8::Isolate*); @@ -124,8 +145,9 @@ namespace WebCore { } StringCache* stringCache() { return &m_stringCache; } +#if ENABLE(INSPECTOR) void visitJSExternalStrings(DOMWrapperVisitor*); - +#endif DOMDataList& allStores() { return m_domDataList; } V8HiddenPropertyName* hiddenPropertyName() { return &m_hiddenPropertyName; } @@ -153,8 +175,14 @@ namespace WebCore { #ifndef NDEBUG GlobalHandleMap& globalHandleMap() { return m_globalHandleMap; } + + int internalScriptRecursionLevel() const { return m_internalScriptRecursionLevel; } + int incrementInternalScriptRecursionLevel() { return ++m_internalScriptRecursionLevel; } + int decrementInternalScriptRecursionLevel() { return --m_internalScriptRecursionLevel; } #endif + GCEventData& gcEventData() { return m_gcEventData; } + private: explicit V8BindingPerIsolateData(v8::Isolate*); ~V8BindingPerIsolateData(); @@ -179,7 +207,9 @@ namespace WebCore { #ifndef NDEBUG GlobalHandleMap m_globalHandleMap; + int m_internalScriptRecursionLevel; #endif + GCEventData m_gcEventData; }; class ConstructorMode { @@ -208,38 +238,6 @@ namespace WebCore { bool m_previous; }; - class SafeAllocation { - public: - static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>); - static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::ObjectTemplate>); - static inline v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>, int argc, v8::Handle<v8::Value> argv[]); - }; - - v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::Function> function) - { - if (function.IsEmpty()) - return v8::Local<v8::Object>(); - ConstructorMode constructorMode; - return function->NewInstance(); - } - - v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::ObjectTemplate> objectTemplate) - { - if (objectTemplate.IsEmpty()) - return v8::Local<v8::Object>(); - ConstructorMode constructorMode; - return objectTemplate->NewInstance(); - } - - v8::Local<v8::Object> SafeAllocation::newInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[]) - { - if (function.IsEmpty()) - return v8::Local<v8::Object>(); - ConstructorMode constructorMode; - return function->NewInstance(argc, argv); - } - - enum ExternalMode { Externalize, @@ -270,20 +268,59 @@ namespace WebCore { // 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. - inline v8::Local<v8::String> v8ExternalString(const String& string) + inline v8::Local<v8::String> v8ExternalString(const String& string, v8::Isolate* isolate = 0) { StringImpl* stringImpl = string.impl(); if (!stringImpl) return v8::String::Empty(); - V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); + V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(isolate); return data->stringCache()->v8ExternalString(stringImpl); } // Convert a string to a V8 string. - inline v8::Handle<v8::String> v8String(const String& string) + inline v8::Handle<v8::String> v8String(const String& string, v8::Isolate* isolate = 0) + { + return v8ExternalString(string, isolate); + } + + template<typename T> + v8::Handle<v8::Value> v8Array(const Vector<T>& iterator, v8::Isolate* isolate) + { + v8::Local<v8::Array> result = v8::Array::New(iterator.size()); + int index = 0; + typename Vector<T>::const_iterator end = iterator.end(); + for (typename Vector<T>::const_iterator iter = iterator.begin(); iter != end; ++iter) + result->Set(v8::Integer::New(index++), toV8(WTF::getPtr(*iter), isolate)); + return result; + } + + template<> + inline v8::Handle<v8::Value> v8Array(const Vector<String>& iterator, v8::Isolate* isolate) { - return v8ExternalString(string); + v8::Local<v8::Array> array = v8::Array::New(iterator.size()); + Vector<String>::const_iterator end = iterator.end(); + int index = 0; + for (Vector<String>::const_iterator iter = iterator.begin(); iter != end; ++iter) + array->Set(v8::Integer::New(index++), v8String(*iter, isolate)); + return array; + } + + template <class T> + Vector<T> toNativeArray(v8::Handle<v8::Value> value) + { + if (!value->IsArray()) + return Vector<T>(); + + Vector<T> result; + v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(value)); + v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(v8Value); + size_t length = array->Length(); + + for (size_t i = 0; i < length; ++i) { + result.append(v8ValueToWebCoreString(array->Get(i))); + } + return result; } // Enables caching v8 wrappers created for WTF::StringImpl. Currently this cache requires @@ -353,9 +390,8 @@ namespace WebCore { // If the object has any internal fields, then we won't be able to serialize or deserialize // them; conveniently, this is also a quick way to detect DOM wrapper objects, because // the mechanism for these relies on data stored in these fields. We should - // catch external array data and external pixel data as a special case (noting that CanvasPixelArrays - // can't be serialized without being wrapped by ImageData according to the standard). - return object->InternalFieldCount() || object->HasIndexedPropertiesInPixelData() || object->HasIndexedPropertiesInExternalArrayData(); + // catch external array data as a special case. + return object->InternalFieldCount() || object->HasIndexedPropertiesInExternalArrayData(); } inline v8::Handle<v8::Boolean> v8Boolean(bool value) @@ -383,19 +419,19 @@ namespace WebCore { return v8::String::NewUndetectable(fromWebCoreString(str), str.length()); } - inline v8::Handle<v8::Value> v8StringOrNull(const String& str) + inline v8::Handle<v8::Value> v8StringOrNull(const String& str, v8::Isolate* isolate = 0) { - return str.isNull() ? v8::Handle<v8::Value>(v8::Null()) : v8::Handle<v8::Value>(v8String(str)); + return str.isNull() ? v8::Handle<v8::Value>(v8::Null()) : v8::Handle<v8::Value>(v8String(str, isolate)); } - inline v8::Handle<v8::Value> v8StringOrUndefined(const String& str) + inline v8::Handle<v8::Value> v8StringOrUndefined(const String& str, v8::Isolate* isolate = 0) { - return str.isNull() ? v8::Handle<v8::Value>(v8::Undefined()) : v8::Handle<v8::Value>(v8String(str)); + return str.isNull() ? v8::Handle<v8::Value>(v8::Undefined()) : v8::Handle<v8::Value>(v8String(str, isolate)); } - inline v8::Handle<v8::Value> v8StringOrFalse(const String& str) + inline v8::Handle<v8::Value> v8StringOrFalse(const String& str, v8::Isolate* isolate = 0) { - return str.isNull() ? v8::Handle<v8::Value>(v8::False()) : v8::Handle<v8::Value>(v8String(str)); + return str.isNull() ? v8::Handle<v8::Value>(v8::False()) : v8::Handle<v8::Value>(v8String(str, isolate)); } template <class T> v8::Handle<v8::Value> v8NumberArray(const Vector<T>& values) diff --git a/Source/WebCore/bindings/v8/V8BindingPerContextData.cpp b/Source/WebCore/bindings/v8/V8BindingPerContextData.cpp new file mode 100644 index 000000000..a010efa78 --- /dev/null +++ b/Source/WebCore/bindings/v8/V8BindingPerContextData.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8BindingPerContextData.h" + +#include "SafeAllocation.h" + +namespace WebCore { + +void V8BindingPerContextData::dispose() +{ + { + WrapperBoilerplateMap::iterator it = m_wrapperBoilerplates.begin(); + for (; it != m_wrapperBoilerplates.end(); ++it) { + v8::Persistent<v8::Object> wrapper = it->second; + wrapper.Dispose(); + } + m_wrapperBoilerplates.clear(); + } + + { + ConstructorMap::iterator it = m_constructorMap.begin(); + for (; it != m_constructorMap.end(); ++it) { + v8::Persistent<v8::Function> wrapper = it->second; + wrapper.Dispose(); + } + m_constructorMap.clear(); + } +} + +bool V8BindingPerContextData::init() +{ + ASSERT(m_objectPrototype.get().IsEmpty()); + + v8::Handle<v8::String> objectString = v8::String::New("Object"); + v8::Handle<v8::String> prototypeString = v8::String::New("prototype"); + if (objectString.IsEmpty() || prototypeString.IsEmpty()) + return false; + + v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(m_context->Global()->Get(objectString)); + if (object.IsEmpty()) + return false; + v8::Handle<v8::Value> objectPrototype = object->Get(prototypeString); + if (objectPrototype.IsEmpty()) + return false; + + m_objectPrototype.set(objectPrototype); + return true; +} + +v8::Local<v8::Object> V8BindingPerContextData::createWrapperFromCacheSlowCase(WrapperTypeInfo* type) +{ + ASSERT(!m_objectPrototype.get().IsEmpty()); + + v8::Context::Scope scope(m_context); + v8::Local<v8::Function> function = constructorForType(type); + v8::Local<v8::Object> instance = SafeAllocation::newInstance(function); + if (!instance.IsEmpty()) { + m_wrapperBoilerplates.set(type, v8::Persistent<v8::Object>::New(instance)); + return instance->Clone(); + } + return v8::Local<v8::Object>(); +} + +v8::Local<v8::Function> V8BindingPerContextData::constructorForTypeSlowCase(WrapperTypeInfo* type) +{ + ASSERT(!m_objectPrototype.get().IsEmpty()); + + v8::Context::Scope scope(m_context); + v8::Handle<v8::FunctionTemplate> functionTemplate = type->getTemplate(); + // Getting the function might fail if we're running out of stack or memory. + v8::TryCatch tryCatch; + v8::Local<v8::Function> function = functionTemplate->GetFunction(); + if (function.IsEmpty()) + return v8::Local<v8::Function>(); + + function->SetPrototype(m_objectPrototype.get()); + + m_constructorMap.set(type, v8::Persistent<v8::Function>::New(function)); + + return function; +} + +} // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8BindingPerContextData.h b/Source/WebCore/bindings/v8/V8BindingPerContextData.h new file mode 100644 index 000000000..1a94a038b --- /dev/null +++ b/Source/WebCore/bindings/v8/V8BindingPerContextData.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2012 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 V8BindingPerContextData_h +#define V8BindingPerContextData_h + +#include "OwnHandle.h" +#include "WrapperTypeInfo.h" +#include <v8.h> +#include <wtf/HashMap.h> +#include <wtf/PassOwnPtr.h> + +namespace WebCore { + +class V8BindingPerContextData { +public: + static PassOwnPtr<V8BindingPerContextData> create(v8::Handle<v8::Context> context) + { + return adoptPtr(new V8BindingPerContextData(context)); + } + + ~V8BindingPerContextData() + { + dispose(); + } + + bool init(); + + // To create JS Wrapper objects, we create a cache of a 'boiler plate' + // object, and then simply Clone that object each time we need a new one. + // This is faster than going through the full object creation process. + v8::Local<v8::Object> createWrapperFromCache(WrapperTypeInfo* type) + { + v8::Persistent<v8::Object> boilerplate = m_wrapperBoilerplates.get(type); + return !boilerplate.IsEmpty() ? boilerplate->Clone() : createWrapperFromCacheSlowCase(type); + } + + v8::Local<v8::Function> constructorForType(WrapperTypeInfo* type) + { + v8::Persistent<v8::Function> function = m_constructorMap.get(type); + if (!function.IsEmpty()) + return v8::Local<v8::Function>::New(function); + return constructorForTypeSlowCase(type); + } + +private: + explicit V8BindingPerContextData(v8::Handle<v8::Context> context) + : m_context(context) + { + } + + void dispose(); + + v8::Local<v8::Object> createWrapperFromCacheSlowCase(WrapperTypeInfo*); + v8::Local<v8::Function> constructorForTypeSlowCase(WrapperTypeInfo*); + + // For each possible type of wrapper, we keep a boilerplate object. + // The boilerplate is used to create additional wrappers of the same type. + typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Object> > WrapperBoilerplateMap; + WrapperBoilerplateMap m_wrapperBoilerplates; + + typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Function> > ConstructorMap; + ConstructorMap m_constructorMap; + + v8::Handle<v8::Context> m_context; + OwnHandle<v8::Value> m_objectPrototype; +}; + +} // namespace WebCore + +#endif // V8BindingPerContextData_h diff --git a/Source/WebCore/bindings/v8/V8Collection.cpp b/Source/WebCore/bindings/v8/V8Collection.cpp index 2ff5c88dd..8dcbcc1dd 100644 --- a/Source/WebCore/bindings/v8/V8Collection.cpp +++ b/Source/WebCore/bindings/v8/V8Collection.cpp @@ -37,7 +37,7 @@ namespace WebCore { -v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value> value, HTMLSelectElement* base) +v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value> value, HTMLSelectElement* base, v8::Isolate* isolate) { if (value->IsNull() || value->IsUndefined()) { base->remove(index); @@ -48,14 +48,14 @@ v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::V // Check that the value is an HTMLOptionElement. If not, throw a TYPE_MISMATCH_ERR DOMException. if (!V8HTMLOptionElement::HasInstance(value)) { - V8Proxy::setDOMException(TYPE_MISMATCH_ERR); + V8Proxy::setDOMException(TYPE_MISMATCH_ERR, isolate); return value; } HTMLOptionElement* element = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>::Cast(value)); base->setOption(index, element, ec); - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, isolate); return value; } diff --git a/Source/WebCore/bindings/v8/V8Collection.h b/Source/WebCore/bindings/v8/V8Collection.h index 38a7c8cf7..136204d02 100644 --- a/Source/WebCore/bindings/v8/V8Collection.h +++ b/Source/WebCore/bindings/v8/V8Collection.h @@ -42,11 +42,11 @@ namespace WebCore { // FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param). // See https://bugs.webkit.org/show_bug.cgi?id=24664. -template<class T> static v8::Handle<v8::Value> getV8Object(T* implementation) +template<class T> static v8::Handle<v8::Value> getV8Object(T* implementation, v8::Isolate* isolate) { if (!implementation) return v8::Handle<v8::Value>(); - return toV8(implementation); + return toV8(implementation, isolate); } template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object) @@ -54,20 +54,20 @@ template<class Collection> static Collection* toNativeCollection(v8::Local<v8::O return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } -template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation) +template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation, v8::Isolate* isolate) { - return getV8Object(implementation.get()); + return getV8Object(implementation.get(), isolate); } // Returns named property of a collection. -template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object) +template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object, v8::Isolate* isolate) { // FIXME: assert object is a collection type ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); ASSERT(V8DOMWrapper::domWrapperType(object) != &V8Node::info); Collection* collection = toNativeCollection<Collection>(object); AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name); - return getV8Object<ItemType>(collection->namedItem(propertyName)); + return getV8Object<ItemType>(collection->namedItem(propertyName), isolate); } // A template of named property accessor of collections. @@ -78,23 +78,23 @@ template<class Collection, class ItemType> static v8::Handle<v8::Value> collecti if (info.Holder()->HasRealNamedCallbackProperty(name)) return notHandledByInterceptor(); - return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder()); + return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder(), info.GetIsolate()); } // Returns the property at the index of a collection. -template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object) +template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object, v8::Isolate* isolate) { // FIXME: Assert that object must be a collection type. ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); ASSERT(V8DOMWrapper::domWrapperType(object) != &V8Node::info); Collection* collection = toNativeCollection<Collection>(object); - return getV8Object<ItemType>(collection->item(index)); + return getV8Object<ItemType>(collection->item(index), isolate); } // A template of index interceptor of collections. template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) { - return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder()); + return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder(), info.GetIsolate()); } // Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement. @@ -176,7 +176,7 @@ template<class Collection> static void setCollectionStringIndexedGetter(v8::Hand desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>); } -v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*); +v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*, v8::Isolate*); } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8DOMMap.cpp b/Source/WebCore/bindings/v8/V8DOMMap.cpp index 93d5a1b9f..f09a4a895 100644 --- a/Source/WebCore/bindings/v8/V8DOMMap.cpp +++ b/Source/WebCore/bindings/v8/V8DOMMap.cpp @@ -50,47 +50,33 @@ DOMDataStoreHandle::~DOMDataStoreHandle() V8BindingPerIsolateData::current()->unregisterDOMDataStore(m_store.get()); } -static inline DOMDataStore& getDOMDataStore() -{ - return DOMData::getCurrentStore(); -} - void enableFasterDOMStoreAccess() { } -DOMNodeMapping& getDOMNodeMap() +DOMNodeMapping& getDOMNodeMap(v8::Isolate* isolate) { - return getDOMDataStore().domNodeMap(); + return DOMData::getCurrentStore(isolate).domNodeMap(); } -DOMNodeMapping& getActiveDOMNodeMap() +DOMNodeMapping& getActiveDOMNodeMap(v8::Isolate* isolate) { - return getDOMDataStore().activeDomNodeMap(); + return DOMData::getCurrentStore(isolate).activeDomNodeMap(); } -DOMWrapperMap<void>& getDOMObjectMap() +DOMWrapperMap<void>& getDOMObjectMap(v8::Isolate* isolate) { - return getDOMDataStore().domObjectMap(); + return DOMData::getCurrentStore(isolate).domObjectMap(); } -DOMWrapperMap<void>& getActiveDOMObjectMap() +DOMWrapperMap<void>& getActiveDOMObjectMap(v8::Isolate* isolate) { - return getDOMDataStore().activeDomObjectMap(); + return DOMData::getCurrentStore(isolate).activeDomObjectMap(); } -#if ENABLE(SVG) - -DOMWrapperMap<SVGElementInstance>& getDOMSVGElementInstanceMap() -{ - return getDOMDataStore().domSvgElementInstanceMap(); -} - -#endif // ENABLE(SVG) - void removeAllDOMObjects() { - DOMDataStore& store = getDOMDataStore(); + DOMDataStore& store = DOMData::getCurrentStore(); v8::HandleScope scope; @@ -101,11 +87,6 @@ void removeAllDOMObjects() // Remove all active DOM nodes. DOMData::removeObjectsFromWrapperMap<Node>(&store, store.activeDomNodeMap()); - -#if ENABLE(SVG) - // Remove all SVG element instances in the wrapper map. - DOMData::removeObjectsFromWrapperMap<SVGElementInstance>(&store, store.domSvgElementInstanceMap()); -#endif } // Remove all DOM objects in the wrapper map. @@ -163,20 +144,4 @@ void visitActiveDOMObjects(DOMWrapperMap<void>::Visitor* visitor) } } -#if ENABLE(SVG) - -void visitDOMSVGElementInstances(DOMWrapperMap<SVGElementInstance>::Visitor* visitor) -{ - v8::HandleScope scope; - - DOMDataList& list = DOMDataStore::allStores(); - for (size_t i = 0; i < list.size(); ++i) { - DOMDataStore* store = list[i]; - - store->domSvgElementInstanceMap().visit(store, visitor); - } -} - -#endif - } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8DOMMap.h b/Source/WebCore/bindings/v8/V8DOMMap.h index 4fa48e45e..bc51540a2 100644 --- a/Source/WebCore/bindings/v8/V8DOMMap.h +++ b/Source/WebCore/bindings/v8/V8DOMMap.h @@ -38,9 +38,6 @@ namespace WebCore { class DOMDataStore; class Node; -#if ENABLE(SVG) - class SVGElementInstance; -#endif template <class KeyType, class ValueType> class AbstractWeakReferenceMap { public: @@ -141,9 +138,6 @@ namespace WebCore { DOMWrapperMap(v8::WeakReferenceCallback callback) : WeakReferenceMap<KeyType, v8::Object>(callback) { } }; - // An opaque class that represents a set of DOM wrappers. - class DOMDataStore; - // A utility class to manage the lifetime of set of DOM wrappers. class DOMDataStoreHandle { public: @@ -157,28 +151,22 @@ namespace WebCore { }; // A map from DOM node to its JS wrapper. - DOMNodeMapping& getDOMNodeMap(); - DOMNodeMapping& getActiveDOMNodeMap(); + DOMNodeMapping& getDOMNodeMap(v8::Isolate* = 0); + DOMNodeMapping& getActiveDOMNodeMap(v8::Isolate* = 0); void visitDOMNodes(DOMWrapperMap<Node>::Visitor*); void visitActiveDOMNodes(DOMWrapperMap<Node>::Visitor*); // A map from a DOM object (non-node) to its JS wrapper. This map does not contain the DOM objects which can have pending activity (active dom objects). - DOMWrapperMap<void>& getDOMObjectMap(); + DOMWrapperMap<void>& getDOMObjectMap(v8::Isolate* = 0); void visitDOMObjects(DOMWrapperMap<void>::Visitor*); // A map from a DOM object to its JS wrapper for DOM objects which can have pending activity. - DOMWrapperMap<void>& getActiveDOMObjectMap(); + DOMWrapperMap<void>& getActiveDOMObjectMap(v8::Isolate* = 0); void visitActiveDOMObjects(DOMWrapperMap<void>::Visitor*); // This should be called to remove all DOM objects associated with the current thread when it is tearing down. void removeAllDOMObjects(); -#if ENABLE(SVG) - // A map for SVGElementInstances to its JS wrapper. - DOMWrapperMap<SVGElementInstance>& getDOMSVGElementInstanceMap(); - void visitSVGElementInstances(DOMWrapperMap<SVGElementInstance>::Visitor*); -#endif - void enableFasterDOMStoreAccess(); } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp index 8c02201f7..90dc0f80d 100644 --- a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp +++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp @@ -36,9 +36,11 @@ #include "DocumentLoader.h" #include "Frame.h" #include "FrameLoaderClient.h" +#include "MemoryUsageSupport.h" #include "Page.h" #include "PageGroup.h" #include "RuntimeEnabledFeatures.h" +#include "SafeAllocation.h" #include "ScriptCallStack.h" #include "ScriptCallStackFactory.h" #include "ScriptProfiler.h" @@ -46,6 +48,7 @@ #include "StorageNamespace.h" #include "StylePropertySet.h" #include "V8Binding.h" +#include "V8BindingPerContextData.h" #include "V8BindingState.h" #include "V8Collection.h" #include "V8DOMMap.h" @@ -92,7 +95,7 @@ static void reportFatalErrorInV8(const char* location, const char* message) // FIXME: clean up V8Proxy and disable JavaScript. int memoryUsageMB = -1; #if PLATFORM(CHROMIUM) - memoryUsageMB = PlatformSupport::actualMemoryUsageMB(); + memoryUsageMB = MemoryUsageSupport::actualMemoryUsageMB(); #endif printf("V8 error: %s (%s). Current memory usage: %d MB\n", message, location, memoryUsageMB); handleFatalErrorInV8(); @@ -180,16 +183,11 @@ void V8DOMWindowShell::disposeContextHandles() // It's likely that disposing the context has created a lot of // garbage. Notify V8 about this so it'll have a chance of cleaning // it up when idle. - V8GCForContextDispose::instance().notifyContextDisposed(); + bool isMainFrame = m_frame->page() && (m_frame->page()->mainFrame() == m_frame); + V8GCForContextDispose::instance().notifyContextDisposed(isMainFrame); } - WrapperBoilerplateMap::iterator it = m_wrapperBoilerplates.begin(); - for (; it != m_wrapperBoilerplates.end(); ++it) { - v8::Persistent<v8::Object> wrapper = it->second; - wrapper.Dispose(); - wrapper.Clear(); - } - m_wrapperBoilerplates.clear(); + m_perContextData.clear(); } void V8DOMWindowShell::destroyGlobal() @@ -297,9 +295,9 @@ bool V8DOMWindowShell::initContextIfNeeded() v8::V8::AddMessageListener(&v8UncaughtExceptionHandler); v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess); - +#if ENABLE(JAVASCRIPT_DEBUGGER) ScriptProfiler::initialize(); - +#endif V8BindingPerIsolateData::ensureInitialized(v8::Isolate::GetCurrent()); isV8Initialized = true; @@ -325,7 +323,8 @@ bool V8DOMWindowShell::initContextIfNeeded() #endif } - if (!installHiddenObjectPrototype(v8Context)) { + m_perContextData = V8BindingPerContextData::create(m_context); + if (!m_perContextData->init()) { disposeContextHandles(); return false; } @@ -403,7 +402,7 @@ void V8DOMWindowShell::setContext(v8::Handle<v8::Context> context) bool V8DOMWindowShell::installDOMWindow(v8::Handle<v8::Context> context, DOMWindow* window) { // Create a new JS window object and use it as the prototype for the shadow global object. - v8::Handle<v8::Function> windowConstructor = V8DOMWrapper::getConstructor(&V8DOMWindow::info, getHiddenObjectPrototype(context)); + v8::Handle<v8::Function> windowConstructor = V8DOMWrapper::constructorForType(&V8DOMWindow::info, window); v8::Local<v8::Object> jsWindow = SafeAllocation::newInstance(windowConstructor); // Bail out if allocation failed. if (jsWindow.IsEmpty()) @@ -413,8 +412,7 @@ bool V8DOMWindowShell::installDOMWindow(v8::Handle<v8::Context> context, DOMWind V8DOMWrapper::setDOMWrapper(jsWindow, &V8DOMWindow::info, window); V8DOMWrapper::setDOMWrapper(v8::Handle<v8::Object>::Cast(jsWindow->GetPrototype()), &V8DOMWindow::info, window); - window->ref(); - V8DOMWrapper::setJSWrapperForDOMObject(window, v8::Persistent<v8::Object>::New(jsWindow)); + V8DOMWrapper::setJSWrapperForDOMObject(PassRefPtr<DOMWindow>(window), v8::Persistent<v8::Object>::New(jsWindow)); // Insert the window instance as the prototype of the shadow object. v8::Handle<v8::Object> v8RealGlobal = v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype()); @@ -553,7 +551,7 @@ v8::Handle<v8::Value> getter(v8::Local<v8::String> property, const v8::AccessorI AtomicString name = v8StringToAtomicWebCoreString(property); HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder()); ASSERT(htmlDocument); - v8::Handle<v8::Value> result = V8HTMLDocument::GetNamedProperty(htmlDocument, name); + v8::Handle<v8::Value> result = V8HTMLDocument::GetNamedProperty(htmlDocument, name, info.GetIsolate()); if (!result.IsEmpty()) return result; v8::Handle<v8::Value> prototype = info.Holder()->GetPrototype(); @@ -597,54 +595,4 @@ void V8DOMWindowShell::updateSecurityOrigin() setSecurityToken(); } -v8::Handle<v8::Value> V8DOMWindowShell::getHiddenObjectPrototype(v8::Handle<v8::Context> context) -{ - return context->Global()->GetHiddenValue(V8HiddenPropertyName::objectPrototype()); -} - -bool V8DOMWindowShell::installHiddenObjectPrototype(v8::Handle<v8::Context> context) -{ - v8::Handle<v8::String> objectString = v8::String::New("Object"); - v8::Handle<v8::String> prototypeString = v8::String::New("prototype"); - v8::Handle<v8::String> hiddenObjectPrototypeString = V8HiddenPropertyName::objectPrototype(); - // Bail out if allocation failed. - if (objectString.IsEmpty() || prototypeString.IsEmpty() || hiddenObjectPrototypeString.IsEmpty()) - return false; - - v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(objectString)); - // Bail out if fetching failed. - if (object.IsEmpty()) - return false; - v8::Handle<v8::Value> objectPrototype = object->Get(prototypeString); - // Bail out if fetching failed. - if (objectPrototype.IsEmpty()) - return false; - - context->Global()->SetHiddenValue(hiddenObjectPrototypeString, objectPrototype); - - return true; -} - -v8::Local<v8::Object> V8DOMWindowShell::createWrapperFromCacheSlowCase(WrapperTypeInfo* type) -{ - // Not in cache. - if (!initContextIfNeeded()) - return notHandledByInterceptor(); - - v8::Context::Scope scope(m_context); - v8::Local<v8::Function> function = V8DOMWrapper::getConstructor(type, getHiddenObjectPrototype(m_context)); - v8::Local<v8::Object> instance = SafeAllocation::newInstance(function); - if (!instance.IsEmpty()) { - m_wrapperBoilerplates.set(type, v8::Persistent<v8::Object>::New(instance)); - return instance->Clone(); - } - return notHandledByInterceptor(); -} - -void V8DOMWindowShell::setLocation(DOMWindow* window, const String& locationString) -{ - State<V8Binding>* state = V8BindingState::Only(); - window->setLocation(locationString, state->activeWindow(), state->firstWindow()); -} - } // WebCore diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.h b/Source/WebCore/bindings/v8/V8DOMWindowShell.h index 5977499bd..0676f1450 100644 --- a/Source/WebCore/bindings/v8/V8DOMWindowShell.h +++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.h @@ -31,6 +31,7 @@ #ifndef V8DOMWindowShell_h #define V8DOMWindowShell_h +#include "V8BindingPerContextData.h" #include "WrapperTypeInfo.h" #include <wtf/Forward.h> #include <wtf/HashMap.h> @@ -77,20 +78,7 @@ public: void destroyGlobal(); - static v8::Handle<v8::Value> getHiddenObjectPrototype(v8::Handle<v8::Context>); - // WARNING: Call |installHiddenObjectPrototype| only on fresh contexts! - static bool installHiddenObjectPrototype(v8::Handle<v8::Context>); - - // To create JS Wrapper objects, we create a cache of a 'boiler plate' - // object, and then simply Clone that object each time we need a new one. - // This is faster than going through the full object creation process. - v8::Local<v8::Object> createWrapperFromCache(WrapperTypeInfo* type) - { - v8::Persistent<v8::Object> boilerplate = m_wrapperBoilerplates.get(type); - return boilerplate.IsEmpty() ? createWrapperFromCacheSlowCase(type) : boilerplate->Clone(); - } - - static void setLocation(DOMWindow*, const String& relativeURL); + V8BindingPerContextData* perContextData() { return m_perContextData.get(); } private: V8DOMWindowShell(Frame*); @@ -107,14 +95,9 @@ private: void updateDocumentWrapperCache(); void clearDocumentWrapperCache(); - v8::Local<v8::Object> createWrapperFromCacheSlowCase(WrapperTypeInfo*); - Frame* m_frame; - // For each possible type of wrapper, we keep a boilerplate object. - // The boilerplate is used to create additional wrappers of the same type. - typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Object> > WrapperBoilerplateMap; - WrapperBoilerplateMap m_wrapperBoilerplates; + OwnPtr<V8BindingPerContextData> m_perContextData; v8::Persistent<v8::Context> m_context; v8::Persistent<v8::Object> m_global; diff --git a/Source/WebCore/bindings/v8/V8DOMWrapper.cpp b/Source/WebCore/bindings/v8/V8DOMWrapper.cpp index 4cf3c9a46..0ad4e2214 100644 --- a/Source/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/Source/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -31,23 +31,22 @@ #include "config.h" #include "V8DOMWrapper.h" -#include "ArrayBufferView.h" -#include "DOMDataStore.h" +#include <wtf/ArrayBufferView.h> #include "DocumentLoader.h" #include "EventTargetHeaders.h" #include "EventTargetInterfaces.h" #include "FrameLoaderClient.h" +#include "SafeAllocation.h" #include "StylePropertySet.h" #include "V8AbstractEventListener.h" #include "V8Binding.h" +#include "V8BindingPerContextData.h" #include "V8Collection.h" -#include "V8DOMMap.h" #include "V8EventListener.h" #include "V8EventListenerList.h" #include "V8HTMLCollection.h" #include "V8HTMLDocument.h" #include "V8HiddenPropertyName.h" -#include "V8IsolatedContext.h" #include "V8Location.h" #include "V8NamedNodeMap.h" #include "V8NodeFilterCondition.h" @@ -69,111 +68,56 @@ namespace WebCore { -typedef HashMap<Node*, v8::Object*> DOMNodeMap; -typedef HashMap<void*, v8::Object*> DOMObjectMap; - -static ALWAYS_INLINE v8::Handle<v8::Object> getExistingWrapperInline(Node* node) +void V8DOMWrapper::setJSWrapperForDOMNode(PassRefPtr<Node> node, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate) { - V8IsolatedContext* context = V8IsolatedContext::getEntered(); - if (LIKELY(!context)) { - v8::Persistent<v8::Object>* wrapper = node->wrapper(); - if (!wrapper) - return v8::Handle<v8::Object>(); - return *wrapper; - } - DOMDataStore* store = context->world()->domDataStore(); - DOMNodeMapping& domNodeMap = node->isActiveNode() ? store->activeDomNodeMap() : store->domNodeMap(); - return domNodeMap.get(node); + ASSERT(maybeDOMWrapper(wrapper)); + ASSERT(!node->isActiveNode()); + getDOMNodeMap(isolate).set(node.leakRef(), wrapper); } -// The caller must have increased obj's ref count. -void V8DOMWrapper::setJSWrapperForDOMObject(void* object, v8::Persistent<v8::Object> wrapper) +void V8DOMWrapper::setJSWrapperForActiveDOMNode(PassRefPtr<Node> node, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate) { - ASSERT(V8DOMWrapper::maybeDOMWrapper(wrapper)); - ASSERT(!domWrapperType(wrapper)->toActiveDOMObjectFunction); - getDOMObjectMap().set(object, wrapper); + ASSERT(maybeDOMWrapper(wrapper)); + ASSERT(node->isActiveNode()); + getActiveDOMNodeMap(isolate).set(node.leakRef(), wrapper); } -// The caller must have increased obj's ref count. -void V8DOMWrapper::setJSWrapperForActiveDOMObject(void* object, v8::Persistent<v8::Object> wrapper) +v8::Local<v8::Function> V8DOMWrapper::constructorForType(WrapperTypeInfo* type, DOMWindow* window) { - ASSERT(V8DOMWrapper::maybeDOMWrapper(wrapper)); - ASSERT(domWrapperType(wrapper)->toActiveDOMObjectFunction); - getActiveDOMObjectMap().set(object, wrapper); -} + Frame* frame = window->frame(); + if (!frame) + return v8::Local<v8::Function>(); -// The caller must have increased node's ref count. -void V8DOMWrapper::setJSWrapperForDOMNode(Node* node, v8::Persistent<v8::Object> wrapper) -{ - ASSERT(V8DOMWrapper::maybeDOMWrapper(wrapper)); - if (node->isActiveNode()) - getActiveDOMNodeMap().set(node, wrapper); - else - getDOMNodeMap().set(node, wrapper); -} + if (V8BindingPerContextData* contextData = V8Proxy::retrievePerContextData(frame)) + return contextData->constructorForType(type); -v8::Local<v8::Function> V8DOMWrapper::getConstructor(WrapperTypeInfo* type, v8::Handle<v8::Value> objectPrototype) -{ - // A DOM constructor is a function instance created from a DOM constructor - // template. There is one instance per context. A DOM constructor is - // different from a normal function in two ways: - // 1) it cannot be called as constructor (aka, used to create a DOM object) - // 2) its __proto__ points to Object.prototype rather than - // Function.prototype. - // The reason for 2) is that, in Safari, a DOM constructor is a normal JS - // object, but not a function. Hotmail relies on the fact that, in Safari, - // HTMLElement.__proto__ == Object.prototype. - v8::Handle<v8::FunctionTemplate> functionTemplate = type->getTemplate(); - // Getting the function might fail if we're running out of - // stack or memory. - v8::TryCatch tryCatch; - v8::Local<v8::Function> value = functionTemplate->GetFunction(); - if (value.IsEmpty()) - return v8::Local<v8::Function>(); - // Hotmail fix, see comments above. - if (!objectPrototype.IsEmpty()) - value->SetPrototype(objectPrototype); - return value; + return v8::Local<v8::Function>(); } -v8::Local<v8::Function> V8DOMWrapper::getConstructorForContext(WrapperTypeInfo* type, v8::Handle<v8::Context> context) +#if ENABLE(WORKERS) +v8::Local<v8::Function> V8DOMWrapper::constructorForType(WrapperTypeInfo* type, WorkerContext*) { - // Enter the scope for this context to get the correct constructor. - v8::Context::Scope scope(context); - - return getConstructor(type, V8DOMWindowShell::getHiddenObjectPrototype(context)); + WorkerScriptController* controller = WorkerScriptController::controllerForContext(); + WorkerContextExecutionProxy* proxy = controller ? controller->proxy() : 0; + return proxy ? proxy->perContextData()->constructorForType(type) : v8::Local<v8::Function>(); } +#endif -v8::Local<v8::Function> V8DOMWrapper::getConstructor(WrapperTypeInfo* type, DOMWindow* window) +V8BindingPerContextData* V8DOMWrapper::perContextData(V8Proxy* proxy) { - Frame* frame = window->frame(); - if (!frame) - return v8::Local<v8::Function>(); - - v8::Handle<v8::Context> context = V8Proxy::context(frame); - if (context.IsEmpty()) - return v8::Local<v8::Function>(); - - return getConstructorForContext(type, context); + V8DOMWindowShell* shell = proxy->windowShell(); + return shell ? shell->perContextData() : 0; } #if ENABLE(WORKERS) -v8::Local<v8::Function> V8DOMWrapper::getConstructor(WrapperTypeInfo* type, WorkerContext*) +V8BindingPerContextData* V8DOMWrapper::perContextData(WorkerContext*) { WorkerScriptController* controller = WorkerScriptController::controllerForContext(); WorkerContextExecutionProxy* proxy = controller ? controller->proxy() : 0; - if (!proxy) - return v8::Local<v8::Function>(); - - v8::Handle<v8::Context> context = proxy->context(); - if (context.IsEmpty()) - return v8::Local<v8::Function>(); - - return getConstructorForContext(type, context); + return proxy ? proxy->perContextData() : 0; } #endif - void V8DOMWrapper::setNamedHiddenReference(v8::Handle<v8::Object> parent, const char* name, v8::Handle<v8::Value> child) { parent->SetHiddenValue(V8HiddenPropertyName::hiddenReferenceName(name), child); @@ -220,12 +164,10 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, WrapperT #if ENABLE(WORKERS) WorkerContext* workerContext = 0; #endif - if (V8IsolatedContext::getEntered()) { - // This effectively disables the wrapper cache for isolated worlds. - proxy = 0; - // FIXME: Do we need a wrapper cache for the isolated world? We should - // see if the performance gains are worth while. - // We'll get one once we give the isolated context a proper window shell. + V8BindingPerContextData* contextData = 0; + V8IsolatedContext* isolatedContext; + if (UNLIKELY(!!(isolatedContext = V8IsolatedContext::getEntered()))) { + contextData = isolatedContext->perContextData(); } else if (!proxy) { v8::Handle<v8::Context> context = v8::Context::GetCurrent(); if (!context.IsEmpty()) { @@ -236,26 +178,29 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, WrapperT proxy = V8Proxy::retrieve(frame); } #if ENABLE(WORKERS) - else + else if (isWrapperOfType(globalPrototype, &V8WorkerContext::info)) workerContext = V8WorkerContext::toNative(lookupDOMWrapper(V8WorkerContext::GetTemplate(), context->Global())); #endif } } v8::Local<v8::Object> instance; - if (proxy) - // FIXME: Fix this to work properly with isolated worlds (see above). - instance = proxy->windowShell()->createWrapperFromCache(type); - else { - v8::Local<v8::Function> function; + if (!contextData) { + if (proxy) + contextData = perContextData(proxy); #if ENABLE(WORKERS) - if (workerContext) - function = getConstructor(type, workerContext); - else + else if (workerContext) + contextData = perContextData(workerContext); #endif - function = type->getTemplate()->GetFunction(); + } + + if (contextData) + instance = contextData->createWrapperFromCache(type); + else { + v8::Local<v8::Function> function = type->getTemplate()->GetFunction(); instance = SafeAllocation::newInstance(function); } + if (!instance.IsEmpty()) { // Avoid setting the DOM wrapper for failed allocations. setDOMWrapper(instance, type, impl); @@ -306,19 +251,6 @@ bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, WrapperTypeInfo* return typeInfo == type; } -v8::Handle<v8::Object> V8DOMWrapper::getExistingWrapperSlow(Node* node) -{ - return getExistingWrapperInline(node); -} - -v8::Handle<v8::Value> V8DOMWrapper::getWrapperSlow(Node* node) -{ - v8::Handle<v8::Object> wrapper = getExistingWrapperInline(node); - if (!wrapper.IsEmpty()) - return wrapper; - return toV8Slow(node, false); -} - #define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \ if (eventNames().interfaceFor##interfaceName == desiredInterface) \ return toV8(static_cast<interfaceName*>(target)); @@ -364,4 +296,5 @@ RefPtr<XPathNSResolver> V8DOMWrapper::getXPathNSResolver(v8::Handle<v8::Value> v return resolver; } + } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8DOMWrapper.h b/Source/WebCore/bindings/v8/V8DOMWrapper.h index d3ca51e06..b3c9ff9d7 100644 --- a/Source/WebCore/bindings/v8/V8DOMWrapper.h +++ b/Source/WebCore/bindings/v8/V8DOMWrapper.h @@ -31,19 +31,23 @@ #ifndef V8DOMWrapper_h #define V8DOMWrapper_h +#include "DOMDataStore.h" #include "Event.h" #include "IsolatedWorld.h" #include "Node.h" #include "NodeFilter.h" #include "PlatformString.h" #include "V8CustomXPathNSResolver.h" +#include "V8DOMMap.h" #include "V8Event.h" +#include "V8IsolatedContext.h" #include "V8Utilities.h" #include "V8XPathNSResolver.h" #include "WrapperTypeInfo.h" #include "XPathNSResolver.h" #include <v8.h> #include <wtf/MainThread.h> +#include <wtf/PassRefPtr.h> namespace WebCore { @@ -51,6 +55,7 @@ namespace WebCore { class EventTarget; class Frame; class Node; + class V8BindingPerContextData; class V8Proxy; class WorkerContext; @@ -96,17 +101,15 @@ namespace WebCore { // Wrap JS node filter in C++. static PassRefPtr<NodeFilter> wrapNativeNodeFilter(v8::Handle<v8::Value>); - static v8::Local<v8::Function> getConstructorForContext(WrapperTypeInfo*, v8::Handle<v8::Context>); - static v8::Local<v8::Function> getConstructor(WrapperTypeInfo*, v8::Handle<v8::Value> objectPrototype); - static v8::Local<v8::Function> getConstructor(WrapperTypeInfo*, DOMWindow*); + static v8::Local<v8::Function> constructorForType(WrapperTypeInfo*, DOMWindow*); #if ENABLE(WORKERS) - static v8::Local<v8::Function> getConstructor(WrapperTypeInfo*, WorkerContext*); + static v8::Local<v8::Function> constructorForType(WrapperTypeInfo*, WorkerContext*); #endif - // Set JS wrapper of a DOM object, the caller in charge of increase ref. - static void setJSWrapperForDOMObject(void*, v8::Persistent<v8::Object>); - static void setJSWrapperForActiveDOMObject(void*, v8::Persistent<v8::Object>); - static void setJSWrapperForDOMNode(Node*, v8::Persistent<v8::Object>); + template<typename T> static void setJSWrapperForDOMObject(PassRefPtr<T>, v8::Persistent<v8::Object>, v8::Isolate* = 0); + template<typename T> static void setJSWrapperForActiveDOMObject(PassRefPtr<T>, v8::Persistent<v8::Object>, v8::Isolate* = 0); + static void setJSWrapperForDOMNode(PassRefPtr<Node>, v8::Persistent<v8::Object>, v8::Isolate* = 0); + static void setJSWrapperForActiveDOMNode(PassRefPtr<Node>, v8::Persistent<v8::Object>, v8::Isolate* = 0); static bool isValidDOMObject(v8::Handle<v8::Value>); @@ -124,7 +127,7 @@ namespace WebCore { static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, WrapperTypeInfo*, void* impl); - static v8::Handle<v8::Object> getExistingWrapper(Node* node) + static v8::Handle<v8::Object> getCachedWrapper(Node* node) { ASSERT(isMainThread()); if (LIKELY(!IsolatedWorld::count())) { @@ -132,25 +135,40 @@ namespace WebCore { if (LIKELY(!!wrapper)) return *wrapper; } - return getExistingWrapperSlow(node); - } - static v8::Handle<v8::Value> getWrapper(Node* node) - { - ASSERT(isMainThread()); - if (LIKELY(!IsolatedWorld::count())) { + V8IsolatedContext* context = V8IsolatedContext::getEntered(); + if (LIKELY(!context)) { v8::Persistent<v8::Object>* wrapper = node->wrapper(); - if (LIKELY(!!wrapper)) - return *wrapper; + if (!wrapper) + return v8::Handle<v8::Object>(); + return *wrapper; } - return getWrapperSlow(node); + DOMDataStore* store = context->world()->domDataStore(); + DOMNodeMapping& domNodeMap = node->isActiveNode() ? store->activeDomNodeMap() : store->domNodeMap(); + return domNodeMap.get(node); } - private: - static v8::Handle<v8::Object> getExistingWrapperSlow(Node*); - static v8::Handle<v8::Value> getWrapperSlow(Node*); + static V8BindingPerContextData* perContextData(V8Proxy*); +#if ENABLE(WORKERS) + static V8BindingPerContextData* perContextData(WorkerContext*); +#endif }; + template<typename T> + void V8DOMWrapper::setJSWrapperForDOMObject(PassRefPtr<T> object, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate) + { + ASSERT(maybeDOMWrapper(wrapper)); + ASSERT(!domWrapperType(wrapper)->toActiveDOMObjectFunction); + getDOMObjectMap(isolate).set(object.leakRef(), wrapper); + } + + template<typename T> + void V8DOMWrapper::setJSWrapperForActiveDOMObject(PassRefPtr<T> object, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate) + { + ASSERT(maybeDOMWrapper(wrapper)); + ASSERT(domWrapperType(wrapper)->toActiveDOMObjectFunction); + getActiveDOMObjectMap(isolate).set(object.leakRef(), wrapper); + } } #endif // V8DOMWrapper_h diff --git a/Source/WebCore/bindings/v8/V8GCController.cpp b/Source/WebCore/bindings/v8/V8GCController.cpp index 540312432..d88a53c2f 100644 --- a/Source/WebCore/bindings/v8/V8GCController.cpp +++ b/Source/WebCore/bindings/v8/V8GCController.cpp @@ -37,6 +37,7 @@ #include "DOMImplementation.h" #include "HTMLImageElement.h" #include "HTMLNames.h" +#include "MemoryUsageSupport.h" #include "MessagePort.h" #include "PlatformSupport.h" #include "RetainedDOMInfo.h" @@ -291,7 +292,7 @@ typedef Vector<GrouperItem> GrouperList; // element of the tree to which it belongs. static GroupId calculateGroupId(Node* node) { - if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && !static_cast<HTMLImageElement*>(node)->haveFiredLoadEvent())) + if (node->inDocument() || (node->hasTagName(HTMLNames::imgTag) && static_cast<HTMLImageElement*>(node)->hasPendingLoadEvent())) return GroupId(node->document()); Node* root = node; @@ -468,7 +469,7 @@ namespace { int getMemoryUsageInMB() { #if PLATFORM(CHROMIUM) - return PlatformSupport::memoryUsageMB(); + return MemoryUsageSupport::memoryUsageMB(); #else return 0; #endif @@ -477,7 +478,7 @@ int getMemoryUsageInMB() int getActualMemoryUsageInMB() { #if PLATFORM(CHROMIUM) - return PlatformSupport::actualMemoryUsageMB(); + return MemoryUsageSupport::actualMemoryUsageMB(); #else return 0; #endif @@ -513,9 +514,9 @@ void V8GCController::gcEpilogue() void V8GCController::checkMemoryUsage() { #if PLATFORM(CHROMIUM) || PLATFORM(QT) - const int lowMemoryUsageMB = PlatformSupport::lowMemoryUsageMB(); - const int highMemoryUsageMB = PlatformSupport::highMemoryUsageMB(); - const int highUsageDeltaMB = PlatformSupport::highUsageDeltaMB(); + const int lowMemoryUsageMB = MemoryUsageSupport::lowMemoryUsageMB(); + const int highMemoryUsageMB = MemoryUsageSupport::highMemoryUsageMB(); + const int highUsageDeltaMB = MemoryUsageSupport::highUsageDeltaMB(); int memoryUsageMB = getMemoryUsageInMB(); if ((memoryUsageMB > lowMemoryUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highMemoryUsageMB && memoryUsageMB > workingSetEstimateMB + highUsageDeltaMB)) v8::V8::LowMemoryNotification(); diff --git a/Source/WebCore/bindings/v8/V8GCForContextDispose.cpp b/Source/WebCore/bindings/v8/V8GCForContextDispose.cpp index 06a0555da..b67abd808 100644 --- a/Source/WebCore/bindings/v8/V8GCForContextDispose.cpp +++ b/Source/WebCore/bindings/v8/V8GCForContextDispose.cpp @@ -37,11 +37,13 @@ namespace WebCore { V8GCForContextDispose::V8GCForContextDispose() : m_pseudoIdleTimer(this, &V8GCForContextDispose::pseudoIdleTimerFired) + , m_didDisposeContextForMainFrame(false) { } -void V8GCForContextDispose::notifyContextDisposed() +void V8GCForContextDispose::notifyContextDisposed(bool isMainFrame) { + m_didDisposeContextForMainFrame = m_didDisposeContextForMainFrame || isMainFrame; v8::V8::ContextDisposedNotification(); if (!m_pseudoIdleTimer.isActive()) m_pseudoIdleTimer.startOneShot(0.8); @@ -66,7 +68,11 @@ V8GCForContextDispose& V8GCForContextDispose::instance() void V8GCForContextDispose::pseudoIdleTimerFired(Timer<V8GCForContextDispose>*) { - v8::V8::IdleNotification(); + const int longIdlePauseInMs = 1000; + const int shortIdlePauseInMs = 10; + int hint = m_didDisposeContextForMainFrame ? longIdlePauseInMs : shortIdlePauseInMs; + v8::V8::IdleNotification(hint); + m_didDisposeContextForMainFrame = false; } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8GCForContextDispose.h b/Source/WebCore/bindings/v8/V8GCForContextDispose.h index b15c5af3d..44632c63d 100644 --- a/Source/WebCore/bindings/v8/V8GCForContextDispose.h +++ b/Source/WebCore/bindings/v8/V8GCForContextDispose.h @@ -38,7 +38,7 @@ namespace WebCore { class V8GCForContextDispose { public: - void notifyContextDisposed(); + void notifyContextDisposed(bool isMainFrame); void notifyIdleSooner(double maximumFireInterval); static V8GCForContextDispose& instance(); @@ -48,6 +48,7 @@ private: void pseudoIdleTimerFired(Timer<V8GCForContextDispose>*); Timer<V8GCForContextDispose> m_pseudoIdleTimer; + bool m_didDisposeContextForMainFrame; }; } diff --git a/Source/WebCore/bindings/v8/V8IsolatedContext.cpp b/Source/WebCore/bindings/v8/V8IsolatedContext.cpp index ba7505cf9..60766f66d 100644 --- a/Source/WebCore/bindings/v8/V8IsolatedContext.cpp +++ b/Source/WebCore/bindings/v8/V8IsolatedContext.cpp @@ -35,11 +35,17 @@ #include "Frame.h" #include "FrameLoaderClient.h" #include "SecurityOrigin.h" +#include "V8BindingPerContextData.h" #include "V8DOMWindow.h" -#include "V8HiddenPropertyName.h" +#include "V8Proxy.h" +#include <wtf/StringExtras.h> namespace WebCore { +V8IsolatedContext* V8IsolatedContext::isolatedContext() +{ + return reinterpret_cast<V8IsolatedContext*>(getGlobalObject(v8::Context::GetEntered())->GetPointerFromInternalField(V8DOMWindow::enteredIsolatedWorldIndex)); +} void V8IsolatedContext::contextWeakReferenceCallback(v8::Persistent<v8::Value> object, void* isolatedContext) { @@ -48,11 +54,25 @@ void V8IsolatedContext::contextWeakReferenceCallback(v8::Persistent<v8::Value> o delete context; } +static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext, int debugId) +{ + char buffer[32]; + if (debugId == -1) + snprintf(buffer, sizeof(buffer), "injected"); + else + snprintf(buffer, sizeof(buffer), "injected,%d", debugId); + targetContext->SetData(v8::String::New(buffer)); +} + V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int worldId) : m_world(IsolatedWorld::create(worldId)), m_frame(proxy->frame()) { v8::HandleScope scope; + v8::Handle<v8::Context> mainWorldContext = proxy->windowShell()->context(); + if (mainWorldContext.IsEmpty()) + return; + // FIXME: We should be creating a new V8DOMWindowShell here instead of riping out the context. m_context = SharedPersistent<v8::Context>::create(proxy->windowShell()->createNewContext(v8::Handle<v8::Object>(), extensionGroup, m_world->id())); if (m_context->get().IsEmpty()) @@ -61,9 +81,14 @@ V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int wor // Run code in the new context. v8::Context::Scope contextScope(m_context->get()); + // Setup context id for JS debugger. + setInjectedScriptContextDebugId(m_context->get(), proxy->contextDebugId(mainWorldContext)); + getGlobalObject(m_context->get())->SetPointerInInternalField(V8DOMWindow::enteredIsolatedWorldIndex, this); - V8DOMWindowShell::installHiddenObjectPrototype(m_context->get()); + m_perContextData = V8BindingPerContextData::create(m_context->get()); + m_perContextData->init(); + // FIXME: This will go away once we have a windowShell for the isolated world. proxy->windowShell()->installDOMWindow(m_context->get(), m_frame->domWindow()); diff --git a/Source/WebCore/bindings/v8/V8IsolatedContext.h b/Source/WebCore/bindings/v8/V8IsolatedContext.h index ac6ccd44a..9bfe8b10b 100644 --- a/Source/WebCore/bindings/v8/V8IsolatedContext.h +++ b/Source/WebCore/bindings/v8/V8IsolatedContext.h @@ -33,14 +33,14 @@ #include "IsolatedWorld.h" #include "ScriptSourceCode.h" // for WebCore::ScriptSourceCode -#include "V8DOMWindow.h" -#include "V8Proxy.h" +#include "SharedPersistent.h" #include "V8Utilities.h" #include <v8.h> namespace WebCore { class SecurityOrigin; +class V8BindingPerContextData; class V8Proxy; // V8IsolatedContext @@ -77,8 +77,8 @@ public: // static V8IsolatedContext* getEntered() { - // This is a temporary performance optimization. Essentially, - // GetHiddenValue is too slow for this code path. We need to get the + // This is a temporary performance optimization. Essentially, + // GetHiddenValue is too slow for this code path. We need to get the // V8 team to add a real property to v8::Context for isolated worlds. // Until then, we optimize the common case of not having any isolated // worlds at all. @@ -86,7 +86,7 @@ public: return 0; if (!v8::Context::InContext()) return 0; - return reinterpret_cast<V8IsolatedContext*>(getGlobalObject(v8::Context::GetEntered())->GetPointerFromInternalField(V8DOMWindow::enteredIsolatedWorldIndex)); + return isolatedContext(); } v8::Handle<v8::Context> context() { return m_context->get(); } @@ -97,6 +97,8 @@ public: SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } void setSecurityOrigin(PassRefPtr<SecurityOrigin>); + V8BindingPerContextData* perContextData() { return m_perContextData.get(); } + private: static v8::Handle<v8::Object> getGlobalObject(v8::Handle<v8::Context> context) { @@ -107,6 +109,8 @@ private: // to be destroyed. static void contextWeakReferenceCallback(v8::Persistent<v8::Value> object, void* isolatedContext); + static V8IsolatedContext* isolatedContext(); + // The underlying v8::Context. This object is keep on the heap as // long as |m_context| has not been garbage collected. RefPtr<SharedPersistent<v8::Context> > m_context; @@ -116,6 +120,8 @@ private: RefPtr<SecurityOrigin> m_securityOrigin; Frame* m_frame; + + OwnPtr<V8BindingPerContextData> m_perContextData; }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8LazyEventListener.cpp b/Source/WebCore/bindings/v8/V8LazyEventListener.cpp index d2eaef1e5..840de7fd2 100644 --- a/Source/WebCore/bindings/v8/V8LazyEventListener.cpp +++ b/Source/WebCore/bindings/v8/V8LazyEventListener.cpp @@ -44,24 +44,22 @@ #include "V8HiddenPropertyName.h" #include "V8Node.h" #include "V8Proxy.h" +#include "V8RecursionScope.h" #include "WorldContextHandle.h" #include <wtf/StdLibExtras.h> namespace WebCore { -V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, PassRefPtr<Node> node, const WorldContextHandle& worldContext) +V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, Node* node, const WorldContextHandle& worldContext) : V8AbstractEventListener(true, worldContext) , m_functionName(functionName) , m_eventParameterName(eventParameterName) , m_code(code) , m_sourceURL(sourceURL) , m_node(node) - , m_formElement(0) , m_position(position) { - if (m_node && m_node->isHTMLElement()) - m_formElement = static_cast<HTMLElement*>(m_node.get())->form(); } template<typename T> @@ -155,9 +153,12 @@ void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context) if (script.IsEmpty()) return; - // Call v8::Script::Run() directly to avoid an erroneous call to V8RecursionScope::didLeaveScriptContext(). // FIXME: Remove this code when we stop doing the 'with' hack above. - v8::Local<v8::Value> value = script->Run(); + v8::Local<v8::Value> value; + { + V8RecursionScope::MicrotaskSuppression scope; + value = script->Run(); + } if (value.IsEmpty()) return; @@ -165,20 +166,25 @@ void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context) ASSERT(value->IsFunction()); v8::Local<v8::Function> intermediateFunction = value.As<v8::Function>(); - v8::Handle<v8::Object> nodeWrapper = toObjectWrapper<Node>(m_node.get()); - v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(m_formElement.get()); - v8::Handle<v8::Object> documentWrapper = toObjectWrapper<Document>(m_node ? m_node->ownerDocument() : 0); + HTMLFormElement* formElement = 0; + if (m_node && m_node->isHTMLElement()) + formElement = static_cast<HTMLElement*>(m_node)->form(); - m_node.clear(); - m_formElement.clear(); + v8::Handle<v8::Object> nodeWrapper = toObjectWrapper<Node>(m_node); + v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(formElement); + v8::Handle<v8::Object> documentWrapper = toObjectWrapper<Document>(m_node ? m_node->ownerDocument() : 0); v8::Handle<v8::Value> parameters[3] = { nodeWrapper, formWrapper, documentWrapper }; - // Use Call directly to avoid an erroneous call to V8RecursionScope::didLeaveScriptContext(). // FIXME: Remove this code when we stop doing the 'with' hack above. - v8::Local<v8::Value> innerValue = intermediateFunction->Call(v8Context->Global(), 3, parameters); + v8::Local<v8::Value> innerValue; + { + V8RecursionScope::MicrotaskSuppression scope; + innerValue = intermediateFunction->Call(v8Context->Global(), 3, parameters); + } + if (innerValue.IsEmpty() || !innerValue->IsFunction()) + return; - ASSERT(innerValue->IsFunction()); v8::Local<v8::Function> wrappedFunction = innerValue.As<v8::Function>(); // Change the toString function on the wrapper function to avoid it @@ -205,11 +211,22 @@ void V8LazyEventListener::prepareListenerObject(ScriptExecutionContext* context) toStringResult.append(m_code); toStringResult.append("\n}"); wrappedFunction->SetHiddenValue(V8HiddenPropertyName::toStringString(), v8ExternalString(toStringResult)); - wrappedFunction->Set(v8::String::New("toString"), toStringFunction); + wrappedFunction->Set(v8::String::NewSymbol("toString"), toStringFunction); } wrappedFunction->SetName(v8::String::New(fromWebCoreString(m_functionName), m_functionName.length())); + // FIXME: Remove the following comment-outs. + // See https://bugs.webkit.org/show_bug.cgi?id=85152 for more details. + // + // For the time being, we comment out the following code since the + // second parsing can happen. + // // Since we only parse once, there's no need to keep data used for parsing around anymore. + // m_functionName = String(); + // m_code = String(); + // m_eventParameterName = String(); + // m_sourceURL = String(); + setListenerObject(wrappedFunction); } diff --git a/Source/WebCore/bindings/v8/V8LazyEventListener.h b/Source/WebCore/bindings/v8/V8LazyEventListener.h index 1fb565add..335e21d73 100644 --- a/Source/WebCore/bindings/v8/V8LazyEventListener.h +++ b/Source/WebCore/bindings/v8/V8LazyEventListener.h @@ -48,7 +48,7 @@ namespace WebCore { // A V8LazyEventListener is either a HTML or SVG event handler. class V8LazyEventListener : public V8AbstractEventListener { public: - static PassRefPtr<V8LazyEventListener> create(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String& sourceURL, const TextPosition& position, PassRefPtr<Node> node, const WorldContextHandle& worldContext) + static PassRefPtr<V8LazyEventListener> create(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String& sourceURL, const TextPosition& position, Node* node, const WorldContextHandle& worldContext) { return adoptRef(new V8LazyEventListener(functionName, eventParameterName, code, sourceURL, position, node, worldContext)); } @@ -59,7 +59,7 @@ namespace WebCore { virtual void prepareListenerObject(ScriptExecutionContext*); private: - V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition&, PassRefPtr<Node>, const WorldContextHandle&); + V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition&, Node*, const WorldContextHandle&); virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*); @@ -73,8 +73,7 @@ namespace WebCore { AtomicString m_eventParameterName; String m_code; String m_sourceURL; - RefPtr<Node> m_node; - RefPtr<HTMLFormElement> m_formElement; + Node* m_node; TextPosition m_position; }; diff --git a/Source/WebCore/bindings/v8/V8NPObject.cpp b/Source/WebCore/bindings/v8/V8NPObject.cpp index e43d27e64..f6dd1f8f3 100644 --- a/Source/WebCore/bindings/v8/V8NPObject.cpp +++ b/Source/WebCore/bindings/v8/V8NPObject.cpp @@ -34,6 +34,7 @@ #include "HTMLPlugInElement.h" #include "NPV8Object.h" +#include "SafeAllocation.h" #include "V8Binding.h" #include "V8DOMMap.h" #include "V8HTMLAppletElement.h" diff --git a/Source/WebCore/bindings/v8/V8Proxy.cpp b/Source/WebCore/bindings/v8/V8Proxy.cpp index d8a7d466f..e927d53af 100644 --- a/Source/WebCore/bindings/v8/V8Proxy.cpp +++ b/Source/WebCore/bindings/v8/V8Proxy.cpp @@ -217,7 +217,7 @@ bool V8Proxy::handleOutOfMemory() return true; } -void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup) +void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, WTF::Vector<v8::Local<v8::Value> >* results) { // FIXME: This will need to get reorganized once we have a windowShell for the isolated world. if (!windowShell()->initContextIfNeeded()) @@ -239,15 +239,8 @@ void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode // FIXME: We should change this to using window shells to match JSC. m_isolatedWorlds.set(worldID, isolatedContext); - - // Setup context id for JS debugger. - if (!setInjectedScriptContextDebugId(isolatedContext->context())) { - m_isolatedWorlds.take(worldID); - delete isolatedContext; - return; - } } - + IsolatedWorldSecurityOriginMap::iterator securityOriginIter = m_isolatedWorldSecurityOrigins.find(worldID); if (securityOriginIter != m_isolatedWorldSecurityOrigins.end()) isolatedContext->setSecurityOrigin(securityOriginIter->second); @@ -261,11 +254,17 @@ void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedContext->context()); v8::Context::Scope context_scope(context); - for (size_t i = 0; i < sources.size(); ++i) - evaluate(sources[i], 0); + + if (results) { + for (size_t i = 0; i < sources.size(); ++i) + results->append(evaluate(sources[i], 0)); + } else { + for (size_t i = 0; i < sources.size(); ++i) + evaluate(sources[i], 0); + } if (worldID == 0) - isolatedContext->destroy(); + isolatedContext->destroy(); } void V8Proxy::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin> prpSecurityOriginIn) @@ -278,25 +277,6 @@ void V8Proxy::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOri iter->second->setSecurityOrigin(securityOrigin); } -bool V8Proxy::setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext) -{ - // Setup context id for JS debugger. - v8::Context::Scope contextScope(targetContext); - v8::Handle<v8::Context> context = windowShell()->context(); - if (context.IsEmpty()) - return false; - int debugId = contextDebugId(context); - - char buffer[32]; - if (debugId == -1) - snprintf(buffer, sizeof(buffer), "injected"); - else - snprintf(buffer, sizeof(buffer), "injected,%d", debugId); - targetContext->SetData(v8::String::New(buffer)); - - 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 @@ -455,6 +435,7 @@ v8::Local<v8::Value> V8Proxy::newInstance(v8::Handle<v8::Function> constructor, // V8Proxy::callFunction. v8::Local<v8::Value> result; { + V8RecursionScope recursionScope(frame() ? frame()->document() : 0); result = constructor->NewInstance(argc, args); } @@ -536,6 +517,14 @@ V8Proxy* V8Proxy::retrieve(ScriptExecutionContext* context) return retrieve(static_cast<Document*>(context)->frame()); } +V8BindingPerContextData* V8Proxy::retrievePerContextData(Frame* frame) +{ + V8IsolatedContext* isolatedContext; + if (UNLIKELY(!!(isolatedContext = V8IsolatedContext::getEntered()))) + return isolatedContext->perContextData(); + return V8Proxy::retrieve(frame)->windowShell()->perContextData(); +} + void V8Proxy::resetIsolatedWorlds() { for (IsolatedWorldMap::iterator iter = m_isolatedWorlds.begin(); @@ -560,10 +549,10 @@ void V8Proxy::clearForNavigation() #define TRY_TO_CREATE_EXCEPTION(interfaceName) \ case interfaceName##Type: \ - exception = toV8(interfaceName::create(description)); \ + exception = toV8(interfaceName::create(description), isolate); \ break; -void V8Proxy::setDOMException(int ec) +void V8Proxy::setDOMException(int ec, v8::Isolate* isolate) { if (ec <= 0) return; @@ -581,19 +570,19 @@ void V8Proxy::setDOMException(int ec) #undef TRY_TO_CREATE_EXCEPTION -v8::Handle<v8::Value> V8Proxy::throwError(ErrorType type, const char* message) +v8::Handle<v8::Value> V8Proxy::throwError(ErrorType type, const char* message, v8::Isolate* isolate) { switch (type) { case RangeError: - return v8::ThrowException(v8::Exception::RangeError(v8String(message))); + return v8::ThrowException(v8::Exception::RangeError(v8String(message, isolate))); case ReferenceError: - return v8::ThrowException(v8::Exception::ReferenceError(v8String(message))); + return v8::ThrowException(v8::Exception::ReferenceError(v8String(message, isolate))); case SyntaxError: - return v8::ThrowException(v8::Exception::SyntaxError(v8String(message))); + return v8::ThrowException(v8::Exception::SyntaxError(v8String(message, isolate))); case TypeError: - return v8::ThrowException(v8::Exception::TypeError(v8String(message))); + return v8::ThrowException(v8::Exception::TypeError(v8String(message, isolate))); case GeneralError: - return v8::ThrowException(v8::Exception::Error(v8String(message))); + return v8::ThrowException(v8::Exception::Error(v8String(message, isolate))); default: ASSERT_NOT_REACHED(); return notHandledByInterceptor(); @@ -605,9 +594,9 @@ v8::Handle<v8::Value> V8Proxy::throwTypeError() return throwError(TypeError, "Type error"); } -v8::Handle<v8::Value> V8Proxy::throwSyntaxError() +v8::Handle<v8::Value> V8Proxy::throwNotEnoughArgumentsError() { - return throwError(SyntaxError, "Syntax error"); + return throwError(TypeError, "Not enough arguments"); } v8::Local<v8::Context> V8Proxy::context(Frame* frame) @@ -642,6 +631,20 @@ v8::Local<v8::Context> V8Proxy::mainWorldContext() return v8::Local<v8::Context>::New(windowShell()->context()); } +bool V8Proxy::matchesCurrentContext() +{ + v8::Handle<v8::Context> context; + if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) { + context = isolatedContext->sharedContext()->get(); + if (m_frame != V8Proxy::retrieveFrame(context)) + return false; + } else { + windowShell()->initContextIfNeeded(); + context = windowShell()->context(); + } + return context == context->GetCurrent(); +} + v8::Local<v8::Context> V8Proxy::mainWorldContext(Frame* frame) { V8Proxy* proxy = retrieve(frame); diff --git a/Source/WebCore/bindings/v8/V8Proxy.h b/Source/WebCore/bindings/v8/V8Proxy.h index fe49563ca..66dbf5968 100644 --- a/Source/WebCore/bindings/v8/V8Proxy.h +++ b/Source/WebCore/bindings/v8/V8Proxy.h @@ -33,6 +33,7 @@ #include "PlatformSupport.h" #include "SharedPersistent.h" +#include "StatsCounter.h" #include "V8AbstractEventListener.h" #include "V8DOMWindowShell.h" #include "V8DOMWrapper.h" @@ -46,7 +47,7 @@ #include <wtf/text/TextPosition.h> #if defined(ENABLE_DOM_STATS_COUNTERS) && PLATFORM(CHROMIUM) -#define INC_STATS(name) PlatformSupport::incrementStatsCounter(name) +#define INC_STATS(name) StatsCounter::incrementStatsCounter(name) #else #define INC_STATS(name) #endif @@ -60,6 +61,7 @@ namespace WebCore { class ScriptExecutionContext; class ScriptSourceCode; class SecurityOrigin; + class V8BindingPerContextData; class V8EventListener; class V8IsolatedContext; class WorldContextHandle; @@ -145,8 +147,8 @@ namespace WebCore { // global scope, its own prototypes for intrinsic JavaScript objects (String, // Array, and so-on), and its own wrappers for all DOM nodes and DOM // constructors. - void evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup); - + void evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, WTF::Vector<v8::Local<v8::Value> >* result); + void setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<SecurityOrigin>); // Evaluate a script file in the current execution environment. @@ -169,8 +171,6 @@ namespace WebCore { // Returns the window object associated with a context. static DOMWindow* retrieveWindow(v8::Handle<v8::Context>); - static DOMWindow* retriveWindowForCallingCOntext(); - // Returns V8Proxy object of the currently executing context. static V8Proxy* retrieve(); // Returns V8Proxy object associated with a frame. @@ -182,6 +182,7 @@ namespace WebCore { // a context. static Frame* retrieveFrame(v8::Handle<v8::Context>); + static V8BindingPerContextData* retrievePerContextData(Frame*); // The three functions below retrieve WebFrame instances relating the // currently executing JavaScript. Since JavaScript can make function calls @@ -232,17 +233,18 @@ namespace WebCore { // If the exception code is different from zero, a DOM exception is // schedule to be thrown. - static void setDOMException(int exceptionCode); + static void setDOMException(int exceptionCode, v8::Isolate*); // Schedule an error object to be thrown. - static v8::Handle<v8::Value> throwError(ErrorType, const char* message); + static v8::Handle<v8::Value> throwError(ErrorType, const char* message, v8::Isolate* = 0); // Helpers for throwing syntax and type errors with predefined messages. static v8::Handle<v8::Value> throwTypeError(); - static v8::Handle<v8::Value> throwSyntaxError(); + static v8::Handle<v8::Value> throwNotEnoughArgumentsError(); v8::Local<v8::Context> context(); v8::Local<v8::Context> mainWorldContext(); + bool matchesCurrentContext(); // FIXME: This should eventually take DOMWrapperWorld argument! V8DOMWindowShell* windowShell() const { return m_windowShell.get(); } @@ -268,9 +270,6 @@ namespace WebCore { 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); - static const char* rangeExceptionName(int exceptionCode); static const char* eventExceptionName(int exceptionCode); static const char* xmlHttpRequestExceptionName(int exceptionCode); @@ -323,21 +322,29 @@ namespace WebCore { { return v8::Local<v8::Boolean>(); } - inline v8::Handle<v8::Primitive> throwError(const char* message, V8Proxy::ErrorType type = V8Proxy::TypeError) + + inline v8::Handle<v8::Primitive> throwError(const char* message, v8::Isolate* isolate = 0) + { + if (!v8::V8::IsExecutionTerminating()) + V8Proxy::throwError(V8Proxy::TypeError, message, isolate); + return v8::Undefined(); + } + + inline v8::Handle<v8::Primitive> throwError(const char* message, V8Proxy::ErrorType type, v8::Isolate* isolate = 0) { if (!v8::V8::IsExecutionTerminating()) - V8Proxy::throwError(type, message); + V8Proxy::throwError(type, message, isolate); return v8::Undefined(); } - inline v8::Handle<v8::Primitive> throwError(ExceptionCode ec) + inline v8::Handle<v8::Primitive> throwError(ExceptionCode ec, v8::Isolate* isolate = 0) { if (!v8::V8::IsExecutionTerminating()) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, isolate); return v8::Undefined(); } - inline v8::Handle<v8::Primitive> throwError(v8::Local<v8::Value> exception) + inline v8::Handle<v8::Primitive> throwError(v8::Local<v8::Value> exception, v8::Isolate* isolate = 0) { if (!v8::V8::IsExecutionTerminating()) v8::ThrowException(exception); @@ -348,17 +355,6 @@ namespace WebCore { MarkIndependent, DoNotMarkIndependent }; - - template <class T> inline v8::Handle<v8::Object> toV8(PassRefPtr<T> object, v8::Local<v8::Object> holder, IndependentMode independent = DoNotMarkIndependent) - { - object->ref(); - v8::Persistent<v8::Object> handle = v8::Persistent<v8::Object>::New(holder); - if (independent == MarkIndependent) - handle.MarkIndependent(); - V8DOMWrapper::setJSWrapperForDOMObject(object.get(), handle); - return holder; - } - } #endif // V8Proxy_h diff --git a/Source/WebCore/bindings/v8/V8RecursionScope.cpp b/Source/WebCore/bindings/v8/V8RecursionScope.cpp index cad7498c6..92be720b1 100644 --- a/Source/WebCore/bindings/v8/V8RecursionScope.cpp +++ b/Source/WebCore/bindings/v8/V8RecursionScope.cpp @@ -32,12 +32,11 @@ #include "V8RecursionScope.h" #include "IDBPendingTransactionMonitor.h" -#include "ScriptExecutionContext.h" #include "WebKitMutationObserver.h" namespace WebCore { -void V8RecursionScope::didLeaveScriptContext(ScriptExecutionContext* context) +void V8RecursionScope::didLeaveScriptContext() { // FIXME: Instrument any work that takes place when script exits to c++ (e.g. Mutation Observers). @@ -49,7 +48,7 @@ void V8RecursionScope::didLeaveScriptContext(ScriptExecutionContext* context) #endif #if ENABLE(MUTATION_OBSERVERS) - if (context && context->isDocument()) + if (m_isDocumentContext) WebKitMutationObserver::deliverAllMutations(); #endif } diff --git a/Source/WebCore/bindings/v8/V8RecursionScope.h b/Source/WebCore/bindings/v8/V8RecursionScope.h index 6cfbbab1e..0e776e1ea 100644 --- a/Source/WebCore/bindings/v8/V8RecursionScope.h +++ b/Source/WebCore/bindings/v8/V8RecursionScope.h @@ -31,17 +31,34 @@ #ifndef V8RecursionScope_h #define V8RecursionScope_h +#include "ScriptExecutionContext.h" #include "V8Binding.h" +#include <wtf/Noncopyable.h> namespace WebCore { -class ScriptExecutionContext; - +// C++ calls into script contexts which are "owned" by WebKit (created in a +// process where WebKit.cpp initializes v8) must declare their type: +// +// 1. Calls into page/author script from a frame +// 2. Calls into page/author script from a worker +// 3. Calls into internal script (typically setup/teardown work) +// +// Debug-time checking of this is enforced via this class. +// +// Calls of type (1) should generally go through V8Proxy, as inspector +// instrumentation is needed. Calls of type (2) should always stack-allocate a +// V8RecursionScope in the same block as the call into script. Calls of type (3) +// should stack allocate a V8RecursionScope::MicrotaskSuppression -- this +// skips work that is spec'd to happen at the end of the outer-most script stack +// frame of calls into page script: +// +// http://www.whatwg.org/specs/web-apps/current-work/#perform-a-microtask-checkpoint class V8RecursionScope { WTF_MAKE_NONCOPYABLE(V8RecursionScope); public: explicit V8RecursionScope(ScriptExecutionContext* context) - : m_context(context) + : m_isDocumentContext(context && context->isDocument()) { V8BindingPerIsolateData::current()->incrementRecursionLevel(); } @@ -49,15 +66,42 @@ public: ~V8RecursionScope() { if (!V8BindingPerIsolateData::current()->decrementRecursionLevel()) - didLeaveScriptContext(m_context); + didLeaveScriptContext(); + } + + static int recursionLevel() + { + return V8BindingPerIsolateData::current()->recursionLevel(); } - static int recursionLevel() { return V8BindingPerIsolateData::current()->recursionLevel(); } +#ifndef NDEBUG + static bool properlyUsed() + { + return recursionLevel() > 0 || V8BindingPerIsolateData::current()->internalScriptRecursionLevel() > 0; + } +#endif + + class MicrotaskSuppression { + public: + MicrotaskSuppression() + { +#ifndef NDEBUG + V8BindingPerIsolateData::current()->incrementInternalScriptRecursionLevel(); +#endif + } + + ~MicrotaskSuppression() + { +#ifndef NDEBUG + V8BindingPerIsolateData::current()->decrementInternalScriptRecursionLevel(); +#endif + } + }; private: - static void didLeaveScriptContext(ScriptExecutionContext*); + void didLeaveScriptContext(); - ScriptExecutionContext* m_context; + bool m_isDocumentContext; }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/V8Utilities.cpp b/Source/WebCore/bindings/v8/V8Utilities.cpp index f30a47c53..d39049c8f 100644 --- a/Source/WebCore/bindings/v8/V8Utilities.cpp +++ b/Source/WebCore/bindings/v8/V8Utilities.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "V8Utilities.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "Document.h" #include "ExceptionCode.h" #include "Frame.h" @@ -184,11 +184,6 @@ Frame* callingOrEnteredFrame() return V8BindingState::Only()->activeFrame(); } -bool shouldAllowNavigation(Frame* frame) -{ - return V8BindingSecurity::shouldAllowNavigation(V8BindingState::Only(), frame); -} - KURL completeURL(const String& relativeURL) { return completeURL(V8BindingState::Only(), relativeURL); diff --git a/Source/WebCore/bindings/v8/V8Utilities.h b/Source/WebCore/bindings/v8/V8Utilities.h index bf7577534..46da31934 100644 --- a/Source/WebCore/bindings/v8/V8Utilities.h +++ b/Source/WebCore/bindings/v8/V8Utilities.h @@ -56,7 +56,6 @@ namespace WebCore { // Combo create/remove, for generated event-handler-setter bindings: void transferHiddenDependency(v8::Handle<v8::Object>, EventListener* oldValue, v8::Local<v8::Value> newValue, int cacheIndex); - bool shouldAllowNavigation(Frame*); KURL completeURL(const String& relativeURL); ScriptExecutionContext* getScriptExecutionContext(); diff --git a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp index 51be5ca83..1f4848bad 100644 --- a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp +++ b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp @@ -37,11 +37,14 @@ #include "DedicatedWorkerContext.h" #include "Event.h" +#include "SafeAllocation.h" #include "ScriptCallStack.h" #include "SharedWorker.h" #include "SharedWorkerContext.h" #include "V8Binding.h" +#include "V8BindingPerContextData.h" #include "V8DOMMap.h" +#include "V8DOMWindowShell.h" #include "V8DedicatedWorkerContext.h" #include "V8Proxy.h" #include "V8RecursionScope.h" @@ -101,6 +104,8 @@ void WorkerContextExecutionProxy::dispose() } m_events.clear(); + m_perContextData.clear(); + // Dispose the context. if (!m_context.IsEmpty()) { m_context.Dispose(); @@ -148,6 +153,12 @@ bool WorkerContextExecutionProxy::initContextIfNeeded() v8::Context::Scope scope(context); + m_perContextData = V8BindingPerContextData::create(m_context); + if (!m_perContextData->init()) { + dispose(); + return false; + } + // Set DebugId for the new context. context->SetData(v8::String::New("worker")); @@ -157,7 +168,7 @@ bool WorkerContextExecutionProxy::initContextIfNeeded() if (!m_workerContext->isDedicatedWorkerContext()) contextType = &V8SharedWorkerContext::info; #endif - v8::Handle<v8::Function> workerContextConstructor = V8DOMWrapper::getConstructorForContext(contextType, context); + v8::Handle<v8::Function> workerContextConstructor = m_perContextData->constructorForType(contextType); v8::Local<v8::Object> jsWorkerContext = SafeAllocation::newInstance(workerContextConstructor); // Bail out if allocation failed. if (jsWorkerContext.IsEmpty()) { @@ -168,8 +179,7 @@ bool WorkerContextExecutionProxy::initContextIfNeeded() // Wrap the object. V8DOMWrapper::setDOMWrapper(jsWorkerContext, contextType, m_workerContext); - V8DOMWrapper::setJSWrapperForDOMObject(m_workerContext, v8::Persistent<v8::Object>::New(jsWorkerContext)); - m_workerContext->ref(); + V8DOMWrapper::setJSWrapperForDOMObject(PassRefPtr<WorkerContext>(m_workerContext), v8::Persistent<v8::Object>::New(jsWorkerContext)); // Insert the object instance as the prototype of the shadow object. v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype()); diff --git a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h index e6c160544..0df5a3ae7 100644 --- a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h +++ b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h @@ -44,7 +44,9 @@ namespace WebCore { class Event; class EventTarget; + class V8BindingPerContextData; class WorkerContext; + struct WrapperTypeInfo; struct WorkerContextExecutionState { WorkerContextExecutionState() : hadException(false), lineNumber(0) { } @@ -72,6 +74,8 @@ namespace WebCore { // Returns a local handle of the context. v8::Local<v8::Context> context() { return v8::Local<v8::Context>::New(m_context); } + V8BindingPerContextData* perContextData() { return m_perContextData.get(); } + private: void initIsolate(); bool initContextIfNeeded(); @@ -88,6 +92,8 @@ namespace WebCore { v8::Persistent<v8::Context> m_context; Vector<Event*> m_events; + + OwnPtr<V8BindingPerContextData> m_perContextData; }; } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/WorkerScriptController.cpp b/Source/WebCore/bindings/v8/WorkerScriptController.cpp index 433c3288a..a692c8615 100644 --- a/Source/WebCore/bindings/v8/WorkerScriptController.cpp +++ b/Source/WebCore/bindings/v8/WorkerScriptController.cpp @@ -65,6 +65,12 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) WorkerScriptController::~WorkerScriptController() { removeAllDOMObjects(); +#if PLATFORM(CHROMIUM) + // The corresponding call to didStartWorkerRunLoop is in + // WorkerThread::workerThread(). + // See http://webkit.org/b/83104#c14 for why this is here. + PlatformSupport::didStopWorkerRunLoop(&m_workerContext->thread()->runLoop()); +#endif m_proxy.clear(); m_isolate->Exit(); V8BindingPerIsolateData::dispose(m_isolate); diff --git a/Source/WebCore/bindings/v8/WorldContextHandle.cpp b/Source/WebCore/bindings/v8/WorldContextHandle.cpp index 24f461ffe..8456a3e5f 100644 --- a/Source/WebCore/bindings/v8/WorldContextHandle.cpp +++ b/Source/WebCore/bindings/v8/WorldContextHandle.cpp @@ -32,6 +32,7 @@ #include "WorldContextHandle.h" #include "V8IsolatedContext.h" +#include "V8Proxy.h" namespace WebCore { diff --git a/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp b/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp index f0dbd4854..cf690fd2b 100644 --- a/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp @@ -29,7 +29,7 @@ */ #include "config.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "ExceptionCode.h" #include "V8Binding.h" @@ -73,7 +73,8 @@ v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& ar 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()); + V8DOMWrapper::setJSWrapperForDOMObject(buffer.release(), v8::Persistent<v8::Object>::New(args.Holder())); + return args.Holder(); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h b/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h index 8e7ecafe3..a0fc5aed5 100644 --- a/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h +++ b/Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h @@ -31,7 +31,7 @@ #ifndef V8ArrayBufferViewCustom_h #define V8ArrayBufferViewCustom_h -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "ExceptionCode.h" #include "V8ArrayBuffer.h" @@ -81,14 +81,17 @@ v8::Handle<v8::Value> constructWebGLArrayWithArrayBufferArgument(const v8::Argum } RefPtr<ArrayClass> array = ArrayClass::create(buf, offset, length); if (!array) { - V8Proxy::setDOMException(INDEX_SIZE_ERR); + V8Proxy::setDOMException(INDEX_SIZE_ERR, args.GetIsolate()); return notHandledByInterceptor(); } // Transform the holder into a wrapper object for the array. V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get()); if (hasIndexer) args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length()); - return toV8(array.release(), args.Holder(), MarkIndependent); + v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::New(args.Holder()); + wrapper.MarkIndependent(); + V8DOMWrapper::setJSWrapperForDOMObject(array.release(), wrapper); + return args.Holder(); } // Template function used by the ArrayBufferView*Constructor callbacks. @@ -117,7 +120,10 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType // Do not call SetIndexedPropertiesToExternalArrayData on this // object. Not only is there no point from a performance // perspective, but doing so causes errors in the subset() case. - return toV8(array.release(), args.Holder(), MarkIndependent); + v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::New(args.Holder()); + wrapper.MarkIndependent(); + V8DOMWrapper::setJSWrapperForDOMObject(array.release(), wrapper); + return args.Holder(); } // Supported constructors: @@ -173,14 +179,17 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType if (!srcArray.IsEmpty()) copyElements(args.Holder(), srcArray, 0); - return toV8(array.release(), args.Holder(), MarkIndependent); + v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::New(args.Holder()); + wrapper.MarkIndependent(); + V8DOMWrapper::setJSWrapperForDOMObject(array.release(), wrapper); + return args.Holder(); } template <class CPlusPlusArrayType, class JavaScriptWrapperArrayType> v8::Handle<v8::Value> setWebGLArrayHelper(const v8::Arguments& args) { if (args.Length() < 1) { - V8Proxy::setDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR, args.GetIsolate()); return notHandledByInterceptor(); } @@ -193,7 +202,7 @@ v8::Handle<v8::Value> setWebGLArrayHelper(const v8::Arguments& args) if (args.Length() == 2) offset = toUInt32(args[1]); if (!impl->set(src, offset)) - V8Proxy::setDOMException(INDEX_SIZE_ERR); + V8Proxy::setDOMException(INDEX_SIZE_ERR, args.GetIsolate()); return v8::Undefined(); } @@ -208,7 +217,7 @@ v8::Handle<v8::Value> setWebGLArrayHelper(const v8::Arguments& args) || offset + length > impl->length() || offset + length < offset) // Out of range offset or overflow - V8Proxy::setDOMException(INDEX_SIZE_ERR); + V8Proxy::setDOMException(INDEX_SIZE_ERR, args.GetIsolate()); else { if (!fastSetInstalled(args.Holder())) { installFastSet(args.Holder()); @@ -221,7 +230,7 @@ v8::Handle<v8::Value> setWebGLArrayHelper(const v8::Arguments& args) return v8::Undefined(); } - V8Proxy::setDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR, args.GetIsolate()); return notHandledByInterceptor(); } diff --git a/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp b/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp index 49af931d5..ec6338d42 100644 --- a/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp @@ -28,7 +28,7 @@ #include "V8AudioContext.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "AudioBuffer.h" #include "AudioContext.h" #include "Frame.h" @@ -61,14 +61,17 @@ v8::Handle<v8::Value> V8AudioContext::constructorCallback(const v8::Arguments& a if (!args.Length()) { // Constructor for default AudioContext which talks to audio hardware. - audioContext = AudioContext::create(document); + ExceptionCode ec = 0; + audioContext = AudioContext::create(document, ec); + if (ec) + return throwError(ec); if (!audioContext.get()) return throwError("audio resources unavailable for AudioContext construction", V8Proxy::SyntaxError); } else { // Constructor for offline (render-target) AudioContext which renders into an AudioBuffer. // new AudioContext(in unsigned long numberOfChannels, in unsigned long numberOfFrames, in float sampleRate); if (args.Length() < 3) - return throwError("Not enough arguments", V8Proxy::SyntaxError); + return V8Proxy::throwNotEnoughArgumentsError(); bool ok = false; diff --git a/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp b/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp index 6853578e9..50b4873b7 100644 --- a/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8BlobCustom.cpp @@ -31,22 +31,108 @@ #include "config.h" #include "Blob.h" +#include "Dictionary.h" +#include "V8ArrayBuffer.h" +#include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8Blob.h" #include "V8File.h" #include "V8Proxy.h" +#include "V8Utilities.h" +#include "WebKitBlobBuilder.h" #include <wtf/RefPtr.h> namespace WebCore { -v8::Handle<v8::Value> toV8(Blob* impl) +v8::Handle<v8::Value> toV8(Blob* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); if (impl->isFile()) - return toV8(static_cast<File*>(impl)); + return toV8(static_cast<File*>(impl), isolate); - return V8Blob::wrap(impl); + return V8Blob::wrap(impl, isolate); +} + +v8::Handle<v8::Value> V8Blob::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.Blob.Constructor"); + + if (!args.IsConstructCall()) + return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError); + + if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) + return args.Holder(); + + // Get the script execution context. + ScriptExecutionContext* context = getScriptExecutionContext(); + if (!context) + return throwError("Blob constructor associated document is unavailable", V8Proxy::ReferenceError); + + if (!args.Length()) { + RefPtr<Blob> blob = Blob::create(); + return toV8(blob.get(), args.GetIsolate()); + } + + v8::Local<v8::Value> firstArg = args[0]; + if (!firstArg->IsArray()) + return throwError("First argument of the constructor is not of type Array", V8Proxy::TypeError); + + String type; + String endings = "transparent"; + + if (args.Length() > 1) { + if (!args[1]->IsObject()) + return throwError("Second argument of the constructor is not of type Object", V8Proxy::TypeError); + + Dictionary dictionary(args[1]); + + v8::TryCatch tryCatchEndings; + bool containsEndings = dictionary.get("endings", endings); + if (tryCatchEndings.HasCaught()) + return throwError(tryCatchEndings.Exception()); + + if (containsEndings) { + if (endings != "transparent" && endings != "native") + return throwError("The endings property must be either \"transparent\" or \"native\"", V8Proxy::TypeError); + } + + v8::TryCatch tryCatchType; + dictionary.get("type", type); + if (tryCatchType.HasCaught()) + return throwError(tryCatchType.Exception()); + } + + ASSERT(endings == "transparent" || endings == "native"); + + RefPtr<WebKitBlobBuilder> blobBuilder = WebKitBlobBuilder::create(); + + EXCEPTION_BLOCK(v8::Local<v8::Array>, blobParts, v8::Local<v8::Array>::Cast(firstArg)); + uint32_t length = blobParts->Length(); + + for (uint32_t i = 0; i < length; ++i) { + v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(i)); + ASSERT(!item.IsEmpty()); +#if ENABLE(BLOB) + if (V8ArrayBuffer::HasInstance(item)) { + ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item)); + ASSERT(arrayBuffer); + blobBuilder->append(arrayBuffer); + } else +#endif + if (V8Blob::HasInstance(item)) { + Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item)); + ASSERT(blob); + blobBuilder->append(blob); + } else { + EXCEPTION_BLOCK(String, stringValue, toWebCoreString(item->ToString())); + blobBuilder->append(stringValue, endings, ASSERT_NO_EXCEPTION); + } + } + + RefPtr<Blob> blob = blobBuilder->getBlob(type); + return toV8(blob.get(), args.GetIsolate()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp b/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp index ab6768c4d..a025ecb38 100644 --- a/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp @@ -43,7 +43,7 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(CSSRule* impl) +v8::Handle<v8::Value> toV8(CSSRule* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); @@ -52,27 +52,27 @@ v8::Handle<v8::Value> toV8(CSSRule* impl) // CSSUnknownRule.idl is explicitly excluded as it doesn't add anything // over CSSRule.idl (see WebCore.gyp/WebCore.gyp: 'bindings_idl_files'). // -> Use the base class wrapper here. - return V8CSSRule::wrap(impl); + return V8CSSRule::wrap(impl, isolate); case CSSRule::STYLE_RULE: - return toV8(static_cast<CSSStyleRule*>(impl)); + return toV8(static_cast<CSSStyleRule*>(impl), isolate); case CSSRule::CHARSET_RULE: - return toV8(static_cast<CSSCharsetRule*>(impl)); + return toV8(static_cast<CSSCharsetRule*>(impl), isolate); case CSSRule::IMPORT_RULE: - return toV8(static_cast<CSSImportRule*>(impl)); + return toV8(static_cast<CSSImportRule*>(impl), isolate); case CSSRule::MEDIA_RULE: - return toV8(static_cast<CSSMediaRule*>(impl)); + return toV8(static_cast<CSSMediaRule*>(impl), isolate); case CSSRule::FONT_FACE_RULE: - return toV8(static_cast<CSSFontFaceRule*>(impl)); + return toV8(static_cast<CSSFontFaceRule*>(impl), isolate); case CSSRule::PAGE_RULE: - return toV8(static_cast<CSSPageRule*>(impl)); + return toV8(static_cast<CSSPageRule*>(impl), isolate); case CSSRule::WEBKIT_KEYFRAME_RULE: - return toV8(static_cast<WebKitCSSKeyframeRule*>(impl)); + return toV8(static_cast<WebKitCSSKeyframeRule*>(impl), isolate); case CSSRule::WEBKIT_KEYFRAMES_RULE: - return toV8(static_cast<WebKitCSSKeyframesRule*>(impl)); + return toV8(static_cast<WebKitCSSKeyframesRule*>(impl), isolate); case CSSRule::WEBKIT_REGION_RULE: - return toV8(static_cast<WebKitCSSRegionRule*>(impl)); + return toV8(static_cast<WebKitCSSRegionRule*>(impl), isolate); } - return V8CSSRule::wrap(impl); + return V8CSSRule::wrap(impl, isolate); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp b/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp index 993bc934f..5308efe50 100644 --- a/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp @@ -85,7 +85,7 @@ static bool hasCSSPropertyNamePrefix(const String& propertyName, const char* pre class CSSPropertyInfo { public: - int propID; + CSSPropertyID propID; bool hadPixelOrPosPrefix; }; @@ -126,8 +126,11 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName) i += 3; hadPixelOrPosPrefix = true; } else if (hasCSSPropertyNamePrefix(propertyName, "webkit") +#if ENABLE(LEGACY_CSS_VENDOR_PREFIXES) || hasCSSPropertyNamePrefix(propertyName, "khtml") - || hasCSSPropertyNamePrefix(propertyName, "apple")) + || hasCSSPropertyNamePrefix(propertyName, "apple") +#endif + ) builder.append('-'); else if (isASCIIUpper(propertyName[0])) return 0; @@ -143,7 +146,7 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName) } String propName = builder.toString(); - int propertyID = cssPropertyID(propName); + CSSPropertyID propertyID = cssPropertyID(propName); if (propertyID) { propInfo = new CSSPropertyInfo(); propInfo->hadPixelOrPosPrefix = hadPixelOrPosPrefix; diff --git a/Source/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp b/Source/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp index 9b2988b7e..a81beb541 100644 --- a/Source/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp @@ -36,15 +36,15 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(CSSStyleSheet* impl) +v8::Handle<v8::Value> toV8(CSSStyleSheet* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8CSSStyleSheet::wrap(impl); + v8::Handle<v8::Object> wrapper = V8CSSStyleSheet::wrap(impl, isolate); // Add a hidden reference from stylesheet object to its owner node. Node* ownerNode = impl->ownerNode(); if (ownerNode && !wrapper.IsEmpty()) - V8DOMWrapper::setNamedHiddenReference(wrapper, "ownerNode", toV8(ownerNode)); + V8DOMWrapper::setNamedHiddenReference(wrapper, "ownerNode", toV8(ownerNode, isolate)); return wrapper; } diff --git a/Source/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp b/Source/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp index 601a62a5a..81912a89a 100644 --- a/Source/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp @@ -42,23 +42,23 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(CSSValue* impl) +v8::Handle<v8::Value> toV8(CSSValue* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); if (impl->isWebKitCSSTransformValue()) - return toV8(static_cast<WebKitCSSTransformValue*>(impl)); + return toV8(static_cast<WebKitCSSTransformValue*>(impl), isolate); if (impl->isValueList()) - return toV8(static_cast<CSSValueList*>(impl)); + return toV8(static_cast<CSSValueList*>(impl), isolate); if (impl->isPrimitiveValue()) - return toV8(static_cast<CSSPrimitiveValue*>(impl)); + return toV8(static_cast<CSSPrimitiveValue*>(impl), isolate); #if ENABLE(SVG) if (impl->isSVGPaint()) - return toV8(static_cast<SVGPaint*>(impl)); + return toV8(static_cast<SVGPaint*>(impl), isolate); if (impl->isSVGColor()) - return toV8(static_cast<SVGColor*>(impl)); + return toV8(static_cast<SVGColor*>(impl), isolate); #endif - return V8CSSValue::wrap(impl); + return V8CSSValue::wrap(impl, isolate); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp deleted file mode 100644 index 91e39b75c..000000000 --- a/Source/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "V8CanvasPixelArray.h" - -namespace WebCore { - -v8::Handle<v8::Value> toV8(CanvasPixelArray* impl) -{ - if (!impl) - return v8::Null(); - v8::Handle<v8::Object> wrapper = V8CanvasPixelArray::wrap(impl); - if (!wrapper.IsEmpty()) { - wrapper->SetIndexedPropertiesToPixelData(impl->data()->data(), impl->length()); - wrapper->Set(v8::String::NewSymbol("length"), - v8::Integer::New(impl->length()), - v8::ReadOnly); - } - return wrapper; -} - -} // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/Source/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp index 2febd8205..79a60552f 100644 --- a/Source/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp @@ -49,13 +49,13 @@ namespace WebCore { -static v8::Handle<v8::Value> toV8Object(CanvasStyle* style) +static v8::Handle<v8::Value> toV8Object(CanvasStyle* style, v8::Isolate* isolate) { if (style->canvasGradient()) - return toV8(style->canvasGradient()); + return toV8(style->canvasGradient(), isolate); if (style->canvasPattern()) - return toV8(style->canvasPattern()); + return toV8(style->canvasPattern(), isolate); return v8String(style->color()); } @@ -74,7 +74,7 @@ static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value) v8::Handle<v8::Value> V8CanvasRenderingContext2D::strokeStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder()); - return toV8Object(impl->strokeStyle()); + return toV8Object(impl->strokeStyle(), info.GetIsolate()); } void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -89,7 +89,7 @@ void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String> v8::Handle<v8::Value> V8CanvasRenderingContext2D::fillStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder()); - return toV8Object(impl->fillStyle()); + return toV8Object(impl->fillStyle(), info.GetIsolate()); } void V8CanvasRenderingContext2D::fillStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/Source/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/Source/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp index 7ade8688d..e7e0ee7e0 100644 --- a/Source/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp @@ -36,32 +36,13 @@ #include "ScriptArguments.h" #include "ScriptCallStack.h" #include "ScriptCallStackFactory.h" -#include "ScriptProfile.h" #include "V8Binding.h" #include "V8BindingMacros.h" #include "V8MemoryInfo.h" #include "V8Proxy.h" -#include "V8ScriptProfile.h" namespace WebCore { -typedef Vector<RefPtr<ScriptProfile> > ProfilesArray; - -#if ENABLE(JAVASCRIPT_DEBUGGER) -v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) -{ - INC_STATS("DOM.Console.profilesAccessorGetter"); - Console* imp = V8Console::toNative(info.Holder()); - const ProfilesArray& profiles = imp->profiles(); - v8::Handle<v8::Array> result = v8::Array::New(profiles.size()); - int index = 0; - ProfilesArray::const_iterator end = profiles.end(); - for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter) - result->Set(v8::Integer::New(index++), toV8(iter->get())); - return result; -} -#endif - v8::Handle<v8::Value> V8Console::traceCallback(const v8::Arguments& args) { INC_STATS("DOM.Console.traceCallback"); @@ -113,7 +94,7 @@ v8::Handle<v8::Value> V8Console::memoryAccessorGetter(v8::Local<v8::String> name { INC_STATS("DOM.Console.memoryAccessorGetter"); Console* imp = V8Console::toNative(info.Holder()); - return toV8(imp->memory()); + return toV8(imp->memory(), info.GetIsolate()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp index 9ee27fb72..c07986b76 100644 --- a/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp +++ b/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp @@ -56,8 +56,8 @@ bool V8SQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLEr v8::Context::Scope scope(v8Context); - v8::Handle<v8::Value> transactionHandle = toV8(transaction); - v8::Handle<v8::Value> errorHandle = toV8(error); + v8::Handle<v8::Value> transactionHandle = toV8(transaction, 0); + v8::Handle<v8::Value> errorHandle = toV8(error, 0); if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); diff --git a/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp b/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp index da4275015..896d1000c 100644 --- a/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp +++ b/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp @@ -65,6 +65,11 @@ void V8CustomVoidCallback::handleEvent() bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext) { + return invokeCallback(callback, v8::Context::GetCurrent()->Global(), argc, argv, callbackReturnValue, scriptExecutionContext); +} + +bool invokeCallback(v8::Persistent<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext) +{ v8::TryCatch exceptionCatcher; exceptionCatcher.SetVerbose(true); @@ -81,8 +86,6 @@ bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8 if (callbackFunction.IsEmpty()) return false; - v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global(); - Frame* frame = scriptExecutionContext && scriptExecutionContext->isDocument() ? static_cast<Document*>(scriptExecutionContext)->frame() : 0; v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(frame, callbackFunction, thisObject, argc, argv); diff --git a/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.h b/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.h index 94bb7821c..c7dfbe25e 100644 --- a/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.h +++ b/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.h @@ -61,7 +61,8 @@ private: }; // Returns false if callback failed (null, wrong type, or threw exception). -bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext); +bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*); +bool invokeCallback(v8::Persistent<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*); } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp index e34ea6fa8..a8d077dc5 100644 --- a/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DOMFormDataCustom.cpp @@ -56,7 +56,8 @@ v8::Handle<v8::Value> V8DOMFormData::constructorCallback(const v8::Arguments& ar RefPtr<DOMFormData> domFormData = DOMFormData::create(form); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, domFormData.get()); - return toV8(domFormData.release(), args.Holder()); + V8DOMWrapper::setJSWrapperForDOMObject(domFormData.release(), v8::Persistent<v8::Object>::New(args.Holder())); + return args.Holder(); } v8::Handle<v8::Value> V8DOMFormData::appendCallback(const v8::Arguments& args) diff --git a/Source/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp index ddf22a746..9335e0980 100644 --- a/Source/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp @@ -84,15 +84,15 @@ v8::Handle<v8::Value> V8DOMStringMap::namedPropertySetter(v8::Local<v8::String> return value; } -v8::Handle<v8::Value> toV8(DOMStringMap* impl) +v8::Handle<v8::Value> toV8(DOMStringMap* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8DOMStringMap::wrap(impl); + v8::Handle<v8::Object> wrapper = V8DOMStringMap::wrap(impl, isolate); // Add a hidden reference from the element to the DOMStringMap. Element* element = impl->element(); if (!wrapper.IsEmpty() && element) { - v8::Handle<v8::Value> elementValue = toV8(element); + v8::Handle<v8::Value> elementValue = toV8(element, isolate); if (!elementValue.IsEmpty() && elementValue->IsObject()) elementValue.As<v8::Object>()->SetHiddenValue(V8HiddenPropertyName::domStringMap(), wrapper); } diff --git a/Source/WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp index a23da4810..090a2179e 100644 --- a/Source/WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DOMTokenListCustom.cpp @@ -38,15 +38,15 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(DOMTokenList* impl) +v8::Handle<v8::Value> toV8(DOMTokenList* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8DOMTokenList::wrap(impl); + v8::Handle<v8::Object> wrapper = V8DOMTokenList::wrap(impl, isolate); // Add a hidden reference from the element to the DOMTokenList. Element* element = impl->element(); if (!wrapper.IsEmpty() && element) { - v8::Handle<v8::Value> elementValue = toV8(element); + v8::Handle<v8::Value> elementValue = toV8(element, isolate); if (!elementValue.IsEmpty() && elementValue->IsObject()) elementValue.As<v8::Object>()->SetHiddenValue(V8HiddenPropertyName::domTokenList(), wrapper); } diff --git a/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index cbae11300..2abcf3ca6 100644 --- a/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "V8DOMWindow.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "Chrome.h" #include "ContentSecurityPolicy.h" #include "DOMTimer.h" @@ -42,6 +42,7 @@ #include "FrameView.h" #include "HTMLCollection.h" #include "HTMLDocument.h" +#include "Location.h" #include "MediaPlayer.h" #include "MessagePort.h" #include "Page.h" @@ -77,7 +78,7 @@ v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singl ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document()); if (!scriptContext) { - V8Proxy::setDOMException(INVALID_ACCESS_ERR); + V8Proxy::setDOMException(INVALID_ACCESS_ERR, args.GetIsolate()); return v8::Undefined(); } @@ -195,7 +196,8 @@ void V8DOMWindow::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v if (!firstWindow) return; - imp->setLocation(toWebCoreString(value), activeWindow, firstWindow); + if (Location* location = imp->location()) + location->setHref(toWebCoreString(value), activeWindow, firstWindow); } void V8DOMWindow::openerAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -334,7 +336,8 @@ static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args SerializedScriptValue::create(args[0], &portArray, extendedTransfer ? &arrayBufferArray : 0, - didThrow); + didThrow, + args.GetIsolate()); if (didThrow) return v8::Undefined(); @@ -426,18 +429,17 @@ v8::Handle<v8::Value> V8DOMWindow::showModalDialogCallback(const v8::Arguments& { INC_STATS("DOM.DOMWindow.showModalDialog()"); DOMWindow* impl = V8DOMWindow::toNative(args.Holder()); - V8BindingState* state = V8BindingState::Only(); - - DOMWindow* activeWindow = state->activeWindow(); - DOMWindow* firstWindow = state->firstWindow(); + if (!V8BindingSecurity::canAccessFrame(state, impl->frame(), true)) + return v8::Undefined(); // FIXME: Handle exceptions properly. String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]); - String dialogFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]); - DialogHandler handler(args[1]); + String dialogFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]); + DOMWindow* activeWindow = state->activeWindow(); + DOMWindow* firstWindow = state->firstWindow(); impl->showModalDialog(urlString, dialogFeaturesString, activeWindow, firstWindow, setUpDialog, &handler); return handler.returnValue(); @@ -447,21 +449,22 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args) { INC_STATS("DOM.DOMWindow.open()"); DOMWindow* impl = V8DOMWindow::toNative(args.Holder()); - V8BindingState* state = V8BindingState::Only(); - - DOMWindow* activeWindow = state->activeWindow(); - DOMWindow* firstWindow = state->firstWindow(); + if (!V8BindingSecurity::canAccessFrame(state, impl->frame(), true)) + return v8::Undefined(); // FIXME: Handle exceptions properly. String urlString = toWebCoreStringWithNullOrUndefinedCheck(args[0]); AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1])); String windowFeaturesString = toWebCoreStringWithNullOrUndefinedCheck(args[2]); + DOMWindow* activeWindow = state->activeWindow(); + DOMWindow* firstWindow = state->firstWindow(); RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeWindow, firstWindow); if (!openedWindow) return v8::Undefined(); - return toV8(openedWindow.release()); + + return toV8(openedWindow.release(), args.GetIsolate()); } v8::Handle<v8::Value> V8DOMWindow::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) @@ -478,7 +481,7 @@ v8::Handle<v8::Value> V8DOMWindow::indexedPropertyGetter(uint32_t index, const v Frame* child = frame->tree()->scopedChild(index); if (child) - return toV8(child->domWindow()); + return toV8(child->domWindow(), info.GetIsolate()); return notHandledByInterceptor(); } @@ -501,7 +504,7 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam AtomicString propName = v8StringToAtomicWebCoreString(name); Frame* child = frame->tree()->scopedChild(propName); if (child) - return toV8(child->domWindow()); + return toV8(child->domWindow(), info.GetIsolate()); // Search IDL functions defined in the prototype if (!info.Holder()->GetRealNamedProperty(name).IsEmpty()) @@ -515,8 +518,8 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam HTMLCollection* items = doc->windowNamedItems(propName); if (items->length() >= 1) { if (items->length() == 1) - return toV8(items->firstItem()); - return toV8(items); + return toV8(items->firstItem(), info.GetIsolate()); + return toV8(items, info.GetIsolate()); } } } @@ -596,7 +599,7 @@ bool V8DOMWindow::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t inde return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false); } -v8::Handle<v8::Value> toV8(DOMWindow* window) +v8::Handle<v8::Value> toV8(DOMWindow* window, v8::Isolate* isolate) { if (!window) return v8::Null(); diff --git a/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp index 9203fedcc..ba5f8c458 100755 --- a/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp @@ -49,32 +49,33 @@ v8::Handle<v8::Value> V8DataView::constructorCallback(const v8::Arguments& args) // 'new DataView()' and the call used to construct the cached DataView object. RefPtr<DataView> dataView = DataView::create(0); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, dataView.get()); - return toV8(dataView.release(), args.Holder()); + V8DOMWrapper::setJSWrapperForDOMObject(dataView.release(), v8::Persistent<v8::Object>::New(args.Holder())); + return args.Holder(); } if (args[0]->IsNull() || !V8ArrayBuffer::HasInstance(args[0])) return V8Proxy::throwTypeError(); return constructWebGLArrayWithArrayBufferArgument<DataView, char>(args, &info, v8::kExternalByteArray, false); } -v8::Handle<v8::Value> toV8(DataView* impl) +v8::Handle<v8::Value> toV8(DataView* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - return V8DataView::wrap(impl); + return V8DataView::wrap(impl, isolate); } v8::Handle<v8::Value> V8DataView::getInt8Callback(const v8::Arguments& args) { INC_STATS("DOM.DataView.getInt8"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); DataView* imp = V8DataView::toNative(args.Holder()); ExceptionCode ec = 0; EXCEPTION_BLOCK(unsigned, byteOffset, toUInt32(args[0])); int8_t result = imp->getInt8(byteOffset, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } return v8::Integer::New(result); @@ -84,14 +85,14 @@ v8::Handle<v8::Value> V8DataView::getUint8Callback(const v8::Arguments& args) { INC_STATS("DOM.DataView.getUint8"); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); DataView* imp = V8DataView::toNative(args.Holder()); ExceptionCode ec = 0; EXCEPTION_BLOCK(unsigned, byteOffset, toUInt32(args[0])); uint8_t result = imp->getUint8(byteOffset, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } return v8::Integer::New(result); @@ -101,7 +102,7 @@ v8::Handle<v8::Value> V8DataView::setInt8Callback(const v8::Arguments& args) { INC_STATS("DOM.DataView.setInt8"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); DataView* imp = V8DataView::toNative(args.Holder()); ExceptionCode ec = 0; @@ -109,7 +110,7 @@ v8::Handle<v8::Value> V8DataView::setInt8Callback(const v8::Arguments& args) EXCEPTION_BLOCK(int, value, toInt32(args[1])); imp->setInt8(byteOffset, static_cast<int8_t>(value), ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } @@ -117,7 +118,7 @@ v8::Handle<v8::Value> V8DataView::setUint8Callback(const v8::Arguments& args) { INC_STATS("DOM.DataView.setUint8"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); DataView* imp = V8DataView::toNative(args.Holder()); ExceptionCode ec = 0; @@ -125,7 +126,7 @@ v8::Handle<v8::Value> V8DataView::setUint8Callback(const v8::Arguments& args) EXCEPTION_BLOCK(int, value, toInt32(args[1])); imp->setUint8(byteOffset, static_cast<uint8_t>(value), ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } diff --git a/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp index a1f2a7632..89aaf72ae 100644 --- a/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp @@ -33,7 +33,7 @@ #if ENABLE(WORKERS) #include "V8DedicatedWorkerContext.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "DedicatedWorkerContext.h" #include "WorkerContextExecutionProxy.h" #include "V8Binding.h" @@ -57,7 +57,8 @@ static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args SerializedScriptValue::create(args[0], &ports, extendedTransfer ? &arrayBuffers : 0, - didThrow); + didThrow, + args.GetIsolate()); if (didThrow) return v8::Undefined(); ExceptionCode ec = 0; @@ -67,13 +68,13 @@ static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args v8::Handle<v8::Value> V8DedicatedWorkerContext::postMessageCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.DedicatedWorkerContext.postMessage"); + INC_STATS("DOM.DedicatedWorkerContext.postMessage"); return handlePostMessageCallback(args, false); } v8::Handle<v8::Value> V8DedicatedWorkerContext::webkitPostMessageCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.DedicatedWorkerContext.postMessage"); + INC_STATS("DOM.DedicatedWorkerContext.postMessage"); return handlePostMessageCallback(args, true); } diff --git a/Source/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp index a8062fb77..19d7a3b69 100644 --- a/Source/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp @@ -51,7 +51,7 @@ v8::Handle<v8::Value> V8DirectoryEntry::getDirectoryCallback(const v8::Arguments DirectoryEntry* imp = V8DirectoryEntry::toNative(args.Holder()); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, path, args[0]); if (args.Length() <= 1) { @@ -95,7 +95,7 @@ v8::Handle<v8::Value> V8DirectoryEntry::getFileCallback(const v8::Arguments& arg DirectoryEntry* imp = V8DirectoryEntry::toNative(args.Holder()); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, path, args[0]); if (args.Length() <= 1) { diff --git a/Source/WebCore/bindings/v8/custom/V8DirectoryEntrySyncCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DirectoryEntrySyncCustom.cpp index 897848b59..5135bce33 100644 --- a/Source/WebCore/bindings/v8/custom/V8DirectoryEntrySyncCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DirectoryEntrySyncCustom.cpp @@ -99,15 +99,15 @@ v8::Handle<v8::Value> V8DirectoryEntrySync::getDirectoryCallback(const v8::Argum STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, path, args[0]); RefPtr<WebKitFlags> flags = getFlags(args[1], ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } RefPtr<DirectoryEntrySync> result = imp->getDirectory(path, flags, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } v8::Handle<v8::Value> V8DirectoryEntrySync::getFileCallback(const v8::Arguments& args) @@ -118,15 +118,15 @@ v8::Handle<v8::Value> V8DirectoryEntrySync::getFileCallback(const v8::Arguments& STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, path, args[0]); RefPtr<WebKitFlags> flags = getFlags(args[1], ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } RefPtr<FileEntrySync> result = imp->getFile(path, flags, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } diff --git a/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp index e6ba75b73..5793626fe 100644 --- a/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp @@ -91,7 +91,7 @@ v8::Handle<v8::Value> V8Document::evaluateCallback(const v8::Arguments& args) if (ec) return throwError(ec); - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } v8::Handle<v8::Value> V8Document::getCSSCanvasContextCallback(const v8::Arguments& args) @@ -107,26 +107,26 @@ v8::Handle<v8::Value> V8Document::getCSSCanvasContextCallback(const v8::Argument if (!result) return v8::Undefined(); if (result->is2d()) - return toV8(static_cast<CanvasRenderingContext2D*>(result)); + return toV8(static_cast<CanvasRenderingContext2D*>(result), args.GetIsolate()); #if ENABLE(WEBGL) else if (result->is3d()) - return toV8(static_cast<WebGLRenderingContext*>(result)); + return toV8(static_cast<WebGLRenderingContext*>(result), args.GetIsolate()); #endif // ENABLE(WEBGL) ASSERT_NOT_REACHED(); return v8::Undefined(); } -v8::Handle<v8::Value> toV8(Document* impl, bool forceNewObject) +v8::Handle<v8::Value> toV8(Document* impl, v8::Isolate* isolate, bool forceNewObject) { if (!impl) return v8::Null(); if (impl->isHTMLDocument()) - return toV8(static_cast<HTMLDocument*>(impl), forceNewObject); + return toV8(static_cast<HTMLDocument*>(impl), isolate, forceNewObject); #if ENABLE(SVG) if (impl->isSVGDocument()) - return toV8(static_cast<SVGDocument*>(impl), forceNewObject); + return toV8(static_cast<SVGDocument*>(impl), isolate, forceNewObject); #endif - v8::Handle<v8::Object> wrapper = V8Document::wrap(impl, forceNewObject); + v8::Handle<v8::Object> wrapper = V8Document::wrap(impl, isolate, forceNewObject); if (wrapper.IsEmpty()) return wrapper; if (!V8IsolatedContext::getEntered()) { @@ -147,7 +147,7 @@ v8::Handle<v8::Value> V8Document::createTouchListCallback(const v8::Arguments& a touchList->append(V8Touch::toNative(args[i]->ToObject())); } - return toV8(touchList.release()); + return toV8(touchList.release(), args.GetIsolate()); } #endif diff --git a/Source/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp index f86054b76..b45377c61 100644 --- a/Source/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp @@ -26,7 +26,9 @@ #include "DOMWindow.h" #include "Frame.h" +#include "Location.h" #include "V8Binding.h" +#include "V8BindingState.h" #include "V8Location.h" #include "V8Proxy.h" @@ -39,7 +41,7 @@ v8::Handle<v8::Value> V8Document::locationAccessorGetter(v8::Local<v8::String> n return v8::Null(); DOMWindow* window = document->frame()->domWindow(); - return toV8(window->location()); + return toV8(window->location(), info.GetIsolate()); } void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -48,9 +50,19 @@ void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8 if (!document->frame()) return; + State<V8Binding>* state = V8BindingState::Only(); + + DOMWindow* activeWindow = state->activeWindow(); + if (!activeWindow) + return; + + DOMWindow* firstWindow = state->firstWindow(); + if (!firstWindow) + return; + DOMWindow* window = document->frame()->domWindow(); - // setLocation does security checks. // XXXMB- verify! - V8DOMWindowShell::setLocation(window, toWebCoreString(value)); + if (Location* location = window->location()) + location->setHref(toWebCoreString(value), activeWindow, firstWindow); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8EntryCustom.cpp b/Source/WebCore/bindings/v8/custom/V8EntryCustom.cpp index c02cd6fd5..dc3a53fb9 100644 --- a/Source/WebCore/bindings/v8/custom/V8EntryCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8EntryCustom.cpp @@ -44,16 +44,16 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(Entry* impl) +v8::Handle<v8::Value> toV8(Entry* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); if (impl->isFile()) - return toV8(static_cast<FileEntry*>(impl)); + return toV8(static_cast<FileEntry*>(impl), isolate); ASSERT(impl->isDirectory()); - return toV8(static_cast<DirectoryEntry*>(impl)); + return toV8(static_cast<DirectoryEntry*>(impl), isolate); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8EntrySyncCustom.cpp b/Source/WebCore/bindings/v8/custom/V8EntrySyncCustom.cpp index e98df19b0..13ae6d811 100644 --- a/Source/WebCore/bindings/v8/custom/V8EntrySyncCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8EntrySyncCustom.cpp @@ -44,16 +44,16 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(EntrySync* impl) +v8::Handle<v8::Value> toV8(EntrySync* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); if (impl->isFile()) - return toV8(static_cast<FileEntrySync*>(impl)); + return toV8(static_cast<FileEntrySync*>(impl), isolate); ASSERT(impl->isDirectory()); - return toV8(static_cast<DirectoryEntrySync*>(impl)); + return toV8(static_cast<DirectoryEntrySync*>(impl), isolate); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp b/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp index 48939cf01..e305c9a03 100644 --- a/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp @@ -54,7 +54,7 @@ v8::Handle<v8::Value> V8Event::dataTransferAccessorGetter(v8::Local<v8::String> Event* event = V8Event::toNative(info.Holder()); if (event->isDragEvent()) - return toV8(static_cast<MouseEvent*>(event)->clipboard()); + return toV8(static_cast<MouseEvent*>(event)->clipboard(), info.GetIsolate()); return v8::Undefined(); } @@ -64,16 +64,16 @@ v8::Handle<v8::Value> V8Event::clipboardDataAccessorGetter(v8::Local<v8::String> Event* event = V8Event::toNative(info.Holder()); if (event->isClipboardEvent()) - return toV8(static_cast<ClipboardEvent*>(event)->clipboard()); + return toV8(static_cast<ClipboardEvent*>(event)->clipboard(), info.GetIsolate()); return v8::Undefined(); } #define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \ if (eventNames().interfaceFor##interfaceName == desiredInterface) \ - return toV8(static_cast<interfaceName*>(event)); + return toV8(static_cast<interfaceName*>(event), isolate); -v8::Handle<v8::Value> toV8(Event* event) +v8::Handle<v8::Value> toV8(Event* event, v8::Isolate *isolate) { if (!event) return v8::Null(); @@ -82,11 +82,11 @@ v8::Handle<v8::Value> toV8(Event* event) // We need to check Event first to avoid infinite recursion. if (eventNames().interfaceForEvent == desiredInterface) - return V8Event::wrap(event); + return V8Event::wrap(event, isolate); DOM_EVENT_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE) - return V8Event::wrap(event); + return V8Event::wrap(event, isolate); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8FileReaderCustom.cpp b/Source/WebCore/bindings/v8/custom/V8FileReaderCustom.cpp index b5b574836..0cffe6d83 100755 --- a/Source/WebCore/bindings/v8/custom/V8FileReaderCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8FileReaderCustom.cpp @@ -46,7 +46,7 @@ v8::Handle<v8::Value> V8FileReader::resultAccessorGetter(v8::Local<v8::String> n v8::Handle<v8::Object> holder = info.Holder(); FileReader* imp = V8FileReader::toNative(holder); if (imp->readType() == FileReaderLoader::ReadAsArrayBuffer) - return toV8(imp->arrayBufferResult()); + return toV8(imp->arrayBufferResult(), info.GetIsolate()); return v8StringOrNull(imp->stringResult()); } diff --git a/Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp index 178307eb5..06360615b 100644 --- a/Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp @@ -29,13 +29,14 @@ */ #include "config.h" -#include "ArrayBuffer.h" -#include "Float32Array.h" +#include "V8Float32Array.h" + +#include <wtf/ArrayBuffer.h> +#include <wtf/Float32Array.h> #include "V8Binding.h" #include "V8ArrayBuffer.h" #include "V8ArrayBufferViewCustom.h" -#include "V8Float32Array.h" #include "V8Proxy.h" namespace WebCore { @@ -53,11 +54,11 @@ v8::Handle<v8::Value> V8Float32Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Float32Array, V8Float32Array>(args); } -v8::Handle<v8::Value> toV8(Float32Array* impl) +v8::Handle<v8::Value> toV8(Float32Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Float32Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Float32Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp index 429e96234..8987b4faa 100644 --- a/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp @@ -24,15 +24,16 @@ */ #include "config.h" -#include "Float64Array.h" +#include "V8Float64Array.h" -#include "ArrayBuffer.h" #include "V8ArrayBuffer.h" #include "V8ArrayBufferViewCustom.h" #include "V8Binding.h" -#include "V8Float64Array.h" #include "V8Proxy.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Float64Array.h> + namespace WebCore { v8::Handle<v8::Value> V8Float64Array::constructorCallback(const v8::Arguments& args) @@ -48,11 +49,11 @@ v8::Handle<v8::Value> V8Float64Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Float64Array, V8Float64Array>(args); } -v8::Handle<v8::Value> toV8(Float64Array* impl) +v8::Handle<v8::Value> toV8(Float64Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalDoubleArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp index 1dc7836e4..0a0594833 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp @@ -41,7 +41,7 @@ namespace WebCore { -static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, AtomicString name) +static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, AtomicString name, v8::Isolate* isolate) { Vector<RefPtr<Node> > namedItems; collection->namedItems(name, namedItems); @@ -50,16 +50,16 @@ static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, Atomic return v8::Handle<v8::Value>(); if (namedItems.size() == 1) - return toV8(namedItems.at(0).release()); + return toV8(namedItems.at(0).release(), isolate); - return toV8(V8NamedNodesCollection::create(namedItems)); + return toV8(V8NamedNodesCollection::create(namedItems), isolate); } -static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v8::Value> argument) +static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v8::Value> argument, v8::Isolate* isolate) { v8::Local<v8::Uint32> index = argument->ToArrayIndex(); if (index.IsEmpty()) { - v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(argument->ToString())); + v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(argument->ToString()), isolate); if (result.IsEmpty()) return v8::Undefined(); @@ -68,7 +68,7 @@ static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v } RefPtr<Node> result = collection->item(index->Uint32Value()); - return toV8(result.release()); + return toV8(result.release(), isolate); } v8::Handle<v8::Value> V8HTMLAllCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -81,21 +81,21 @@ v8::Handle<v8::Value> V8HTMLAllCollection::namedPropertyGetter(v8::Local<v8::Str return notHandledByInterceptor(); HTMLAllCollection* imp = V8HTMLAllCollection::toNative(info.Holder()); - return getNamedItems(imp, v8StringToAtomicWebCoreString(name)); + return getNamedItems(imp, v8StringToAtomicWebCoreString(name), info.GetIsolate()); } v8::Handle<v8::Value> V8HTMLAllCollection::itemCallback(const v8::Arguments& args) { INC_STATS("DOM.HTMLAllCollection.item()"); HTMLAllCollection* imp = V8HTMLAllCollection::toNative(args.Holder()); - return getItem(imp, args[0]); + return getItem(imp, args[0], args.GetIsolate()); } v8::Handle<v8::Value> V8HTMLAllCollection::namedItemCallback(const v8::Arguments& args) { INC_STATS("DOM.HTMLAllCollection.namedItem()"); HTMLAllCollection* imp = V8HTMLAllCollection::toNative(args.Holder()); - v8::Handle<v8::Value> result = getNamedItems(imp, toWebCoreString(args[0])); + v8::Handle<v8::Value> result = getNamedItems(imp, toWebCoreString(args[0]), args.GetIsolate()); if (result.IsEmpty()) return v8::Undefined(); @@ -112,7 +112,7 @@ v8::Handle<v8::Value> V8HTMLAllCollection::callAsFunctionCallback(const v8::Argu HTMLAllCollection* imp = V8HTMLAllCollection::toNative(args.Holder()); if (args.Length() == 1) - return getItem(imp, args[0]); + return getItem(imp, args[0], args.GetIsolate()); // If there is a second argument it is the index of the item we want. String name = toWebCoreString(args[0]); @@ -121,7 +121,7 @@ v8::Handle<v8::Value> V8HTMLAllCollection::callAsFunctionCallback(const v8::Argu return v8::Undefined(); if (Node* node = imp->namedItemWithIndex(name, index->Uint32Value())) - return toV8(node); + return toV8(node, args.GetIsolate()); return v8::Undefined(); } diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp index 52465b62e..01c54db46 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp @@ -86,10 +86,10 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Argument if (!result) return v8::Null(); if (result->is2d()) - return toV8(static_cast<CanvasRenderingContext2D*>(result)); + return toV8(static_cast<CanvasRenderingContext2D*>(result), args.GetIsolate()); #if ENABLE(WEBGL) else if (result->is3d()) - return toV8(static_cast<WebGLRenderingContext*>(result)); + return toV8(static_cast<WebGLRenderingContext*>(result), args.GetIsolate()); #endif ASSERT_NOT_REACHED(); return v8::Null(); @@ -110,7 +110,7 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::toDataURLCallback(const v8::Arguments } String result = canvas->toDataURL(type, qualityPtr, ec); - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8StringOrUndefined(result); } diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp index dda51d402..87bfcda79 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp @@ -41,7 +41,7 @@ namespace WebCore { -static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicString name) +static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicString name, v8::Isolate* isolate) { Vector<RefPtr<Node> > namedItems; collection->namedItems(name, namedItems); @@ -50,9 +50,9 @@ static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicStr return v8::Handle<v8::Value>(); if (namedItems.size() == 1) - return toV8(namedItems.at(0).release()); + return toV8(namedItems.at(0).release(), isolate); - return toV8(V8NamedNodesCollection::create(namedItems)); + return toV8(V8NamedNodesCollection::create(namedItems), isolate); } v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -65,14 +65,14 @@ v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String return notHandledByInterceptor(); HTMLCollection* imp = V8HTMLCollection::toNative(info.Holder()); - return getNamedItems(imp, v8StringToAtomicWebCoreString(name)); + return getNamedItems(imp, v8StringToAtomicWebCoreString(name), info.GetIsolate()); } v8::Handle<v8::Value> V8HTMLCollection::namedItemCallback(const v8::Arguments& args) { INC_STATS("DOM.HTMLCollection.namedItem()"); HTMLCollection* imp = V8HTMLCollection::toNative(args.Holder()); - v8::Handle<v8::Value> result = getNamedItems(imp, toWebCoreString(args[0])); + v8::Handle<v8::Value> result = getNamedItems(imp, toWebCoreString(args[0]), args.GetIsolate()); if (result.IsEmpty()) return v8::Undefined(); @@ -80,11 +80,11 @@ v8::Handle<v8::Value> V8HTMLCollection::namedItemCallback(const v8::Arguments& a return result; } -v8::Handle<v8::Value> toV8(HTMLCollection* impl) +v8::Handle<v8::Value> toV8(HTMLCollection* impl, v8::Isolate* isolate) { if (impl->type() == DocAll) - return toV8(static_cast<HTMLAllCollection*>(impl)); - return V8HTMLCollection::wrap(impl); + return toV8(static_cast<HTMLAllCollection*>(impl), isolate); + return V8HTMLCollection::wrap(impl, isolate); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp index 41ae07171..b5d857525 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp @@ -44,6 +44,7 @@ #include "V8IsolatedContext.h" #include "V8Node.h" #include "V8Proxy.h" +#include "V8RecursionScope.h" #include <wtf/OwnArrayPtr.h> #include <wtf/RefPtr.h> #include <wtf/StdLibExtras.h> @@ -66,7 +67,11 @@ v8::Local<v8::Object> V8HTMLDocument::WrapInShadowObject(v8::Local<v8::Object> w if (shadowConstructor.IsEmpty()) return v8::Local<v8::Object>(); - v8::Local<v8::Object> shadow = shadowConstructor->NewInstance(); + v8::Local<v8::Object> shadow; + { + V8RecursionScope::MicrotaskSuppression scope; + shadow = shadowConstructor->NewInstance(); + } if (shadow.IsEmpty()) return v8::Local<v8::Object>(); V8DOMWrapper::setDOMWrapper(shadow, &V8HTMLDocument::info, impl); @@ -74,7 +79,7 @@ v8::Local<v8::Object> V8HTMLDocument::WrapInShadowObject(v8::Local<v8::Object> w return shadow; } -v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key) +v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key, v8::Isolate* isolate) { if (!htmlDocument->hasNamedItem(key.impl()) && !htmlDocument->hasExtraNamedItem(key.impl())) return v8::Handle<v8::Value>(); @@ -87,12 +92,12 @@ v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocumen Node* node = items->firstItem(); Frame* frame = 0; if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) - return toV8(frame->domWindow()); + return toV8(frame->domWindow(), isolate); - return toV8(node); + return toV8(node, isolate); } - return toV8(items); + return toV8(items, isolate); } // HTMLDocument ---------------------------------------------------------------- @@ -172,7 +177,7 @@ v8::Handle<v8::Value> V8HTMLDocument::allAccessorGetter(v8::Local<v8::String> na INC_STATS("DOM.HTMLDocument.all._get"); v8::Handle<v8::Object> holder = info.Holder(); HTMLDocument* htmlDocument = V8HTMLDocument::toNative(holder); - return toV8(htmlDocument->all()); + return toV8(htmlDocument->all(), info.GetIsolate()); } void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -181,11 +186,11 @@ void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8: info.This()->ForceSet(name, value); } -v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject) +v8::Handle<v8::Value> toV8(HTMLDocument* impl, v8::Isolate* isolate, bool forceNewObject) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8HTMLDocument::wrap(impl, forceNewObject); + v8::Handle<v8::Object> wrapper = V8HTMLDocument::wrap(impl, isolate, forceNewObject); if (wrapper.IsEmpty()) return wrapper; if (!V8IsolatedContext::getEntered()) { diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp index 1ca6bd388..dea17ec8c 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp @@ -41,19 +41,19 @@ namespace WebCore { #if ENABLE(MICRODATA) -static v8::Handle<v8::Value> toV8Object(MicroDataItemValue* itemValue) +static v8::Handle<v8::Value> toV8Object(MicroDataItemValue* itemValue, v8::Isolate* isolate) { if (!itemValue) return v8::Null(); if (itemValue->isNode()) - return toV8(itemValue->getNode()); + return toV8(itemValue->getNode(), isolate); return v8String(itemValue->getString()); } #endif -v8::Handle<v8::Value> toV8(HTMLElement* impl, bool forceNewObject) +v8::Handle<v8::Value> toV8(HTMLElement* impl, v8::Isolate* isolate, bool forceNewObject) { if (!impl) return v8::Null(); @@ -64,7 +64,7 @@ v8::Handle<v8::Value> toV8(HTMLElement* impl, bool forceNewObject) v8::Handle<v8::Value> V8HTMLElement::itemValueAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { HTMLElement* impl = V8HTMLElement::toNative(info.Holder()); - return toV8Object(impl->itemValue().get()); + return toV8Object(impl->itemValue().get(), info.GetIsolate()); } void V8HTMLElement::itemValueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -73,7 +73,7 @@ void V8HTMLElement::itemValueAccessorSetter(v8::Local<v8::String> name, v8::Loca ExceptionCode ec = 0; impl->setItemValue(toWebCoreString(value), ec); if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); } #endif diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp index 9baf78a6d..f8524c160 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp @@ -49,7 +49,7 @@ v8::Handle<v8::Value> V8HTMLFormElement::indexedPropertyGetter(uint32_t index, c RefPtr<Node> formElement = form->elements()->item(index); if (!formElement) return notHandledByInterceptor(); - return toV8(formElement.release()); + return toV8(formElement.release(), info.GetIsolate()); } v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -75,9 +75,9 @@ v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::Strin ASSERT(!elements.isEmpty()); if (elements.size() == 1) - return toV8(elements.at(0).release()); + return toV8(elements.at(0).release(), info.GetIsolate()); - return toV8(V8NamedNodesCollection::create(elements)); + return toV8(V8NamedNodesCollection::create(elements), info.GetIsolate()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp index 6a45be773..16cd59daa 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp @@ -55,7 +55,7 @@ v8::Handle<v8::Value> V8HTMLFrameSetElement::namedPropertyGetter(v8::Local<v8::S if (!doc) return v8::Undefined(); if (Frame* frame = doc->frame()) - return toV8(frame->domWindow()); + return toV8(frame->domWindow(), info.GetIsolate()); } return notHandledByInterceptor(); } diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp index 67b9d1a52..8c73a38e7 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp @@ -69,7 +69,7 @@ static v8::Handle<v8::Value> v8HTMLImageElementConstructorCallback(const v8::Arg // FIXME: The correct way to do this would be to make HTMLImageElement derive from // ActiveDOMObject and use its interface to keep its wrapper alive. Then we would // remove this code and the special case in isObservableThroughDOM. - toV8(document); + toV8(document, args.GetIsolate()); int width; int height; @@ -86,8 +86,7 @@ static v8::Handle<v8::Value> v8HTMLImageElementConstructorCallback(const v8::Arg RefPtr<HTMLImageElement> image = HTMLImageElement::createForJSConstructor(document, optionalWidth, optionalHeight); V8DOMWrapper::setDOMWrapper(args.Holder(), &V8HTMLImageElementConstructor::info, image.get()); - image->ref(); - V8DOMWrapper::setJSWrapperForDOMNode(image.get(), v8::Persistent<v8::Object>::New(args.Holder())); + V8DOMWrapper::setJSWrapperForDOMNode(image.release(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLLinkElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLLinkElementCustom.cpp index 78a22645d..5a3c06fc6 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLLinkElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLLinkElementCustom.cpp @@ -42,7 +42,7 @@ v8::Handle<v8::Value> V8HTMLLinkElement::sizesAccessorGetter(v8::Local<v8::Strin { INC_STATS("DOM.HTMLLinkElement.sizes._get"); HTMLLinkElement* imp = V8HTMLLinkElement::toNative(info.Holder()); - return toV8(imp->sizes()); + return toV8(imp->sizes(), info.GetIsolate()); } void V8HTMLLinkElement::sizesAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp index e320c847a..d595d0eec 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp @@ -56,7 +56,7 @@ v8::Handle<v8::Value> V8HTMLOptionsCollection::addCallback(const v8::Arguments& { INC_STATS("DOM.HTMLOptionsCollection.add()"); if (!V8HTMLOptionElement::HasInstance(args[0])) { - V8Proxy::setDOMException(TYPE_MISMATCH_ERR); + V8Proxy::setDOMException(TYPE_MISMATCH_ERR, args.GetIsolate()); return v8::Undefined(); } HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(args.Holder()); @@ -80,7 +80,7 @@ v8::Handle<v8::Value> V8HTMLOptionsCollection::addCallback(const v8::Arguments& } if (ec != 0) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } @@ -111,7 +111,7 @@ void V8HTMLOptionsCollection::lengthAccessorSetter(v8::Local<v8::String> name, v if (!ec) imp->setLength(newLength, ec); - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); } v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) @@ -123,7 +123,7 @@ v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertyGetter(uint32_t in if (!result) return notHandledByInterceptor(); - return toV8(result.release()); + return toV8(result.release(), info.GetIsolate()); } v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -131,7 +131,7 @@ v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertySetter(uint32_t in INC_STATS("DOM.HTMLOptionsCollection.IndexedPropertySetter"); HTMLOptionsCollection* collection = V8HTMLOptionsCollection::toNative(info.Holder()); HTMLSelectElement* base = static_cast<HTMLSelectElement*>(collection->base()); - return toOptionsCollectionSetter(index, value, base); + return toOptionsCollectionSetter(index, value, base, info.GetIsolate()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp index ad86dd214..4eeaef639 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp @@ -42,7 +42,7 @@ v8::Handle<v8::Value> V8HTMLOutputElement::htmlForAccessorGetter(v8::Local<v8::S { INC_STATS("DOM.HTMLOutputElement.htmlFor._get"); HTMLOutputElement* imp = V8HTMLOutputElement::toNative(info.Holder()); - return toV8(imp->htmlFor()); + return toV8(imp->htmlFor(), info.GetIsolate()); } void V8HTMLOutputElement::htmlForAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/Source/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp index 7cd3926fe..e1d5914aa 100644 --- a/Source/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp @@ -53,14 +53,14 @@ v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertyGetter(uint32_t index, if (!result) return notHandledByInterceptor(); - return toV8(result.release()); + return toV8(result.release(), info.GetIsolate()); } v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { INC_STATS("DOM.HTMLSelectElement.IndexedPropertySetter"); HTMLSelectElement* select = V8HTMLSelectElement::toNative(info.Holder()); - return toOptionsCollectionSetter(index, value, select); + return toOptionsCollectionSetter(index, value, select, info.GetIsolate()); } v8::Handle<v8::Value> V8HTMLSelectElement::removeCallback(const v8::Arguments& args) diff --git a/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp index abaddcaa1..944368277 100644 --- a/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp @@ -53,7 +53,7 @@ v8::Handle<v8::Value> V8History::stateAccessorGetter(v8::Local<v8::String> name, return value; SerializedScriptValue* serialized = history->state(); - value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::Null()); + value = serialized ? serialized->deserialize(0, info.GetIsolate()) : v8::Handle<v8::Value>(v8::Null()); info.Holder()->SetHiddenValue(V8HiddenPropertyName::state(), value); return value; @@ -62,7 +62,7 @@ v8::Handle<v8::Value> V8History::stateAccessorGetter(v8::Local<v8::String> name, v8::Handle<v8::Value> V8History::pushStateCallback(const v8::Arguments& args) { bool didThrow = false; - RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, 0, didThrow); + RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, 0, didThrow, args.GetIsolate()); if (didThrow) return v8::Undefined(); @@ -87,7 +87,7 @@ v8::Handle<v8::Value> V8History::pushStateCallback(const v8::Arguments& args) v8::Handle<v8::Value> V8History::replaceStateCallback(const v8::Arguments& args) { bool didThrow = false; - RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, 0, didThrow); + RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(args[0], 0, 0, didThrow, args.GetIsolate()); if (didThrow) return v8::Undefined(); diff --git a/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp b/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp index e4831ad9a..1733ec8bc 100644 --- a/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp @@ -44,7 +44,7 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(IDBAny* impl) +v8::Handle<v8::Value> toV8(IDBAny* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); @@ -73,7 +73,7 @@ v8::Handle<v8::Value> toV8(IDBAny* impl) case IDBAny::IDBTransactionType: return toV8(impl->idbTransaction()); case IDBAny::SerializedScriptValueType: - return impl->serializedScriptValue()->deserialize(); + return impl->serializedScriptValue()->deserialize(0, isolate); } ASSERT_NOT_REACHED(); diff --git a/Source/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp b/Source/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp index 0fbfe1bf2..9b0e65414 100644 --- a/Source/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8IDBKeyCustom.cpp @@ -38,7 +38,7 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(IDBKey* key) +v8::Handle<v8::Value> toV8(IDBKey* key, v8::Isolate* isolate) { if (!key) return v8::Null(); @@ -58,7 +58,7 @@ v8::Handle<v8::Value> toV8(IDBKey* key) { v8::Local<v8::Array> array = v8::Array::New(key->array().size()); for (size_t i = 0; i < key->array().size(); ++i) - array->Set(i, toV8(key->array()[i].get())); + array->Set(i, toV8(key->array()[i].get(), isolate)); return array; } } diff --git a/Source/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp b/Source/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp index b4549e416..7a8544dd9 100644 --- a/Source/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8ImageDataCustom.cpp @@ -31,18 +31,18 @@ #include "config.h" #include "V8ImageData.h" -#include "V8CanvasPixelArray.h" +#include "V8Uint8ClampedArray.h" namespace WebCore { -v8::Handle<v8::Value> toV8(ImageData* impl) +v8::Handle<v8::Value> toV8(ImageData* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8ImageData::wrap(impl); + v8::Handle<v8::Object> wrapper = V8ImageData::wrap(impl, isolate); if (!wrapper.IsEmpty()) { - // Create a V8 CanvasPixelArray object. - v8::Handle<v8::Value> pixelArray = toV8(impl->data()); + // Create a V8 Uint8ClampedArray object. + v8::Handle<v8::Value> pixelArray = toV8(impl->data(), isolate); // Set the "data" property of the ImageData object to // the created v8 object, eliminating the C++ callback // when accessing the "data" property. diff --git a/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp index 951f18969..87d195ace 100644 --- a/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp @@ -35,18 +35,28 @@ #include "Database.h" #include "InjectedScript.h" #include "InjectedScriptHost.h" +#include "InspectorDOMAgent.h" #include "InspectorValues.h" #include "ScriptValue.h" #include "V8Binding.h" #include "V8BindingState.h" #include "V8Database.h" +#include "V8Float32Array.h" +#include "V8Float64Array.h" #include "V8HTMLAllCollection.h" #include "V8HTMLCollection.h" #include "V8HiddenPropertyName.h" +#include "V8Int16Array.h" +#include "V8Int32Array.h" +#include "V8Int8Array.h" #include "V8NodeList.h" #include "V8Node.h" #include "V8Proxy.h" #include "V8Storage.h" +#include "V8Uint16Array.h" +#include "V8Uint32Array.h" +#include "V8Uint8Array.h" +#include "V8Uint8ClampedArray.h" namespace WebCore { @@ -132,6 +142,14 @@ v8::Handle<v8::Value> V8InjectedScriptHost::typeCallback(const v8::Arguments& ar return v8::String::New("array"); if (V8HTMLCollection::HasInstance(value)) return v8::String::New("array"); + if (V8Int8Array::HasInstance(value) || V8Int16Array::HasInstance(value) || V8Int32Array::HasInstance(value)) + return v8::String::New("array"); + if (V8Uint8Array::HasInstance(value) || V8Uint16Array::HasInstance(value) || V8Uint32Array::HasInstance(value)) + return v8::String::New("array"); + if (V8Float32Array::HasInstance(value) || V8Float64Array::HasInstance(value)) + return v8::String::New("array"); + if (V8Uint8ClampedArray::HasInstance(value)) + return v8::String::New("array"); return v8::Undefined(); } @@ -168,6 +186,65 @@ v8::Handle<v8::Value> V8InjectedScriptHost::functionDetailsCallback(const v8::Ar return result; } +static v8::Handle<v8::Array> getJSListenerFunctions(Document* document, const EventListenerInfo& listenerInfo) +{ + v8::Local<v8::Array> result = v8::Array::New(); + size_t handlersCount = listenerInfo.eventListenerVector.size(); + for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) { + RefPtr<EventListener> listener = listenerInfo.eventListenerVector[i].listener; + if (listener->type() != EventListener::JSEventListenerType) { + ASSERT_NOT_REACHED(); + continue; + } + V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener.get()); + v8::Local<v8::Context> context = toV8Context(document, v8Listener->worldContext()); + // Hide listeners from other contexts. + if (context != V8Proxy::currentContext()) + continue; + v8::Local<v8::Object> function = v8Listener->getListenerObject(document); + v8::Local<v8::Object> listenerEntry = v8::Object::New(); + listenerEntry->Set(v8::String::New("listener"), function); + listenerEntry->Set(v8::String::New("useCapture"), v8::Boolean::New(listenerInfo.eventListenerVector[i].useCapture)); + result->Set(v8::Number::New(outputIndex++), listenerEntry); + } + return result; +} + +v8::Handle<v8::Value> V8InjectedScriptHost::getEventListenersCallback(const v8::Arguments& args) +{ + INC_STATS("InjectedScriptHost.queryEventListenerCallback()"); + if (args.Length() < 1) + return v8::Undefined(); + + v8::HandleScope handleScope; + + v8::Local<v8::Value> value = args[0]; + if (!V8Node::HasInstance(value)) + return v8::Undefined(); + Node* node = V8Node::toNative(value->ToObject()); + if (!node) + return v8::Undefined(); + // This can only happen for orphan DocumentType nodes. + Document* document = node->document(); + if (!node->document()) + return v8::Undefined(); + + InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); + Vector<EventListenerInfo> listenersArray; + host->getEventListenersImpl(node, listenersArray); + + v8::Local<v8::Object> result = v8::Object::New(); + for (size_t i = 0; i < listenersArray.size(); ++i) { + v8::Handle<v8::Array> listeners = getJSListenerFunctions(document, listenersArray[i]); + if (!listeners->Length()) + continue; + AtomicString eventType = listenersArray[i].eventType; + result->Set(v8::String::New(fromWebCoreString(eventType), eventType.length()), listeners); + } + + return result; +} + v8::Handle<v8::Value> V8InjectedScriptHost::inspectCallback(const v8::Arguments& args) { INC_STATS("InjectedScriptHost.inspect()"); @@ -191,7 +268,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::databaseIdCallback(const v8::Argumen InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); Database* database = V8Database::toNative(v8::Handle<v8::Object>::Cast(args[0])); if (database) - return v8::Number::New(host->databaseIdImpl(database)); + return v8StringOrUndefined(host->databaseIdImpl(database)); #endif return v8::Undefined(); } @@ -204,7 +281,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::storageIdCallback(const v8::Argument InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(args[0])); if (storage) - return v8::Number::New(host->storageIdImpl(storage)); + return v8StringOrUndefined(host->storageIdImpl(storage)); return v8::Undefined(); } diff --git a/Source/WebCore/bindings/v8/custom/V8InjectedScriptManager.cpp b/Source/WebCore/bindings/v8/custom/V8InjectedScriptManager.cpp index 8bb4281e3..45559fc6e 100644 --- a/Source/WebCore/bindings/v8/custom/V8InjectedScriptManager.cpp +++ b/Source/WebCore/bindings/v8/custom/V8InjectedScriptManager.cpp @@ -29,11 +29,13 @@ */ #include "config.h" +#if ENABLE(INSPECTOR) #include "InjectedScriptManager.h" #include "DOMWindow.h" #include "InjectedScript.h" #include "InjectedScriptHost.h" +#include "SafeAllocation.h" #include "ScriptValue.h" #include "V8Binding.h" #include "V8BindingState.h" @@ -41,6 +43,7 @@ #include "V8HiddenPropertyName.h" #include "V8InjectedScriptHost.h" #include "V8Proxy.h" +#include "V8RecursionScope.h" #include <wtf/RefPtr.h> namespace WebCore { @@ -96,6 +99,7 @@ ScriptObject InjectedScriptManager::createInjectedScript(const String& scriptSou // injected script id and explicit reference to the inspected global object. The function is expected // to create and configure InjectedScript instance that is going to be used by the inspector. v8::Local<v8::Script> script = v8::Script::Compile(v8String(scriptSource)); + V8RecursionScope::MicrotaskSuppression recursionScope; v8::Local<v8::Value> v = script->Run(); ASSERT(!v.IsEmpty()); ASSERT(v->IsFunction()); @@ -168,3 +172,5 @@ bool InjectedScriptManager::canAccessInspectedWindow(ScriptState* scriptState) } } // namespace WebCore + +#endif // ENABLE(INSPECTOR) diff --git a/Source/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp b/Source/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp index 431e4e5d3..2e871f9ab 100644 --- a/Source/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp @@ -32,12 +32,10 @@ #if ENABLE(INSPECTOR) #include "V8InspectorFrontendHost.h" +#include "HistogramSupport.h" #include "InspectorController.h" #include "InspectorFrontendClient.h" #include "InspectorFrontendHost.h" -#if !PLATFORM(QT) -#include "PlatformSupport.h" -#endif #include "PlatformString.h" #include "V8Binding.h" @@ -125,7 +123,7 @@ static v8::Handle<v8::Value> histogramEnumeration(const char* name, const v8::Ar int sample = args[0]->ToInt32()->Value(); if (sample < boundaryValue) - PlatformSupport::histogramEnumeration(name, sample, boundaryValue); + HistogramSupport::histogramEnumeration(name, sample, boundaryValue); return v8::Undefined(); } diff --git a/Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp index 90a3c71a3..3199dd0a6 100644 --- a/Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp @@ -29,8 +29,8 @@ */ #include "config.h" -#include "ArrayBuffer.h" -#include "Int16Array.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Int16Array.h> #include "V8Binding.h" #include "V8ArrayBuffer.h" @@ -53,11 +53,11 @@ v8::Handle<v8::Value> V8Int16Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Int16Array, V8Int16Array>(args); } -v8::Handle<v8::Value> toV8(Int16Array* impl) +v8::Handle<v8::Value> toV8(Int16Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Int16Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Int16Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalShortArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp index 8fa38a76f..42945c077 100644 --- a/Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp @@ -29,8 +29,8 @@ */ #include "config.h" -#include "ArrayBuffer.h" -#include "Int32Array.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Int32Array.h> #include "V8Binding.h" #include "V8ArrayBuffer.h" @@ -53,11 +53,11 @@ v8::Handle<v8::Value> V8Int32Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Int32Array, V8Int32Array>(args); } -v8::Handle<v8::Value> toV8(Int32Array* impl) +v8::Handle<v8::Value> toV8(Int32Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Int32Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Int32Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalIntArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp index 33458dc09..a88a7e76c 100644 --- a/Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp @@ -29,8 +29,8 @@ */ #include "config.h" -#include "ArrayBuffer.h" -#include "Int8Array.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Int8Array.h> #include "V8Binding.h" #include "V8ArrayBuffer.h" @@ -53,11 +53,11 @@ v8::Handle<v8::Value> V8Int8Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Int8Array, V8Int8Array>(args); } -v8::Handle<v8::Value> toV8(Int8Array* impl) +v8::Handle<v8::Value> toV8(Int8Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Int8Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Int8Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalByteArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp b/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp new file mode 100644 index 000000000..d87ed75d2 --- /dev/null +++ b/Source/WebCore/bindings/v8/custom/V8IntentConstructor.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Google, Inc. ("Google") 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 GOOGLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Intent.h" + +#include "ExceptionCode.h" +#include "MessagePort.h" +#include "SerializedScriptValue.h" + +#include "V8Binding.h" +#include "V8BindingMacros.h" +#include "V8DOMWrapper.h" +#include "V8Intent.h" +#include "V8MessagePort.h" +#include "V8Proxy.h" +#include <wtf/ArrayBuffer.h> + +namespace WebCore { + +v8::Handle<v8::Value> V8Intent::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.Intent.Constructor"); + + if (!args.IsConstructCall()) + return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError); + + if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) + return args.Holder(); + if (args.Length() < 1) + return V8Proxy::throwNotEnoughArgumentsError(); + if (args.Length() == 1) { + // Use the dictionary constructor. This block will return if the + // argument isn't a valid Dictionary. + EXCEPTION_BLOCK(Dictionary, options, args[0]); + ExceptionCode ec = 0; + RefPtr<Intent> impl = Intent::create(ScriptState::current(), options, ec); + if (ec) + return throwError(ec); + + v8::Handle<v8::Object> wrapper = args.Holder(); + V8DOMWrapper::setDOMWrapper(wrapper, &info, impl.get()); + V8DOMWrapper::setJSWrapperForDOMObject(impl.release(), v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; + } + + ExceptionCode ec = 0; + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, action, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)); + STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined)); + MessagePortArray messagePortArrayTransferList; + ArrayBufferArray arrayBufferArrayTransferList; + if (args.Length() > 3) { + if (!extractTransferables(args[3], messagePortArrayTransferList, arrayBufferArrayTransferList)) + return throwError("Could not extract transferables", V8Proxy::TypeError); + } + bool dataDidThrow = false; + RefPtr<SerializedScriptValue> data = SerializedScriptValue::create(args[2], &messagePortArrayTransferList, &arrayBufferArrayTransferList, dataDidThrow); + if (dataDidThrow) + return throwError(DATA_CLONE_ERR); + + RefPtr<Intent> impl = Intent::create(action, type, data, messagePortArrayTransferList, ec); + if (ec) + return throwError(ec); + + v8::Handle<v8::Object> wrapper = args.Holder(); + V8DOMWrapper::setDOMWrapper(wrapper, &info, impl.get()); + V8DOMWrapper::setJSWrapperForDOMObject(impl.release(), v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + + +} // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp b/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp index 7db74e858..f40344bcc 100644 --- a/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8LocationCustom.cpp @@ -131,7 +131,7 @@ void V8Location::protocolAccessorSetter(v8::Local<v8::String> name, v8::Local<v8 ExceptionCode ec = 0; impl->setProtocol(protocol, state->activeWindow(), state->firstWindow(), ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); } void V8Location::searchAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -272,13 +272,13 @@ bool V8Location::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Va return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), false); } -v8::Handle<v8::Value> toV8(Location* impl) +v8::Handle<v8::Value> toV8(Location* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); if (wrapper.IsEmpty()) { - wrapper = V8Location::wrap(impl); + wrapper = V8Location::wrap(impl, isolate); if (!wrapper.IsEmpty()) V8DOMWrapper::setNamedHiddenWindowReference(impl->frame(), "location", wrapper); } diff --git a/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp b/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp index 6fda83192..bad469a50 100644 --- a/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp +++ b/Source/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp @@ -70,12 +70,13 @@ v8::Handle<v8::Value> V8MessageChannel::constructorCallback(const v8::Arguments& // Create references from the MessageChannel wrapper to the two // MessagePort wrappers to make sure that the MessagePort wrappers // stay alive as long as the MessageChannel wrapper is around. - V8DOMWrapper::setNamedHiddenReference(messageChannel, "port1", toV8(obj->port1())); - V8DOMWrapper::setNamedHiddenReference(messageChannel, "port2", toV8(obj->port2())); + V8DOMWrapper::setNamedHiddenReference(messageChannel, "port1", toV8(obj->port1(), args.GetIsolate())); + V8DOMWrapper::setNamedHiddenReference(messageChannel, "port2", toV8(obj->port2(), args.GetIsolate())); // Setup the standard wrapper object internal fields. V8DOMWrapper::setDOMWrapper(messageChannel, &info, obj.get()); - return toV8(obj.release(), messageChannel); + V8DOMWrapper::setJSWrapperForDOMObject(obj.release(), v8::Persistent<v8::Object>::New(messageChannel)); + return messageChannel; } diff --git a/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp b/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp index 64abe4028..5bb0187ae 100644 --- a/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp @@ -61,7 +61,7 @@ v8::Handle<v8::Value> V8MessageEvent::dataAccessorGetter(v8::Local<v8::String> n case MessageEvent::DataTypeSerializedScriptValue: if (SerializedScriptValue* serializedValue = event->dataAsSerializedScriptValue()) - result = serializedValue->deserialize(event->ports()); + result = serializedValue->deserialize(event->ports(), info.GetIsolate()); else result = v8::Null(); break; @@ -73,11 +73,11 @@ v8::Handle<v8::Value> V8MessageEvent::dataAccessorGetter(v8::Local<v8::String> n } case MessageEvent::DataTypeBlob: - result = toV8(event->dataAsBlob()); + result = toV8(event->dataAsBlob(), info.GetIsolate()); break; case MessageEvent::DataTypeArrayBuffer: - result = toV8(event->dataAsArrayBuffer()); + result = toV8(event->dataAsArrayBuffer(), info.GetIsolate()); break; } @@ -101,7 +101,7 @@ v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String> v8::Local<v8::Array> portArray = v8::Array::New(portsCopy.size()); for (size_t i = 0; i < portsCopy.size(); ++i) - portArray->Set(v8::Integer::New(i), toV8(portsCopy[i].get())); + portArray->Set(v8::Integer::New(i), toV8(portsCopy[i].get(), info.GetIsolate())); return portArray; } diff --git a/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp b/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp index 72df2893f..ee7d16caf 100644 --- a/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp @@ -30,7 +30,7 @@ #include "config.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "ExceptionCode.h" #include "MessagePort.h" #include "SerializedScriptValue.h" @@ -56,7 +56,8 @@ static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args SerializedScriptValue::create(args[0], &portArray, extendedTransfer ? &arrayBufferArray : 0, - didThrow); + didThrow, + args.GetIsolate()); if (didThrow) return v8::Undefined(); ExceptionCode ec = 0; diff --git a/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp b/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp index 585593089..45e8dc8c3 100644 --- a/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp @@ -66,22 +66,25 @@ bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, WebKitMutat v8::Local<v8::Array> mutationsArray = v8::Array::New(mutations->size()); for (size_t i = 0; i < mutations->size(); ++i) - mutationsArray->Set(v8::Integer::New(i), toV8(mutations->at(i).get())); + mutationsArray->Set(v8::Integer::New(i), toV8(mutations->at(i).get(), 0)); - v8::Handle<v8::Value> observerHandle = toV8(observer); + v8::Handle<v8::Value> observerHandle = toV8(observer, 0); if (observerHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } + if (!observerHandle->IsObject()) + return true; + v8::Handle<v8::Value> argv[] = { mutationsArray, observerHandle }; bool callbackReturnValue = false; - return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()); + return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp b/Source/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp index f303128e0..d869dc3b6 100644 --- a/Source/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp @@ -51,7 +51,7 @@ v8::Handle<v8::Value> V8NamedNodeMap::indexedPropertyGetter(uint32_t index, cons if (!result) return notHandledByInterceptor(); - return toV8(result.release()); + return toV8(result.release(), info.GetIsolate()); } v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -68,18 +68,18 @@ v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> if (!result) return notHandledByInterceptor(); - return toV8(result.release()); + return toV8(result.release(), info.GetIsolate()); } -v8::Handle<v8::Value> toV8(NamedNodeMap* impl) +v8::Handle<v8::Value> toV8(NamedNodeMap* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8NamedNodeMap::wrap(impl); + v8::Handle<v8::Object> wrapper = V8NamedNodeMap::wrap(impl, isolate); // Add a hidden reference from named node map to its owner node. Element* element = impl->element(); if (!wrapper.IsEmpty() && element) - wrapper->SetHiddenValue(V8HiddenPropertyName::ownerNode(), toV8(element)); + wrapper->SetHiddenValue(V8HiddenPropertyName::ownerNode(), toV8(element, isolate)); return wrapper; } diff --git a/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp b/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp index 242711344..71e471a26 100644 --- a/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8NodeCustom.cpp @@ -74,7 +74,7 @@ v8::Handle<v8::Value> V8Node::insertBeforeCallback(const v8::Arguments& args) Node* refChild = V8Node::HasInstance(args[1]) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; bool success = imp->insertBefore(newChild, refChild, ec, true); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } if (success) @@ -93,7 +93,7 @@ v8::Handle<v8::Value> V8Node::replaceChildCallback(const v8::Arguments& args) Node* oldChild = V8Node::HasInstance(args[1]) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; bool success = imp->replaceChild(newChild, oldChild, ec, true); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } if (success) @@ -110,7 +110,7 @@ v8::Handle<v8::Value> V8Node::removeChildCallback(const v8::Arguments& args) Node* oldChild = V8Node::HasInstance(args[0]) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; bool success = imp->removeChild(oldChild, ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } if (success) @@ -128,7 +128,7 @@ v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args) Node* newChild = V8Node::HasInstance(args[0]) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; bool success = imp->appendChild(newChild, ec, true ); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } if (success) @@ -136,49 +136,49 @@ v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args) return v8::Null(); } -v8::Handle<v8::Value> toV8Slow(Node* impl, bool forceNewObject) +v8::Handle<v8::Value> toV8Slow(Node* impl, v8::Isolate* isolate, bool forceNewObject) { if (!impl) return v8::Null(); if (!forceNewObject) { - v8::Handle<v8::Value> wrapper = V8DOMWrapper::getExistingWrapper(impl); + v8::Handle<v8::Value> wrapper = V8DOMWrapper::getCachedWrapper(impl); if (!wrapper.IsEmpty()) return wrapper; } switch (impl->nodeType()) { case Node::ELEMENT_NODE: if (impl->isHTMLElement()) - return toV8(toHTMLElement(impl), forceNewObject); + return toV8(toHTMLElement(impl), isolate, forceNewObject); #if ENABLE(SVG) if (impl->isSVGElement()) - return toV8(static_cast<SVGElement*>(impl), forceNewObject); + return toV8(static_cast<SVGElement*>(impl), isolate, forceNewObject); #endif - return V8Element::wrap(static_cast<Element*>(impl), forceNewObject); + return V8Element::wrap(static_cast<Element*>(impl), isolate, forceNewObject); case Node::ATTRIBUTE_NODE: - return toV8(static_cast<Attr*>(impl), forceNewObject); + return toV8(static_cast<Attr*>(impl), isolate, forceNewObject); case Node::TEXT_NODE: - return toV8(toText(impl), forceNewObject); + return toV8(toText(impl), isolate, forceNewObject); case Node::CDATA_SECTION_NODE: - return toV8(static_cast<CDATASection*>(impl), forceNewObject); + return toV8(static_cast<CDATASection*>(impl), isolate, forceNewObject); case Node::ENTITY_REFERENCE_NODE: - return toV8(static_cast<EntityReference*>(impl), forceNewObject); + return toV8(static_cast<EntityReference*>(impl), isolate, forceNewObject); case Node::ENTITY_NODE: - return toV8(static_cast<Entity*>(impl), forceNewObject); + return toV8(static_cast<Entity*>(impl), isolate, forceNewObject); case Node::PROCESSING_INSTRUCTION_NODE: - return toV8(static_cast<ProcessingInstruction*>(impl), forceNewObject); + return toV8(static_cast<ProcessingInstruction*>(impl), isolate, forceNewObject); case Node::COMMENT_NODE: - return toV8(static_cast<Comment*>(impl), forceNewObject); + return toV8(static_cast<Comment*>(impl), isolate, forceNewObject); case Node::DOCUMENT_NODE: - return toV8(static_cast<Document*>(impl), forceNewObject); + return toV8(static_cast<Document*>(impl), isolate, forceNewObject); case Node::DOCUMENT_TYPE_NODE: - return toV8(static_cast<DocumentType*>(impl), forceNewObject); + return toV8(static_cast<DocumentType*>(impl), isolate, forceNewObject); case Node::DOCUMENT_FRAGMENT_NODE: - return toV8(static_cast<DocumentFragment*>(impl), forceNewObject); + return toV8(static_cast<DocumentFragment*>(impl), isolate, forceNewObject); case Node::NOTATION_NODE: - return toV8(static_cast<Notation*>(impl), forceNewObject); + return toV8(static_cast<Notation*>(impl), isolate, forceNewObject); default: break; // XPATH_NAMESPACE_NODE } - return V8Node::wrap(impl, forceNewObject); + return V8Node::wrap(impl, isolate, forceNewObject); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp index 81eb4f85b..b1e58261a 100644 --- a/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8NodeListCustom.cpp @@ -56,7 +56,7 @@ v8::Handle<v8::Value> V8NodeList::namedPropertyGetter(v8::Local<v8::String> name if (!result) return notHandledByInterceptor(); - return toV8(result.release()); + return toV8(result.release(), info.GetIsolate()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp b/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp index 7eec7efd9..bc1ecc7e7 100644 --- a/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp @@ -30,7 +30,7 @@ #include "config.h" -#if ENABLE(NOTIFICATIONS) +#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) #include "V8NotificationCenter.h" #include "ExceptionCode.h" @@ -49,7 +49,7 @@ namespace WebCore { v8::Handle<v8::Value> V8NotificationCenter::createHTMLNotificationCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.NotificationCenter.CreateHTMLNotification()"); + INC_STATS("DOM.NotificationCenter.CreateHTMLNotification()"); NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args.Holder()); ExceptionCode ec = 0; @@ -60,12 +60,12 @@ v8::Handle<v8::Value> V8NotificationCenter::createHTMLNotificationCallback(const return throwError(ec); notification->ref(); - return toV8(notification.get()); + return toV8(notification.get(), args.GetIsolate()); } v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.NotificationCenter.CreateNotification()"); + INC_STATS("DOM.NotificationCenter.CreateNotification()"); NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args.Holder()); ExceptionCode ec = 0; @@ -75,12 +75,12 @@ v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8: return throwError(ec); notification->ref(); - return toV8(notification.get()); + return toV8(notification.get(), args.GetIsolate()); } v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.NotificationCenter.RequestPermission()"); + INC_STATS("DOM.NotificationCenter.RequestPermission()"); NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args.Holder()); ScriptExecutionContext* context = notificationCenter->scriptExecutionContext(); @@ -107,4 +107,4 @@ v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8:: } // namespace WebCore -#endif // ENABLE(NOTIFICATIONS) +#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) diff --git a/Source/WebCore/bindings/v8/custom/V8NotificationCustom.cpp b/Source/WebCore/bindings/v8/custom/V8NotificationCustom.cpp new file mode 100644 index 000000000..9e4add7a8 --- /dev/null +++ b/Source/WebCore/bindings/v8/custom/V8NotificationCustom.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 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" + +#if ENABLE(NOTIFICATIONS) +#include "V8Notification.h" + +#include "ExceptionCode.h" +#include "V8NotificationPermissionCallback.h" +#include "V8Proxy.h" + +namespace WebCore { + +v8::Handle<v8::Value> V8Notification::requestPermissionCallback(const v8::Arguments& args) +{ + INC_STATS(L"DOM.Notification.requestPermission"); + + bool succeeded = false; + RefPtr<V8NotificationPermissionCallback> callback = createFunctionOnlyCallback<V8NotificationPermissionCallback>(args[0], succeeded); + if (!succeeded) + return v8::Undefined(); + ASSERT(callback); + + Notification* notification = V8Notification::toNative(args.Holder()); + ScriptExecutionContext* context = notification->scriptExecutionContext(); + Notification::requestPermission(context, callback.release()); + return v8::Undefined(); +} + +} // namespace WebCore + +#endif // ENABLE(NOTIFICATIONS) diff --git a/Source/WebCore/bindings/v8/custom/V8PerformanceCustom.cpp b/Source/WebCore/bindings/v8/custom/V8PerformanceCustom.cpp index cc625ceea..61fa6d37f 100644 --- a/Source/WebCore/bindings/v8/custom/V8PerformanceCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8PerformanceCustom.cpp @@ -45,7 +45,7 @@ v8::Handle<v8::Value> V8Performance::memoryAccessorGetter(v8::Local<v8::String> { INC_STATS("DOM.Performance.memoryAccessorGetter"); Performance* imp = V8Performance::toNative(info.Holder()); - return toV8(imp->memory()); + return toV8(imp->memory(), info.GetIsolate()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp b/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp index c0f3e3589..b3d90f4d2 100644 --- a/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp @@ -73,16 +73,16 @@ v8::Handle<v8::Value> V8PopStateEvent::stateAccessorGetter(v8::Local<v8::String> bool isSameState = history->isSameAsCurrentState(event->serializedState()); if (isSameState) { - v8::Handle<v8::Object> v8History = toV8(history).As<v8::Object>(); + v8::Handle<v8::Object> v8History = toV8(history, info.GetIsolate()).As<v8::Object>(); if (!history->stateChanged()) { result = v8History->GetHiddenValue(V8HiddenPropertyName::state()); if (!result.IsEmpty()) return cacheState(info.Holder(), result); } - result = event->serializedState()->deserialize(); + result = event->serializedState()->deserialize(0, info.GetIsolate()); v8History->SetHiddenValue(V8HiddenPropertyName::state(), result); } else - result = event->serializedState()->deserialize(); + result = event->serializedState()->deserialize(0, info.GetIsolate()); return cacheState(info.Holder(), result); } diff --git a/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp b/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp index b07c68f44..f8520f01e 100644 --- a/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp @@ -110,7 +110,7 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments& ExceptionCode ec = 0; transaction->executeSQL(statement, sqlValues, callback, errorCallback, ec); - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } diff --git a/Source/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp b/Source/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp index bcec942a5..59e4c0de0 100644 --- a/Source/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp @@ -91,8 +91,8 @@ v8::Handle<v8::Value> V8SQLTransactionSync::executeSqlCallback(const v8::Argumen SQLTransactionSync* transaction = V8SQLTransactionSync::toNative(args.Holder()); ExceptionCode ec = 0; - v8::Handle<v8::Value> result = toV8(transaction->executeSQL(statement, sqlValues, ec)); - V8Proxy::setDOMException(ec); + v8::Handle<v8::Value> result = toV8(transaction->executeSQL(statement, sqlValues, ec), args.GetIsolate()); + V8Proxy::setDOMException(ec, args.GetIsolate()); return result; } diff --git a/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp b/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp index 8dce61b32..f54b8b7de 100644 --- a/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp @@ -38,11 +38,11 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(SVGDocument* impl, bool forceNewObject) +v8::Handle<v8::Value> toV8(SVGDocument* impl, v8::Isolate* isolate, bool forceNewObject) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8SVGDocument::wrap(impl, forceNewObject); + v8::Handle<v8::Object> wrapper = V8SVGDocument::wrap(impl, isolate, forceNewObject); if (wrapper.IsEmpty()) return wrapper; if (!V8IsolatedContext::getEntered()) { diff --git a/Source/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp b/Source/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp index 7ad5f4157..fcce45a87 100644 --- a/Source/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp @@ -37,7 +37,7 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(SVGElement* impl, bool forceNewObject) +v8::Handle<v8::Value> toV8(SVGElement* impl, v8::Isolate* isolate, bool forceNewObject) { if (!impl) return v8::Null(); diff --git a/Source/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp b/Source/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp index a26305a53..87e311421 100644 --- a/Source/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp @@ -50,7 +50,7 @@ v8::Handle<v8::Value> V8SVGLength::valueAccessorGetter(v8::Local<v8::String> nam SVGLengthContext lengthContext(wrapper->contextElement()); float value = imp.value(lengthContext, ec); if (UNLIKELY(ec)) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Handle<v8::Value>(); } return v8::Number::New(value); @@ -61,7 +61,7 @@ void V8SVGLength::valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8:: INC_STATS("DOM.SVGLength.value._set"); SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(info.Holder()); if (wrapper->role() == AnimValRole) { - V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR); + V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, info.GetIsolate()); return; } @@ -75,7 +75,7 @@ void V8SVGLength::valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8:: SVGLengthContext lengthContext(wrapper->contextElement()); imp.setValue(static_cast<float>(value->NumberValue()), lengthContext, ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); else wrapper->commitChange(); } @@ -85,12 +85,12 @@ v8::Handle<v8::Value> V8SVGLength::convertToSpecifiedUnitsCallback(const v8::Arg INC_STATS("DOM.SVGLength.convertToSpecifiedUnits"); SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(args.Holder()); if (wrapper->role() == AnimValRole) { - V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR); + V8Proxy::setDOMException(NO_MODIFICATION_ALLOWED_ERR, args.GetIsolate()); return v8::Handle<v8::Value>(); } if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SyntaxError); + return V8Proxy::throwNotEnoughArgumentsError(); SVGLength& imp = wrapper->propertyReference(); ExceptionCode ec = 0; @@ -98,7 +98,7 @@ v8::Handle<v8::Value> V8SVGLength::convertToSpecifiedUnitsCallback(const v8::Arg SVGLengthContext lengthContext(wrapper->contextElement()); imp.convertToSpecifiedUnits(unitType, lengthContext, ec); if (UNLIKELY(ec)) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); else wrapper->commitChange(); return v8::Handle<v8::Value>(); diff --git a/Source/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp b/Source/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp index 5544f839e..5527d1246 100644 --- a/Source/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp @@ -57,52 +57,52 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(SVGPathSeg* impl) +v8::Handle<v8::Value> toV8(SVGPathSeg* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); switch (impl->pathSegType()) { case SVGPathSeg::PATHSEG_CLOSEPATH: - return toV8(static_cast<SVGPathSegClosePath*>(impl)); + return toV8(static_cast<SVGPathSegClosePath*>(impl), isolate); case SVGPathSeg::PATHSEG_MOVETO_ABS: - return toV8(static_cast<SVGPathSegMovetoAbs*>(impl)); + return toV8(static_cast<SVGPathSegMovetoAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_MOVETO_REL: - return toV8(static_cast<SVGPathSegMovetoRel*>(impl)); + return toV8(static_cast<SVGPathSegMovetoRel*>(impl), isolate); case SVGPathSeg::PATHSEG_LINETO_ABS: - return toV8(static_cast<SVGPathSegLinetoAbs*>(impl)); + return toV8(static_cast<SVGPathSegLinetoAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_LINETO_REL: - return toV8(static_cast<SVGPathSegLinetoRel*>(impl)); + return toV8(static_cast<SVGPathSegLinetoRel*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: - return toV8(static_cast<SVGPathSegCurvetoCubicAbs*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoCubicAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: - return toV8(static_cast<SVGPathSegCurvetoCubicRel*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoCubicRel*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: - return toV8(static_cast<SVGPathSegCurvetoQuadraticAbs*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoQuadraticAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: - return toV8(static_cast<SVGPathSegCurvetoQuadraticRel*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoQuadraticRel*>(impl), isolate); case SVGPathSeg::PATHSEG_ARC_ABS: - return toV8(static_cast<SVGPathSegArcAbs*>(impl)); + return toV8(static_cast<SVGPathSegArcAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_ARC_REL: - return toV8(static_cast<SVGPathSegArcRel*>(impl)); + return toV8(static_cast<SVGPathSegArcRel*>(impl), isolate); case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: - return toV8(static_cast<SVGPathSegLinetoHorizontalAbs*>(impl)); + return toV8(static_cast<SVGPathSegLinetoHorizontalAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: - return toV8(static_cast<SVGPathSegLinetoHorizontalRel*>(impl)); + return toV8(static_cast<SVGPathSegLinetoHorizontalRel*>(impl), isolate); case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: - return toV8(static_cast<SVGPathSegLinetoVerticalAbs*>(impl)); + return toV8(static_cast<SVGPathSegLinetoVerticalAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: - return toV8(static_cast<SVGPathSegLinetoVerticalRel*>(impl)); + return toV8(static_cast<SVGPathSegLinetoVerticalRel*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: - return toV8(static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: - return toV8(static_cast<SVGPathSegCurvetoCubicSmoothRel*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoCubicSmoothRel*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: - return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(impl), isolate); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: - return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(impl)); + return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(impl), isolate); } ASSERT_NOT_REACHED(); - return V8SVGPathSeg::wrap(impl); + return V8SVGPathSeg::wrap(impl, isolate); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8ScriptProfileCustom.cpp b/Source/WebCore/bindings/v8/custom/V8ScriptProfileCustom.cpp index 32d87268c..7bab46bb8 100644 --- a/Source/WebCore/bindings/v8/custom/V8ScriptProfileCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8ScriptProfileCustom.cpp @@ -32,6 +32,7 @@ #if ENABLE(JAVASCRIPT_DEBUGGER) #include "V8ScriptProfile.h" +#include "SafeAllocation.h" #include "ScriptProfile.h" #include "V8Binding.h" #include "V8Proxy.h" @@ -40,7 +41,7 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(ScriptProfile* impl) +v8::Handle<v8::Value> toV8(ScriptProfile* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); diff --git a/Source/WebCore/bindings/v8/custom/V8ScriptProfileNodeCustom.cpp b/Source/WebCore/bindings/v8/custom/V8ScriptProfileNodeCustom.cpp index fedfffe86..3ee8f8fe2 100644 --- a/Source/WebCore/bindings/v8/custom/V8ScriptProfileNodeCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8ScriptProfileNodeCustom.cpp @@ -32,6 +32,7 @@ #if ENABLE(JAVASCRIPT_DEBUGGER) #include "V8ScriptProfileNode.h" +#include "SafeAllocation.h" #include "ScriptProfileNode.h" #include "V8Binding.h" #include "V8Proxy.h" @@ -40,19 +41,6 @@ namespace WebCore { -v8::Handle<v8::Value> V8ScriptProfileNode::childrenAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) -{ - INC_STATS("DOM.ScriptProfileNode.childrenAccessorGetter"); - ScriptProfileNode* imp = V8ScriptProfileNode::toNative(info.Holder()); - const ProfileNodesList& children = imp->children(); - v8::Handle<v8::Array> result = v8::Array::New(children.size()); - int index = 0; - ProfileNodesList::const_iterator end = children.end(); - for (ProfileNodesList::const_iterator iter = children.begin(); iter != end; ++iter) - result->Set(v8::Integer::New(index++), toV8(iter->get())); - return result; -} - v8::Handle<v8::Value> V8ScriptProfileNode::callUIDAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.ScriptProfileNode.callUIDAccessorGetter"); @@ -60,7 +48,7 @@ v8::Handle<v8::Value> V8ScriptProfileNode::callUIDAccessorGetter(v8::Local<v8::S return v8::Number::New(imp->callUID()); } -v8::Handle<v8::Value> toV8(ScriptProfileNode* impl) +v8::Handle<v8::Value> toV8(ScriptProfileNode* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); diff --git a/Source/WebCore/bindings/v8/custom/V8StorageCustom.cpp b/Source/WebCore/bindings/v8/custom/V8StorageCustom.cpp index cd664760b..896330439 100644 --- a/Source/WebCore/bindings/v8/custom/V8StorageCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8StorageCustom.cpp @@ -58,7 +58,7 @@ static v8::Handle<v8::Value> storageGetter(v8::Local<v8::String> v8Name, const v Storage* storage = V8Storage::toNative(info.Holder()); String name = toWebCoreString(v8Name); - if (storage->contains(name) && name != "length") + if (name != "length" && storage->contains(name)) return v8String(storage->getItem(name)); return notHandledByInterceptor(); @@ -74,6 +74,8 @@ v8::Handle<v8::Value> V8Storage::indexedPropertyGetter(uint32_t index, const v8: v8::Handle<v8::Value> V8Storage::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.Storage.NamedPropertyGetter"); + if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) + return notHandledByInterceptor(); return storageGetter(name, info); } @@ -84,7 +86,7 @@ v8::Handle<v8::Integer> V8Storage::namedPropertyQuery(v8::Local<v8::String> v8Na Storage* storage = V8Storage::toNative(info.Holder()); String name = toWebCoreString(v8Name); - if (storage->contains(name) && name != "length") + if (name != "length" && storage->contains(name)) return v8::Integer::New(v8::None); return v8::Handle<v8::Integer>(); diff --git a/Source/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp b/Source/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp index 0fe6af850..6a03cefbe 100644 --- a/Source/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp @@ -37,17 +37,17 @@ namespace WebCore { -v8::Handle<v8::Value> toV8(StyleSheet* impl) +v8::Handle<v8::Value> toV8(StyleSheet* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); if (impl->isCSSStyleSheet()) - return toV8(static_cast<CSSStyleSheet*>(impl)); - v8::Handle<v8::Object> wrapper = V8StyleSheet::wrap(impl); + return toV8(static_cast<CSSStyleSheet*>(impl), isolate); + v8::Handle<v8::Object> wrapper = V8StyleSheet::wrap(impl, isolate); // Add a hidden reference from stylesheet object to its owner node. Node* ownerNode = impl->ownerNode(); if (ownerNode && !wrapper.IsEmpty()) - V8DOMWrapper::setNamedHiddenReference(wrapper, "ownerNode", toV8(ownerNode)); + V8DOMWrapper::setNamedHiddenReference(wrapper, "ownerNode", toV8(ownerNode, isolate)); return wrapper; } diff --git a/Source/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp b/Source/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp index cee18383a..e28665490 100644 --- a/Source/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp @@ -52,7 +52,7 @@ v8::Handle<v8::Value> V8StyleSheetList::namedPropertyGetter(v8::Local<v8::String if (!item) return notHandledByInterceptor(); - return toV8(item->sheet()); + return toV8(item->sheet(), info.GetIsolate()); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8TrackEventCustom.cpp b/Source/WebCore/bindings/v8/custom/V8TrackEventCustom.cpp index 37fd3db8b..5942f5c4d 100644 --- a/Source/WebCore/bindings/v8/custom/V8TrackEventCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8TrackEventCustom.cpp @@ -57,7 +57,7 @@ v8::Handle<v8::Value> V8TrackEvent::trackAccessorGetter(v8::Local<v8::String> na break; case TrackBase::TextTrack: - return toV8(static_cast<TextTrack*>(track)); + return toV8(static_cast<TextTrack*>(track), info.GetIsolate()); break; case TrackBase::AudioTrack: diff --git a/Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp index aebe3108a..d0fc02060 100644 --- a/Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp @@ -29,8 +29,8 @@ */ #include "config.h" -#include "ArrayBuffer.h" -#include "Uint16Array.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Uint16Array.h> #include "V8Binding.h" #include "V8ArrayBuffer.h" @@ -53,11 +53,11 @@ v8::Handle<v8::Value> V8Uint16Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Uint16Array, V8Uint16Array>(args); } -v8::Handle<v8::Value> toV8(Uint16Array* impl) +v8::Handle<v8::Value> toV8(Uint16Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Uint16Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Uint16Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp index 563df8ea3..6c9073a25 100644 --- a/Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp @@ -29,8 +29,8 @@ */ #include "config.h" -#include "ArrayBuffer.h" -#include "Uint32Array.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Uint32Array.h> #include "V8Binding.h" #include "V8ArrayBuffer.h" @@ -53,11 +53,11 @@ v8::Handle<v8::Value> V8Uint32Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Uint32Array, V8Uint32Array>(args); } -v8::Handle<v8::Value> toV8(Uint32Array* impl) +v8::Handle<v8::Value> toV8(Uint32Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Uint32Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Uint32Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedIntArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp index aa46863ab..f7c70d484 100644 --- a/Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp @@ -29,8 +29,8 @@ */ #include "config.h" -#include "ArrayBuffer.h" -#include "Uint8Array.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Uint8Array.h> #include "V8Binding.h" #include "V8ArrayBuffer.h" @@ -53,11 +53,11 @@ v8::Handle<v8::Value> V8Uint8Array::setCallback(const v8::Arguments& args) return setWebGLArrayHelper<Uint8Array, V8Uint8Array>(args); } -v8::Handle<v8::Value> toV8(Uint8Array* impl) +v8::Handle<v8::Value> toV8(Uint8Array* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Uint8Array::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Uint8Array::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp b/Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp index 8812acf14..aecb493db 100644 --- a/Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp @@ -25,9 +25,9 @@ */ #include "config.h" -#include "Uint8ClampedArray.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/Uint8ClampedArray.h> #include "V8ArrayBuffer.h" #include "V8ArrayBufferViewCustom.h" @@ -50,11 +50,11 @@ v8::Handle<v8::Value> V8Uint8ClampedArray::setCallback(const v8::Arguments& args return setWebGLArrayHelper<Uint8ClampedArray, V8Uint8ClampedArray>(args); } -v8::Handle<v8::Value> toV8(Uint8ClampedArray* impl) +v8::Handle<v8::Value> toV8(Uint8ClampedArray* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8Uint8ClampedArray::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Uint8ClampedArray::wrap(impl, isolate); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalPixelArray, impl->length()); return wrapper; diff --git a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 7dcedbe25..47a32e593 100644 --- a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -115,7 +115,7 @@ static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len) return data; } -static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info) +static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info, v8::Isolate* isolate) { switch (info.getType()) { case WebGLGetInfo::kTypeBool: @@ -138,34 +138,34 @@ static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info) case WebGLGetInfo::kTypeUnsignedInt: return v8::Integer::NewFromUnsigned(info.getUnsignedInt()); case WebGLGetInfo::kTypeWebGLBuffer: - return toV8(info.getWebGLBuffer()); + return toV8(info.getWebGLBuffer(), isolate); case WebGLGetInfo::kTypeWebGLFloatArray: - return toV8(info.getWebGLFloatArray()); + return toV8(info.getWebGLFloatArray(), isolate); case WebGLGetInfo::kTypeWebGLFramebuffer: - return toV8(info.getWebGLFramebuffer()); + return toV8(info.getWebGLFramebuffer(), isolate); case WebGLGetInfo::kTypeWebGLIntArray: - return toV8(info.getWebGLIntArray()); + return toV8(info.getWebGLIntArray(), isolate); // FIXME: implement WebGLObjectArray // case WebGLGetInfo::kTypeWebGLObjectArray: case WebGLGetInfo::kTypeWebGLProgram: - return toV8(info.getWebGLProgram()); + return toV8(info.getWebGLProgram(), isolate); case WebGLGetInfo::kTypeWebGLRenderbuffer: - return toV8(info.getWebGLRenderbuffer()); + return toV8(info.getWebGLRenderbuffer(), isolate); case WebGLGetInfo::kTypeWebGLTexture: - return toV8(info.getWebGLTexture()); + return toV8(info.getWebGLTexture(), isolate); case WebGLGetInfo::kTypeWebGLUnsignedByteArray: - return toV8(info.getWebGLUnsignedByteArray()); + return toV8(info.getWebGLUnsignedByteArray(), isolate); case WebGLGetInfo::kTypeWebGLUnsignedIntArray: - return toV8(info.getWebGLUnsignedIntArray()); + return toV8(info.getWebGLUnsignedIntArray(), isolate); case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES: - return toV8(info.getWebGLVertexArrayObjectOES()); + return toV8(info.getWebGLVertexArrayObjectOES(), isolate); default: notImplemented(); return v8::Undefined(); } } -static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8::Object> contextObject) +static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8::Object> contextObject, v8::Isolate* isolate) { if (!extension) return v8::Null(); @@ -173,35 +173,35 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 const char* referenceName = 0; switch (extension->getName()) { case WebGLExtension::WebKitWebGLLoseContextName: - extensionObject = toV8(static_cast<WebGLLoseContext*>(extension)); + extensionObject = toV8(static_cast<WebGLLoseContext*>(extension), isolate); referenceName = "webKitWebGLLoseContextName"; break; case WebGLExtension::EXTTextureFilterAnisotropicName: - extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extension)); + extensionObject = toV8(static_cast<EXTTextureFilterAnisotropic*>(extension), isolate); referenceName = "extTextureFilterAnisotropicName"; break; case WebGLExtension::OESStandardDerivativesName: - extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension)); + extensionObject = toV8(static_cast<OESStandardDerivatives*>(extension), isolate); referenceName = "oesStandardDerivativesName"; break; case WebGLExtension::OESTextureFloatName: - extensionObject = toV8(static_cast<OESTextureFloat*>(extension)); + extensionObject = toV8(static_cast<OESTextureFloat*>(extension), isolate); referenceName = "oesTextureFloatName"; break; case WebGLExtension::OESVertexArrayObjectName: - extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension)); + extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), isolate); referenceName = "oesVertexArrayObjectName"; break; case WebGLExtension::WebGLDebugRendererInfoName: - extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension)); + extensionObject = toV8(static_cast<WebGLDebugRendererInfo*>(extension), isolate); referenceName = "webGLDebugRendererInfoName"; break; case WebGLExtension::WebGLDebugShadersName: - extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension)); + extensionObject = toV8(static_cast<WebGLDebugShaders*>(extension), isolate); referenceName = "webGLDebugShadersName"; break; case WebGLExtension::WebKitWebGLCompressedTextureS3TCName: - extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extension)); + extensionObject = toV8(static_cast<WebGLCompressedTextureS3TC*>(extension), isolate); referenceName = "webKitWebGLCompressedTextureS3TCName"; break; } @@ -216,10 +216,8 @@ enum ObjectType { static v8::Handle<v8::Value> getObjectParameter(const v8::Arguments& args, ObjectType objectType) { - if (args.Length() != 2) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 2) + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); @@ -245,10 +243,10 @@ static v8::Handle<v8::Value> getObjectParameter(const v8::Arguments& args, Objec break; } if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } - return toV8Object(info); + return toV8Object(info, args.GetIsolate()); } static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value, bool& ok) @@ -270,10 +268,8 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getAttachedShadersCallback(const { INC_STATS("DOM.WebGLRenderingContext.getAttachedShaders()"); - if (args.Length() < 1) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() < 1) + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); @@ -285,14 +281,14 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getAttachedShadersCallback(const Vector<RefPtr<WebGLShader> > shaders; bool succeed = context->getAttachedShaders(program, shaders, ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Null(); } if (!succeed) return v8::Null(); v8::Local<v8::Array> array = v8::Array::New(shaders.size()); for (size_t ii = 0; ii < shaders.size(); ++ii) - array->Set(v8::Integer::New(ii), toV8(shaders[ii].get())); + array->Set(v8::Integer::New(ii), toV8(shaders[ii].get(), args.GetIsolate())); return array; } @@ -306,23 +302,19 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getExtensionCallback(const v8::Ar { INC_STATS("DOM.WebGLRenderingContext.getExtensionCallback()"); WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder()); - if (args.Length() < 1) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() < 1) + return V8Proxy::throwNotEnoughArgumentsError(); STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, name, args[0]); WebGLExtension* extension = imp->getExtension(name); - return toV8Object(extension, args.Holder()); + return toV8Object(extension, args.Holder(), args.GetIsolate()); } v8::Handle<v8::Value> V8WebGLRenderingContext::getFramebufferAttachmentParameterCallback(const v8::Arguments& args) { INC_STATS("DOM.WebGLRenderingContext.getFramebufferAttachmentParameter()"); - if (args.Length() != 3) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 3) + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); @@ -331,40 +323,36 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getFramebufferAttachmentParameter unsigned pname = toInt32(args[2]); WebGLGetInfo info = context->getFramebufferAttachmentParameter(target, attachment, pname, ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } - return toV8Object(info); + return toV8Object(info, args.GetIsolate()); } v8::Handle<v8::Value> V8WebGLRenderingContext::getParameterCallback(const v8::Arguments& args) { INC_STATS("DOM.WebGLRenderingContext.getParameter()"); - if (args.Length() != 1) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 1) + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); unsigned pname = toInt32(args[0]); WebGLGetInfo info = context->getParameter(pname, ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } - return toV8Object(info); + return toV8Object(info, args.GetIsolate()); } v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const v8::Arguments& args) { INC_STATS("DOM.WebGLRenderingContext.getProgramParameter()"); - if (args.Length() != 2) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 2) + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); @@ -376,10 +364,10 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const unsigned pname = toInt32(args[1]); WebGLGetInfo info = context->getProgramParameter(program, pname, ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } - return toV8Object(info); + return toV8Object(info, args.GetIsolate()); } v8::Handle<v8::Value> V8WebGLRenderingContext::getRenderbufferParameterCallback(const v8::Arguments& args) @@ -392,10 +380,8 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const { INC_STATS("DOM.WebGLRenderingContext.getShaderParameter()"); - if (args.Length() != 2) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 2) + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); @@ -407,10 +393,10 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const unsigned pname = toInt32(args[1]); WebGLGetInfo info = context->getShaderParameter(shader, pname, ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } - return toV8Object(info); + return toV8Object(info, args.GetIsolate()); } v8::Handle<v8::Value> V8WebGLRenderingContext::getSupportedExtensionsCallback(const v8::Arguments& args) @@ -437,10 +423,8 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu { INC_STATS("DOM.WebGLRenderingContext.getUniform()"); - if (args.Length() != 2) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 2) + return V8Proxy::throwNotEnoughArgumentsError(); ExceptionCode ec = 0; WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); @@ -459,10 +443,10 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu WebGLGetInfo info = context->getUniform(program, location, ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } - return toV8Object(info); + return toV8Object(info, args.GetIsolate()); } v8::Handle<v8::Value> V8WebGLRenderingContext::getVertexAttribCallback(const v8::Arguments& args) @@ -510,10 +494,8 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& // * glVertexAttrib4fv(GLint index, Array data); // * glVertexAttrib4fv(GLint index, Float32Array data); - if (args.Length() != 2) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 2) + return V8Proxy::throwNotEnoughArgumentsError(); bool ok = false; int index = -1; @@ -547,7 +529,7 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& default: ASSERT_NOT_REACHED(); break; } if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } @@ -561,7 +543,7 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& float* data = jsArrayToFloatArray(array, len); if (!data) { // FIXME: consider different / better exception type. - V8Proxy::setDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR, args.GetIsolate()); return notHandledByInterceptor(); } ExceptionCode ec = 0; @@ -578,7 +560,7 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& } fastFree(data); if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } @@ -594,10 +576,8 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args, // * glUniform4iv(GLUniformLocation location, Array data); // * glUniform4iv(GLUniformLocation location, Int32Array data); - if (args.Length() != 2) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 2) + return V8Proxy::throwNotEnoughArgumentsError(); WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) { @@ -619,7 +599,7 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args, default: ASSERT_NOT_REACHED(); break; } if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } @@ -633,7 +613,7 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args, int* data = jsArrayToIntArray(array, len); if (!data) { // FIXME: consider different / better exception type. - V8Proxy::setDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR, args.GetIsolate()); return notHandledByInterceptor(); } ExceptionCode ec = 0; @@ -646,7 +626,7 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args, } fastFree(data); if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } @@ -710,10 +690,8 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array data); // // FIXME: need to change to accept Float32Array as well. - if (args.Length() != 3) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } + if (args.Length() != 3) + return V8Proxy::throwNotEnoughArgumentsError(); WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); @@ -736,7 +714,7 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, default: ASSERT_NOT_REACHED(); break; } if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } @@ -750,7 +728,7 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, float* data = jsArrayToFloatArray(array, len); if (!data) { // FIXME: consider different / better exception type. - V8Proxy::setDOMException(SYNTAX_ERR); + V8Proxy::setDOMException(SYNTAX_ERR, args.GetIsolate()); return notHandledByInterceptor(); } ExceptionCode ec = 0; @@ -762,7 +740,7 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, } fastFree(data); if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Undefined(); } diff --git a/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp index d32b44ffc..e75b94476 100644 --- a/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp @@ -34,8 +34,8 @@ #include "V8WebKitMutationObserver.h" +#include "Dictionary.h" #include "ExceptionCode.h" -#include "OptionsObject.h" #include "V8Binding.h" #include "V8BindingMacros.h" #include "V8DOMWrapper.h" @@ -61,7 +61,7 @@ v8::Handle<v8::Value> V8WebKitMutationObserver::constructorCallback(const v8::Ar return args.Holder(); if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); v8::Local<v8::Value> arg = args[0]; if (!arg->IsObject()) @@ -75,8 +75,7 @@ v8::Handle<v8::Value> V8WebKitMutationObserver::constructorCallback(const v8::Ar RefPtr<WebKitMutationObserver> observer = WebKitMutationObserver::create(callback.release()); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, observer.get()); - observer->ref(); - V8DOMWrapper::setJSWrapperForDOMObject(observer.get(), v8::Persistent<v8::Object>::New(args.Holder())); + V8DOMWrapper::setJSWrapperForDOMObject(observer.release(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } @@ -84,14 +83,14 @@ v8::Handle<v8::Value> V8WebKitMutationObserver::observeCallback(const v8::Argume { INC_STATS("DOM.WebKitMutationObserver.observe"); if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::TypeError); + return V8Proxy::throwNotEnoughArgumentsError(); WebKitMutationObserver* imp = V8WebKitMutationObserver::toNative(args.Holder()); EXCEPTION_BLOCK(Node*, target, V8Node::HasInstance(args[0]) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0); if (!args[1]->IsObject()) return throwError(TYPE_MISMATCH_ERR); - OptionsObject optionsObject(args[1]); + Dictionary optionsObject(args[1]); unsigned options = 0; HashSet<AtomicString> attributeFilter; bool option; @@ -113,7 +112,7 @@ v8::Handle<v8::Value> V8WebKitMutationObserver::observeCallback(const v8::Argume ExceptionCode ec = 0; imp->observe(target, options, attributeFilter, ec); if (ec) - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, args.GetIsolate()); return v8::Handle<v8::Value>(); } diff --git a/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp b/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp index 69d8b2a57..9a83bb8d5 100644 --- a/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WebKitPointConstructor.cpp @@ -66,7 +66,8 @@ v8::Handle<v8::Value> V8WebKitPoint::constructorCallback(const v8::Arguments& ar } RefPtr<WebKitPoint> point = WebKitPoint::create(x, y); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, point.get()); - return toV8(point.release(), args.Holder()); + V8DOMWrapper::setJSWrapperForDOMObject(point.release(), v8::Persistent<v8::Object>::New(args.Holder())); + return args.Holder(); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp index 9b5e10b66..ae12b6fee 100644 --- a/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WebSocketCustom.cpp @@ -62,7 +62,7 @@ v8::Handle<v8::Value> V8WebSocket::constructorCallback(const v8::Arguments& args return args.Holder(); if (args.Length() == 0) - return throwError("Not enough arguments", V8Proxy::SyntaxError); + return V8Proxy::throwNotEnoughArgumentsError(); v8::TryCatch tryCatch; v8::Handle<v8::String> urlstring = args[0]->ToString(); @@ -107,13 +107,8 @@ v8::Handle<v8::Value> V8WebSocket::constructorCallback(const v8::Arguments& args if (ec) return throwError(ec); - // Setup the standard wrapper object internal fields. V8DOMWrapper::setDOMWrapper(args.Holder(), &info, webSocket.get()); - - // Add object to the wrapper map. - webSocket->ref(); - V8DOMWrapper::setJSWrapperForActiveDOMObject(webSocket.get(), v8::Persistent<v8::Object>::New(args.Holder())); - + V8DOMWrapper::setJSWrapperForActiveDOMObject(webSocket.release(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } @@ -122,7 +117,7 @@ v8::Handle<v8::Value> V8WebSocket::sendCallback(const v8::Arguments& args) INC_STATS("DOM.WebSocket.send()"); if (!args.Length()) - return throwError("Not enough arguments", V8Proxy::SyntaxError); + return V8Proxy::throwNotEnoughArgumentsError(); WebSocket* webSocket = V8WebSocket::toNative(args.Holder()); v8::Handle<v8::Value> message = args[0]; diff --git a/Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp index 1d8f335f7..91ba0077c 100644 --- a/Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp @@ -88,7 +88,7 @@ v8::Handle<v8::Value> SetTimeoutOrInterval(const v8::Arguments& args, bool singl v8::Handle<v8::Value> V8WorkerContext::importScriptsCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.WorkerContext.importScripts()"); + INC_STATS("DOM.WorkerContext.importScripts()"); if (!args.Length()) return v8::Undefined(); @@ -114,17 +114,17 @@ v8::Handle<v8::Value> V8WorkerContext::importScriptsCallback(const v8::Arguments v8::Handle<v8::Value> V8WorkerContext::setTimeoutCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.WorkerContext.setTimeout()"); + INC_STATS("DOM.WorkerContext.setTimeout()"); return SetTimeoutOrInterval(args, true); } v8::Handle<v8::Value> V8WorkerContext::setIntervalCallback(const v8::Arguments& args) { - INC_STATS(L"DOM.WorkerContext.setInterval()"); + INC_STATS("DOM.WorkerContext.setInterval()"); return SetTimeoutOrInterval(args, false); } -v8::Handle<v8::Value> toV8(WorkerContext* impl) +v8::Handle<v8::Value> toV8(WorkerContext* impl, v8::Isolate* isolate) { if (!impl) return v8::Null(); diff --git a/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp index abb3e4f0b..60e5bbe47 100644 --- a/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp @@ -35,7 +35,7 @@ #include "Worker.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "ExceptionCode.h" #include "Frame.h" #include "SerializedScriptValue.h" @@ -62,7 +62,8 @@ static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args SerializedScriptValue::create(args[0], &ports, extendedTransfer ? &arrayBuffers : 0, - didThrow); + didThrow, + args.GetIsolate()); if (didThrow) return v8::Undefined(); ExceptionCode ec = 0; diff --git a/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp b/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp index 5a5b0c65c..71d7dd286 100644 --- a/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp +++ b/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestConstructor.cpp @@ -64,10 +64,7 @@ v8::Handle<v8::Value> V8XMLHttpRequest::constructorCallback(const v8::Arguments& securityOrigin = isolatedContext->securityOrigin(); RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, securityOrigin); V8DOMWrapper::setDOMWrapper(args.Holder(), &info, xmlHttpRequest.get()); - - // Add object to the wrapper map. - xmlHttpRequest->ref(); - V8DOMWrapper::setJSWrapperForActiveDOMObject(xmlHttpRequest.get(), v8::Persistent<v8::Object>::New(args.Holder())); + V8DOMWrapper::setJSWrapperForActiveDOMObject(xmlHttpRequest.release(), v8::Persistent<v8::Object>::New(args.Holder())); return args.Holder(); } diff --git a/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp index 087289f4f..199a5944a 100644 --- a/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "V8XMLHttpRequest.h" -#include "ArrayBuffer.h" +#include <wtf/ArrayBuffer.h> #include "Document.h" #include "Frame.h" #include "InspectorInstrumentation.h" @@ -75,10 +75,10 @@ v8::Handle<v8::Value> V8XMLHttpRequest::responseAccessorGetter(v8::Local<v8::Str ExceptionCode ec = 0; Document* document = xmlHttpRequest->responseXML(ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Undefined(); } - return toV8(document); + return toV8(document, info.GetIsolate()); } case XMLHttpRequest::ResponseTypeBlob: @@ -87,10 +87,10 @@ v8::Handle<v8::Value> V8XMLHttpRequest::responseAccessorGetter(v8::Local<v8::Str ExceptionCode ec = 0; Blob* blob = xmlHttpRequest->responseBlob(ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Undefined(); } - return toV8(blob); + return toV8(blob, info.GetIsolate()); } #else return v8::Undefined(); @@ -101,10 +101,10 @@ v8::Handle<v8::Value> V8XMLHttpRequest::responseAccessorGetter(v8::Local<v8::Str ExceptionCode ec = 0; ArrayBuffer* arrayBuffer = xmlHttpRequest->responseArrayBuffer(ec); if (ec) { - V8Proxy::setDOMException(ec); + V8Proxy::setDOMException(ec, info.GetIsolate()); return v8::Undefined(); } - return toV8(arrayBuffer); + return toV8(arrayBuffer, info.GetIsolate()); } } @@ -121,7 +121,7 @@ v8::Handle<v8::Value> V8XMLHttpRequest::openCallback(const v8::Arguments& args) // open(method, url, async, user, passwd) if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::SyntaxError); + return V8Proxy::throwNotEnoughArgumentsError(); XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); diff --git a/Source/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp b/Source/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp index 680c7a151..e9f951754 100644 --- a/Source/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp @@ -74,7 +74,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToFragmentCallback(const v8::Arg Node* source = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0])); Document* owner = V8Document::toNative(v8::Handle<v8::Object>::Cast(args[1])); RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner); - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } @@ -95,7 +95,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToDocumentCallback(const v8::Arg if (!result) return v8::Undefined(); - return toV8(result.release()); + return toV8(result.release(), args.GetIsolate()); } |