diff options
Diffstat (limited to 'Source/WebCore/bindings')
110 files changed, 1765 insertions, 749 deletions
diff --git a/Source/WebCore/bindings/ScriptControllerBase.cpp b/Source/WebCore/bindings/ScriptControllerBase.cpp index e128d11..fbf6d3e 100644 --- a/Source/WebCore/bindings/ScriptControllerBase.cpp +++ b/Source/WebCore/bindings/ScriptControllerBase.cpp @@ -21,6 +21,7 @@ #include "config.h" #include "ScriptController.h" +#include "DocumentLoader.h" #include "Frame.h" #include "FrameLoaderClient.h" #include "Page.h" @@ -71,13 +72,10 @@ bool ScriptController::executeIfJavaScriptURL(const KURL& url, ShouldReplaceDocu if (!protocolIsJavaScript(url)) return false; - if (!m_frame->page()) - return true; - - if (!m_frame->page()->javaScriptURLsAreAllowed()) - return true; - - if (m_frame->inViewSourceMode()) + if (!m_frame->page() + || !m_frame->page()->javaScriptURLsAreAllowed() + || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs() + || m_frame->inViewSourceMode()) return true; // We need to hold onto the Frame here because executing script can diff --git a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h index 4f9a21e..7e21214 100644 --- a/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h +++ b/Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h @@ -60,14 +60,11 @@ public: static bool webkitIDBDatabaseEnabled() { return isIndexedDBEnabled; } static bool webkitIDBDatabaseErrorEnabled() { return isIndexedDBEnabled; } static bool webkitIDBDatabaseExceptionEnabled() { return isIndexedDBEnabled; } - static bool webkitIDBErrorEventEnabled() { return isIndexedDBEnabled; } - static bool webkitIDBEventEnabled() { return isIndexedDBEnabled; } static bool webkitIDBFactoryEnabled() { return isIndexedDBEnabled; } static bool webkitIDBIndexEnabled() { return isIndexedDBEnabled; } static bool webkitIDBKeyRangeEnabled() { return isIndexedDBEnabled; } static bool webkitIDBObjectStoreEnabled() { return isIndexedDBEnabled; } static bool webkitIDBRequestEnabled() { return isIndexedDBEnabled; } - static bool webkitIDBSuccessEventEnabled() { return isIndexedDBEnabled; } static bool webkitIDBTransactionEnabled() { return isIndexedDBEnabled; } #if ENABLE(VIDEO) diff --git a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h index a7ef436..cb9981d 100644 --- a/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h +++ b/Source/WebCore/bindings/js/JSArrayBufferViewHelper.h @@ -104,25 +104,6 @@ PassRefPtr<C> constructArrayBufferViewWithArrayBufferArgument(JSC::ExecState* ex return array; } -template<typename T> -inline T convertArrayValue(JSC::ExecState* exec, JSC::JSValue v) -{ - // For integral types, NaN values must be converted to zero. - return static_cast<T>(v.toInteger(exec)); -} - -template<> -inline float convertArrayValue(JSC::ExecState* exec, JSC::JSValue v) -{ - return static_cast<float>(v.toNumber(exec)); -} - -template<> -inline double convertArrayValue(JSC::ExecState* exec, JSC::JSValue v) -{ - return static_cast<double>(v.toNumber(exec)); -} - template<class C, typename T> PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec) { @@ -152,24 +133,19 @@ PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec) if (view) return view; - JSC::JSObject* array = asObject(exec->argument(0)); - unsigned length = array->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); - void* tempValues; - if (!tryFastCalloc(length, sizeof(T)).getValue(tempValues)) { - JSC::throwError(exec, createError(exec, "Error")); - return 0; + JSC::JSObject* srcArray = asObject(exec->argument(0)); + uint32_t length = srcArray->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); + RefPtr<C> array = C::create(length); + if (!array) { + setDOMException(exec, INDEX_SIZE_ERR); + return array; } - - OwnFastMallocPtr<T> values(static_cast<T*>(tempValues)); + for (unsigned i = 0; i < length; ++i) { - JSC::JSValue v = array->get(exec, i); - values.get()[i] = convertArrayValue<T>(exec, v); + JSC::JSValue v = srcArray->get(exec, i); + array->set(i, v.toNumber(exec)); } - - RefPtr<C> result = C::create(values.get(), length); - if (!result) - setDOMException(exec, INDEX_SIZE_ERR); - return result; + return array; } int length = exec->argument(0).toInt32(exec); diff --git a/Source/WebCore/bindings/js/JSAudioConstructor.cpp b/Source/WebCore/bindings/js/JSAudioConstructor.cpp index c19d795..f0040fa 100644 --- a/Source/WebCore/bindings/js/JSAudioConstructor.cpp +++ b/Source/WebCore/bindings/js/JSAudioConstructor.cpp @@ -37,11 +37,12 @@ using namespace JSC; namespace WebCore { -const ClassInfo JSAudioConstructor::s_info = { "AudioConstructor", 0, 0, 0 }; +const ClassInfo JSAudioConstructor::s_info = { "AudioConstructor", &DOMConstructorWithDocument::s_info, 0, 0 }; JSAudioConstructor::JSAudioConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorWithDocument(JSAudioConstructor::createStructure(globalObject->objectPrototype()), globalObject) { + ASSERT(inherits(&s_info)); putDirect(exec->globalData(), exec->propertyNames().prototype, JSHTMLAudioElementPrototype::self(exec, globalObject), None); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum); } diff --git a/Source/WebCore/bindings/js/JSAudioConstructor.h b/Source/WebCore/bindings/js/JSAudioConstructor.h index 3496897..c90abbf 100644 --- a/Source/WebCore/bindings/js/JSAudioConstructor.h +++ b/Source/WebCore/bindings/js/JSAudioConstructor.h @@ -38,11 +38,15 @@ namespace WebCore { public: JSAudioConstructor(JSC::ExecState*, JSDOMGlobalObject*); + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + static const JSC::ClassInfo s_info; + private: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } }; } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp index 7c5edc6..b53d950 100644 --- a/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -56,6 +56,7 @@ #include "JSDOMBinding.cpp" #include "JSDOMFormDataCustom.cpp" #include "JSDOMGlobalObject.cpp" +#include "JSDOMImplementationCustom.cpp" #include "JSDOMMimeTypeArrayCustom.cpp" #include "JSDOMPluginArrayCustom.cpp" #include "JSDOMPluginCustom.cpp" @@ -67,7 +68,6 @@ #include "JSDataGridColumnListCustom.cpp" #include "JSDataGridDataSource.cpp" #include "JSDataViewCustom.cpp" -#include "JSDebugWrapperSet.cpp" #include "JSDedicatedWorkerContextCustom.cpp" #include "JSDesktopNotificationsCustom.cpp" #include "JSDeviceOrientationEventCustom.cpp" diff --git a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp index 1a448ee..1e750e5 100644 --- a/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp +++ b/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp @@ -135,6 +135,8 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo static bool isCSSPropertyName(const Identifier& propertyName) { + // FIXME: This mallocs a string for the property name and then throws it + // away. This shows up on peacekeeper's domDynamicCreationCreateElement. return CSSStyleDeclaration::isPropertyName(cssPropertyName(propertyName)); } diff --git a/Source/WebCore/bindings/js/JSCallbackData.h b/Source/WebCore/bindings/js/JSCallbackData.h index f7b8bfe..942cd9c 100644 --- a/Source/WebCore/bindings/js/JSCallbackData.h +++ b/Source/WebCore/bindings/js/JSCallbackData.h @@ -32,8 +32,8 @@ #include "JSDOMBinding.h" #include "JSDOMGlobalObject.h" #include "ScriptExecutionContext.h" +#include <collector/handles/Global.h> #include <runtime/JSObject.h> -#include <runtime/Protect.h> #include <wtf/Threading.h> namespace WebCore { @@ -47,8 +47,8 @@ public: static void deleteData(void*); JSCallbackData(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) - : m_callback(callback) - , m_globalObject(globalObject) + : m_callback(globalObject->globalData(), callback) + , m_globalObject(globalObject->globalData(), globalObject) #ifndef NDEBUG , m_thread(currentThread()) #endif @@ -66,8 +66,8 @@ public: JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer&, bool* raisedException = 0); private: - JSC::ProtectedPtr<JSC::JSObject> m_callback; - JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject; + JSC::Global<JSC::JSObject> m_callback; + JSC::Global<JSDOMGlobalObject> m_globalObject; #ifndef NDEBUG ThreadIdentifier m_thread; #endif diff --git a/Source/WebCore/bindings/js/JSCustomVoidCallback.h b/Source/WebCore/bindings/js/JSCustomVoidCallback.h index 8ffee48..922e380 100644 --- a/Source/WebCore/bindings/js/JSCustomVoidCallback.h +++ b/Source/WebCore/bindings/js/JSCustomVoidCallback.h @@ -31,7 +31,7 @@ #include "JSDOMGlobalObject.h" #include "VoidCallback.h" -#include <runtime/Protect.h> +#include <collector/handles/Global.h> #include <wtf/Forward.h> namespace WebCore { diff --git a/Source/WebCore/bindings/js/JSDOMBinding.cpp b/Source/WebCore/bindings/js/JSDOMBinding.cpp index 7de2719..4d18a4e 100644 --- a/Source/WebCore/bindings/js/JSDOMBinding.cpp +++ b/Source/WebCore/bindings/js/JSDOMBinding.cpp @@ -41,7 +41,6 @@ #include "HTMLStyleElement.h" #include "JSDOMCoreException.h" #include "JSDOMWindowCustom.h" -#include "JSDebugWrapperSet.h" #include "JSEventException.h" #include "JSExceptionBase.h" #include "JSMainThreadExecState.h" @@ -61,7 +60,6 @@ #include <runtime/DateInstance.h> #include <runtime/Error.h> #include <runtime/JSFunction.h> -#include <runtime/PrototypeFunction.h> #include <wtf/MathExtras.h> #include <wtf/StdLibExtras.h> @@ -143,7 +141,7 @@ const JSC::HashTable* getHashTableForGlobalData(JSGlobalData& globalData, const bool hasCachedDOMObjectWrapperUnchecked(JSGlobalData* globalData, void* objectHandle) { for (JSGlobalDataWorldIterator worldIter(globalData); worldIter; ++worldIter) { - if (worldIter->m_wrappers.uncheckedGet(objectHandle)) + if (worldIter->m_wrappers.get(objectHandle)) return true; } return false; @@ -165,8 +163,7 @@ DOMObject* getCachedDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle) void cacheDOMObjectWrapper(JSC::ExecState* exec, void* objectHandle, DOMObject* wrapper) { - JSDebugWrapperSet::willCacheWrapper(wrapper); - domObjectWrapperMapFor(exec).set(objectHandle, wrapper); + domObjectWrapperMapFor(exec).set(exec->globalData(), objectHandle, wrapper); } bool hasCachedDOMNodeWrapperUnchecked(Document* document, Node* node) @@ -176,64 +173,21 @@ bool hasCachedDOMNodeWrapperUnchecked(Document* document, Node* node) JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap(); for (JSWrapperCacheMap::iterator iter = wrapperCacheMap.begin(); iter != wrapperCacheMap.end(); ++iter) { - if (iter->second->uncheckedGet(node)) + if (iter->second->get(node)) return true; } return false; } -void forgetDOMObject(DOMObject* wrapper, void* objectHandle) -{ - JSC::JSGlobalData* globalData = Heap::heap(wrapper)->globalData(); - - // Check the normal world first! - JSGlobalData::ClientData* clientData = globalData->clientData; - ASSERT(clientData); - DOMObjectWrapperMap& wrappers = static_cast<WebCoreJSClientData*>(clientData)->normalWorld()->m_wrappers; - if (wrappers.uncheckedRemove(objectHandle, wrapper)) { - JSDebugWrapperSet::didUncacheWrapper(wrapper); - return; - } - - // We can't guarantee that a wrapper is in the cache when it uncaches itself, - // since a new wrapper may be cached before the old wrapper's destructor runs. - for (JSGlobalDataWorldIterator worldIter(globalData); worldIter; ++worldIter) { - if (worldIter->m_wrappers.uncheckedRemove(objectHandle, wrapper)) - break; - } - JSDebugWrapperSet::didUncacheWrapper(wrapper); -} - -void forgetDOMNode(JSNode* wrapper, Node* node, Document* document) -{ - node->clearWrapper(wrapper); - - if (!document) { - forgetDOMObject(wrapper, node); - return; - } - - // We can't guarantee that a wrapper is in the cache when it uncaches itself, - // since a new wrapper may be cached before the old wrapper's destructor runs. - JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap(); - for (JSWrapperCacheMap::iterator wrappersIter = wrapperCacheMap.begin(); wrappersIter != wrapperCacheMap.end(); ++wrappersIter) { - if (wrappersIter->second->uncheckedRemove(node, wrapper)) - break; - } - JSDebugWrapperSet::didUncacheWrapper(wrapper); -} - void cacheDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node, JSNode* wrapper) { - JSDebugWrapperSet::willCacheWrapper(wrapper); - if (!document) - domObjectWrapperMapFor(exec).set(node, wrapper); + domObjectWrapperMapFor(exec).set(exec->globalData(), node, wrapper); else - document->getWrapperCache(currentWorld(exec))->set(node, wrapper); + document->getWrapperCache(currentWorld(exec))->set(exec->globalData(), node, wrapper); if (currentWorld(exec)->isNormal()) - node->setWrapper(wrapper); + node->setWrapper(exec->globalData(), wrapper); } static inline bool isObservableThroughDOM(JSNode* jsNode, DOMWrapperWorld* world) @@ -265,7 +219,7 @@ static inline bool isObservableThroughDOM(JSNode* jsNode, DOMWrapperWorld* world // keep the node wrappers protecting them alive. if (node->isElementNode()) { if (NamedNodeMap* attributes = static_cast<Element*>(node)->attributeMap()) { - if (DOMObject* wrapper = world->m_wrappers.uncheckedGet(attributes)) { + if (DOMObject* wrapper = world->m_wrappers.get(attributes)) { // FIXME: This check seems insufficient, because NamedNodeMap items can have custom properties themselves. // Maybe it would be OK to just keep the wrapper alive, as it is done for CSSOM objects below. if (wrapper->hasCustomProperties()) @@ -274,31 +228,31 @@ static inline bool isObservableThroughDOM(JSNode* jsNode, DOMWrapperWorld* world } if (node->isStyledElement()) { if (CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(node)->inlineStyleDecl()) { - if (world->m_wrappers.uncheckedGet(style)) + if (world->m_wrappers.get(style)) return true; } } if (static_cast<Element*>(node)->hasTagName(canvasTag)) { if (CanvasRenderingContext* context = static_cast<HTMLCanvasElement*>(node)->renderingContext()) { - if (DOMObject* wrapper = world->m_wrappers.uncheckedGet(context)) { + if (DOMObject* wrapper = world->m_wrappers.get(context)) { if (wrapper->hasCustomProperties()) return true; } } } else if (static_cast<Element*>(node)->hasTagName(linkTag)) { if (StyleSheet* sheet = static_cast<HTMLLinkElement*>(node)->sheet()) { - if (world->m_wrappers.uncheckedGet(sheet)) + if (world->m_wrappers.get(sheet)) return true; } } else if (static_cast<Element*>(node)->hasTagName(styleTag)) { if (StyleSheet* sheet = static_cast<HTMLStyleElement*>(node)->sheet()) { - if (world->m_wrappers.uncheckedGet(sheet)) + if (world->m_wrappers.get(sheet)) return true; } } } else if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) { if (StyleSheet* sheet = static_cast<ProcessingInstruction*>(node)->sheet()) { - if (world->m_wrappers.uncheckedGet(sheet)) + if (world->m_wrappers.get(sheet)) return true; } } @@ -333,11 +287,10 @@ void markDOMNodesForDocument(MarkStack& markStack, Document* document) DOMWrapperWorld* world = wrappersIter->first; JSWrapperCache* nodeDict = wrappersIter->second; - JSWrapperCache::iterator nodeEnd = nodeDict->uncheckedEnd(); - for (JSWrapperCache::iterator nodeIt = nodeDict->uncheckedBegin(); nodeIt != nodeEnd; ++nodeIt) { - DeprecatedPtr<JSNode>& jsNode = nodeIt->second; - if (isObservableThroughDOM(jsNode.get(), world)) - markStack.append(&jsNode); + JSWrapperCache::iterator nodeEnd = nodeDict->end(); + for (JSWrapperCache::iterator nodeIt = nodeDict->begin(); nodeIt != nodeEnd; ++nodeIt) { + if (isObservableThroughDOM(nodeIt.get().second, world)) + markStack.deprecatedAppend(nodeIt.getSlot().second); } } } @@ -374,18 +327,14 @@ static inline void takeWrappers(Node* node, Document* document, WrapperSet& wrap if (document) { JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap(); for (JSWrapperCacheMap::iterator iter = wrapperCacheMap.begin(); iter != wrapperCacheMap.end(); ++iter) { - if (JSNode* wrapper = iter->second->take(node)) { - JSDebugWrapperSet::didUncacheWrapper(wrapper); + if (JSNode* wrapper = iter->second->take(node)) wrapperSet.append(WrapperAndWorld(wrapper, iter->first)); - } } } else { for (JSGlobalDataWorldIterator worldIter(JSDOMWindow::commonJSGlobalData()); worldIter; ++worldIter) { DOMWrapperWorld* world = *worldIter; - if (JSNode* wrapper = static_cast<JSNode*>(world->m_wrappers.take(node))) { - JSDebugWrapperSet::didUncacheWrapper(wrapper); + if (JSNode* wrapper = static_cast<JSNode*>(world->m_wrappers.take(node))) wrapperSet.append(WrapperAndWorld(wrapper, world)); - } } } } @@ -399,11 +348,10 @@ void updateDOMNodeDocument(Node* node, Document* oldDocument, Document* newDocum for (unsigned i = 0; i < wrapperSet.size(); ++i) { JSNode* wrapper = wrapperSet[i].first; - JSDebugWrapperSet::willCacheWrapper(wrapper); if (newDocument) - newDocument->getWrapperCache(wrapperSet[i].second)->set(node, wrapper); + newDocument->getWrapperCache(wrapperSet[i].second)->set(*wrapperSet[i].second->globalData(), node, wrapper); else - wrapperSet[i].second->m_wrappers.set(node, wrapper); + wrapperSet[i].second->m_wrappers.set(*wrapperSet[i].second->globalData(), node, wrapper); } } @@ -416,8 +364,8 @@ void markDOMObjectWrapper(MarkStack& markStack, JSGlobalData& globalData, void* return; for (JSGlobalDataWorldIterator worldIter(&globalData); worldIter; ++worldIter) { - if (DeprecatedPtr<DOMObject>* wrapperSlot = worldIter->m_wrappers.uncheckedGetSlot(object)) - markStack.append(wrapperSlot); + if (HandleSlot wrapperSlot = worldIter->m_wrappers.getSlot(object)) + markStack.deprecatedAppend(wrapperSlot); } } @@ -426,49 +374,28 @@ void markDOMNodeWrapper(MarkStack& markStack, Document* document, Node* node) if (document) { JSWrapperCacheMap& wrapperCacheMap = document->wrapperCacheMap(); for (JSWrapperCacheMap::iterator iter = wrapperCacheMap.begin(); iter != wrapperCacheMap.end(); ++iter) { - if (DeprecatedPtr<JSNode>* wrapperSlot = iter->second->uncheckedGetSlot(node)) - markStack.append(wrapperSlot); + if (HandleSlot wrapperSlot = iter->second->getSlot(node)) + markStack.deprecatedAppend(wrapperSlot); } return; } for (JSGlobalDataWorldIterator worldIter(JSDOMWindow::commonJSGlobalData()); worldIter; ++worldIter) { - if (DeprecatedPtr<DOMObject>* wrapperSlot = worldIter->m_wrappers.uncheckedGetSlot(node)) - markStack.append(wrapperSlot); + if (HandleSlot wrapperSlot = worldIter->m_wrappers.getSlot(node)) + markStack.deprecatedAppend(wrapperSlot); } } -static void stringWrapperDestroyed(JSString* str, void* context) +static void stringWrapperDestroyed(JSString*, void* context) { StringImpl* cacheKey = static_cast<StringImpl*>(context); - JSC::JSGlobalData* globalData = Heap::heap(str)->globalData(); - - // Check the normal world first! - JSGlobalData::ClientData* clientData = globalData->clientData; - ASSERT(clientData); - JSStringCache& cache = static_cast<WebCoreJSClientData*>(clientData)->normalWorld()->m_stringCache; - if (cache.uncheckedRemove(cacheKey, str)) { - cacheKey->deref(); - return; - } - - for (JSGlobalDataWorldIterator worldIter(globalData); worldIter; ++worldIter) { - if (worldIter->m_stringCache.uncheckedRemove(cacheKey, str)) - break; - } - cacheKey->deref(); } JSValue jsStringSlowCase(ExecState* exec, JSStringCache& stringCache, StringImpl* stringImpl) { - // If there is a stale entry, we have to explicitly remove it to avoid - // problems down the line. - if (JSString* wrapper = stringCache.uncheckedGet(stringImpl)) - stringCache.uncheckedRemove(stringImpl, wrapper); - JSString* wrapper = jsStringWithFinalizer(exec, UString(stringImpl), stringWrapperDestroyed, stringImpl); - stringCache.set(stringImpl, wrapper); + stringCache.set(exec->globalData(), stringImpl, wrapper); // ref explicitly instead of using a RefPtr-keyed hashtable because the wrapper can // outlive the cache, so the stringImpl has to match the wrapper's lifetime. stringImpl->ref(); @@ -563,7 +490,7 @@ double valueToDate(ExecState* exec, JSValue value) { if (value.isNumber()) return value.uncheckedGetNumber(); - if (!value.inherits(&DateInstance::info)) + if (!value.inherits(&DateInstance::s_info)) return std::numeric_limits<double>::quiet_NaN(); return static_cast<DateInstance*>(value.toObject(exec))->internalNumber(); } @@ -710,7 +637,7 @@ bool processingUserGesture() JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, objectProtoFuncToString); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, objectProtoFuncToString); } Structure* getCachedDOMStructure(JSDOMGlobalObject* globalObject, const ClassInfo* classInfo) diff --git a/Source/WebCore/bindings/js/JSDOMBinding.h b/Source/WebCore/bindings/js/JSDOMBinding.h index 52a1a71..4fe3d16 100644 --- a/Source/WebCore/bindings/js/JSDOMBinding.h +++ b/Source/WebCore/bindings/js/JSDOMBinding.h @@ -66,7 +66,7 @@ namespace WebCore { static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } protected: @@ -85,7 +85,7 @@ namespace WebCore { public: static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } protected: @@ -116,8 +116,6 @@ namespace WebCore { DOMObject* getCachedDOMObjectWrapper(JSC::ExecState*, void* objectHandle); bool hasCachedDOMObjectWrapper(JSC::JSGlobalData*, void* objectHandle); void cacheDOMObjectWrapper(JSC::ExecState*, void* objectHandle, DOMObject* wrapper); - void forgetDOMNode(JSNode* wrapper, Node* node, Document* document); - void forgetDOMObject(DOMObject* wrapper, void* objectHandle); JSNode* getCachedDOMNodeWrapper(JSC::ExecState*, Document*, Node*); void cacheDOMNodeWrapper(JSC::ExecState*, Document*, Node*, JSNode* wrapper); diff --git a/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp b/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp index a328ee9..efd0ae0 100644 --- a/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp +++ b/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp @@ -40,11 +40,12 @@ using namespace JSC; namespace WebCore { -const ClassInfo JSDOMGlobalObject::s_info = { "DOMGlobalObject", 0, 0, 0 }; +const ClassInfo JSDOMGlobalObject::s_info = { "DOMGlobalObject", &JSGlobalObject::s_info, 0, 0 }; JSDOMGlobalObject::JSDOMGlobalObject(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject::JSDOMGlobalObjectData* data, JSObject* thisValue) : JSGlobalObject(structure, data, thisValue) { + ASSERT(inherits(&s_info)); } void JSDOMGlobalObject::markChildren(MarkStack& markStack) diff --git a/Source/WebCore/bindings/js/JSDOMGlobalObject.h b/Source/WebCore/bindings/js/JSDOMGlobalObject.h index 4dce7a5..ac07969 100644 --- a/Source/WebCore/bindings/js/JSDOMGlobalObject.h +++ b/Source/WebCore/bindings/js/JSDOMGlobalObject.h @@ -67,9 +67,13 @@ namespace WebCore { DOMWrapperWorld* world() { return d()->m_world.get(); } - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + protected: struct JSDOMGlobalObjectData : public JSC::JSGlobalObject::JSGlobalObjectData { JSDOMGlobalObjectData(DOMWrapperWorld* world, Destructor destructor = destroyJSDOMGlobalObjectData) diff --git a/Source/WebCore/bindings/js/JSDOMImplementationCustom.cpp b/Source/WebCore/bindings/js/JSDOMImplementationCustom.cpp new file mode 100644 index 0000000..ac83c69 --- /dev/null +++ b/Source/WebCore/bindings/js/JSDOMImplementationCustom.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE 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 "JSDOMImplementation.h" + +#include "DOMImplementation.h" + +using namespace JSC; + +namespace WebCore { + +void JSDOMImplementation::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + DOMImplementation* domImplementation = impl(); + Document* ownerDocument = domImplementation->ownerDocument(); + if (ownerDocument) + markDOMNodeWrapper(markStack, ownerDocument, ownerDocument); +} + +} diff --git a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp index 68c0088..df01f77 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp +++ b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp @@ -55,6 +55,8 @@ JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData(PassRefPtr<DOMWindow> JSDOMWindowBase::JSDOMWindowBase(NonNullPassRefPtr<Structure> structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell) : JSDOMGlobalObject(structure, new JSDOMWindowBaseData(window, shell), shell) { + ASSERT(inherits(&s_info)); + GlobalPropertyInfo staticGlobals[] = { GlobalPropertyInfo(Identifier(globalExec(), "document"), jsNull(), DontDelete | ReadOnly), GlobalPropertyInfo(Identifier(globalExec(), "window"), d()->shell, DontDelete | ReadOnly) @@ -67,7 +69,7 @@ void JSDOMWindowBase::updateDocument() { ASSERT(d()->impl->document()); ExecState* exec = globalExec(); - symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, this, d()->impl->document()), DontDelete | ReadOnly); + symbolTablePutWithAttributes(exec->globalData(), Identifier(exec, "document"), toJS(exec, this, d()->impl->document()), DontDelete | ReadOnly); } ScriptExecutionContext* JSDOMWindowBase::scriptExecutionContext() const diff --git a/Source/WebCore/bindings/js/JSDOMWindowBase.h b/Source/WebCore/bindings/js/JSDOMWindowBase.h index fbef808..91b4f42 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowBase.h +++ b/Source/WebCore/bindings/js/JSDOMWindowBase.h @@ -22,7 +22,7 @@ #include "PlatformString.h" #include "JSDOMBinding.h" -#include <runtime/Protect.h> +#include <collector/handles/Global.h> #include <wtf/Forward.h> #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> @@ -55,9 +55,13 @@ namespace WebCore { // Called just before removing this window from the JSDOMWindowShell. void willRemoveFromWindowShell(); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + virtual JSC::ExecState* globalExec(); virtual bool supportsProfiling() const; virtual bool supportsRichSourceInfo() const; diff --git a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp index c12d1c4..03f9d68 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -55,7 +55,6 @@ #include "Settings.h" #include "SharedWorkerRepository.h" #include <runtime/JSFunction.h> -#include <runtime/PrototypeFunction.h> #if ENABLE(SHARED_WORKERS) #include "JSSharedWorker.h" @@ -106,7 +105,7 @@ void JSDOMWindow::markChildren(MarkStack& markStack) template<NativeFunction nativeFunction, int length> JSValue nonCachingStaticFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), length, propertyName, nativeFunction); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), length, propertyName, nativeFunction); } static JSValue childFrameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) diff --git a/Source/WebCore/bindings/js/JSDOMWindowShell.cpp b/Source/WebCore/bindings/js/JSDOMWindowShell.cpp index 40f9910..a4cc777 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowShell.cpp +++ b/Source/WebCore/bindings/js/JSDOMWindowShell.cpp @@ -41,12 +41,13 @@ namespace WebCore { ASSERT_CLASS_FITS_IN_CELL(JSDOMWindowShell); -const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", 0, 0, 0 }; +const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", &Base::s_info, 0, 0 }; JSDOMWindowShell::JSDOMWindowShell(PassRefPtr<DOMWindow> window, DOMWrapperWorld* world) : Base(JSDOMWindowShell::createStructure(jsNull())) , m_world(world) { + ASSERT(inherits(&s_info)); setWindow(window); } @@ -60,9 +61,9 @@ void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> domWindow) // when we allocate the global object. (Once the global object is fully // constructed, it can mark its own prototype.) RefPtr<Structure> prototypeStructure = JSDOMWindowPrototype::createStructure(jsNull()); - ProtectedPtr<JSDOMWindowPrototype> prototype = new JSDOMWindowPrototype(0, prototypeStructure.release()); + Global<JSDOMWindowPrototype> prototype(*JSDOMWindow::commonJSGlobalData(), new JSDOMWindowPrototype(0, prototypeStructure.release())); - RefPtr<Structure> structure = JSDOMWindow::createStructure(prototype); + RefPtr<Structure> structure = JSDOMWindow::createStructure(prototype.get()); JSDOMWindow* jsDOMWindow = new (JSDOMWindow::commonJSGlobalData()) JSDOMWindow(structure.release(), domWindow, this); prototype->putAnonymousValue(*JSDOMWindow::commonJSGlobalData(), 0, jsDOMWindow); setWindow(*JSDOMWindow::commonJSGlobalData(), jsDOMWindow); diff --git a/Source/WebCore/bindings/js/JSDOMWindowShell.h b/Source/WebCore/bindings/js/JSDOMWindowShell.h index d585fd4..06dd1ff 100644 --- a/Source/WebCore/bindings/js/JSDOMWindowShell.h +++ b/Source/WebCore/bindings/js/JSDOMWindowShell.h @@ -37,8 +37,8 @@ namespace WebCore { class DOMWindow; class Frame; - class JSDOMWindowShell : public JSC::JSObject { - typedef JSC::JSObject Base; + class JSDOMWindowShell : public JSC::JSNonFinalObject { + typedef JSC::JSNonFinalObject Base; public: JSDOMWindowShell(PassRefPtr<DOMWindow>, DOMWrapperWorld* world); virtual ~JSDOMWindowShell(); @@ -60,7 +60,7 @@ namespace WebCore { static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } DOMWrapperWorld* world() { return m_world.get(); } @@ -83,7 +83,6 @@ namespace WebCore { virtual JSC::JSValue lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName); virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName); virtual JSC::JSObject* unwrappedObject(); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } JSC::WriteBarrier<JSDOMWindow> m_window; RefPtr<DOMWrapperWorld> m_world; diff --git a/Source/WebCore/bindings/js/JSDOMWrapper.cpp b/Source/WebCore/bindings/js/JSDOMWrapper.cpp index 9548f2f..794f039 100644 --- a/Source/WebCore/bindings/js/JSDOMWrapper.cpp +++ b/Source/WebCore/bindings/js/JSDOMWrapper.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "JSDOMWrapper.h" -#include "JSDebugWrapperSet.h" #include <runtime/Error.h> using namespace JSC; @@ -37,7 +36,6 @@ namespace WebCore { DOMObject::~DOMObject() { - ASSERT(!JSDebugWrapperSet::shared().contains(this)); } #endif diff --git a/Source/WebCore/bindings/js/JSDataGridDataSource.h b/Source/WebCore/bindings/js/JSDataGridDataSource.h index 077ef8f..684a663 100644 --- a/Source/WebCore/bindings/js/JSDataGridDataSource.h +++ b/Source/WebCore/bindings/js/JSDataGridDataSource.h @@ -29,8 +29,8 @@ #if ENABLE(DATAGRID) #include "DataGridDataSource.h" +#include <collector/handles/Global.h> #include <runtime/JSValue.h> -#include <runtime/Protect.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> diff --git a/Source/WebCore/bindings/js/JSDebugWrapperSet.cpp b/Source/WebCore/bindings/js/JSDebugWrapperSet.cpp deleted file mode 100644 index b0d6ca9..0000000 --- a/Source/WebCore/bindings/js/JSDebugWrapperSet.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSDebugWrapperSet.h" - -#include <wtf/StdLibExtras.h> - -#if ENABLE(WORKERS) -#include <wtf/ThreadSpecific.h> -#endif - -namespace WebCore { - -JSDebugWrapperSet& JSDebugWrapperSet::shared() -{ -#if ENABLE(WORKERS) - DEFINE_STATIC_LOCAL(WTF::ThreadSpecific<JSDebugWrapperSet>, staticWrapperSet, ()); - return *staticWrapperSet; -#else - DEFINE_STATIC_LOCAL(JSDebugWrapperSet, staticWrapperSet, ()); - return staticWrapperSet; -#endif -} - -JSDebugWrapperSet::JSDebugWrapperSet() -{ -} - -} // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSDebugWrapperSet.h b/Source/WebCore/bindings/js/JSDebugWrapperSet.h deleted file mode 100644 index e1138ed..0000000 --- a/Source/WebCore/bindings/js/JSDebugWrapperSet.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSDebugWrapperSet_h -#define JSDebugWrapperSet_h - -#include "JSDOMWrapper.h" -#include <wtf/HashSet.h> -#include <wtf/Noncopyable.h> - -namespace WebCore { - -// For debugging, keep a set of wrappers currently cached, and check that -// all are uncached before they are destroyed. This helps us catch bugs like: -// - wrappers being deleted without being removed from the cache -// - wrappers being cached twice - -class JSDebugWrapperSet { - WTF_MAKE_NONCOPYABLE(JSDebugWrapperSet); - friend class WTF::ThreadSpecific<JSDebugWrapperSet>; -public: - static JSDebugWrapperSet& shared(); - - void add(DOMObject* object) { m_wrapperSet.add(object); } - void remove(DOMObject* object) { m_wrapperSet.remove(object); } - bool contains(DOMObject* object) const { return m_wrapperSet.contains(object); } - - static void willCacheWrapper(DOMObject*); - static void didUncacheWrapper(DOMObject*); - -private: - JSDebugWrapperSet(); - - HashSet<DOMObject*> m_wrapperSet; -}; - -#ifdef NDEBUG - -inline void JSDebugWrapperSet::willCacheWrapper(DOMObject*) -{ -} - -inline void JSDebugWrapperSet::didUncacheWrapper(DOMObject*) -{ -} - -#else - -inline void JSDebugWrapperSet::willCacheWrapper(DOMObject* wrapper) -{ - ASSERT(!JSDebugWrapperSet::shared().contains(wrapper)); - JSDebugWrapperSet::shared().add(wrapper); -} - -inline void JSDebugWrapperSet::didUncacheWrapper(DOMObject* wrapper) -{ - if (!wrapper) - return; - ASSERT(JSDebugWrapperSet::shared().contains(wrapper)); - JSDebugWrapperSet::shared().remove(wrapper); -} - -#endif - -} // namespace WebCore - -#endif // JSDebugWrapperSet_h diff --git a/Source/WebCore/bindings/js/JSEventCustom.cpp b/Source/WebCore/bindings/js/JSEventCustom.cpp index fd80360..9e95e74 100644 --- a/Source/WebCore/bindings/js/JSEventCustom.cpp +++ b/Source/WebCore/bindings/js/JSEventCustom.cpp @@ -94,10 +94,8 @@ #endif #if ENABLE(INDEXED_DATABASE) -#include "IDBErrorEvent.h" -#include "IDBSuccessEvent.h" -#include "JSIDBErrorEvent.h" -#include "JSIDBSuccessEvent.h" +#include "IDBVersionChangeEvent.h" +#include "JSIDBVersionChangeEvent.h" #endif #if ENABLE(WEB_AUDIO) @@ -166,10 +164,8 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event) wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, StorageEvent, event); #endif #if ENABLE(INDEXED_DATABASE) - else if (event->isIDBErrorEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, IDBErrorEvent, event); - else if (event->isIDBSuccessEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, IDBSuccessEvent, event); + else if (event->isIDBVersionChangeEvent()) + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, IDBVersionChangeEvent, event); #endif else if (event->isWebKitAnimationEvent()) wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WebKitAnimationEvent, event); diff --git a/Source/WebCore/bindings/js/JSEventListener.cpp b/Source/WebCore/bindings/js/JSEventListener.cpp index 6427683..90a164b 100644 --- a/Source/WebCore/bindings/js/JSEventListener.cpp +++ b/Source/WebCore/bindings/js/JSEventListener.cpp @@ -34,11 +34,10 @@ namespace WebCore { JSEventListener::JSEventListener(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) : EventListener(JSEventListenerType) + , m_wrapper(*isolatedWorld->globalData(), wrapper) , m_isAttribute(isAttribute) , m_isolatedWorld(isolatedWorld) { - if (wrapper) - m_wrapper = wrapper; m_jsFunction.set(*m_isolatedWorld->globalData(), wrapper, function); } @@ -127,9 +126,10 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext globalObject->setCurrentEvent(savedEvent); - if (exec->hadException()) + if (exec->hadException()) { + event->target()->uncaughtExceptionInEventHandler(); reportCurrentException(exec); - else { + } else { if (!retval.isUndefinedOrNull() && event->storesResultAsString()) event->storeResult(ustringToString(retval.toString(exec))); if (m_isAttribute) { diff --git a/Source/WebCore/bindings/js/JSEventListener.h b/Source/WebCore/bindings/js/JSEventListener.h index 47ff44e..0af0f86 100644 --- a/Source/WebCore/bindings/js/JSEventListener.h +++ b/Source/WebCore/bindings/js/JSEventListener.h @@ -53,12 +53,11 @@ namespace WebCore { DOMWrapperWorld* isolatedWorld() const { return m_isolatedWorld.get(); } JSC::JSObject* wrapper() const { return m_wrapper.get(); } - void setWrapper(JSC::JSObject* wrapper) const { m_wrapper = wrapper; } + void setWrapper(JSC::JSGlobalData& globalData, JSC::JSObject* wrapper) const { m_wrapper.set(globalData, wrapper, 0); } private: virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const; virtual void markJSFunction(JSC::MarkStack&); - virtual void invalidateJSFunction(JSC::JSObject*); virtual bool virtualisAttribute() const; protected: @@ -91,11 +90,6 @@ namespace WebCore { return m_jsFunction.get(); } - inline void JSEventListener::invalidateJSFunction(JSC::JSObject* wrapper) - { - m_wrapper.clear(wrapper); - } - // Creates a JS EventListener for an "onXXX" event attribute. inline PassRefPtr<JSEventListener> createJSAttributeEventListener(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper) { diff --git a/Source/WebCore/bindings/js/JSEventTarget.cpp b/Source/WebCore/bindings/js/JSEventTarget.cpp index 04be175..e4d6724 100644 --- a/Source/WebCore/bindings/js/JSEventTarget.cpp +++ b/Source/WebCore/bindings/js/JSEventTarget.cpp @@ -160,8 +160,14 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ #endif #if ENABLE(INDEXED_DATABASE) + if (IDBDatabase* idbDatabase = target->toIDBDatabase()) + return toJS(exec, idbDatabase); + if (IDBRequest* idbRequest = target->toIDBRequest()) return toJS(exec, idbRequest); + + if (IDBTransaction* idbTransaction = target->toIDBTransaction()) + return toJS(exec, idbTransaction); #endif #if ENABLE(WEB_AUDIO) diff --git a/Source/WebCore/bindings/js/JSGeolocationCustom.cpp b/Source/WebCore/bindings/js/JSGeolocationCustom.cpp index 1e40f86..248adcf 100644 --- a/Source/WebCore/bindings/js/JSGeolocationCustom.cpp +++ b/Source/WebCore/bindings/js/JSGeolocationCustom.cpp @@ -50,7 +50,7 @@ static PassRefPtr<PositionCallback> createPositionCallback(ExecState* exec, JSDO { // The spec specifies 'FunctionOnly' for this object. // FIXME: This check disallows callable objects created via JSC API. It's not clear what exactly the specification intends to allow. - if (!value.inherits(&JSFunction::info)) { + if (!value.inherits(&JSFunction::s_info)) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } @@ -67,7 +67,7 @@ static PassRefPtr<PositionErrorCallback> createPositionErrorCallback(ExecState* // The spec specifies 'FunctionOnly' for this object. // FIXME: This check disallows callable objects created via JSC API. It's not clear what exactly the specification intends to allow. - if (!value.inherits(&JSFunction::info)) { + if (!value.inherits(&JSFunction::s_info)) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; } diff --git a/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp index 4194657..0d2bf94 100644 --- a/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp @@ -33,19 +33,19 @@ namespace WebCore { using namespace JSC; -void JSHTMLElement::pushEventHandlerScope(ExecState* exec, ScopeChain& scope) const +ScopeChainNode* JSHTMLElement::pushEventHandlerScope(ExecState* exec, ScopeChainNode* scope) const { HTMLElement* element = impl(); // The document is put on first, fall back to searching it only after the element and form. - scope.push(asObject(toJS(exec, globalObject(), element->ownerDocument()))); + scope = scope->push(asObject(toJS(exec, globalObject(), element->ownerDocument()))); // The form is next, searched before the document, but after the element itself. if (HTMLFormElement* form = element->form()) - scope.push(asObject(toJS(exec, globalObject(), form))); + scope = scope->push(asObject(toJS(exec, globalObject(), form))); // The element is on top, searched first. - scope.push(asObject(toJS(exec, globalObject(), element))); + return scope->push(asObject(toJS(exec, globalObject(), element))); } } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSHistoryCustom.cpp b/Source/WebCore/bindings/js/JSHistoryCustom.cpp index 6a2f614..d0eae28 100644 --- a/Source/WebCore/bindings/js/JSHistoryCustom.cpp +++ b/Source/WebCore/bindings/js/JSHistoryCustom.cpp @@ -32,7 +32,6 @@ #include "Frame.h" #include "History.h" #include <runtime/JSFunction.h> -#include <runtime/PrototypeFunction.h> using namespace JSC; @@ -40,17 +39,17 @@ namespace WebCore { static JSValue nonCachingStaticBackFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionBack); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsHistoryPrototypeFunctionBack); } static JSValue nonCachingStaticForwardFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsHistoryPrototypeFunctionForward); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsHistoryPrototypeFunctionForward); } static JSValue nonCachingStaticGoFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsHistoryPrototypeFunctionGo); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsHistoryPrototypeFunctionGo); } bool JSHistory::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) diff --git a/Source/WebCore/bindings/js/JSImageConstructor.cpp b/Source/WebCore/bindings/js/JSImageConstructor.cpp index 5192e12..1ddf136 100644 --- a/Source/WebCore/bindings/js/JSImageConstructor.cpp +++ b/Source/WebCore/bindings/js/JSImageConstructor.cpp @@ -32,11 +32,12 @@ namespace WebCore { ASSERT_CLASS_FITS_IN_CELL(JSImageConstructor); -const ClassInfo JSImageConstructor::s_info = { "ImageConstructor", 0, 0, 0 }; +const ClassInfo JSImageConstructor::s_info = { "ImageConstructor", &DOMConstructorWithDocument::s_info, 0, 0 }; JSImageConstructor::JSImageConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorWithDocument(JSImageConstructor::createStructure(globalObject->objectPrototype()), globalObject) { + ASSERT(inherits(&s_info)); putDirect(exec->globalData(), exec->propertyNames().prototype, JSHTMLImageElementPrototype::self(exec, globalObject), None); } diff --git a/Source/WebCore/bindings/js/JSImageConstructor.h b/Source/WebCore/bindings/js/JSImageConstructor.h index 0525f5e..73293c7 100644 --- a/Source/WebCore/bindings/js/JSImageConstructor.h +++ b/Source/WebCore/bindings/js/JSImageConstructor.h @@ -29,10 +29,15 @@ namespace WebCore { public: JSImageConstructor(JSC::ExecState*, JSDOMGlobalObject*); + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + static const JSC::ClassInfo s_info; + private: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } }; } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSImageDataCustom.cpp b/Source/WebCore/bindings/js/JSImageDataCustom.cpp index 878e1de..b5592d8 100644 --- a/Source/WebCore/bindings/js/JSImageDataCustom.cpp +++ b/Source/WebCore/bindings/js/JSImageDataCustom.cpp @@ -47,9 +47,9 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData* imageD wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, ImageData, imageData); Identifier dataName(exec, "data"); - DEFINE_STATIC_LOCAL(RefPtr<Structure>, cpaStructure, (JSByteArray::createStructure(jsNull()))); - static const ClassInfo cpaClassInfo = { "CanvasPixelArray", 0, 0, 0 }; - wrapper->putDirect(exec->globalData(), dataName, new (exec) JSByteArray(exec, cpaStructure, imageData->data()->data(), &cpaClassInfo), DontDelete | ReadOnly); + static const ClassInfo cpaClassInfo = { "CanvasPixelArray", &JSByteArray::Base::s_info, 0, 0 }; + DEFINE_STATIC_LOCAL(RefPtr<Structure>, cpaStructure, (JSByteArray::createStructure(jsNull(), &cpaClassInfo))); + wrapper->putDirect(exec->globalData(), dataName, new (exec) JSByteArray(exec, cpaStructure, imageData->data()->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 dd36c2e..bc1d877 100644 --- a/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp +++ b/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp @@ -54,6 +54,7 @@ #include "JSRange.h" #include "Node.h" #include "Page.h" +#include "ScriptValue.h" #if ENABLE(DOM_STORAGE) #include "Storage.h" #include "JSStorage.h" @@ -76,6 +77,18 @@ using namespace JSC; namespace WebCore { +Node* InjectedScriptHost::scriptValueAsNode(ScriptValue value) +{ + if (!value.isObject() || value.isNull()) + return 0; + return toNode(value.jsValue()); +} + +ScriptValue InjectedScriptHost::nodeAsScriptValue(ScriptState* state, Node* node) +{ + return ScriptValue(state->globalData(), toJS(state, node)); +} + ScriptObject InjectedScriptHost::createInjectedScript(const String& source, ScriptState* scriptState, long id) { SourceCode sourceCode = makeSource(stringToUString(source)); @@ -107,30 +120,30 @@ void InjectedScriptHost::discardInjectedScript(ScriptState* scriptState) globalObject->setInjectedScript(0); } -#if ENABLE(JAVASCRIPT_DEBUGGER) JSValue JSInjectedScriptHost::currentCallFrame(ExecState* exec) { +#if ENABLE(JAVASCRIPT_DEBUGGER) JavaScriptCallFrame* callFrame = ScriptDebugServer::shared().currentCallFrame(); if (!callFrame || !callFrame->isValid()) return jsUndefined(); JSLock lock(SilenceAssertionsOnly); return toJS(exec, callFrame); -} +#else + UNUSED_PARAM(exec); + return jsUndefined(); #endif +} -JSValue JSInjectedScriptHost::nodeForId(ExecState* exec) +JSValue JSInjectedScriptHost::inspectedNode(ExecState* exec) { if (exec->argumentCount() < 1) return jsUndefined(); - Node* node = impl()->nodeForId(exec->argument(0).toInt32(exec)); + Node* node = impl()->inspectedNode(exec->argument(0).toInt32(exec)); if (!node) return jsUndefined(); - if (!impl()->inspectorAgent()) - return jsUndefined(); - JSLock lock(SilenceAssertionsOnly); return toJS(exec, node); } @@ -144,47 +157,39 @@ JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec) return jsString(exec, result); } -JSValue JSInjectedScriptHost::pushNodePathToFrontend(ExecState* exec) +JSValue JSInjectedScriptHost::inspect(ExecState* exec) { - if (exec->argumentCount() < 3) - return jsUndefined(); - - Node* node = toNode(exec->argument(0)); - if (!node) - return jsUndefined(); - - bool withChildren = exec->argument(1).toBoolean(exec); - bool selectInUI = exec->argument(2).toBoolean(exec); - return jsNumber(impl()->pushNodePathToFrontend(node, withChildren, selectInUI)); + if (exec->argumentCount() >= 2) { + ScriptValue objectId(exec->globalData(), exec->argument(0)); + ScriptValue hints(exec->globalData(), exec->argument(1)); + impl()->inspectImpl(objectId.toInspectorValue(exec), hints.toInspectorValue(exec)); + } + return jsUndefined(); } -#if ENABLE(DATABASE) -JSValue JSInjectedScriptHost::selectDatabase(ExecState* exec) +JSValue JSInjectedScriptHost::databaseId(ExecState* exec) { if (exec->argumentCount() < 1) return jsUndefined(); - +#if ENABLE(DATABASE) Database* database = toDatabase(exec->argument(0)); if (database) - impl()->selectDatabase(database); + return jsNumber(impl()->databaseIdImpl(database)); +#endif return jsUndefined(); } -#endif -#if ENABLE(DOM_STORAGE) -JSValue JSInjectedScriptHost::selectDOMStorage(ExecState* exec) +JSValue JSInjectedScriptHost::storageId(ExecState* exec) { if (exec->argumentCount() < 1) return jsUndefined(); - if (!impl()->inspectorAgent()) - return jsUndefined(); - +#if ENABLE(DOM_STORAGE) Storage* storage = toStorage(exec->argument(0)); if (storage) - impl()->selectDOMStorage(storage); + return jsNumber(impl()->storageIdImpl(storage)); +#endif return jsUndefined(); } -#endif InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState) { diff --git a/Source/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp b/Source/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp index 7c00bd4..e493508 100644 --- a/Source/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp +++ b/Source/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp @@ -70,7 +70,7 @@ JSValue JSJavaScriptCallFrame::scopeChain(ExecState* exec) const if (!impl()->scopeChain()) return jsNull(); - const ScopeChainNode* scopeChain = impl()->scopeChain(); + ScopeChainNode* scopeChain = impl()->scopeChain(); ScopeChainIterator iter = scopeChain->begin(); ScopeChainIterator end = scopeChain->end(); @@ -95,12 +95,12 @@ JSValue JSJavaScriptCallFrame::scopeType(ExecState* exec) return jsUndefined(); int index = exec->argument(0).asInt32(); - const ScopeChainNode* scopeChain = impl()->scopeChain(); + ScopeChainNode* scopeChain = impl()->scopeChain(); ScopeChainIterator end = scopeChain->end(); bool foundLocalScope = false; for (ScopeChainIterator iter = scopeChain->begin(); iter != end; ++iter) { - JSC::DeprecatedPtr<JSObject> scope = *iter; + JSObject* scope = iter->get(); if (scope->isActivationObject()) { if (!foundLocalScope) { // First activation object is local scope, each successive activation object is closure. diff --git a/Source/WebCore/bindings/js/JSLazyEventListener.cpp b/Source/WebCore/bindings/js/JSLazyEventListener.cpp index 1aad7df..98db97a 100644 --- a/Source/WebCore/bindings/js/JSLazyEventListener.cpp +++ b/Source/WebCore/bindings/js/JSLazyEventListener.cpp @@ -115,14 +115,12 @@ JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* exec // Ensure that 'node' has a JavaScript wrapper to mark the event listener we're creating. JSLock lock(SilenceAssertionsOnly); // FIXME: Should pass the global object associated with the node - setWrapper(asObject(toJS(globalObject->globalExec(), globalObject, m_originalNode))); + setWrapper(exec->globalData(), asObject(toJS(exec, globalObject, m_originalNode))); } // Add the event's home element to the scope // (and the document, and the form - see JSHTMLElement::eventHandlerScope) - ScopeChain scope = listenerAsFunction->scope(); - static_cast<JSNode*>(wrapper())->pushEventHandlerScope(exec, scope); - listenerAsFunction->setScope(scope); + listenerAsFunction->setScope(exec->globalData(), static_cast<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/JSLocationCustom.cpp b/Source/WebCore/bindings/js/JSLocationCustom.cpp index 432155e..a82c469 100644 --- a/Source/WebCore/bindings/js/JSLocationCustom.cpp +++ b/Source/WebCore/bindings/js/JSLocationCustom.cpp @@ -25,7 +25,6 @@ #include "Location.h" #include <runtime/JSFunction.h> -#include <runtime/PrototypeFunction.h> using namespace JSC; @@ -33,17 +32,17 @@ namespace WebCore { static JSValue nonCachingStaticReplaceFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace); } static JSValue nonCachingStaticReloadFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload); } static JSValue nonCachingStaticAssignFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName) { - return new (exec) NativeFunctionWrapper(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign); + return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign); } bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -266,7 +265,7 @@ JSValue JSLocation::assign(ExecState* exec) return jsUndefined(); } -JSValue JSLocation::toString(ExecState* exec) +JSValue JSLocation::toStringFunction(ExecState* exec) { Frame* frame = impl()->frame(); if (!frame || !allowsAccessFromFrame(exec, frame)) diff --git a/Source/WebCore/bindings/js/JSMainThreadExecState.h b/Source/WebCore/bindings/js/JSMainThreadExecState.h index 349dc14..fb01000 100644 --- a/Source/WebCore/bindings/js/JSMainThreadExecState.h +++ b/Source/WebCore/bindings/js/JSMainThreadExecState.h @@ -48,7 +48,7 @@ public: return JSC::call(exec, functionObject, callType, callData, thisValue, args); }; - static JSC::Completion evaluate(JSC::ExecState* exec, JSC::ScopeChain& chain, const JSC::SourceCode& source, JSC::JSValue thisValue) + static JSC::Completion evaluate(JSC::ExecState* exec, JSC::ScopeChainNode* chain, const JSC::SourceCode& source, JSC::JSValue thisValue) { JSMainThreadExecState currentState(exec); return JSC::evaluate(exec, chain, source, thisValue); diff --git a/Source/WebCore/bindings/js/JSNodeCustom.cpp b/Source/WebCore/bindings/js/JSNodeCustom.cpp index 8d00447..17f57f4 100644 --- a/Source/WebCore/bindings/js/JSNodeCustom.cpp +++ b/Source/WebCore/bindings/js/JSNodeCustom.cpp @@ -112,8 +112,9 @@ JSValue JSNode::appendChild(ExecState* exec) return jsNull(); } -void JSNode::pushEventHandlerScope(ExecState*, ScopeChain&) const +ScopeChainNode* JSNode::pushEventHandlerScope(ExecState*, ScopeChainNode* node) const { + return node; } void JSNode::markChildren(MarkStack& markStack) diff --git a/Source/WebCore/bindings/js/JSOptionConstructor.cpp b/Source/WebCore/bindings/js/JSOptionConstructor.cpp index e14fb6d..a3c9aab 100644 --- a/Source/WebCore/bindings/js/JSOptionConstructor.cpp +++ b/Source/WebCore/bindings/js/JSOptionConstructor.cpp @@ -33,11 +33,12 @@ namespace WebCore { ASSERT_CLASS_FITS_IN_CELL(JSOptionConstructor); -const ClassInfo JSOptionConstructor::s_info = { "OptionConstructor", 0, 0, 0 }; +const ClassInfo JSOptionConstructor::s_info = { "OptionConstructor", &DOMConstructorWithDocument::s_info, 0, 0 }; JSOptionConstructor::JSOptionConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorWithDocument(JSOptionConstructor::createStructure(globalObject->objectPrototype()), globalObject) { + ASSERT(inherits(&s_info)); putDirect(exec->globalData(), exec->propertyNames().prototype, JSHTMLOptionElementPrototype::self(exec, globalObject), None); putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(4), ReadOnly | DontDelete | DontEnum); } diff --git a/Source/WebCore/bindings/js/JSOptionConstructor.h b/Source/WebCore/bindings/js/JSOptionConstructor.h index 246e7fa..03633c7 100644 --- a/Source/WebCore/bindings/js/JSOptionConstructor.h +++ b/Source/WebCore/bindings/js/JSOptionConstructor.h @@ -30,10 +30,15 @@ namespace WebCore { public: JSOptionConstructor(JSC::ExecState*, JSDOMGlobalObject*); + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + static const JSC::ClassInfo s_info; + private: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } }; } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp index eb4f6e2..0f52301 100644 --- a/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp @@ -39,6 +39,8 @@ #include "JSImageData.h" #include "JSOESStandardDerivatives.h" #include "JSOESTextureFloat.h" +#include "JSOESVertexArrayObject.h" +#include "JSWebGLVertexArrayObjectOES.h" #include "JSWebGLBuffer.h" #include "JSFloat32Array.h" #include "JSWebGLFramebuffer.h" @@ -53,6 +55,8 @@ #include "NotImplemented.h" #include "OESStandardDerivatives.h" #include "OESTextureFloat.h" +#include "OESVertexArrayObject.h" +#include "WebGLVertexArrayObjectOES.h" #include "WebGLBuffer.h" #include "Float32Array.h" #include "WebGLExtension.h" @@ -115,6 +119,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, const WebG return toJS(exec, globalObject, info.getWebGLTexture()); case WebGLGetInfo::kTypeWebGLUnsignedByteArray: return toJS(exec, globalObject, info.getWebGLUnsignedByteArray()); + case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES: + return toJS(exec, globalObject, info.getWebGLVertexArrayObjectOES()); default: notImplemented(); return jsUndefined(); @@ -179,6 +185,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten return toJS(exec, globalObject, static_cast<OESStandardDerivatives*>(extension)); case WebGLExtension::OESTextureFloatName: return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension)); + case WebGLExtension::OESVertexArrayObjectName: + return toJS(exec, globalObject, static_cast<OESVertexArrayObject*>(extension)); } ASSERT_NOT_REACHED(); return jsNull(); diff --git a/Source/WebCore/bindings/js/JSWorkerContextBase.cpp b/Source/WebCore/bindings/js/JSWorkerContextBase.cpp index effe488..88fa43f 100644 --- a/Source/WebCore/bindings/js/JSWorkerContextBase.cpp +++ b/Source/WebCore/bindings/js/JSWorkerContextBase.cpp @@ -48,6 +48,7 @@ JSWorkerContextBase::JSWorkerContextBase(NonNullPassRefPtr<JSC::Structure> struc : JSDOMGlobalObject(structure, new JSDOMGlobalObjectData(normalWorld(*impl->script()->globalData())), this) , m_impl(impl) { + ASSERT(inherits(&s_info)); } JSWorkerContextBase::~JSWorkerContextBase() diff --git a/Source/WebCore/bindings/js/JSWorkerContextBase.h b/Source/WebCore/bindings/js/JSWorkerContextBase.h index 45238f1..99948b7 100644 --- a/Source/WebCore/bindings/js/JSWorkerContextBase.h +++ b/Source/WebCore/bindings/js/JSWorkerContextBase.h @@ -44,12 +44,16 @@ namespace WebCore { JSWorkerContextBase(NonNullPassRefPtr<JSC::Structure>, PassRefPtr<WorkerContext>); virtual ~JSWorkerContextBase(); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; WorkerContext* impl() const { return m_impl.get(); } virtual ScriptExecutionContext* scriptExecutionContext() const; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + private: RefPtr<WorkerContext> m_impl; }; diff --git a/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp b/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp index cc6986a..5bafeda 100644 --- a/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp +++ b/Source/WebCore/bindings/js/JavaScriptCallFrame.cpp @@ -42,7 +42,7 @@ using namespace JSC; namespace WebCore { -JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition) +JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition0& textPosition) : m_debuggerCallFrame(debuggerCallFrame) , m_caller(caller) , m_sourceID(sourceID) @@ -56,7 +56,7 @@ JavaScriptCallFrame* JavaScriptCallFrame::caller() return m_caller.get(); } -const JSC::ScopeChainNode* JavaScriptCallFrame::scopeChain() const +JSC::ScopeChainNode* JavaScriptCallFrame::scopeChain() const { ASSERT(m_isValid); if (!m_isValid) diff --git a/Source/WebCore/bindings/js/JavaScriptCallFrame.h b/Source/WebCore/bindings/js/JavaScriptCallFrame.h index 74e0a70..f3a114b 100644 --- a/Source/WebCore/bindings/js/JavaScriptCallFrame.h +++ b/Source/WebCore/bindings/js/JavaScriptCallFrame.h @@ -39,7 +39,7 @@ namespace WebCore { class JavaScriptCallFrame : public RefCounted<JavaScriptCallFrame> { public: - static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1& textPosition) + static PassRefPtr<JavaScriptCallFrame> create(const JSC::DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition0& textPosition) { return adoptRef(new JavaScriptCallFrame(debuggerCallFrame, caller, sourceID, textPosition)); } @@ -55,10 +55,11 @@ public: JavaScriptCallFrame* caller(); intptr_t sourceID() const { return m_sourceID; } - int line() const { return m_textPosition.m_line.oneBasedInt(); } - int column() const { return m_textPosition.m_column.oneBasedInt(); } + const TextPosition0& position() const { return m_textPosition; } + int line() const { return m_textPosition.m_line.zeroBasedInt(); } + int column() const { return m_textPosition.m_column.zeroBasedInt(); } - void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, const TextPosition1& textPosition) + void update(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, const TextPosition0& textPosition) { m_debuggerCallFrame = debuggerCallFrame; m_textPosition = textPosition; @@ -68,19 +69,19 @@ public: String functionName() const; JSC::DebuggerCallFrame::Type type() const; - const JSC::ScopeChainNode* scopeChain() const; + JSC::ScopeChainNode* scopeChain() const; JSC::JSGlobalObject* dynamicGlobalObject() const; JSC::JSObject* thisObject() const; JSC::JSValue evaluate(const JSC::UString& script, JSC::JSValue& exception) const; private: - JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition1&); + JavaScriptCallFrame(const JSC::DebuggerCallFrame&, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition0&); JSC::DebuggerCallFrame m_debuggerCallFrame; RefPtr<JavaScriptCallFrame> m_caller; intptr_t m_sourceID; - TextPosition1 m_textPosition; + TextPosition0 m_textPosition; bool m_isValid; }; diff --git a/Source/WebCore/bindings/js/ScheduledAction.cpp b/Source/WebCore/bindings/js/ScheduledAction.cpp index d6f8a38..f623017 100644 --- a/Source/WebCore/bindings/js/ScheduledAction.cpp +++ b/Source/WebCore/bindings/js/ScheduledAction.cpp @@ -61,13 +61,13 @@ PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperW } ScheduledAction::ScheduledAction(ExecState* exec, JSValue function, DOMWrapperWorld* isolatedWorld) - : m_function(function) + : m_function(exec->globalData(), function) , m_isolatedWorld(isolatedWorld) { // setTimeout(function, interval, arg0, arg1...). // Start at 2 to skip function and interval. for (size_t i = 2; i < exec->argumentCount(); ++i) - m_args.append(exec->argument(i)); + m_args.append(Global<JSC::Unknown>(exec->globalData(), exec->argument(i))); } void ScheduledAction::execute(ScriptExecutionContext* context) @@ -99,13 +99,13 @@ void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSV MarkedArgumentBuffer args; size_t size = m_args.size(); for (size_t i = 0; i < size; ++i) - args.append(m_args[i]); + args.append(m_args[i].get()); globalObject->globalData().timeoutChecker.start(); if (context->isDocument()) - JSMainThreadExecState::call(exec, m_function, callType, callData, thisValue, args); + JSMainThreadExecState::call(exec, m_function.get(), callType, callData, thisValue, args); else - JSC::call(exec, m_function, callType, callData, thisValue, args); + JSC::call(exec, m_function.get(), callType, callData, thisValue, args); globalObject->globalData().timeoutChecker.stop(); if (exec->hadException()) diff --git a/Source/WebCore/bindings/js/ScheduledAction.h b/Source/WebCore/bindings/js/ScheduledAction.h index 59ad6fc..c4b3edf 100644 --- a/Source/WebCore/bindings/js/ScheduledAction.h +++ b/Source/WebCore/bindings/js/ScheduledAction.h @@ -22,8 +22,8 @@ #include "PlatformString.h" #include <JSDOMBinding.h> +#include <collector/handles/Global.h> #include <runtime/JSCell.h> -#include <runtime/Protect.h> #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> @@ -51,7 +51,8 @@ namespace WebCore { private: ScheduledAction(JSC::ExecState*, JSC::JSValue function, DOMWrapperWorld* isolatedWorld); ScheduledAction(const String& code, DOMWrapperWorld* isolatedWorld) - : m_code(code) + : m_function(*isolatedWorld->globalData()) + , m_code(code) , m_isolatedWorld(isolatedWorld) { } @@ -62,8 +63,8 @@ namespace WebCore { void execute(WorkerContext*); #endif - JSC::ProtectedJSValue m_function; - Vector<JSC::ProtectedJSValue> m_args; + JSC::Global<JSC::Unknown> m_function; + Vector<JSC::Global<JSC::Unknown> > m_args; String m_code; RefPtr<DOMWrapperWorld> m_isolatedWorld; }; diff --git a/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp b/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp index d65bce2..5a467f2 100644 --- a/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp +++ b/Source/WebCore/bindings/js/ScriptCachedFrameData.cpp @@ -54,7 +54,7 @@ ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame) ScriptController::ShellMap::iterator windowShellsEnd = windowShells.end(); for (ScriptController::ShellMap::iterator iter = windowShells.begin(); iter != windowShellsEnd; ++iter) { JSDOMWindow* window = iter->second->window(); - m_windows.add(iter->first.get(), window); + m_windows.add(iter->first.get(), Global<JSDOMWindow>(window->globalData(), window)); m_domWindow = window->impl(); } @@ -83,7 +83,7 @@ void ScriptCachedFrameData::restore(Frame* frame) DOMWrapperWorld* world = iter->first.get(); JSDOMWindowShell* windowShell = iter->second.get(); - if (JSDOMWindow* window = m_windows.get(world)) + if (JSDOMWindow* window = m_windows.get(world).get()) windowShell->setWindow(window->globalData(), window); else { windowShell->setWindow(frame->domWindow()); diff --git a/Source/WebCore/bindings/js/ScriptCachedFrameData.h b/Source/WebCore/bindings/js/ScriptCachedFrameData.h index 5f691d9..08874d5 100644 --- a/Source/WebCore/bindings/js/ScriptCachedFrameData.h +++ b/Source/WebCore/bindings/js/ScriptCachedFrameData.h @@ -32,7 +32,7 @@ #ifndef ScriptCachedFrameData_h #define ScriptCachedFrameData_h -#include <runtime/Protect.h> +#include <collector/handles/Global.h> namespace WebCore { class Frame; @@ -42,7 +42,7 @@ namespace WebCore { class ScriptCachedFrameData { WTF_MAKE_NONCOPYABLE(ScriptCachedFrameData); WTF_MAKE_FAST_ALLOCATED; - typedef HashMap< RefPtr<DOMWrapperWorld>, JSC::ProtectedPtr<JSDOMWindow> > JSDOMWindowSet; + typedef HashMap< RefPtr<DOMWrapperWorld>, JSC::Global<JSDOMWindow> > JSDOMWindowSet; public: ScriptCachedFrameData(Frame*); diff --git a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp b/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp index 94cd127..a266449 100644 --- a/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp +++ b/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp @@ -88,7 +88,7 @@ PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned Vector<ScriptValue> arguments; size_t argumentCount = exec->argumentCount(); for (size_t i = skipArgumentCount; i < argumentCount; ++i) - arguments.append(ScriptValue(exec->argument(i))); + arguments.append(ScriptValue(exec->globalData(), exec->argument(i))); return ScriptArguments::create(exec, arguments); } diff --git a/Source/WebCore/bindings/js/ScriptController.cpp b/Source/WebCore/bindings/js/ScriptController.cpp index e7eafd0..4b0f44f 100644 --- a/Source/WebCore/bindings/js/ScriptController.cpp +++ b/Source/WebCore/bindings/js/ScriptController.cpp @@ -108,10 +108,11 @@ void ScriptController::destroyWindowShell(DOMWrapperWorld* world) JSDOMWindowShell* ScriptController::createWindowShell(DOMWrapperWorld* world) { ASSERT(!m_windowShells.contains(world)); - JSDOMWindowShell* windowShell = new JSDOMWindowShell(m_frame->domWindow(), world); + Global<JSDOMWindowShell> windowShell(*world->globalData(), new JSDOMWindowShell(m_frame->domWindow(), world)); + Global<JSDOMWindowShell> windowShell2(windowShell); m_windowShells.add(world, windowShell); world->didCreateWindowShell(this); - return windowShell; + return windowShell.get(); } ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode, DOMWrapperWorld* world) @@ -149,14 +150,14 @@ ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode& sourceCode if (comp.complType() == Normal || comp.complType() == ReturnValue) { m_sourceURL = savedSourceURL; - return comp.value(); + return ScriptValue(exec->globalData(), comp.value()); } if (comp.complType() == Throw || comp.complType() == Interrupted) reportException(exec, comp.value()); m_sourceURL = savedSourceURL; - return JSValue(); + return ScriptValue(); } ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) @@ -182,7 +183,7 @@ void ScriptController::clearWindowShell(bool goingIntoPageCache) JSLock lock(SilenceAssertionsOnly); for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) { - JSDOMWindowShell* windowShell = iter->second; + JSDOMWindowShell* windowShell = iter->second.get(); // Clear the debugger from the current window before setting the new window. attachDebugger(windowShell, 0); @@ -317,7 +318,7 @@ bool ScriptController::canAccessFromCurrentOrigin(Frame *frame) void ScriptController::attachDebugger(JSC::Debugger* debugger) { for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter) - attachDebugger(iter->second, debugger); + attachDebugger(iter->second.get(), debugger); } void ScriptController::attachDebugger(JSDOMWindowShell* shell, JSC::Debugger* debugger) diff --git a/Source/WebCore/bindings/js/ScriptController.h b/Source/WebCore/bindings/js/ScriptController.h index 19542af..2ec3872 100644 --- a/Source/WebCore/bindings/js/ScriptController.h +++ b/Source/WebCore/bindings/js/ScriptController.h @@ -25,7 +25,7 @@ #include "JSDOMWindowShell.h" #include "ScriptControllerBase.h" #include "ScriptInstance.h" -#include <runtime/Protect.h> +#include <collector/handles/Global.h> #include <wtf/Forward.h> #include <wtf/RefPtr.h> @@ -64,7 +64,7 @@ typedef HashMap<void*, RefPtr<JSC::Bindings::RootObject> > RootObjectMap; class ScriptController { friend class ScriptCachedFrameData; - typedef WTF::HashMap< RefPtr<DOMWrapperWorld>, JSC::ProtectedPtr<JSDOMWindowShell> > ShellMap; + typedef WTF::HashMap< RefPtr<DOMWrapperWorld>, JSC::Global<JSDOMWindowShell> > ShellMap; public: ScriptController(Frame*); diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.cpp b/Source/WebCore/bindings/js/ScriptDebugServer.cpp index aed2ad4..32a3b2d 100644 --- a/Source/WebCore/bindings/js/ScriptDebugServer.cpp +++ b/Source/WebCore/bindings/js/ScriptDebugServer.cpp @@ -159,7 +159,7 @@ void ScriptDebugServer::removeBreakpoint(const String& breakpointId) it->second.remove(lineNumber + 1); } -bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, unsigned lineNumber) const +bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, const TextPosition0& position) const { if (!m_breakpointsActivated) return false; @@ -167,6 +167,9 @@ bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, unsigned lineNumber) co SourceIdToBreakpointsMap::const_iterator it = m_sourceIdToBreakpoints.find(sourceID); if (it == m_sourceIdToBreakpoints.end()) return false; + int lineNumber = position.m_line.convertAsOneBasedInt(); + if (lineNumber <= 0) + return false; LineToBreakpointMap::const_iterator breakIt = it->second.find(lineNumber); if (breakIt == it->second.end() || !breakIt->second.enabled) return false; @@ -405,10 +408,13 @@ void ScriptDebugServer::setJavaScriptPaused(Frame* frame, bool paused) frame->script()->setPaused(paused); Document* document = frame->document(); - if (paused) + if (paused) { + document->suspendScriptedAnimationControllerCallbacks(); document->suspendActiveDOMObjects(ActiveDOMObject::JavaScriptDebuggerPaused); - else + } else { document->resumeActiveDOMObjects(); + document->resumeScriptedAnimationControllerCallbacks(); + } setJavaScriptPaused(frame->view(), paused); } @@ -432,7 +438,7 @@ void ScriptDebugServer::setJavaScriptPaused(FrameView* view, bool paused) void ScriptDebugServer::createCallFrameAndPauseIfNeeded(const DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber) { - TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base()); + TextPosition0 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber).convertToZeroBased(), WTF::ZeroBasedNumber::base()); m_currentCallFrame = JavaScriptCallFrame::create(debuggerCallFrame, m_currentCallFrame, sourceID, textPosition); pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); } @@ -443,7 +449,7 @@ void ScriptDebugServer::updateCallFrameAndPauseIfNeeded(const DebuggerCallFrame& if (!m_currentCallFrame) return; - TextPosition1 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::base()); + TextPosition0 textPosition(WTF::OneBasedNumber::fromOneBasedInt(lineNumber).convertToZeroBased(), WTF::ZeroBasedNumber::base()); m_currentCallFrame->update(debuggerCallFrame, sourceID, textPosition); pauseIfNeeded(toPage(debuggerCallFrame.dynamicGlobalObject())); } @@ -458,7 +464,7 @@ void ScriptDebugServer::pauseIfNeeded(Page* page) bool pauseNow = m_pauseOnNextStatement; pauseNow |= (m_pauseOnCallFrame == m_currentCallFrame); - pauseNow |= (m_currentCallFrame->line() > 0 && hasBreakpoint(m_currentCallFrame->sourceID(), m_currentCallFrame->line())); + pauseNow |= hasBreakpoint(m_currentCallFrame->sourceID(), m_currentCallFrame->position()); if (!pauseNow) return; diff --git a/Source/WebCore/bindings/js/ScriptDebugServer.h b/Source/WebCore/bindings/js/ScriptDebugServer.h index 428b254..e7e8502 100644 --- a/Source/WebCore/bindings/js/ScriptDebugServer.h +++ b/Source/WebCore/bindings/js/ScriptDebugServer.h @@ -42,6 +42,7 @@ #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/RefPtr.h> +#include <wtf/text/TextPosition.h> namespace JSC { class DebuggerCallFrame; @@ -100,7 +101,7 @@ private: ScriptDebugServer(); ~ScriptDebugServer(); - bool hasBreakpoint(intptr_t sourceID, unsigned lineNumber) const; + bool hasBreakpoint(intptr_t sourceID, const TextPosition0& position) const; bool hasListenersInterestedInPage(Page*); void setJavaScriptPaused(const PageGroup&, bool paused); diff --git a/Source/WebCore/bindings/js/ScriptFunctionCall.cpp b/Source/WebCore/bindings/js/ScriptFunctionCall.cpp index f77c691..518a787 100644 --- a/Source/WebCore/bindings/js/ScriptFunctionCall.cpp +++ b/Source/WebCore/bindings/js/ScriptFunctionCall.cpp @@ -150,7 +150,7 @@ ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) return ScriptValue(); } - return ScriptValue(result); + return ScriptValue(m_exec->globalData(), result); } ScriptValue ScriptFunctionCall::call() @@ -220,7 +220,7 @@ ScriptValue ScriptCallback::call(bool& hadException) return ScriptValue(); } - return ScriptValue(result); + return ScriptValue(m_exec->globalData(), result); } } // namespace WebCore diff --git a/Source/WebCore/bindings/js/ScriptHeapSnapshot.h b/Source/WebCore/bindings/js/ScriptHeapSnapshot.h index 4c3d915..6b40e20 100644 --- a/Source/WebCore/bindings/js/ScriptHeapSnapshot.h +++ b/Source/WebCore/bindings/js/ScriptHeapSnapshot.h @@ -31,7 +31,6 @@ #ifndef ScriptHeapSnapshot_h #define ScriptHeapSnapshot_h -#include "InspectorValues.h" #include "PlatformString.h" namespace WebCore { @@ -51,6 +50,7 @@ public: unsigned int uid() const { return 0; } void writeJSON(OutputStream*) { } + int exactRetainedSize(uint64_t) { return -1; } private: ScriptHeapSnapshot() { } diff --git a/Source/WebCore/bindings/js/ScriptObject.cpp b/Source/WebCore/bindings/js/ScriptObject.cpp index b5c1f01..035597b 100644 --- a/Source/WebCore/bindings/js/ScriptObject.cpp +++ b/Source/WebCore/bindings/js/ScriptObject.cpp @@ -45,7 +45,7 @@ using namespace JSC; namespace WebCore { ScriptObject::ScriptObject(ScriptState* scriptState, JSObject* object) - : ScriptValue(object) + : ScriptValue(scriptState->globalData(), object) , m_scriptState(scriptState) { } diff --git a/Source/WebCore/bindings/js/ScriptObject.h b/Source/WebCore/bindings/js/ScriptObject.h index f085e8b..c10bf18 100644 --- a/Source/WebCore/bindings/js/ScriptObject.h +++ b/Source/WebCore/bindings/js/ScriptObject.h @@ -34,8 +34,8 @@ #include "ScriptState.h" #include "ScriptValue.h" +#include <collector/handles/Global.h> #include <runtime/JSObject.h> -#include <runtime/Protect.h> namespace WebCore { class InjectedScriptHost; diff --git a/Source/WebCore/bindings/js/ScriptState.cpp b/Source/WebCore/bindings/js/ScriptState.cpp index d6699f6..8a7c9a5 100644 --- a/Source/WebCore/bindings/js/ScriptState.cpp +++ b/Source/WebCore/bindings/js/ScriptState.cpp @@ -45,14 +45,14 @@ ScriptStateProtectedPtr::~ScriptStateProtectedPtr() } ScriptStateProtectedPtr::ScriptStateProtectedPtr(ScriptState* scriptState) - : m_globalObject(scriptState->lexicalGlobalObject()) + : m_globalObject(scriptState->globalData(), scriptState->lexicalGlobalObject()) { } ScriptState* ScriptStateProtectedPtr::get() const { if (m_globalObject) - return m_globalObject->globalExec(); + return const_cast<JSC::JSGlobalObject*>(m_globalObject.get())->globalExec(); return 0; } diff --git a/Source/WebCore/bindings/js/ScriptState.h b/Source/WebCore/bindings/js/ScriptState.h index e19c0c8..f27b306 100644 --- a/Source/WebCore/bindings/js/ScriptState.h +++ b/Source/WebCore/bindings/js/ScriptState.h @@ -32,7 +32,7 @@ #ifndef ScriptState_h #define ScriptState_h -#include <runtime/Protect.h> +#include <collector/handles/Global.h> #include <wtf/Noncopyable.h> namespace JSC { @@ -59,7 +59,7 @@ public: ~ScriptStateProtectedPtr(); ScriptState* get() const; private: - JSC::ProtectedPtr<JSC::JSGlobalObject> m_globalObject; + JSC::Global<JSC::JSGlobalObject> m_globalObject; }; ScriptState* mainWorldScriptState(Frame*); diff --git a/Source/WebCore/bindings/js/ScriptValue.cpp b/Source/WebCore/bindings/js/ScriptValue.cpp index a2a72b6..6fe6ea3 100644 --- a/Source/WebCore/bindings/js/ScriptValue.cpp +++ b/Source/WebCore/bindings/js/ScriptValue.cpp @@ -35,8 +35,8 @@ #include <JavaScriptCore/APICast.h> #include <JavaScriptCore/JSValueRef.h> +#include <collector/handles/Global.h> #include <runtime/JSLock.h> -#include <runtime/Protect.h> #include <runtime/UString.h> using namespace JSC; @@ -87,7 +87,7 @@ bool ScriptValue::isObject() const bool ScriptValue::isFunction() const { CallData callData; - return getCallData(m_value, callData) != CallTypeNone; + return getCallData(m_value.get(), callData) != CallTypeNone; } PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState) @@ -97,7 +97,7 @@ PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptStat ScriptValue ScriptValue::deserialize(ScriptState* scriptState, SerializedScriptValue* value) { - return ScriptValue(value->deserialize(scriptState, scriptState->lexicalGlobalObject())); + return ScriptValue(scriptState->globalData(), value->deserialize(scriptState, scriptState->lexicalGlobalObject())); } #if ENABLE(INSPECTOR) diff --git a/Source/WebCore/bindings/js/ScriptValue.h b/Source/WebCore/bindings/js/ScriptValue.h index 5746c3f..37cf243 100644 --- a/Source/WebCore/bindings/js/ScriptValue.h +++ b/Source/WebCore/bindings/js/ScriptValue.h @@ -34,8 +34,8 @@ #include "JSDOMBinding.h" #include "PlatformString.h" #include "ScriptState.h" +#include <collector/handles/Global.h> #include <runtime/JSValue.h> -#include <runtime/Protect.h> #include <wtf/PassRefPtr.h> namespace WebCore { @@ -45,7 +45,8 @@ class SerializedScriptValue; class ScriptValue { public: - ScriptValue(JSC::JSValue value = JSC::JSValue()) : m_value(value) {} + ScriptValue() : m_value(JSC::Global<JSC::Unknown>::EmptyValue) { } + ScriptValue(JSC::JSGlobalData& globalData, JSC::JSValue value) : m_value(globalData, value) {} virtual ~ScriptValue() {} JSC::JSValue jsValue() const { return m_value.get(); } @@ -56,21 +57,21 @@ public: bool isUndefined() const; bool isObject() const; bool isFunction() const; - bool hasNoValue() const { return m_value == JSC::JSValue(); } + bool hasNoValue() const { return m_value.isEmpty(); } bool operator==(const ScriptValue& other) const { return m_value == other.m_value; } PassRefPtr<SerializedScriptValue> serialize(ScriptState*); static ScriptValue deserialize(ScriptState*, SerializedScriptValue*); - static ScriptValue undefined() { return ScriptValue(JSC::jsUndefined()); } + static ScriptValue undefined(); #if ENABLE(INSPECTOR) PassRefPtr<InspectorValue> toInspectorValue(ScriptState*) const; #endif private: - JSC::ProtectedJSValue m_value; + JSC::Global<JSC::Unknown> m_value; }; } // namespace WebCore diff --git a/Source/WebCore/bindings/js/ScriptWrappable.h b/Source/WebCore/bindings/js/ScriptWrappable.h index c57796c..0fbe9e4 100644 --- a/Source/WebCore/bindings/js/ScriptWrappable.h +++ b/Source/WebCore/bindings/js/ScriptWrappable.h @@ -38,21 +38,20 @@ namespace WebCore { class ScriptWrappable { public: + ScriptWrappable() + { + } + DOMObject* wrapper() const { return m_wrapper.get(); } - - void setWrapper(DOMObject* wrapper) + + void setWrapper(JSC::JSGlobalData& globalData, DOMObject* wrapper) { - m_wrapper = wrapper; - } - - void clearWrapper(DOMObject* wrapper) - { - m_wrapper.clear(wrapper); + m_wrapper.set(globalData, wrapper, 0); } - + private: JSC::WeakGCPtr<DOMObject> m_wrapper; }; diff --git a/Source/WebCore/bindings/js/SerializedScriptValue.cpp b/Source/WebCore/bindings/js/SerializedScriptValue.cpp index f721334..b3d07ca 100644 --- a/Source/WebCore/bindings/js/SerializedScriptValue.cpp +++ b/Source/WebCore/bindings/js/SerializedScriptValue.cpp @@ -39,10 +39,10 @@ #include "SharedBuffer.h" #include <limits> #include <JavaScriptCore/APICast.h> +#include <JavaScriptCore/APIShims.h> #include <runtime/DateInstance.h> #include <runtime/Error.h> #include <runtime/ExceptionHelpers.h> -#include <runtime/JSLock.h> #include <runtime/PropertyNameArray.h> #include <runtime/RegExp.h> #include <runtime/RegExpObject.h> @@ -53,7 +53,7 @@ using namespace JSC; using namespace std; -#if CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN) +#if CPU(BIG_ENDIAN) || CPU(MIDDLE_ENDIAN) || CPU(NEEDS_ALIGNED_ACCESS) #define ASSUME_LITTLE_ENDIAN 0 #else #define ASSUME_LITTLE_ENDIAN 1 @@ -242,7 +242,7 @@ private: if (!value.isObject()) return false; JSObject* object = asObject(value); - return isJSArray(&m_exec->globalData(), object) || object->inherits(&JSArray::info); + return isJSArray(&m_exec->globalData(), object) || object->inherits(&JSArray::s_info); } bool startObjectInternal(JSObject* object) @@ -367,7 +367,7 @@ private: return true; } - if (value.isObject() && asObject(value)->inherits(&DateInstance::info)) { + if (value.isObject() && asObject(value)->inherits(&DateInstance::s_info)) { write(DateTag); write(asDateInstance(value)->internalNumber()); return true; @@ -409,7 +409,7 @@ private: write(data->data()->data()->data(), data->data()->length()); return true; } - if (obj->inherits(&RegExpObject::info)) { + if (obj->inherits(&RegExpObject::s_info)) { RegExpObject* regExp = asRegExpObject(obj); char flags[3]; int flagCount = 0; @@ -1381,8 +1381,8 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(String string) PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(JSContextRef originContext, JSValueRef apiValue, JSValueRef* exception) { - JSLock lock(SilenceAssertionsOnly); ExecState* exec = toJS(originContext); + APIEntryShim entryShim(exec); JSValue value = toJS(exec, apiValue); PassRefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(exec, value); if (exec->hadException()) { @@ -1407,8 +1407,8 @@ JSValue SerializedScriptValue::deserialize(ExecState* exec, JSGlobalObject* glob JSValueRef SerializedScriptValue::deserialize(JSContextRef destinationContext, JSValueRef* exception) { - JSLock lock(SilenceAssertionsOnly); ExecState* exec = toJS(destinationContext); + APIEntryShim entryShim(exec); JSValue value = deserialize(exec, exec->lexicalGlobalObject()); if (exec->hadException()) { if (exception) diff --git a/Source/WebCore/bindings/js/WorkerScriptController.cpp b/Source/WebCore/bindings/js/WorkerScriptController.cpp index 0c89632..d392281 100644 --- a/Source/WebCore/bindings/js/WorkerScriptController.cpp +++ b/Source/WebCore/bindings/js/WorkerScriptController.cpp @@ -52,6 +52,7 @@ namespace WebCore { WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) : m_globalData(JSGlobalData::create(ThreadStackTypeSmall)) , m_workerContext(workerContext) + , m_workerContextWrapper(*m_globalData) , m_executionForbidden(false) { initNormalWorldClientData(m_globalData.get()); @@ -59,7 +60,7 @@ WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) WorkerScriptController::~WorkerScriptController() { - m_workerContextWrapper = 0; // Unprotect the global object. + m_workerContextWrapper.clear(); // Unprotect the global object. m_globalData->heap.destroy(); } @@ -73,26 +74,26 @@ void WorkerScriptController::initScript() // when we allocate the global object. (Once the global object is fully // constructed, it can mark its own prototype.) RefPtr<Structure> workerContextPrototypeStructure = JSWorkerContextPrototype::createStructure(jsNull()); - ProtectedPtr<JSWorkerContextPrototype> workerContextPrototype = new (m_globalData.get()) JSWorkerContextPrototype(0, workerContextPrototypeStructure.release()); + Global<JSWorkerContextPrototype> workerContextPrototype(*m_globalData, new (m_globalData.get()) JSWorkerContextPrototype(0, workerContextPrototypeStructure.release())); if (m_workerContext->isDedicatedWorkerContext()) { - RefPtr<Structure> dedicatedContextPrototypeStructure = JSDedicatedWorkerContextPrototype::createStructure(workerContextPrototype); - ProtectedPtr<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype = new (m_globalData.get()) JSDedicatedWorkerContextPrototype(0, dedicatedContextPrototypeStructure.release()); - RefPtr<Structure> structure = JSDedicatedWorkerContext::createStructure(dedicatedContextPrototype); + RefPtr<Structure> dedicatedContextPrototypeStructure = JSDedicatedWorkerContextPrototype::createStructure(workerContextPrototype.get()); + Global<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype(*m_globalData, new (m_globalData.get()) JSDedicatedWorkerContextPrototype(0, dedicatedContextPrototypeStructure.release())); + RefPtr<Structure> structure = JSDedicatedWorkerContext::createStructure(dedicatedContextPrototype.get()); - m_workerContextWrapper = new (m_globalData.get()) JSDedicatedWorkerContext(structure.release(), m_workerContext->toDedicatedWorkerContext()); - workerContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper); - dedicatedContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper); + m_workerContextWrapper.set(*m_globalData, new (m_globalData.get()) JSDedicatedWorkerContext(structure.release(), m_workerContext->toDedicatedWorkerContext())); + workerContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get()); + dedicatedContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get()); #if ENABLE(SHARED_WORKERS) } else { ASSERT(m_workerContext->isSharedWorkerContext()); - RefPtr<Structure> sharedContextPrototypeStructure = JSSharedWorkerContextPrototype::createStructure(workerContextPrototype); - ProtectedPtr<JSSharedWorkerContextPrototype> sharedContextPrototype = new (m_globalData.get()) JSSharedWorkerContextPrototype(0, sharedContextPrototypeStructure.release()); - RefPtr<Structure> structure = JSSharedWorkerContext::createStructure(sharedContextPrototype); + RefPtr<Structure> sharedContextPrototypeStructure = JSSharedWorkerContextPrototype::createStructure(workerContextPrototype.get()); + Global<JSSharedWorkerContextPrototype> sharedContextPrototype(*m_globalData, new (m_globalData.get()) JSSharedWorkerContextPrototype(0, sharedContextPrototypeStructure.release())); + RefPtr<Structure> structure = JSSharedWorkerContext::createStructure(sharedContextPrototype.get()); - m_workerContextWrapper = new (m_globalData.get()) JSSharedWorkerContext(structure.release(), m_workerContext->toSharedWorkerContext()); - workerContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper); - sharedContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper); + m_workerContextWrapper.set(*m_globalData, new (m_globalData.get()) JSSharedWorkerContext(structure.release(), m_workerContext->toSharedWorkerContext())); + workerContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get()); + sharedContextPrototype->putAnonymousValue(*m_globalData, 0, m_workerContextWrapper.get()); #endif } } @@ -102,10 +103,10 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) { MutexLocker lock(m_sharedDataMutex); if (m_executionForbidden) - return JSValue(); + return ScriptValue(); } ScriptValue exception; - ScriptValue result = evaluate(sourceCode, &exception); + ScriptValue result(evaluate(sourceCode, &exception)); if (exception.jsValue()) { JSLock lock(SilenceAssertionsOnly); reportException(m_workerContextWrapper->globalExec(), exception.jsValue()); @@ -118,7 +119,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, { MutexLocker lock(m_sharedDataMutex); if (m_executionForbidden) - return JSValue(); + return ScriptValue(); } initScriptIfNeeded(); @@ -126,22 +127,22 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, ExecState* exec = m_workerContextWrapper->globalExec(); m_workerContextWrapper->globalData().timeoutChecker.start(); - Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper); + Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper.get()); m_workerContextWrapper->globalData().timeoutChecker.stop(); if (comp.complType() == Normal || comp.complType() == ReturnValue) - return comp.value(); + return ScriptValue(*m_globalData, comp.value()); if (comp.complType() == Throw) { String errorMessage; int lineNumber = 0; String sourceURL = sourceCode.url().string(); if (m_workerContext->sanitizeScriptError(errorMessage, lineNumber, sourceURL)) - *exception = ScriptValue(throwError(exec, createError(exec, errorMessage.impl()))); + *exception = ScriptValue(*m_globalData, throwError(exec, createError(exec, errorMessage.impl()))); else - *exception = comp.value(); + *exception = ScriptValue(*m_globalData, comp.value()); } - return JSValue(); + return ScriptValue(); } void WorkerScriptController::setException(ScriptValue exception) diff --git a/Source/WebCore/bindings/js/WorkerScriptController.h b/Source/WebCore/bindings/js/WorkerScriptController.h index 4578913..c3b8215 100644 --- a/Source/WebCore/bindings/js/WorkerScriptController.h +++ b/Source/WebCore/bindings/js/WorkerScriptController.h @@ -29,7 +29,7 @@ #if ENABLE(WORKERS) -#include <runtime/Protect.h> +#include <collector/handles/Global.h> #include <wtf/Forward.h> #include <wtf/Threading.h> @@ -53,7 +53,7 @@ namespace WebCore { JSWorkerContext* workerContextWrapper() { initScriptIfNeeded(); - return m_workerContextWrapper; + return m_workerContextWrapper.get(); } ScriptValue evaluate(const ScriptSourceCode&); @@ -77,7 +77,7 @@ namespace WebCore { RefPtr<JSC::JSGlobalData> m_globalData; WorkerContext* m_workerContext; - JSC::ProtectedPtr<JSWorkerContext> m_workerContextWrapper; + JSC::Global<JSWorkerContext> m_workerContextWrapper; Mutex m_sharedDataMutex; bool m_executionForbidden; diff --git a/Source/WebCore/bindings/objc/WebScriptObject.mm b/Source/WebCore/bindings/objc/WebScriptObject.mm index ba28d85..d2ef25d 100644 --- a/Source/WebCore/bindings/objc/WebScriptObject.mm +++ b/Source/WebCore/bindings/objc/WebScriptObject.mm @@ -649,13 +649,13 @@ static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* root return self; } -- (void)release +- (oneway void)release { } - (NSUInteger)retainCount { - return UINT_MAX; + return NSUIntegerMax; } - (id)autorelease diff --git a/Source/WebCore/bindings/scripts/CodeGenerator.pm b/Source/WebCore/bindings/scripts/CodeGenerator.pm index 9a9e9d7..7eb676f 100644 --- a/Source/WebCore/bindings/scripts/CodeGenerator.pm +++ b/Source/WebCore/bindings/scripts/CodeGenerator.pm @@ -52,7 +52,7 @@ my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1); my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1); -my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1, "SVGPaintType" => 1); +my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1); my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, "SVGAnimatedEnumeration" => 1, "SVGAnimatedInteger" => 1, diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm index d2309e9..cb51c8a 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -689,9 +689,6 @@ sub GenerateHeader push(@headerContent, " $className(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<$implType>);\n"); } - # Destructor - push(@headerContent, " virtual ~$className();\n") if (!$hasParent or $eventTarget or $interfaceName eq "DOMWindow"); - # Prototype push(@headerContent, " static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*);\n") unless ($dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}); @@ -741,7 +738,6 @@ sub GenerateHeader } # Class info - push(@headerContent, " virtual const JSC::ClassInfo* classInfo() const { return &s_info; }\n"); push(@headerContent, " static const JSC::ClassInfo s_info;\n\n"); # Structure ID @@ -752,7 +748,7 @@ sub GenerateHeader push(@headerContent, " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" . " {\n" . - " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n" . + " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);\n" . " }\n\n"); # markChildren function @@ -762,7 +758,7 @@ sub GenerateHeader } # Custom pushEventHandlerScope function - push(@headerContent, " virtual void pushEventHandlerScope(JSC::ExecState*, JSC::ScopeChain&) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"}; + push(@headerContent, " virtual JSC::ScopeChainNode* pushEventHandlerScope(JSC::ExecState*, JSC::ScopeChainNode*) const;\n\n") if $dataNode->extendedAttributes->{"CustomPushEventHandlerScope"}; # Custom call functions push(@headerContent, " virtual JSC::CallType getCallData(JSC::CallData&);\n\n") if $dataNode->extendedAttributes->{"CustomCall"}; @@ -950,7 +946,6 @@ sub GenerateHeader } else { push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n"); } - push(@headerContent, " virtual const JSC::ClassInfo* classInfo() const { return &s_info; }\n"); push(@headerContent, " static const JSC::ClassInfo s_info;\n"); if ($numFunctions > 0 || $numConstants > 0 || $dataNode->extendedAttributes->{"DelegatingPrototypeGetOwnPropertySlot"}) { push(@headerContent, " virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n"); @@ -965,7 +960,7 @@ sub GenerateHeader push(@headerContent, " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n" . " {\n" . - " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n" . + " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);\n" . " }\n"); if ($dataNode->extendedAttributes->{"DelegatingPrototypePutFunction"}) { push(@headerContent, " virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);\n"); @@ -1310,9 +1305,9 @@ sub GenerateImplementation push(@implContent, "{\n"); push(@implContent, " return getHashTableForGlobalData(exec->globalData(), &${className}PrototypeTable);\n"); push(@implContent, "}\n"); - push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", 0, 0, get${className}PrototypeTable };\n\n"); + push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", &JSC::JSObjectWithGlobalObject::s_info, 0, get${className}PrototypeTable };\n\n"); } else { - push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", 0, &${className}PrototypeTable, 0 };\n\n"); + push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", &JSC::JSObjectWithGlobalObject::s_info, &${className}PrototypeTable, 0 };\n\n"); } if ($interfaceName eq "DOMWindow") { push(@implContent, "void* ${className}Prototype::operator new(size_t size)\n"); @@ -1386,12 +1381,8 @@ sub GenerateImplementation push(@implContent, " return getHashTableForGlobalData(exec->globalData(), &${className}Table);\n"); push(@implContent, "}\n"); } - push(@implContent, "const ClassInfo $className" . "::s_info = { \"${visibleClassName}\", "); - if ($hasParent) { - push(@implContent, "&" . $parentClassName . "::s_info, "); - } else { - push(@implContent, "0, "); - } + + push(@implContent, "const ClassInfo $className" . "::s_info = { \"${visibleClassName}\", &" . $parentClassName . "::s_info, "); if ($numAttributes > 0 && !$dataNode->extendedAttributes->{"NoStaticTables"}) { push(@implContent, "&${className}Table"); @@ -1432,33 +1423,13 @@ sub GenerateImplementation } } push(@implContent, "{\n"); + push(@implContent, " ASSERT(inherits(&s_info));\n"); if ($numCachedAttributes > 0) { push(@implContent, " for (unsigned i = Base::AnonymousSlotCount; i < AnonymousSlotCount; i++)\n"); push(@implContent, " putAnonymousValue(globalObject->globalData(), i, JSValue());\n"); } push(@implContent, "}\n\n"); - # Destructor - if (!$hasParent || $eventTarget) { - push(@implContent, "${className}::~$className()\n"); - push(@implContent, "{\n"); - - if ($eventTarget) { - $implIncludes{"RegisteredEventListener.h"} = 1; - push(@implContent, " impl()->invalidateJSEventListeners(this);\n"); - } - - if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) { - if ($interfaceName eq "Node") { - push(@implContent, " forgetDOMNode(this, impl(), impl()->document());\n"); - } else { - push(@implContent, " forgetDOMObject(this, impl());\n"); - } - } - - push(@implContent, "}\n\n"); - } - if ($needsMarkChildren && !$dataNode->extendedAttributes->{"CustomMarkFunction"}) { push(@implContent, "void ${className}::markChildren(MarkStack& markStack)\n"); push(@implContent, "{\n"); @@ -2039,7 +2010,7 @@ sub GenerateImplementation } } - push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "exec->argument($argsIndex)") . ";\n"); + push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name(" . JSValueToNative($parameter, "exec->argument($argsIndex)") . ");\n"); # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception. # But this needs to be done in the bindings, because the type is unsigned and the fact that it @@ -2398,7 +2369,6 @@ my %nativeType = ( "NodeFilter" => "RefPtr<NodeFilter>", "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", "IDBKey" => "RefPtr<IDBKey>", - "SVGPaintType" => "SVGPaint::SVGPaintType", "boolean" => "bool", "double" => "double", "float" => "float", @@ -2485,7 +2455,6 @@ sub JSValueToNative return "valueToDate(exec, $value)" if $type eq "Date"; return "static_cast<Range::CompareHow>($value.toInt32(exec))" if $type eq "CompareHow"; - return "static_cast<SVGPaint::SVGPaintType>($value.toInt32(exec))" if $type eq "SVGPaintType"; if ($type eq "DOMString") { return "valueToStringWithNullCheck(exec, $value)" if $signature->extendedAttributes->{"ConvertNullToNullString"} || $signature->extendedAttributes->{"Reflect"}; @@ -2494,12 +2463,12 @@ sub JSValueToNative } if ($type eq "DOMObject") { - return "$value"; + return "exec->globalData(), $value"; } if ($type eq "MediaQueryListListener") { $implIncludes{"MediaQueryListListener.h"} = 1; - return "MediaQueryListListener::create(" . $value .")"; + return "MediaQueryListListener::create(ScriptValue(exec->globalData(), " . $value ."))"; } if ($type eq "SerializedScriptValue" or $type eq "any") { @@ -2544,7 +2513,7 @@ sub NativeToJSValue return "jsNumber(std::max(0, " . $value . "))"; } - if ($codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType" or $type eq "DOMTimeStamp") { + if ($codeGenerator->IsPrimitiveType($type) or $type eq "DOMTimeStamp") { $implIncludes{"<runtime/JSNumberCell.h>"} = 1; return "jsNumber($value)"; } @@ -2902,12 +2871,11 @@ sub GenerateConstructorDeclaration push(@$outputArray, " virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);\n"); push(@$outputArray, " virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);\n"); - push(@$outputArray, " virtual const JSC::ClassInfo* classInfo() const { return &s_info; }\n"); push(@$outputArray, " static const JSC::ClassInfo s_info;\n"); push(@$outputArray, " static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)\n"); push(@$outputArray, " {\n"); - push(@$outputArray, " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);\n"); + push(@$outputArray, " return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);\n"); push(@$outputArray, " }\n"); push(@$outputArray, "protected:\n"); @@ -2936,11 +2904,12 @@ sub GenerateConstructorDefinition my $callWith = $dataNode->extendedAttributes->{"CallWith"}; my $numberOfconstructParameters = $dataNode->extendedAttributes->{"ConstructorParameters"}; - push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleClassName}Constructor\", 0, &${constructorClassName}Table, 0 };\n\n"); + push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleClassName}Constructor\", &DOMConstructorObject::s_info, &${constructorClassName}Table, 0 };\n\n"); push(@$outputArray, "${constructorClassName}::${constructorClassName}(ExecState* exec, JSDOMGlobalObject* globalObject)\n"); push(@$outputArray, " : DOMConstructorObject(${constructorClassName}::createStructure(globalObject->objectPrototype()), globalObject)\n"); push(@$outputArray, "{\n"); + push(@$outputArray, " ASSERT(inherits(&s_info));\n"); if ($interfaceName eq "DOMWindow") { push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().prototype, globalObject->prototype(), DontDelete | ReadOnly);\n"); } else { diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 6ccebf9..a032a71 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -474,7 +474,7 @@ sub GetObjCType return "id <$name>" if IsProtocolType($type); return $name if $codeGenerator->IsPrimitiveType($type) or $type eq "DOMTimeStamp"; - return "unsigned short" if $type eq "CompareHow" or $type eq "SVGPaintType"; + return "unsigned short" if $type eq "CompareHow"; return "$name *"; } @@ -492,7 +492,7 @@ sub GetPropertyAttributes push(@attributes, "copy"); } elsif ($codeGenerator->IsSVGAnimatedType($type)) { push(@attributes, "retain"); - } elsif (!$codeGenerator->IsStringType($type) && !$codeGenerator->IsPrimitiveType($type) && $type ne "DOMTimeStamp" && $type ne "CompareHow" && $type ne "SVGPaintType") { + } elsif (!$codeGenerator->IsStringType($type) && !$codeGenerator->IsPrimitiveType($type) && $type ne "DOMTimeStamp" && $type ne "CompareHow") { push(@attributes, "retain"); } @@ -515,7 +515,6 @@ sub GetObjCTypeGetter return $argName if $codeGenerator->IsPrimitiveType($type) or $codeGenerator->IsStringType($type) or IsNativeObjCType($type); return $argName . "Node" if $type eq "EventTarget"; return "static_cast<WebCore::Range::CompareHow>($argName)" if $type eq "CompareHow"; - return "static_cast<WebCore::SVGPaint::SVGPaintType>($argName)" if $type eq "SVGPaintType"; return "WTF::getPtr(nativeEventListener)" if $type eq "EventListener"; return "WTF::getPtr(nativeNodeFilter)" if $type eq "NodeFilter"; return "WTF::getPtr(nativeResolver)" if $type eq "XPathNSResolver"; diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm index f393230..df1c04a 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -247,7 +247,11 @@ sub GenerateHeader my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGPropertyTypes($implClassName); foreach my $headerInclude (sort keys(%headerIncludes)) { - push(@headerContent, "#include \"${headerInclude}\"\n"); + if ($headerInclude =~ /wtf/) { + push(@headerContent, "#include \<${headerInclude}\>\n"); + } else { + push(@headerContent, "#include \"${headerInclude}\"\n"); + } } push(@headerContent, "#include <v8.h>\n"); @@ -367,16 +371,14 @@ END v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) { END - if ($domMapFunction) { - push(@headerContent, " if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName); - my $getWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getWrapper(impl)" : "${domMapFunction}.get(impl)"; - push(@headerContent, <<END); + push(@headerContent, " if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName); + my $getWrapper = IsNodeSubType($dataNode) ? "V8DOMWrapper::getWrapper(impl)" : "${domMapFunction}.get(impl)"; + push(@headerContent, <<END); v8::Handle<v8::Object> wrapper = ${getWrapper}; if (!wrapper.IsEmpty()) return wrapper; END - push(@headerContent, " }\n") if IsDOMNodeType($interfaceName); - } + push(@headerContent, " }\n") if IsDOMNodeType($interfaceName); push(@headerContent, <<END); return ${className}::wrapSlow(impl); } @@ -1832,7 +1834,7 @@ sub GenerateImplementation } my $has_attributes = 0; - if (@$attributes) { + if (@$attributes && (@$attributes > 1 || $$attributes[0]->signature->type ne "SerializedScriptValue")) { $has_attributes = 1; push(@implContent, "static const BatchedAttribute ${interfaceName}Attrs[] = {\n"); GenerateBatchedAttributeData($dataNode, $attributes); @@ -1976,7 +1978,9 @@ END } else { push(@implContent, <<END); 0, 0); + UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. END + $implIncludes{"wtf/UnusedParam.h"} = 1; } if ($dataNode->extendedAttributes->{"CustomConstructor"} || $dataNode->extendedAttributes->{"V8CustomConstructor"} || $dataNode->extendedAttributes->{"CanBeConstructed"}) { @@ -2501,11 +2505,9 @@ END END } - if ($domMapFunction) { - push(@implContent, <<END); + push(@implContent, <<END); ${domMapFunction}.set(impl, v8::Persistent<v8::Object>::New(wrapper)); END - } push(@implContent, <<END); return wrapper; @@ -2549,7 +2551,6 @@ sub GetDomMapFunction my $type = shift; return "getDOMSVGElementInstanceMap()" if $type eq "SVGElementInstance"; return "getDOMNodeMap()" if ($dataNode && IsNodeSubType($dataNode)); - return "" if $type eq "DOMImplementation"; return "getActiveDOMObjectMap()" if IsActiveDomType($type); return "getDOMObjectMap()"; } @@ -2809,7 +2810,6 @@ sub GetNativeType return "bool" if $type eq "boolean"; return "String" if $type eq "DOMString"; return "Range::CompareHow" if $type eq "CompareHow"; - return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType"; return "DOMTimeStamp" if $type eq "DOMTimeStamp"; return "unsigned" if $type eq "unsigned int"; return "Node*" if $type eq "EventTarget" and $isParameter; @@ -2886,7 +2886,6 @@ sub JSValueToNative return "toUInt32($value)" if $type eq "unsigned long" or $type eq "unsigned short"; return "toInt64($value)" if $type eq "unsigned long long" or $type eq "long long"; return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "CompareHow"; - return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())" if $type eq "SVGPaintType"; return "toWebCoreDate($value)" if $type eq "Date"; return "v8ValueToWebCoreDOMStringList($value)" if $type eq "DOMStringList"; @@ -3040,7 +3039,6 @@ my %non_wrapper_types = ( 'DOMString' => 1, 'CompareHow' => 1, 'SerializedScriptValue' => 1, - 'SVGPaintType' => 1, 'DOMTimeStamp' => 1, 'JSObject' => 1, 'DOMObject' => 1, @@ -3117,7 +3115,7 @@ sub NativeToJSValue return "v8DateOrNull($value)" if $type eq "Date"; # long long and unsigned long long are not representable in ECMAScript. return "v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp"; - return "v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType"; + return "v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type); return "$value.v8Value()" if $nativeType eq "ScriptValue"; if ($codeGenerator->IsStringType($type)) { diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.cpp new file mode 100644 index 0000000..e16af2d --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.cpp @@ -0,0 +1,96 @@ +/* + * 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" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "WebDOMTestSerializedScriptValueInterface.h" + +#include "SerializedScriptValue.h" +#include "TestSerializedScriptValueInterface.h" +#include "WebExceptionHandler.h" +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> + +struct WebDOMTestSerializedScriptValueInterface::WebDOMTestSerializedScriptValueInterfacePrivate { + WebDOMTestSerializedScriptValueInterfacePrivate(WebCore::TestSerializedScriptValueInterface* object = 0) + : impl(object) + { + } + + RefPtr<WebCore::TestSerializedScriptValueInterface> impl; +}; + +WebDOMTestSerializedScriptValueInterface::WebDOMTestSerializedScriptValueInterface() + : WebDOMObject() + , m_impl(0) +{ +} + +WebDOMTestSerializedScriptValueInterface::WebDOMTestSerializedScriptValueInterface(WebCore::TestSerializedScriptValueInterface* impl) + : WebDOMObject() + , m_impl(new WebDOMTestSerializedScriptValueInterfacePrivate(impl)) +{ +} + +WebDOMTestSerializedScriptValueInterface::WebDOMTestSerializedScriptValueInterface(const WebDOMTestSerializedScriptValueInterface& copy) + : WebDOMObject() +{ + m_impl = copy.impl() ? new WebDOMTestSerializedScriptValueInterfacePrivate(copy.impl()) : 0; +} + +WebDOMTestSerializedScriptValueInterface& WebDOMTestSerializedScriptValueInterface::operator=(const WebDOMTestSerializedScriptValueInterface& copy) +{ + delete m_impl; + m_impl = copy.impl() ? new WebDOMTestSerializedScriptValueInterfacePrivate(copy.impl()) : 0; + return *this; +} + +WebCore::TestSerializedScriptValueInterface* WebDOMTestSerializedScriptValueInterface::impl() const +{ + return m_impl ? m_impl->impl.get() : 0; +} + +WebDOMTestSerializedScriptValueInterface::~WebDOMTestSerializedScriptValueInterface() +{ + delete m_impl; + m_impl = 0; +} + +WebDOMString WebDOMTestSerializedScriptValueInterface::value() const +{ + if (!impl()) + return WebDOMString(); + + return impl()->value()->toString(); +} + +WebCore::TestSerializedScriptValueInterface* toWebCore(const WebDOMTestSerializedScriptValueInterface& wrapper) +{ + return wrapper.impl(); +} + +WebDOMTestSerializedScriptValueInterface toWebKit(WebCore::TestSerializedScriptValueInterface* value) +{ + return WebDOMTestSerializedScriptValueInterface(value); +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.h new file mode 100644 index 0000000..f0daf55 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/CPP/WebDOMTestSerializedScriptValueInterface.h @@ -0,0 +1,59 @@ +/* + * 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 WebDOMTestSerializedScriptValueInterface_h +#define WebDOMTestSerializedScriptValueInterface_h + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include <WebDOMObject.h> +#include <WebDOMString.h> + +namespace WebCore { +class TestSerializedScriptValueInterface; +}; + +class WebDOMString; + +class WebDOMTestSerializedScriptValueInterface : public WebDOMObject { +public: + WebDOMTestSerializedScriptValueInterface(); + explicit WebDOMTestSerializedScriptValueInterface(WebCore::TestSerializedScriptValueInterface*); + WebDOMTestSerializedScriptValueInterface(const WebDOMTestSerializedScriptValueInterface&); + WebDOMTestSerializedScriptValueInterface& operator=(const WebDOMTestSerializedScriptValueInterface&); + virtual ~WebDOMTestSerializedScriptValueInterface(); + + WebDOMString value() const; + + WebCore::TestSerializedScriptValueInterface* impl() const; + +protected: + struct WebDOMTestSerializedScriptValueInterfacePrivate; + WebDOMTestSerializedScriptValueInterfacePrivate* m_impl; +}; + +WebCore::TestSerializedScriptValueInterface* toWebCore(const WebDOMTestSerializedScriptValueInterface&); +WebDOMTestSerializedScriptValueInterface toWebKit(WebCore::TestSerializedScriptValueInterface*); + +#endif +#endif // ENABLE(Condition1) || ENABLE(Condition2) + diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.cpp new file mode 100644 index 0000000..7592b02 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.cpp @@ -0,0 +1,181 @@ +/* + 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 <glib-object.h> +#include "config.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "DOMObjectCache.h" +#include "ExceptionCode.h" +#include "JSMainThreadExecState.h" +#include "SerializedScriptValue.h" +#include "TestSerializedScriptValueInterface.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.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" + +namespace WebKit { + +WebKitDOMTestSerializedScriptValueInterface* kit(WebCore::TestSerializedScriptValueInterface* obj) +{ + g_return_val_if_fail(obj, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return static_cast<WebKitDOMTestSerializedScriptValueInterface*>(ret); + + return static_cast<WebKitDOMTestSerializedScriptValueInterface*>(DOMObjectCache::put(obj, WebKit::wrapTestSerializedScriptValueInterface(obj))); +} + +} // namespace WebKit // + +WebKitDOMSerializedScriptValue* +webkit_dom_test_serialized_script_value_interface_get_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->value()); + WebKitDOMSerializedScriptValue* res = WebKit::kit(g_res.get()); + return res; +} + + +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); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, + PROP_VALUE, +}; + + +static void webkit_dom_test_serialized_script_value_interface_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject) { + WebCore::TestSerializedScriptValueInterface* coreObject = static_cast<WebCore::TestSerializedScriptValueInterface *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + 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) +{ + WebCore::JSMainThreadNullState state; + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_serialized_script_value_interface_get_property(GObject* object, guint prop_id, 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: + { + RefPtr<WebCore::SerializedScriptValue> ptr = coreSelf->value(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_serialized_script_value_interface_constructed(GObject* object) +{ + + if (G_OBJECT_CLASS(webkit_dom_test_serialized_script_value_interface_parent_class)->constructed) + G_OBJECT_CLASS(webkit_dom_test_serialized_script_value_interface_parent_class)->constructed(object); +} + +static void webkit_dom_test_serialized_script_value_interface_class_init(WebKitDOMTestSerializedScriptValueInterfaceClass* 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; + gobjectClass->constructed = webkit_dom_test_serialized_script_value_interface_constructed; + + g_object_class_install_property(gobjectClass, + PROP_VALUE, + g_param_spec_object("value", /* name */ + "test_serialized_script_value_interface_value", /* short description */ + "read-only WebKitDOMSerializedScriptValue* TestSerializedScriptValueInterface.value", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_SERIALIZED_SCRIPT_VALUE, /* gobject type */ + WEBKIT_PARAM_READABLE)); + + +} + +static void webkit_dom_test_serialized_script_value_interface_init(WebKitDOMTestSerializedScriptValueInterface* request) +{ +} + +namespace WebKit { +WebKitDOMTestSerializedScriptValueInterface* wrapTestSerializedScriptValueInterface(WebCore::TestSerializedScriptValueInterface* 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_SERIALIZED_SCRIPT_VALUE_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE, + "core-object", coreObject, NULL)); +} +} // namespace WebKit +#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 new file mode 100644 index 0000000..4bcc755 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterface.h @@ -0,0 +1,54 @@ +/* + 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 WebKitDOMTestSerializedScriptValueInterface_h +#define WebKitDOMTestSerializedScriptValueInterface_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE (webkit_dom_test_serialized_script_value_interface_get_type()) +#define WEBKIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE, WebKitDOMTestSerializedScriptValueInterface)) +#define WEBKIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE, WebKitDOMTestSerializedScriptValueInterfaceClass) +#define WEBKIT_DOM_IS_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE)) +#define WEBKIT_DOM_IS_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE)) +#define WEBKIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE, WebKitDOMTestSerializedScriptValueInterfaceClass)) + +struct _WebKitDOMTestSerializedScriptValueInterface { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestSerializedScriptValueInterfaceClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_serialized_script_value_interface_get_type (void); + +WEBKIT_API WebKitDOMSerializedScriptValue* +webkit_dom_test_serialized_script_value_interface_get_value(WebKitDOMTestSerializedScriptValueInterface* self); + +G_END_DECLS + +#endif /* WebKitDOMTestSerializedScriptValueInterface_h */ diff --git a/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterfacePrivate.h b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterfacePrivate.h new file mode 100644 index 0000000..82e79a2 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestSerializedScriptValueInterfacePrivate.h @@ -0,0 +1,39 @@ +/* + 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 WEB_KIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_PRIVATE_H +#define WEB_KIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_PRIVATE_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); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_SERIALIZED_SCRIPT_VALUE_INTERFACE_PRIVATE_H */ diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp index 684f587..8d519f5 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -68,11 +68,10 @@ public: virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } protected: static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; @@ -80,12 +79,13 @@ protected: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); }; -const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", 0, &JSTestInterfaceConstructorTable, 0 }; +const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", &DOMConstructorObject::s_info, &JSTestInterfaceConstructorTable, 0 }; JSTestInterfaceConstructor::JSTestInterfaceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorObject(JSTestInterfaceConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly); } bool JSTestInterfaceConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -126,24 +126,20 @@ static const HashTableValue JSTestInterfacePrototypeTableValues[1] = #undef THUNK_GENERATOR static JSC_CONST_HASHTABLE HashTable JSTestInterfacePrototypeTable = { 1, 0, JSTestInterfacePrototypeTableValues, 0 }; -const ClassInfo JSTestInterfacePrototype::s_info = { "TestInterfacePrototype", 0, &JSTestInterfacePrototypeTable, 0 }; +const ClassInfo JSTestInterfacePrototype::s_info = { "TestInterfacePrototype", &JSC::JSObjectWithGlobalObject::s_info, &JSTestInterfacePrototypeTable, 0 }; JSObject* JSTestInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject) { return getDOMPrototype<JSTestInterface>(exec, globalObject); } -const ClassInfo JSTestInterface::s_info = { "TestInterface", 0, &JSTestInterfaceTable, 0 }; +const ClassInfo JSTestInterface::s_info = { "TestInterface", &DOMObjectWithGlobalPointer::s_info, &JSTestInterfaceTable, 0 }; JSTestInterface::JSTestInterface(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestInterface> impl) : DOMObjectWithGlobalPointer(structure, globalObject) , m_impl(impl) { -} - -JSTestInterface::~JSTestInterface() -{ - forgetDOMObject(this, impl()); + ASSERT(inherits(&s_info)); } JSObject* JSTestInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject) diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h index 09d7d7c..2cabc23 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h @@ -36,16 +36,14 @@ class JSTestInterface : public DOMObjectWithGlobalPointer { typedef DOMObjectWithGlobalPointer Base; public: JSTestInterface(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestInterface>); - virtual ~JSTestInterface(); static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); @@ -64,11 +62,10 @@ class JSTestInterfacePrototype : public JSC::JSObjectWithGlobalObject { typedef JSC::JSObjectWithGlobalObject Base; public: static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } JSTestInterfacePrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { } protected: diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp index f1c09b5..0e5edeb 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp @@ -69,22 +69,22 @@ public: virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } protected: static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; }; -const ClassInfo JSTestMediaQueryListListenerConstructor::s_info = { "TestMediaQueryListListenerConstructor", 0, &JSTestMediaQueryListListenerConstructorTable, 0 }; +const ClassInfo JSTestMediaQueryListListenerConstructor::s_info = { "TestMediaQueryListListenerConstructor", &DOMConstructorObject::s_info, &JSTestMediaQueryListListenerConstructorTable, 0 }; JSTestMediaQueryListListenerConstructor::JSTestMediaQueryListListenerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorObject(JSTestMediaQueryListListenerConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSTestMediaQueryListListenerPrototype::self(exec, globalObject), DontDelete | ReadOnly); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestMediaQueryListListenerPrototype::self(exec, globalObject), DontDelete | ReadOnly); } bool JSTestMediaQueryListListenerConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -112,7 +112,7 @@ static const HashTableValue JSTestMediaQueryListListenerPrototypeTableValues[2] #undef THUNK_GENERATOR static JSC_CONST_HASHTABLE HashTable JSTestMediaQueryListListenerPrototypeTable = { 2, 1, JSTestMediaQueryListListenerPrototypeTableValues, 0 }; -const ClassInfo JSTestMediaQueryListListenerPrototype::s_info = { "TestMediaQueryListListenerPrototype", 0, &JSTestMediaQueryListListenerPrototypeTable, 0 }; +const ClassInfo JSTestMediaQueryListListenerPrototype::s_info = { "TestMediaQueryListListenerPrototype", &JSC::JSObjectWithGlobalObject::s_info, &JSTestMediaQueryListListenerPrototypeTable, 0 }; JSObject* JSTestMediaQueryListListenerPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { @@ -129,17 +129,13 @@ bool JSTestMediaQueryListListenerPrototype::getOwnPropertyDescriptor(ExecState* return getStaticFunctionDescriptor<JSObject>(exec, &JSTestMediaQueryListListenerPrototypeTable, this, propertyName, descriptor); } -const ClassInfo JSTestMediaQueryListListener::s_info = { "TestMediaQueryListListener", 0, &JSTestMediaQueryListListenerTable, 0 }; +const ClassInfo JSTestMediaQueryListListener::s_info = { "TestMediaQueryListListener", &DOMObjectWithGlobalPointer::s_info, &JSTestMediaQueryListListenerTable, 0 }; JSTestMediaQueryListListener::JSTestMediaQueryListListener(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestMediaQueryListListener> impl) : DOMObjectWithGlobalPointer(structure, globalObject) , m_impl(impl) { -} - -JSTestMediaQueryListListener::~JSTestMediaQueryListListener() -{ - forgetDOMObject(this, impl()); + ASSERT(inherits(&s_info)); } JSObject* JSTestMediaQueryListListener::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -175,7 +171,7 @@ EncodedJSValue JSC_HOST_CALL jsTestMediaQueryListListenerPrototypeFunctionMethod return throwVMTypeError(exec); JSTestMediaQueryListListener* castedThis = static_cast<JSTestMediaQueryListListener*>(asObject(thisValue)); TestMediaQueryListListener* imp = static_cast<TestMediaQueryListListener*>(castedThis->impl()); - RefPtr<MediaQueryListListener> listener = MediaQueryListListener::create(exec->argument(0)); + RefPtr<MediaQueryListListener> listener(MediaQueryListListener::create(ScriptValue(exec->globalData(), exec->argument(0)))); if (exec->hadException()) return JSValue::encode(jsUndefined()); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h index 1863703..a9f8606 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.h @@ -34,16 +34,14 @@ class JSTestMediaQueryListListener : public DOMObjectWithGlobalPointer { typedef DOMObjectWithGlobalPointer Base; public: JSTestMediaQueryListListener(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestMediaQueryListListener>); - virtual ~JSTestMediaQueryListListener(); static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); @@ -62,13 +60,12 @@ class JSTestMediaQueryListListenerPrototype : public JSC::JSObjectWithGlobalObje typedef JSC::JSObjectWithGlobalObject Base; public: static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } JSTestMediaQueryListListenerPrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { } protected: diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index 9d446a2..fd2f4d9 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -148,22 +148,22 @@ public: virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } protected: static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; }; -const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", 0, &JSTestObjConstructorTable, 0 }; +const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", &DOMConstructorObject::s_info, &JSTestObjConstructorTable, 0 }; JSTestObjConstructor::JSTestObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorObject(JSTestObjConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), DontDelete | ReadOnly); + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), DontDelete | ReadOnly); } bool JSTestObjConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -237,7 +237,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[48] = #undef THUNK_GENERATOR static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = { 136, 127, JSTestObjPrototypeTableValues, 0 }; -const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 }; +const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", &JSC::JSObjectWithGlobalObject::s_info, &JSTestObjPrototypeTable, 0 }; JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { @@ -254,17 +254,13 @@ bool JSTestObjPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identif return getStaticPropertyDescriptor<JSTestObjPrototype, JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, descriptor); } -const ClassInfo JSTestObj::s_info = { "TestObj", 0, &JSTestObjTable, 0 }; +const ClassInfo JSTestObj::s_info = { "TestObj", &DOMObjectWithGlobalPointer::s_info, &JSTestObjTable, 0 }; JSTestObj::JSTestObj(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestObj> impl) : DOMObjectWithGlobalPointer(structure, globalObject) , m_impl(impl) { -} - -JSTestObj::~JSTestObj() -{ - forgetDOMObject(this, impl()); + ASSERT(inherits(&s_info)); } JSObject* JSTestObj::createPrototype(ExecState* exec, JSGlobalObject* globalObject) @@ -852,13 +848,13 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecSt return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); - const String& strArg = ustringToString(exec->argument(1).toString(exec)); + const String& strArg(ustringToString(exec->argument(1).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - TestObj* objArg = toTestObj(exec->argument(2)); + TestObj* objArg(toTestObj(exec->argument(2))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -886,13 +882,13 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecSta return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); - const String& strArg = ustringToString(exec->argument(1).toString(exec)); + const String& strArg(ustringToString(exec->argument(1).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - TestObj* objArg = toTestObj(exec->argument(2)); + TestObj* objArg(toTestObj(exec->argument(2))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -921,13 +917,13 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecSta return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); - const String& strArg = ustringToString(exec->argument(1).toString(exec)); + const String& strArg(ustringToString(exec->argument(1).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - TestObj* objArg = toTestObj(exec->argument(2)); + TestObj* objArg(toTestObj(exec->argument(2))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -945,10 +941,10 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs TestObj* imp = static_cast<TestObj*>(castedThis->impl()); if (exec->argumentCount() < 2) return JSValue::encode(jsUndefined()); - const String& strArg = ustringToString(exec->argument(0).toString(exec)); + const String& strArg(ustringToString(exec->argument(0).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - TestObj* objArg = toTestObj(exec->argument(1)); + TestObj* objArg(toTestObj(exec->argument(1))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -967,10 +963,10 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs if (exec->argumentCount() < 2) return throwVMError(exec, createSyntaxError(exec, "Not enough arguments")); ExceptionCode ec = 0; - const String& strArg = ustringToString(exec->argument(0).toString(exec)); + const String& strArg(ustringToString(exec->argument(0).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - TestObj* objArg = toTestObj(exec->argument(1)); + TestObj* objArg(toTestObj(exec->argument(1))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -987,7 +983,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, exec->argument(0)); + RefPtr<SerializedScriptValue> serializedArg(SerializedScriptValue::create(exec, exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1002,7 +998,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIdbKey(ExecState* exec) return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - RefPtr<IDBKey> key = createIDBKeyFromValue(exec, exec->argument(0)); + RefPtr<IDBKey> key(createIDBKeyFromValue(exec, exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1017,7 +1013,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(ExecState* return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - OptionsObject* oo = toOptionsObject(exec->argument(0)); + OptionsObject* oo(toOptionsObject(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1027,7 +1023,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOptionsObject(ExecState* return JSValue::encode(jsUndefined()); } - OptionsObject* ooo = toOptionsObject(exec->argument(1)); + OptionsObject* ooo(toOptionsObject(exec->argument(1))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1078,7 +1074,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(Ex RefPtr<ScriptArguments> scriptArguments(createScriptArguments(exec, 1)); size_t maxStackSize = imp->shouldCaptureFullStackTrace() ? ScriptCallStack::maxCallStackSizeToCapture : 1; RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, maxStackSize)); - log* intArg = tolog(exec->argument(0)); + log* intArg(tolog(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1140,7 +1136,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(Ex Frame* dynamicFrame = toDynamicFrame(exec); if (!dynamicFrame) return JSValue::encode(jsUndefined()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1158,7 +1154,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOption Frame* dynamicFrame = toDynamicFrame(exec); if (!dynamicFrame) return JSValue::encode(jsUndefined()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1168,7 +1164,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOption return JSValue::encode(jsUndefined()); } - int optionalArg = exec->argument(1).toInt32(exec); + int optionalArg(exec->argument(1).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1186,7 +1182,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe Frame* dynamicFrame = toDynamicFrame(exec); if (!dynamicFrame) return JSValue::encode(jsUndefined()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1204,7 +1200,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe Frame* dynamicFrame = toDynamicFrame(exec); if (!dynamicFrame) return JSValue::encode(jsUndefined()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1214,7 +1210,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGe return JSValue::encode(jsUndefined()); } - int optionalArg = exec->argument(1).toInt32(exec); + int optionalArg(exec->argument(1).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1309,7 +1305,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(Exe return JSValue::encode(jsUndefined()); } - int opt = exec->argument(0).toInt32(exec); + int opt(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1324,7 +1320,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - int nonOpt = exec->argument(0).toInt32(exec); + int nonOpt(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1334,7 +1330,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA return JSValue::encode(jsUndefined()); } - int opt = exec->argument(1).toInt32(exec); + int opt(exec->argument(1).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1349,7 +1345,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - int nonOpt = exec->argument(0).toInt32(exec); + int nonOpt(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1359,10 +1355,10 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgA return JSValue::encode(jsUndefined()); } - int opt1 = exec->argument(1).toInt32(exec); + int opt1(exec->argument(1).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); - int opt2 = exec->argument(2).toInt32(exec); + int opt2(exec->argument(2).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1394,7 +1390,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonCallbackArgA return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - int nonCallback = exec->argument(0).toInt32(exec); + int nonCallback(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); if (exec->argumentCount() <= 1 || !exec->argument(1).isObject()) { @@ -1434,10 +1430,10 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1( return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - TestObj* objArg = toTestObj(exec->argument(0)); + TestObj* objArg(toTestObj(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); - const String& strArg = ustringToString(exec->argument(1).toString(exec)); + const String& strArg(ustringToString(exec->argument(1).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1452,7 +1448,7 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2( return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - TestObj* objArg = toTestObj(exec->argument(0)); + TestObj* objArg(toTestObj(exec->argument(0))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1462,7 +1458,7 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2( return JSValue::encode(jsUndefined()); } - int intArg = exec->argument(1).toInt32(exec); + int intArg(exec->argument(1).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1477,7 +1473,7 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3( return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - const String& strArg = ustringToString(exec->argument(0).toString(exec)); + const String& strArg(ustringToString(exec->argument(0).toString(exec))); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1492,7 +1488,7 @@ static EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4( return throwVMTypeError(exec); JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - int intArg = exec->argument(0).toInt32(exec); + int intArg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); @@ -1559,7 +1555,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionClassMethodWithOptional(E return JSValue::encode(result); } - int arg = exec->argument(0).toInt32(exec); + int arg(exec->argument(0).toInt32(exec)); if (exec->hadException()) return JSValue::encode(jsUndefined()); diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h index b8713ae..7e21168 100644 --- a/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -34,17 +34,15 @@ class JSTestObj : public DOMObjectWithGlobalPointer { typedef DOMObjectWithGlobalPointer Base; public: JSTestObj(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestObj>); - virtual ~JSTestObj(); static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); @@ -71,13 +69,12 @@ class JSTestObjPrototype : public JSC::JSObjectWithGlobalObject { typedef JSC::JSObjectWithGlobalObject Base; public: static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } JSTestObjPrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { } protected: diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp new file mode 100644 index 0000000..5dd6c44 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp @@ -0,0 +1,177 @@ +/* + 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" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "JSTestSerializedScriptValueInterface.h" + +#include "SerializedScriptValue.h" +#include "TestSerializedScriptValueInterface.h" +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestSerializedScriptValueInterface); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestSerializedScriptValueInterfaceTableValues[3] = +{ + { "value", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t)0 THUNK_GENERATOR(0) }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestSerializedScriptValueInterfaceTable = { 4, 3, JSTestSerializedScriptValueInterfaceTableValues, 0 }; +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestSerializedScriptValueInterfaceConstructorTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestSerializedScriptValueInterfaceConstructorTable = { 1, 0, JSTestSerializedScriptValueInterfaceConstructorTableValues, 0 }; +class JSTestSerializedScriptValueInterfaceConstructor : public DOMConstructorObject { +public: + JSTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSDOMGlobalObject*); + + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterfaceConstructor", &DOMConstructorObject::s_info, &JSTestSerializedScriptValueInterfaceConstructorTable, 0 }; + +JSTestSerializedScriptValueInterfaceConstructor::JSTestSerializedScriptValueInterfaceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestSerializedScriptValueInterfaceConstructor::createStructure(globalObject->objectPrototype()), globalObject) +{ + ASSERT(inherits(&s_info)); + putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestSerializedScriptValueInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly); +} + +bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestSerializedScriptValueInterfaceConstructor, DOMObject>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, this, propertyName, slot); +} + +bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestSerializedScriptValueInterfaceConstructor, DOMObject>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestSerializedScriptValueInterfacePrototypeTable = { 1, 0, JSTestSerializedScriptValueInterfacePrototypeTableValues, 0 }; +const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &JSC::JSObjectWithGlobalObject::s_info, &JSTestSerializedScriptValueInterfacePrototypeTable, 0 }; + +JSObject* JSTestSerializedScriptValueInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestSerializedScriptValueInterface>(exec, globalObject); +} + +const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &DOMObjectWithGlobalPointer::s_info, &JSTestSerializedScriptValueInterfaceTable, 0 }; + +JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestSerializedScriptValueInterface> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ + ASSERT(inherits(&s_info)); +} + +JSObject* JSTestSerializedScriptValueInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestSerializedScriptValueInterfacePrototype(globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestSerializedScriptValueInterface::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, this, propertyName, slot); +} + +bool JSTestSerializedScriptValueInterface::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, this, propertyName, descriptor); +} + +JSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestSerializedScriptValueInterface* imp = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl()); + JSValue result = imp->value() ? imp->value()->deserialize(exec, castedThis->globalObject()) : jsNull(); + return result; +} + +JSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestSerializedScriptValueInterface* domObject = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase)); + return JSTestSerializedScriptValueInterface::getConstructor(exec, domObject->globalObject()); +} + +JSValue JSTestSerializedScriptValueInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* object) +{ + return getDOMObjectWrapper<JSTestSerializedScriptValueInterface>(exec, globalObject, object); +} +TestSerializedScriptValueInterface* toTestSerializedScriptValueInterface(JSC::JSValue value) +{ + return value.inherits(&JSTestSerializedScriptValueInterface::s_info) ? static_cast<JSTestSerializedScriptValueInterface*>(asObject(value))->impl() : 0; +} + +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h new file mode 100644 index 0000000..175fb12 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h @@ -0,0 +1,84 @@ +/* + 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 JSTestSerializedScriptValueInterface_h +#define JSTestSerializedScriptValueInterface_h + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/JSObjectWithGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestSerializedScriptValueInterface; + +class JSTestSerializedScriptValueInterface : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestSerializedScriptValueInterface(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestSerializedScriptValueInterface>); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + TestSerializedScriptValueInterface* impl() const { return m_impl.get(); } + +private: + RefPtr<TestSerializedScriptValueInterface> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestSerializedScriptValueInterface*); +TestSerializedScriptValueInterface* toTestSerializedScriptValueInterface(JSC::JSValue); + +class JSTestSerializedScriptValueInterfacePrototype : public JSC::JSObjectWithGlobalObject { + typedef JSC::JSObjectWithGlobalObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info); + } + JSTestSerializedScriptValueInterfacePrototype(JSC::JSGlobalObject* globalObject, NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObjectWithGlobalObject(globalObject, structure) { } +protected: + static const unsigned StructureFlags = Base::StructureFlags; +}; + +// Attributes + +JSC::JSValue jsTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif // ENABLE(Condition1) || ENABLE(Condition2) + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.h new file mode 100644 index 0000000..ff98133 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.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 DOMTestSerializedScriptValueInterface : DOMObject +- (NSString *)value; +@end + +#endif diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.mm b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.mm new file mode 100644 index 0000000..1a0fc7b --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterface.mm @@ -0,0 +1,99 @@ +/* + * 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" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#import "DOMInternal.h" + +#import "DOMTestSerializedScriptValueInterface.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestSerializedScriptValueInterfaceInternal.h" +#import "ExceptionHandlers.h" +#import "JSMainThreadExecState.h" +#import "SerializedScriptValue.h" +#import "TestSerializedScriptValueInterface.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestSerializedScriptValueInterface*>(_internal) + +@implementation DOMTestSerializedScriptValueInterface + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestSerializedScriptValueInterface class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (NSString *)value +{ + WebCore::JSMainThreadNullState state; + return IMPL->value()->toString(); +} + +@end + +WebCore::TestSerializedScriptValueInterface* core(DOMTestSerializedScriptValueInterface *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestSerializedScriptValueInterface*>(wrapper->_internal) : 0; +} + +DOMTestSerializedScriptValueInterface *kit(WebCore::TestSerializedScriptValueInterface* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestSerializedScriptValueInterface *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestSerializedScriptValueInterface *wrapper = [[DOMTestSerializedScriptValueInterface alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterfaceInternal.h b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterfaceInternal.h new file mode 100644 index 0000000..39c40c5 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/ObjC/DOMTestSerializedScriptValueInterfaceInternal.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/DOMTestSerializedScriptValueInterface.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestSerializedScriptValueInterface; +} + +WebCore::TestSerializedScriptValueInterface* core(DOMTestSerializedScriptValueInterface *); +DOMTestSerializedScriptValueInterface *kit(WebCore::TestSerializedScriptValueInterface*); + +#endif diff --git a/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl b/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl new file mode 100644 index 0000000..6cd25bb --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary formstrArg, 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. + */ + +// This IDL file is for testing the bindings code generator and for tracking +// changes in its ouput. +module test { + interface [ + Conditional=Condition1|Condition2, + ] TestSerializedScriptValueInterface { + // The case of a single SerializedScriptValue attribute is a bit of a + // special case. + readonly attribute SerializedScriptValue value; + }; +} diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp index 267f1f0..4c40d98 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp @@ -29,6 +29,7 @@ #include "V8DOMWrapper.h" #include "V8IsolatedContext.h" #include "V8Proxy.h" +#include <wtf/UnusedParam.h> namespace WebCore { @@ -50,6 +51,7 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8: v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestInterface", v8::Persistent<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount, 0, 0, 0, 0); + UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. desc->SetCallHandler(V8TestInterface::constructorCallback); diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h index c1e319b..b9ac143 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.h @@ -26,7 +26,7 @@ #include "TestInterface.h" #include "V8DOMWrapper.h" #include "WrapperTypeInfo.h" -#include "wtf/text/StringHash.h" +#include <wtf/text/StringHash.h> #include <v8.h> #include <wtf/HashMap.h> diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h index 908d9cd..7b1db84 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.h @@ -24,7 +24,7 @@ #include "TestMediaQueryListListener.h" #include "V8DOMWrapper.h" #include "WrapperTypeInfo.h" -#include "wtf/text/StringHash.h" +#include <wtf/text/StringHash.h> #include <v8.h> #include <wtf/HashMap.h> diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h index 1e60488..4edd2e5 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestObj.h @@ -24,7 +24,7 @@ #include "TestObj.h" #include "V8DOMWrapper.h" #include "WrapperTypeInfo.h" -#include "wtf/text/StringHash.h" +#include <wtf/text/StringHash.h> #include <v8.h> #include <wtf/HashMap.h> diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp new file mode 100644 index 0000000..fef8dbd --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp @@ -0,0 +1,97 @@ +/* + 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 "V8TestSerializedScriptValueInterface.h" + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#include "RuntimeEnabledFeatures.h" +#include "SerializedScriptValue.h" +#include "V8Binding.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" +#include <wtf/UnusedParam.h> + +namespace WebCore { + +WrapperTypeInfo V8TestSerializedScriptValueInterface::info = { V8TestSerializedScriptValueInterface::GetTemplate, V8TestSerializedScriptValueInterface::derefObject, 0 }; + +namespace TestSerializedScriptValueInterfaceInternal { + +template <typename T> void V8_USE(T) { } + +} // namespace TestSerializedScriptValueInterfaceInternal + +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestSerializedScriptValueInterfaceTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestSerializedScriptValueInterface", v8::Persistent<v8::FunctionTemplate>(), V8TestSerializedScriptValueInterface::internalFieldCount, + 0, 0, + 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> V8TestSerializedScriptValueInterface::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestSerializedScriptValueInterfaceRawCache = createRawTemplate(); + return V8TestSerializedScriptValueInterfaceRawCache; +} + +v8::Persistent<v8::FunctionTemplate> V8TestSerializedScriptValueInterface::GetTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestSerializedScriptValueInterfaceCache = ConfigureV8TestSerializedScriptValueInterfaceTemplate(GetRawTemplate()); + return V8TestSerializedScriptValueInterfaceCache; +} + +bool V8TestSerializedScriptValueInterface::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::wrapSlow(TestSerializedScriptValueInterface* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (wrapper.IsEmpty()) + return wrapper; + + impl->ref(); + SerializedScriptValue::deserializeAndSetProperty(wrapper, "value", static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly), impl->value()); + getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + +void V8TestSerializedScriptValueInterface::derefObject(void* object) +{ + static_cast<TestSerializedScriptValueInterface*>(object)->deref(); +} + +} // namespace WebCore + +#endif // ENABLE(Condition1) || ENABLE(Condition2) diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h new file mode 100644 index 0000000..5508c99 --- /dev/null +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.h @@ -0,0 +1,76 @@ +/* + 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. +*/ + +#if ENABLE(Condition1) || ENABLE(Condition2) + +#ifndef V8TestSerializedScriptValueInterface_h +#define V8TestSerializedScriptValueInterface_h + +#include "TestSerializedScriptValueInterface.h" +#include "V8DOMWrapper.h" +#include "WrapperTypeInfo.h" +#include <wtf/text/StringHash.h> +#include <v8.h> +#include <wtf/HashMap.h> + +namespace WebCore { + +class V8TestSerializedScriptValueInterface { + +public: + static bool HasInstance(v8::Handle<v8::Value> value); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestSerializedScriptValueInterface* toNative(v8::Handle<v8::Object> object) + { + return reinterpret_cast<TestSerializedScriptValueInterface*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); + } + inline static v8::Handle<v8::Object> wrap(TestSerializedScriptValueInterface*); + static void derefObject(void*); + static WrapperTypeInfo info; + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +private: + static v8::Handle<v8::Object> wrapSlow(TestSerializedScriptValueInterface*); +}; + + +v8::Handle<v8::Object> V8TestSerializedScriptValueInterface::wrap(TestSerializedScriptValueInterface* impl) +{ + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return V8TestSerializedScriptValueInterface::wrapSlow(impl); +} + +inline v8::Handle<v8::Value> toV8(TestSerializedScriptValueInterface* impl) +{ + if (!impl) + return v8::Null(); + return V8TestSerializedScriptValueInterface::wrap(impl); +} +inline v8::Handle<v8::Value> toV8(PassRefPtr< TestSerializedScriptValueInterface > impl) +{ + return toV8(impl.get()); +} +} + +#endif // V8TestSerializedScriptValueInterface_h +#endif // ENABLE(Condition1) || ENABLE(Condition2) + diff --git a/Source/WebCore/bindings/v8/DebuggerScript.js b/Source/WebCore/bindings/v8/DebuggerScript.js index 1798352..0bed33d 100644 --- a/Source/WebCore/bindings/v8/DebuggerScript.js +++ b/Source/WebCore/bindings/v8/DebuggerScript.js @@ -203,8 +203,6 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) // Get location. var location = frameMirror.sourceLocation(); - var line = DebuggerScript._v8ToWebkitLineNumber(location.line); - var column = DebuggerScript._v8ToWebkitLineNumber(location.column); // Get this object. var thisObject = frameMirror.details_.receiver(); @@ -251,8 +249,8 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) return { "sourceID": sourceID, - "line": line, - "column": column, + "line": location.line, + "column": location.column, "functionName": functionName, "type": "function", "thisObject": thisObject, @@ -263,11 +261,6 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame) }; } -DebuggerScript._v8ToWebkitLineNumber = function(line) -{ - return line + 1; -}; - return DebuggerScript; })(); diff --git a/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp b/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp index 2e8d4fe..dcbdd81 100644 --- a/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp +++ b/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp @@ -33,6 +33,7 @@ #include "IDBKeyPath.h" #include "SerializedScriptValue.h" #include "V8Binding.h" +#include "V8IDBKey.h" #include <wtf/Vector.h> namespace WebCore { @@ -51,6 +52,8 @@ PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value> value) return 0; // Signals type error. } +namespace { + template<typename T> bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value) { @@ -61,6 +64,40 @@ bool getValueFrom(T indexOrName, v8::Handle<v8::Value>& v8Value) return true; } +template<typename T> +bool setValue(v8::Handle<v8::Value>& v8Object, T indexOrName, const v8::Handle<v8::Value>& v8Value) +{ + v8::Local<v8::Object> object = v8Object->ToObject(); + ASSERT(!object->Has(indexOrName)); + return object->Set(indexOrName, v8Value); +} + +bool get(v8::Handle<v8::Value>& object, const IDBKeyPathElement& keyPathElement) +{ + switch (keyPathElement.type) { + case IDBKeyPathElement::IsIndexed: + return object->IsArray() && getValueFrom(keyPathElement.index, object); + case IDBKeyPathElement::IsNamed: + return object->IsObject() && getValueFrom(v8String(keyPathElement.identifier), object); + default: + ASSERT_NOT_REACHED(); + } + return false; +} + +bool set(v8::Handle<v8::Value>& object, const IDBKeyPathElement& keyPathElement, const v8::Handle<v8::Value>& v8Value) +{ + switch (keyPathElement.type) { + case IDBKeyPathElement::IsIndexed: + return object->IsArray() && setValue(object, keyPathElement.index, v8Value); + case IDBKeyPathElement::IsNamed: + return object->IsObject() && setValue(object, v8String(keyPathElement.identifier), v8Value); + default: + ASSERT_NOT_REACHED(); + } + return false; +} + class LocalContext { public: LocalContext() @@ -80,25 +117,46 @@ private: v8::Persistent<v8::Context> m_context; }; +v8::Handle<v8::Value> getNthValueOnKeyPath(v8::Handle<v8::Value>& rootValue, const Vector<IDBKeyPathElement>& keyPathElements, size_t index) +{ + v8::Handle<v8::Value> currentValue(rootValue); + + ASSERT(index <= keyPathElements.size()); + for (size_t i = 0; i < index; ++i) { + if (!get(currentValue, keyPathElements[i])) + return v8::Handle<v8::Value>(); + } + + return currentValue; +} + +} // anonymous namespace + PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const Vector<IDBKeyPathElement>& keyPath) { LocalContext localContext; v8::Handle<v8::Value> v8Value(value->deserialize()); - for (size_t i = 0; i < keyPath.size(); ++i) { - switch (keyPath[i].type) { - case IDBKeyPathElement::IsIndexed: - if (!v8Value->IsArray() || !getValueFrom(keyPath[i].index, v8Value)) - return 0; - break; - case IDBKeyPathElement::IsNamed: - if (!v8Value->IsObject() || !getValueFrom(v8String(keyPath[i].identifier), v8Value)) - return 0; - break; - default: - ASSERT_NOT_REACHED(); - } - } - return createIDBKeyFromValue(v8Value); + v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPath, keyPath.size())); + if (v8Key.IsEmpty()) + return 0; + return createIDBKeyFromValue(v8Key); +} + +PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const Vector<IDBKeyPathElement>& keyPath) +{ + LocalContext localContext; + if (!keyPath.size()) + return 0; + + v8::Handle<v8::Value> v8Value(value->deserialize()); + v8::Handle<v8::Value> parent(getNthValueOnKeyPath(v8Value, keyPath, keyPath.size() - 1)); + if (parent.IsEmpty()) + return 0; + + if (!set(parent, keyPath.last(), toV8(key.get()))) + return 0; + + return SerializedScriptValue::create(v8Value); } } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/IDBBindingUtilities.h b/Source/WebCore/bindings/v8/IDBBindingUtilities.h index 1a794b0..1fb855c 100644 --- a/Source/WebCore/bindings/v8/IDBBindingUtilities.h +++ b/Source/WebCore/bindings/v8/IDBBindingUtilities.h @@ -39,6 +39,7 @@ struct IDBKeyPathElement; PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>); PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const Vector<IDBKeyPathElement, 0>& keyPath); +PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const Vector<IDBKeyPathElement, 0>&); } diff --git a/Source/WebCore/bindings/v8/ScriptController.cpp b/Source/WebCore/bindings/v8/ScriptController.cpp index 55f127b..42953f2 100644 --- a/Source/WebCore/bindings/v8/ScriptController.cpp +++ b/Source/WebCore/bindings/v8/ScriptController.cpp @@ -240,7 +240,7 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) m_sourceURL = savedSourceURL; - if (object.IsEmpty() || object->IsUndefined()) + if (object.IsEmpty()) return ScriptValue(); return ScriptValue(object); diff --git a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp index c35d508..09e1e54 100644 --- a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp +++ b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.cpp @@ -76,4 +76,10 @@ void ScriptHeapSnapshot::writeJSON(ScriptHeapSnapshot::OutputStream* stream) m_snapshot->Serialize(&outputStream, v8::HeapSnapshot::kJSON); } +int ScriptHeapSnapshot::exactRetainedSize(uint64_t nodeId) +{ + const v8::HeapGraphNode* node = m_snapshot->GetNodeById(nodeId); + return node ? node->GetRetainedSize(true) : -1; +} + } // namespace WebCore diff --git a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h index d3ae022..6cfd76d 100644 --- a/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h +++ b/Source/WebCore/bindings/v8/ScriptHeapSnapshot.h @@ -59,6 +59,7 @@ public: String title() const; unsigned int uid() const; void writeJSON(OutputStream* stream); + int exactRetainedSize(uint64_t nodeId); private: ScriptHeapSnapshot(const v8::HeapSnapshot* snapshot) diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp index 1c5e4e7..04ef2b1 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.cpp +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.cpp @@ -51,9 +51,7 @@ #include <wtf/RefCounted.h> #include <wtf/Vector.h> -// FIXME: -// - catch V8 exceptions -// - consider crashing in debug mode on deserialization errors +// FIXME: consider crashing in debug mode on deserialization errors namespace WebCore { @@ -221,14 +219,14 @@ public: doWriteUint32(pixelDataLength); append(pixelData, pixelDataLength); } - + void writeRegExp(v8::Local<v8::String> pattern, v8::RegExp::Flags flags) { append(RegExpTag); v8::String::Utf8Value patternUtf8Value(pattern); doWriteString(*patternUtf8Value, patternUtf8Value.length()); doWriteUint32(static_cast<uint32_t>(flags)); - } + } void writeArray(uint32_t length) { @@ -339,26 +337,45 @@ private: class Serializer { class StateBase; public: - explicit Serializer(Writer& writer) + enum Status { + Success, + InputError, + JSException, + JSFailure + }; + + Serializer(Writer& writer, v8::TryCatch& tryCatch) : m_writer(writer) + , m_tryCatch(tryCatch) , m_depth(0) - , m_hasError(false) + , m_status(Success) { + ASSERT(!tryCatch.HasCaught()); } - bool serialize(v8::Handle<v8::Value> value) + Status serialize(v8::Handle<v8::Value> value) { v8::HandleScope scope; StateBase* state = doSerialize(value, 0); while (state) state = state->advance(*this); - return !m_hasError; + return m_status; } // Functions used by serialization states. StateBase* doSerialize(v8::Handle<v8::Value> value, StateBase* next); + StateBase* checkException(StateBase* state) + { + return m_tryCatch.HasCaught() ? handleError(JSException, state) : 0; + } + + StateBase* reportFailure(StateBase* state) + { + return handleError(JSFailure, state); + } + StateBase* writeArray(uint32_t length, StateBase* state) { m_writer.writeArray(length); @@ -447,7 +464,10 @@ private: { ++m_index; for (; m_index < composite()->Length(); ++m_index) { - if (StateBase* newState = serializer.doSerialize(composite()->Get(m_index), this)) + v8::Handle<v8::Value> value = composite()->Get(m_index); + if (StateBase* newState = serializer.checkException(this)) + return newState; + if (StateBase* newState = serializer.doSerialize(value, this)) return newState; } return serializer.writeArray(composite()->Length(), this); @@ -462,8 +482,7 @@ private: public: AbstractObjectState(v8::Handle<v8::Object> object, StateBase* next) : State<v8::Object>(object, next) - , m_propertyNames(object->GetPropertyNames()) - , m_index(-1) + , m_index(0) , m_numSerializedProperties(0) , m_nameDone(false) { @@ -471,15 +490,32 @@ private: virtual StateBase* advance(Serializer& serializer) { - ++m_index; - for (; m_index < m_propertyNames->Length(); ++m_index) { - if (m_propertyName.IsEmpty()) { + if (!m_index) { + m_propertyNames = composite()->GetPropertyNames(); + if (StateBase* newState = serializer.checkException(this)) + return newState; + if (m_propertyNames.IsEmpty()) + return serializer.reportFailure(this); + } + while (m_index < m_propertyNames->Length()) { + if (!m_nameDone) { v8::Local<v8::Value> propertyName = m_propertyNames->Get(m_index); - if ((propertyName->IsString() && composite()->HasRealNamedProperty(propertyName.As<v8::String>())) - || (propertyName->IsUint32() && composite()->HasRealIndexedProperty(propertyName->Uint32Value()))) { + if (StateBase* newState = serializer.checkException(this)) + return newState; + if (propertyName.IsEmpty()) + return serializer.reportFailure(this); + bool hasStringProperty = propertyName->IsString() && composite()->HasRealNamedProperty(propertyName.As<v8::String>()); + if (StateBase* newState = serializer.checkException(this)) + return newState; + bool hasIndexedProperty = !hasStringProperty && propertyName->IsUint32() && composite()->HasRealIndexedProperty(propertyName->Uint32Value()); + if (StateBase* newState = serializer.checkException(this)) + return newState; + if (hasStringProperty || hasIndexedProperty) m_propertyName = propertyName; - } else + else { + ++m_index; continue; + } } ASSERT(!m_propertyName.IsEmpty()); if (!m_nameDone) { @@ -488,8 +524,11 @@ private: return newState; } v8::Local<v8::Value> value = composite()->Get(m_propertyName); + if (StateBase* newState = serializer.checkException(this)) + return newState; m_nameDone = false; m_propertyName.Clear(); + ++m_index; ++m_numSerializedProperties; if (StateBase* newState = serializer.doSerialize(value, this)) return newState; @@ -540,7 +579,7 @@ private: { ASSERT(state); ++m_depth; - return checkComposite(state) ? state : handleError(state); + return checkComposite(state) ? state : handleError(InputError, state); } StateBase* pop(StateBase* state) @@ -552,9 +591,10 @@ private: return next; } - StateBase* handleError(StateBase* state) + StateBase* handleError(Status errorStatus, StateBase* state) { - m_hasError = true; + ASSERT(errorStatus != Success); + m_status = errorStatus; while (state) { StateBase* tmp = state->nextState(); delete state; @@ -616,7 +656,7 @@ private: WTF::ByteArray* pixelArray = imageData->data()->data(); m_writer.writeImageData(imageData->width(), imageData->height(), pixelArray->data(), pixelArray->length()); } - + void writeRegExp(v8::Handle<v8::Value> value) { v8::Handle<v8::RegExp> regExp = value.As<v8::RegExp>(); @@ -632,19 +672,20 @@ private: static StateBase* newObjectState(v8::Handle<v8::Object> object, StateBase* next) { - // FIXME: - // - check not a wrapper - // - support File, etc. + // FIXME: check not a wrapper return new ObjectState(object, next); } Writer& m_writer; + v8::TryCatch& m_tryCatch; int m_depth; - bool m_hasError; + Status m_status; }; Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, StateBase* next) { + if (value.IsEmpty()) + return reportFailure(next); if (value->IsUndefined()) m_writer.writeUndefined(); else if (value->IsNull()) @@ -890,7 +931,7 @@ private: *value = toV8(imageData.release()); return true; } - + bool readRegExp(v8::Handle<v8::Value>* value) { v8::Handle<v8::Value> pattern; @@ -1105,6 +1146,12 @@ void SerializedScriptValue::deserializeAndSetProperty(v8::Handle<v8::Object> obj 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, bool& didThrow) { return adoptRef(new SerializedScriptValue(value, didThrow)); @@ -1173,12 +1220,33 @@ SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, bool& { didThrow = false; Writer writer; - Serializer serializer(writer); - if (!serializer.serialize(value)) { + Serializer::Status status; + { + v8::TryCatch tryCatch; + Serializer serializer(writer, tryCatch); + status = serializer.serialize(value); + if (status == Serializer::JSException) { + // If there was a JS exception thrown, re-throw it. + didThrow = true; + tryCatch.ReThrow(); + return; + } + } + if (status == Serializer::InputError) { + // If there was an input error, throw a new exception outside + // of the TryCatch scope. + didThrow = true; throwError(NOT_SUPPORTED_ERR); + return; + } + if (status == Serializer::JSFailure) { + // If there was a JS failure (but no exception), there's not + // much we can do except for unwinding the C++ stack by + // pretending there was a JS exception. didThrow = true; return; } + ASSERT(status == Serializer::Success); m_data = String(StringImpl::adopt(writer.data())).crossThreadString(); } diff --git a/Source/WebCore/bindings/v8/SerializedScriptValue.h b/Source/WebCore/bindings/v8/SerializedScriptValue.h index d0d8575..c0e9109 100644 --- a/Source/WebCore/bindings/v8/SerializedScriptValue.h +++ b/Source/WebCore/bindings/v8/SerializedScriptValue.h @@ -39,8 +39,10 @@ namespace WebCore { class SerializedScriptValue : public ThreadSafeShared<SerializedScriptValue> { public: - static void deserializeAndSetProperty(v8::Handle<v8::Object> object, const char* propertyName, + 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 diff --git a/Source/WebCore/bindings/v8/V8AbstractEventListener.cpp b/Source/WebCore/bindings/v8/V8AbstractEventListener.cpp index bda4345..6dc49fa 100644 --- a/Source/WebCore/bindings/v8/V8AbstractEventListener.cpp +++ b/Source/WebCore/bindings/v8/V8AbstractEventListener.cpp @@ -147,12 +147,11 @@ void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context v8Context->Global()->SetHiddenValue(eventSymbol, jsEvent); tryCatch.Reset(); - // Call the event handler. returnValue = callListenerFunction(context, jsEvent, event); + if (tryCatch.HasCaught()) + event->target()->uncaughtExceptionInEventHandler(); if (!tryCatch.CanContinue()) return; - - // If an error occurs while handling the event, it should be reported in a regular way. tryCatch.Reset(); // Restore the old event. This must be done for all exit paths through this method. diff --git a/Source/WebCore/bindings/v8/V8GCController.cpp b/Source/WebCore/bindings/v8/V8GCController.cpp index f296b8f..cda9f3d 100644 --- a/Source/WebCore/bindings/v8/V8GCController.cpp +++ b/Source/WebCore/bindings/v8/V8GCController.cpp @@ -290,6 +290,7 @@ public: if (node->isDocumentNode()) { Document* document = reinterpret_cast<Document*>(node); addDOMObjectToGroup(store, groupId, document->styleSheets()); + addDOMObjectToGroup(store, groupId, document->implementation()); } WrapperTypeInfo* typeInfo = V8DOMWrapper::domWrapperType(wrapper); diff --git a/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp b/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp index 14f13cb..f260cff 100755 --- a/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp @@ -36,7 +36,10 @@ namespace WebCore { v8::Handle<v8::Value> V8DataView::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.ArrayBuffer.Constructor"); + INC_STATS("DOM.DataView.Constructor"); + + if (!args.IsConstructCall()) + return throwError("DOM object constructor cannot be called as a function", V8Proxy::SyntaxError); if (args[0]->IsNull() || !V8ArrayBuffer::HasInstance(args[0])) return V8Proxy::throwTypeError(); diff --git a/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp b/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp index ff9b98b..abb7d4c 100644 --- a/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8EventCustom.cpp @@ -44,8 +44,7 @@ #include "V8DeviceOrientationEvent.h" #include "V8ErrorEvent.h" #include "V8HashChangeEvent.h" -#include "V8IDBErrorEvent.h" -#include "V8IDBSuccessEvent.h" +#include "V8IDBVersionChangeEvent.h" #include "V8KeyboardEvent.h" #include "V8MessageEvent.h" #include "V8MouseEvent.h" @@ -156,10 +155,8 @@ v8::Handle<v8::Value> toV8(Event* impl) return toV8(static_cast<StorageEvent*>(impl)); #endif #if ENABLE(INDEXED_DATABASE) - if (impl->isIDBErrorEvent()) - return toV8(static_cast<IDBErrorEvent*>(impl)); - if (impl->isIDBSuccessEvent()) - return toV8(static_cast<IDBSuccessEvent*>(impl)); + if (impl->isIDBVersionChangeEvent()) + return toV8(static_cast<IDBVersionChangeEvent*>(impl)); #endif if (impl->isBeforeLoadEvent()) return toV8(static_cast<BeforeLoadEvent*>(impl)); diff --git a/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp b/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp index fd6f1a5..ccd6fb2 100644 --- a/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp @@ -33,6 +33,7 @@ #include "SerializedScriptValue.h" #include "V8IDBCursor.h" +#include "V8IDBCursorWithValue.h" #include "V8IDBDatabase.h" #include "V8IDBFactory.h" #include "V8IDBIndex.h" @@ -54,6 +55,8 @@ v8::Handle<v8::Value> toV8(IDBAny* impl) return v8::Null(); case IDBAny::IDBCursorType: return toV8(impl->idbCursor()); + case IDBAny::IDBCursorWithValueType: + return toV8(impl->idbCursorWithValue()); case IDBAny::IDBDatabaseType: return toV8(impl->idbDatabase()); case IDBAny::IDBFactoryType: diff --git a/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp index ce1732b..7a33ed0 100644 --- a/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp @@ -40,6 +40,7 @@ #include "Node.h" #include "Page.h" #include "ScriptDebugServer.h" +#include "ScriptValue.h" #include "V8Binding.h" #include "V8BindingState.h" @@ -54,6 +55,22 @@ namespace WebCore { +Node* InjectedScriptHost::scriptValueAsNode(ScriptValue value) +{ + if (!value.isObject() || value.isNull()) + return 0; + return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8Value())); +} + +ScriptValue InjectedScriptHost::nodeAsScriptValue(ScriptState* state, Node* node) +{ + v8::HandleScope scope; + v8::Local<v8::Context> context = state->context(); + v8::Context::Scope contextScope(context); + + return ScriptValue(toV8(node)); +} + static void WeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter) { InjectedScriptHost* nativeObject = static_cast<InjectedScriptHost*>(parameter); @@ -134,21 +151,18 @@ void InjectedScriptHost::discardInjectedScript(ScriptState* inspectedScriptState global->DeleteHiddenValue(key); } -v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8InjectedScriptHost::inspectedNodeCallback(const v8::Arguments& args) { - INC_STATS("InjectedScriptHost.nodeForId()"); + INC_STATS("InjectedScriptHost.inspectedNode()"); if (args.Length() < 1) return v8::Undefined(); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); - Node* node = host->nodeForId(args[0]->ToInt32()->Value()); + Node* node = host->inspectedNode(args[0]->ToInt32()->Value()); if (!node) return v8::Undefined(); - if (!host->inspectorAgent()) - return v8::Undefined(); - return toV8(node); } @@ -164,61 +178,58 @@ v8::Handle<v8::Value> V8InjectedScriptHost::internalConstructorNameCallback(cons return args[0]->ToObject()->GetConstructorName(); } -v8::Handle<v8::Value> V8InjectedScriptHost::pushNodePathToFrontendCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8InjectedScriptHost::inspectCallback(const v8::Arguments& args) { - INC_STATS("InjectedScriptHost.pushNodePathToFrontend()"); - if (args.Length() < 3) + INC_STATS("InjectedScriptHost.inspect()"); + if (args.Length() < 2) return v8::Undefined(); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); - Node* node = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0])); - bool withChildren = args[1]->ToBoolean()->Value(); - bool selectInUI = args[2]->ToBoolean()->Value(); - if (node) - return v8::Number::New(host->pushNodePathToFrontend(node, withChildren, selectInUI)); + ScriptValue objectId(args[0]); + ScriptValue hints(args[1]); + host->inspectImpl(objectId.toInspectorValue(ScriptState::current()), hints.toInspectorValue(ScriptState::current())); return v8::Undefined(); } -#if ENABLE(JAVASCRIPT_DEBUGGER) v8::Handle<v8::Value> V8InjectedScriptHost::currentCallFrameCallback(const v8::Arguments& args) { +#if ENABLE(JAVASCRIPT_DEBUGGER) INC_STATS("InjectedScriptHost.currentCallFrame()"); return toV8(ScriptDebugServer::shared().currentCallFrame()); -} +#else + UNUSED_PARAM(args); + return v8::Undefined(); #endif +} -#if ENABLE(DATABASE) -v8::Handle<v8::Value> V8InjectedScriptHost::selectDatabaseCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8InjectedScriptHost::databaseIdCallback(const v8::Arguments& args) { - INC_STATS("InjectedScriptHost.selectDatabase()"); + INC_STATS("InjectedScriptHost.databaseId()"); if (args.Length() < 1) return v8::Undefined(); - +#if ENABLE(DATABASE) InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); Database* database = V8Database::toNative(v8::Handle<v8::Object>::Cast(args[0])); if (database) - host->selectDatabase(database); - + return v8::Number::New(host->databaseIdImpl(database)); +#endif return v8::Undefined(); } -#endif -#if ENABLE(DOM_STORAGE) -v8::Handle<v8::Value> V8InjectedScriptHost::selectDOMStorageCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8InjectedScriptHost::storageIdCallback(const v8::Arguments& args) { - INC_STATS("InjectedScriptHost.selectDOMStorage()"); if (args.Length() < 1) return v8::Undefined(); - +#if ENABLE(DOM_STORAGE) + INC_STATS("InjectedScriptHost.storageId()"); InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder()); Storage* storage = V8Storage::toNative(v8::Handle<v8::Object>::Cast(args[0])); if (storage) - host->selectDOMStorage(storage); - + return v8::Number::New(host->storageIdImpl(storage)); +#endif return v8::Undefined(); } -#endif InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState) { diff --git a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 5a3f873..af81a41 100644 --- a/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -50,6 +50,7 @@ #include "V8Int8Array.h" #include "V8OESStandardDerivatives.h" #include "V8OESTextureFloat.h" +#include "V8OESVertexArrayObject.h" #include "V8Proxy.h" #include "V8Uint16Array.h" #include "V8Uint32Array.h" @@ -61,6 +62,7 @@ #include "V8WebGLShader.h" #include "V8WebGLTexture.h" #include "V8WebGLUniformLocation.h" +#include "V8WebGLVertexArrayObjectOES.h" #include "WebGLRenderingContext.h" #include <wtf/FastMalloc.h> @@ -146,6 +148,8 @@ static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info) return toV8(info.getWebGLTexture()); case WebGLGetInfo::kTypeWebGLUnsignedByteArray: return toV8(info.getWebGLUnsignedByteArray()); + case WebGLGetInfo::kTypeWebGLVertexArrayObjectOES: + return toV8(info.getWebGLVertexArrayObjectOES()); default: notImplemented(); return v8::Undefined(); @@ -167,6 +171,9 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8 case WebGLExtension::OESTextureFloatName: extensionObject = toV8(static_cast<OESTextureFloat*>(extension)); break; + case WebGLExtension::OESVertexArrayObjectName: + extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension)); + break; } ASSERT(!extensionObject.IsEmpty()); V8DOMWrapper::setHiddenReference(contextObject, extensionObject); |