diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/bindings')
109 files changed, 1361 insertions, 1044 deletions
diff --git a/src/3rdparty/webkit/WebCore/bindings/js/CachedScriptSourceProvider.h b/src/3rdparty/webkit/WebCore/bindings/js/CachedScriptSourceProvider.h index e943fa5b1..1cdd8aa2c 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/CachedScriptSourceProvider.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/CachedScriptSourceProvider.h @@ -29,11 +29,12 @@ #include "CachedResourceClient.h" #include "CachedResourceHandle.h" #include "CachedScript.h" +#include "ScriptSourceProvider.h" #include <parser/SourceCode.h> namespace WebCore { - class CachedScriptSourceProvider : public JSC::SourceProvider, public CachedResourceClient { + class CachedScriptSourceProvider : public ScriptSourceProvider, public CachedResourceClient { public: static PassRefPtr<CachedScriptSourceProvider> create(CachedScript* cachedScript) { return adoptRef(new CachedScriptSourceProvider(cachedScript)); } @@ -45,10 +46,11 @@ namespace WebCore { JSC::UString getRange(int start, int end) const { return JSC::UString(m_cachedScript->script().characters() + start, end - start); } const UChar* data() const { return m_cachedScript->script().characters(); } int length() const { return m_cachedScript->script().length(); } + const String& source() const { return m_cachedScript->script(); } private: CachedScriptSourceProvider(CachedScript* cachedScript) - : SourceProvider(cachedScript->url()) + : ScriptSourceProvider(cachedScript->url()) , m_cachedScript(cachedScript) { m_cachedScript->addClient(this); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/DOMObjectWithSVGContext.h b/src/3rdparty/webkit/WebCore/bindings/js/DOMObjectWithSVGContext.h new file mode 100644 index 000000000..570548dc2 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/bindings/js/DOMObjectWithSVGContext.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2009 Google, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 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 THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR 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 DOMObjectWithSVGContext_h +#define DOMObjectWithSVGContext_h + +#if ENABLE(SVG) + +#include "JSDOMBinding.h" +#include "SVGElement.h" + +namespace WebCore { + + // FIXME: This class (and file) should be removed once all SVG bindings + // have moved context() onto the various impl() pointers. + class DOMObjectWithSVGContext : public DOMObject { + public: + SVGElement* context() const { return m_context.get(); } + + protected: + DOMObjectWithSVGContext(PassRefPtr<JSC::Structure> structure, JSDOMGlobalObject*, SVGElement* context) + : DOMObject(structure) + , m_context(context) + { + // No space to store the JSDOMGlobalObject w/o hitting the CELL_SIZE limit. + } + + protected: // FIXME: Many custom bindings use m_context directly. Making this protected to temporariliy reduce code churn. + RefPtr<SVGElement> m_context; + }; + +} // namespace WebCore + +#endif // ENABLE(SVG) +#endif // DOMObjectWithSVGContext_h diff --git a/src/3rdparty/webkit/WebCore/bindings/js/GCController.cpp b/src/3rdparty/webkit/WebCore/bindings/js/GCController.cpp index db295c2b8..59bcfa372 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/GCController.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/GCController.cpp @@ -44,7 +44,7 @@ namespace WebCore { static void* collect(void*) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSDOMWindow::commonJSGlobalData()->heap.collect(); return 0; } @@ -70,13 +70,13 @@ void GCController::garbageCollectSoon() void GCController::gcTimerFired(Timer<GCController>*) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSDOMWindow::commonJSGlobalData()->heap.collect(); } void GCController::garbageCollectNow() { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSDOMWindow::commonJSGlobalData()->heap.collect(); } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/GCController.h b/src/3rdparty/webkit/WebCore/bindings/js/GCController.h index 452019af6..4c2540787 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/GCController.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/GCController.h @@ -31,7 +31,7 @@ namespace WebCore { - class GCController : Noncopyable { + class GCController : public Noncopyable { friend GCController& gcController(); public: diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp index 82e06e3a4..314641344 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSAbstractWorkerCustom.cpp @@ -30,7 +30,7 @@ #include "config.h" -#if ENABLE(SHARED_WORKERS) +#if ENABLE(WORKERS) #include "JSAbstractWorker.h" @@ -45,7 +45,7 @@ namespace WebCore { void JSAbstractWorker::mark() { - DOMObject::mark(); + Base::mark(); markIfNotNull(m_impl->onerror()); @@ -82,12 +82,6 @@ JSValue JSAbstractWorker::removeEventListener(ExecState* exec, const ArgList& ar return jsUndefined(); } -JSValue toJS(ExecState* exec, AbstractWorker* baseObject) -{ - // Just call the JSEventTarget implementation of toJS(), which already differentiates between the different implementations. - return toJS(exec, static_cast<EventTarget*>(baseObject)); -} - } // namespace WebCore -#endif // ENABLE(SHARED_WORKERS) +#endif // ENABLE(WORKERS) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp index 4f3c8ee10..abd5ad5fc 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSAttrCustom.cpp @@ -47,7 +47,7 @@ void JSAttr::setValue(ExecState* exec, JSValue value) Element* ownerElement = imp->ownerElement(); if (ownerElement && (ownerElement->hasTagName(iframeTag) || ownerElement->hasTagName(frameTag))) { - if (equalIgnoringCase(imp->name(), "src") && protocolIsJavaScript(parseURL(attrValue))) { + if (equalIgnoringCase(imp->name(), "src") && protocolIsJavaScript(deprecatedParseURL(attrValue))) { if (!checkNodeSecurity(exec, static_cast<HTMLFrameElementBase*>(ownerElement)->contentDocument())) return; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.cpp index 74bcad5ec..87a388073 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.cpp @@ -42,35 +42,27 @@ namespace WebCore { const ClassInfo JSAudioConstructor::s_info = { "AudioConstructor", 0, 0, 0 }; JSAudioConstructor::JSAudioConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMObject(JSAudioConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) - , m_globalObject(globalObject) + : DOMConstructorWithDocument(JSAudioConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - ASSERT(globalObject->scriptExecutionContext()); - ASSERT(globalObject->scriptExecutionContext()->isDocument()); - - putDirect(exec->propertyNames().prototype, JSHTMLAudioElementPrototype::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, JSHTMLAudioElementPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); } -Document* JSAudioConstructor::document() const -{ - return static_cast<Document*>(m_globalObject->scriptExecutionContext()); -} - static JSObject* constructAudio(ExecState* exec, JSObject* constructor, const ArgList& args) { + JSAudioConstructor* jsAudio = static_cast<JSAudioConstructor*>(constructor); // FIXME: Why doesn't this need the call toJS on the document like JSImageConstructor? - - Document* document = static_cast<JSAudioConstructor*>(constructor)->document(); + Document* document = jsAudio->document(); if (!document) return throwError(exec, ReferenceError, "Audio constructor associated document is unavailable"); RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document); + audio->setAutobuffer(true); if (args.size() > 0) { audio->setSrc(args.at(0).toString(exec)); audio->scheduleLoad(); } - return asObject(toJS(exec, audio.release())); + return asObject(toJS(exec, jsAudio->globalObject(), audio.release())); } ConstructType JSAudioConstructor::getConstructData(ConstructData& constructData) @@ -79,13 +71,6 @@ ConstructType JSAudioConstructor::getConstructData(ConstructData& constructData) return ConstructTypeHost; } -void JSAudioConstructor::mark() -{ - DOMObject::mark(); - if (!m_globalObject->marked()) - m_globalObject->mark(); -} - } // namespace WebCore #endif // ENABLE(VIDEO) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.h index 0a3a7ea00..3496897a2 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSAudioConstructor.h @@ -34,21 +34,15 @@ namespace WebCore { - class JSAudioConstructor : public DOMObject { + class JSAudioConstructor : public DOMConstructorWithDocument { public: JSAudioConstructor(JSC::ExecState*, JSDOMGlobalObject*); - Document* document() const; - static const JSC::ClassInfo s_info; - - virtual void mark(); private: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - - JSDOMGlobalObject* m_globalObject; }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCDATASectionCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCDATASectionCustom.cpp index 44a8957bd..c2738cc52 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCDATASectionCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCDATASectionCustom.cpp @@ -32,12 +32,12 @@ using namespace JSC; namespace WebCore { -JSValue toJSNewlyCreated(ExecState* exec, CDATASection* section) +JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, CDATASection* section) { if (!section) return jsNull(); - - return CREATE_DOM_NODE_WRAPPER(exec, CDATASection, section); + + return CREATE_DOM_NODE_WRAPPER(exec, globalObject, CDATASection, section); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCSSRuleCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCSSRuleCustom.cpp index 2c204315d..1b96c0627 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCSSRuleCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCSSRuleCustom.cpp @@ -49,46 +49,45 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, CSSRule* rule) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CSSRule* rule) { if (!rule) return jsNull(); DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), rule); - if (wrapper) return wrapper; switch (rule->type()) { case CSSRule::STYLE_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSStyleRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSStyleRule, rule); break; case CSSRule::MEDIA_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSMediaRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSMediaRule, rule); break; case CSSRule::FONT_FACE_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSFontFaceRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSFontFaceRule, rule); break; case CSSRule::PAGE_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSPageRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSPageRule, rule); break; case CSSRule::IMPORT_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSImportRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSImportRule, rule); break; case CSSRule::CHARSET_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSCharsetRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSCharsetRule, rule); break; case CSSRule::VARIABLES_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSVariablesRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSVariablesRule, rule); break; case CSSRule::WEBKIT_KEYFRAME_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, WebKitCSSKeyframeRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WebKitCSSKeyframeRule, rule); break; case CSSRule::WEBKIT_KEYFRAMES_RULE: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, WebKitCSSKeyframesRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WebKitCSSKeyframesRule, rule); break; default: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSRule, rule); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSRule, rule); } return wrapper; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCSSValueCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCSSValueCustom.cpp index ad0cee1cd..87a576025 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCSSValueCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCSSValueCustom.cpp @@ -44,7 +44,7 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, CSSValue* value) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CSSValue* value) { if (!value) return jsNull(); @@ -55,19 +55,19 @@ JSValue toJS(ExecState* exec, CSSValue* value) return wrapper; if (value->isWebKitCSSTransformValue()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, WebKitCSSTransformValue, value); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WebKitCSSTransformValue, value); else if (value->isValueList()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSValueList, value); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSValueList, value); #if ENABLE(SVG) else if (value->isSVGPaint()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, SVGPaint, value); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPaint, value); else if (value->isSVGColor()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, SVGColor, value); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGColor, value); #endif else if (value->isPrimitiveValue()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSPrimitiveValue, value); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSPrimitiveValue, value); else - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSValue, value); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSValue, value); return wrapper; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp index 6f9efd9f9..6abed9901 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionCallback.cpp @@ -48,11 +48,12 @@ void JSCustomPositionCallback::handleEvent(Geoposition* geoposition, bool& raise if (!m_frame->script()->isEnabled()) return; - + + // FIXME: This is likely the wrong globalObject (for prototype chains at least) JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; @@ -67,10 +68,10 @@ void JSCustomPositionCallback::handleEvent(Geoposition* geoposition, bool& raise } RefPtr<JSCustomPositionCallback> protect(this); - + MarkedArgumentBuffer args; - args.append(toJS(exec, geoposition)); - + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), geoposition)); + globalObject->globalData()->timeoutChecker.start(); call(exec, function, callType, callData, m_callback, args); globalObject->globalData()->timeoutChecker.stop(); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp index cc6cd5563..cda5738f6 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp @@ -48,11 +48,12 @@ void JSCustomPositionErrorCallback::handleEvent(PositionError* positionError) if (!m_frame->script()->isEnabled()) return; - + + // FIXME: This is likely the wrong globalObject (for prototype chains at least) JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; @@ -69,7 +70,7 @@ void JSCustomPositionErrorCallback::handleEvent(PositionError* positionError) RefPtr<JSCustomPositionErrorCallback> protect(this); MarkedArgumentBuffer args; - args.append(toJS(exec, positionError)); + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), positionError)); globalObject->globalData()->timeoutChecker.start(); call(exec, function, callType, callData, m_callback, args); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp index 107a49118..d0943dede 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp @@ -54,10 +54,11 @@ void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR if (!m_frame->script()->isEnabled()) return; + // FIXME: This is likely the wrong globalObject (for prototype chains at least) JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; @@ -74,8 +75,8 @@ void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR RefPtr<JSCustomSQLStatementCallback> protect(this); MarkedArgumentBuffer args; - args.append(toJS(exec, transaction)); - args.append(toJS(exec, resultSet)); + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction)); + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), resultSet)); globalObject->globalData()->timeoutChecker.start(); call(exec, function, callType, callData, m_callback, args); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp index 018dabdf1..6c831accc 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp @@ -54,11 +54,12 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, if (!m_frame->script()->isEnabled()) return true; - + + // FIXME: This is likely the wrong globalObject (for prototype chains at least) JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSValue handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData handleEventCallData; @@ -77,8 +78,8 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, RefPtr<JSCustomSQLStatementErrorCallback> protect(this); MarkedArgumentBuffer args; - args.append(toJS(exec, transaction)); - args.append(toJS(exec, error)); + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction)); + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), error)); JSValue result; globalObject->globalData()->timeoutChecker.start(); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp index a41ac7879..3d42f814f 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp @@ -94,11 +94,12 @@ void JSCustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo if (!m_data->frame()->script()->isEnabled()) return; - + + // FIXME: This is likely the wrong globalObject (for prototype chains at least) JSGlobalObject* globalObject = m_data->frame()->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSValue handleEventFunction = m_data->callback()->get(exec, Identifier(exec, "handleEvent")); CallData handleEventCallData; @@ -117,7 +118,7 @@ void JSCustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo RefPtr<JSCustomSQLTransactionCallback> protect(this); MarkedArgumentBuffer args; - args.append(toJS(exec, transaction)); + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction)); globalObject->globalData()->timeoutChecker.start(); if (handleEventCallType != CallTypeNone) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp index 324e2bb6f..2d41bb824 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp @@ -54,10 +54,11 @@ void JSCustomSQLTransactionErrorCallback::handleEvent(SQLError* error) if (!m_frame->script()->isEnabled()) return; + // FIXME: This is likely the wrong globalObject (for prototype chains at least) JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; @@ -74,7 +75,7 @@ void JSCustomSQLTransactionErrorCallback::handleEvent(SQLError* error) RefPtr<JSCustomSQLTransactionErrorCallback> protect(this); MarkedArgumentBuffer args; - args.append(toJS(exec, error)); + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), error)); globalObject->globalData()->timeoutChecker.start(); call(exec, function, callType, callData, m_callback, args); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp index f3f76c428..b4e525b98 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomVoidCallback.cpp @@ -55,7 +55,7 @@ void JSCustomVoidCallback::handleEvent() JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSValue function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp index ffe8cf52a..4476be583 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSCustomXPathNSResolver.cpp @@ -72,7 +72,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix) if (!m_frame->script()->isEnabled()) return String(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp index 7e8d9ce63..a7fae788e 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp @@ -44,7 +44,7 @@ namespace WebCore { void JSDOMApplicationCache::mark() { - DOMObject::mark(); + Base::mark(); markIfNotNull(m_impl->onchecking()); markIfNotNull(m_impl->onerror()); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp index 81d59fbca..910da12b8 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.cpp @@ -455,31 +455,36 @@ void setDOMException(ExecState* exec, ExceptionCode ec) if (!ec || exec->hadException()) return; + // FIXME: All callers to setDOMException need to pass in the right global object + // for now, we're going to assume the lexicalGlobalObject. Which is wrong in cases like this: + // frames[0].document.createElement(null, null); // throws an exception which should have the subframes prototypes. + JSDOMGlobalObject* globalObject = deprecatedGlobalObjectForPrototype(exec); + ExceptionCodeDescription description; getExceptionCodeDescription(ec, description); JSValue errorObject; switch (description.type) { case DOMExceptionType: - errorObject = toJS(exec, DOMCoreException::create(description)); + errorObject = toJS(exec, globalObject, DOMCoreException::create(description)); break; case RangeExceptionType: - errorObject = toJS(exec, RangeException::create(description)); + errorObject = toJS(exec, globalObject, RangeException::create(description)); break; case EventExceptionType: - errorObject = toJS(exec, EventException::create(description)); + errorObject = toJS(exec, globalObject, EventException::create(description)); break; case XMLHttpRequestExceptionType: - errorObject = toJS(exec, XMLHttpRequestException::create(description)); + errorObject = toJS(exec, globalObject, XMLHttpRequestException::create(description)); break; #if ENABLE(SVG) case SVGExceptionType: - errorObject = toJS(exec, SVGException::create(description).get(), 0); + errorObject = toJS(exec, globalObject, SVGException::create(description).get(), 0); break; #endif #if ENABLE(XPATH) case XPathExceptionType: - errorObject = toJS(exec, XPathException::create(description)); + errorObject = toJS(exec, globalObject, XPathException::create(description)); break; #endif } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h index e3fd41733..3975940e1 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMBinding.h @@ -2,6 +2,7 @@ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved. * Copyright (C) 2007 Samuel Weinig <sam@webkit.org> + * Copyright (C) 2009 Google, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,6 +23,7 @@ #define JSDOMBinding_h #include "JSDOMGlobalObject.h" +#include "Document.h" // For DOMConstructorWithDocument #include <runtime/Completion.h> #include <runtime/Lookup.h> #include <runtime/JSFunction.h> @@ -59,6 +61,73 @@ namespace WebCore { #endif }; + // FIXME: This class should colapse into DOMObject once all DOMObjects are + // updated to store a globalObject pointer. + class DOMObjectWithGlobalPointer : public DOMObject { + public: + JSDOMGlobalObject* globalObject() const { return m_globalObject; } + + ScriptExecutionContext* scriptExecutionContext() const + { + // FIXME: Should never be 0, but can be due to bug 27640. + return m_globalObject->scriptExecutionContext(); + } + + protected: + DOMObjectWithGlobalPointer(PassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject) + : DOMObject(structure) + , m_globalObject(globalObject) + { + // FIXME: This ASSERT is valid, but fires in fast/dom/gc-6.html when trying to create + // new JavaScript objects on detached windows due to DOMWindow::document() + // needing to reach through the frame to get to the Document*. See bug 27640. + // ASSERT(globalObject->scriptExecutionContext()); + } + virtual ~DOMObjectWithGlobalPointer() {} + + void mark() + { + DOMObject::mark(); + if (!m_globalObject->marked()) + m_globalObject->mark(); + } + + private: + JSDOMGlobalObject* m_globalObject; + }; + + // Base class for all constructor objects in the JSC bindings. + class DOMConstructorObject : public DOMObjectWithGlobalPointer { + public: + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, JSC::HasStandardGetOwnPropertySlot | JSC::ImplementsHasInstance)); + } + + protected: + DOMConstructorObject(PassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject) + : DOMObjectWithGlobalPointer(structure, globalObject) + { + } + }; + + // Constructors using this base class depend on being in a Document and + // can never be used from a WorkerContext. + class DOMConstructorWithDocument : public DOMConstructorObject { + public: + Document* document() const + { + return static_cast<Document*>(scriptExecutionContext()); + } + + protected: + DOMConstructorWithDocument(PassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(structure, globalObject) + { + ASSERT(globalObject->scriptExecutionContext()->isDocument()); + } + }; + DOMObject* getCachedDOMObjectWrapper(JSC::JSGlobalData&, void* objectHandle); void cacheDOMObjectWrapper(JSC::JSGlobalData&, void* objectHandle, DOMObject* wrapper); void forgetDOMObject(JSC::JSGlobalData&, void* objectHandle); @@ -80,6 +149,14 @@ namespace WebCore { JSC::JSObject* getCachedDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*); void cacheDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*, JSC::JSObject* constructor); + inline JSDOMGlobalObject* deprecatedGlobalObjectForPrototype(JSC::ExecState* exec) + { + // FIXME: Callers to this function should be using the global object + // from which the object is being created, instead of assuming the lexical one. + // e.g. subframe.document.body should use the subframe's global object, not the lexical one. + return static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); + } + template<class WrapperClass> inline JSC::Structure* getDOMStructure(JSC::ExecState* exec, JSDOMGlobalObject* globalObject) { if (JSC::Structure* structure = getCachedDOMStructure(globalObject, &WrapperClass::s_info)) @@ -89,69 +166,69 @@ namespace WebCore { template<class WrapperClass> inline JSC::Structure* deprecatedGetDOMStructure(JSC::ExecState* exec) { // FIXME: This function is wrong. It uses the wrong global object for creating the prototype structure. - return getDOMStructure<WrapperClass>(exec, static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())); + return getDOMStructure<WrapperClass>(exec, deprecatedGlobalObjectForPrototype(exec)); } template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject) { return static_cast<JSC::JSObject*>(asObject(getDOMStructure<WrapperClass>(exec, static_cast<JSDOMGlobalObject*>(globalObject))->storedPrototype())); } - #define CREATE_DOM_OBJECT_WRAPPER(exec, className, object) createDOMObjectWrapper<JS##className>(exec, static_cast<className*>(object)) - template<class WrapperClass, class DOMClass> inline DOMObject* createDOMObjectWrapper(JSC::ExecState* exec, DOMClass* object) + #define CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, className, object) createDOMObjectWrapper<JS##className>(exec, globalObject, static_cast<className*>(object)) + template<class WrapperClass, class DOMClass> inline DOMObject* createDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object) { ASSERT(object); ASSERT(!getCachedDOMObjectWrapper(exec->globalData(), object)); // FIXME: new (exec) could use a different globalData than the globalData this wrapper is cached on. - WrapperClass* wrapper = new (exec) WrapperClass(deprecatedGetDOMStructure<WrapperClass>(exec), object); + WrapperClass* wrapper = new (exec) WrapperClass(getDOMStructure<WrapperClass>(exec, globalObject), globalObject, object); cacheDOMObjectWrapper(exec->globalData(), object, wrapper); return wrapper; } - template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMObjectWrapper(JSC::ExecState* exec, DOMClass* object) + template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object) { if (!object) return JSC::jsNull(); if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), object)) return wrapper; - return createDOMObjectWrapper<WrapperClass>(exec, object); + return createDOMObjectWrapper<WrapperClass>(exec, globalObject, object); } #if ENABLE(SVG) - #define CREATE_SVG_OBJECT_WRAPPER(exec, className, object, context) createDOMObjectWrapper<JS##className>(exec, static_cast<className*>(object), context) - template<class WrapperClass, class DOMClass> inline DOMObject* createDOMObjectWrapper(JSC::ExecState* exec, DOMClass* object, SVGElement* context) + #define CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, className, object, context) createDOMObjectWrapper<JS##className>(exec, globalObject, static_cast<className*>(object), context) + template<class WrapperClass, class DOMClass> inline DOMObject* createDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object, SVGElement* context) { ASSERT(object); ASSERT(!getCachedDOMObjectWrapper(exec->globalData(), object)); - WrapperClass* wrapper = new (exec) WrapperClass(deprecatedGetDOMStructure<WrapperClass>(exec), object, context); + WrapperClass* wrapper = new (exec) WrapperClass(getDOMStructure<WrapperClass>(exec, globalObject), globalObject, object, context); cacheDOMObjectWrapper(exec->globalData(), object, wrapper); return wrapper; } - template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMObjectWrapper(JSC::ExecState* exec, DOMClass* object, SVGElement* context) + template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object, SVGElement* context) { if (!object) return JSC::jsNull(); if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), object)) return wrapper; - return createDOMObjectWrapper<WrapperClass>(exec, object, context); + return createDOMObjectWrapper<WrapperClass>(exec, globalObject, object, context); } #endif - #define CREATE_DOM_NODE_WRAPPER(exec, className, object) createDOMNodeWrapper<JS##className>(exec, static_cast<className*>(object)) - template<class WrapperClass, class DOMClass> inline JSNode* createDOMNodeWrapper(JSC::ExecState* exec, DOMClass* node) + #define CREATE_DOM_NODE_WRAPPER(exec, globalObject, className, object) createDOMNodeWrapper<JS##className>(exec, globalObject, static_cast<className*>(object)) + template<class WrapperClass, class DOMClass> inline JSNode* createDOMNodeWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* node) { ASSERT(node); ASSERT(!getCachedDOMNodeWrapper(node->document(), node)); - WrapperClass* wrapper = new (exec) WrapperClass(deprecatedGetDOMStructure<WrapperClass>(exec), node); + WrapperClass* wrapper = new (exec) WrapperClass(getDOMStructure<WrapperClass>(exec, globalObject), globalObject, node); // FIXME: The entire function can be removed, once we fix caching. // This function is a one-off hack to make Nodes cache in the right global object. cacheDOMNodeWrapper(node->document(), node, wrapper); return wrapper; } - template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMNodeWrapper(JSC::ExecState* exec, DOMClass* node) + template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMNodeWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* node) { if (!node) return JSC::jsNull(); if (JSNode* wrapper = getCachedDOMNodeWrapper(node->document(), node)) return wrapper; - return createDOMNodeWrapper<WrapperClass>(exec, node); + return createDOMNodeWrapper<WrapperClass>(exec, globalObject, node); } const JSC::HashTable* getHashTableForGlobalData(JSC::JSGlobalData&, const JSC::HashTable* staticTable); @@ -178,7 +255,28 @@ namespace WebCore { JSC::UString valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null JSC::UString valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined - template <typename T> inline JSC::JSValue toJS(JSC::ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); } + // FIXME: These are a stop-gap until all toJS calls can be converted to pass a globalObject + template <typename T> + inline JSC::JSValue toJS(JSC::ExecState* exec, T* ptr) + { + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), ptr); + } + template <typename T> + inline JSC::JSValue toJS(JSC::ExecState* exec, PassRefPtr<T> ptr) + { + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), ptr.get()); + } + template <typename T> + inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* exec, T* ptr) + { + return toJSNewlyCreated(exec, deprecatedGlobalObjectForPrototype(exec), ptr); + } + + template <typename T> + inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<T> ptr) + { + return toJS(exec, globalObject, ptr.get()); + } bool checkNodeSecurity(JSC::ExecState*, Node*); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h index 8e4e8203b..bc6c1f2d2 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMGlobalObject.h @@ -67,6 +67,9 @@ namespace WebCore { JSListenersMap& jsEventListeners(); + // Make binding code generation easier. + JSDOMGlobalObject* globalObject() { return this; } + void setCurrentEvent(Event*); Event* currentEvent() const; @@ -89,16 +92,6 @@ namespace WebCore { }; template<class ConstructorClass> - inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec) - { - if (JSC::JSObject* constructor = getCachedDOMConstructor(exec, &ConstructorClass::s_info)) - return constructor; - JSC::JSObject* constructor = new (exec) ConstructorClass(exec); - cacheDOMConstructor(exec, &ConstructorClass::s_info, constructor); - return constructor; - } - - template<class ConstructorClass> inline JSC::JSObject* getDOMConstructor(JSC::ExecState* exec, const JSDOMGlobalObject* globalObject) { if (JSC::JSObject* constructor = globalObject->constructors().get(&ConstructorClass::s_info)) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp index 0f419ba2e..df6068a52 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.cpp @@ -63,7 +63,7 @@ void JSDOMWindowBase::updateDocument() { ASSERT(d()->impl->document()); ExecState* exec = globalExec(); - symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, d()->impl->document()), DontDelete | ReadOnly); + symbolTablePutWithAttributes(Identifier(exec, "document"), toJS(exec, this, d()->impl->document()), DontDelete | ReadOnly); } ScriptExecutionContext* JSDOMWindowBase::scriptExecutionContext() const @@ -172,6 +172,13 @@ JSGlobalData* JSDOMWindowBase::commonJSGlobalData() return globalData; } +// JSDOMGlobalObject* is ignored, accesing a window in any context will +// use that DOMWindow's prototype chain. +JSValue toJS(ExecState* exec, JSDOMGlobalObject*, DOMWindow* domWindow) +{ + return toJS(exec, domWindow); +} + JSValue toJS(ExecState*, DOMWindow* domWindow) { if (!domWindow) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h index 113344f46..84cc81f46 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowBase.h @@ -89,6 +89,9 @@ namespace WebCore { }; // Returns a JSDOMWindow or jsNull() + // JSDOMGlobalObject* is ignored, accesing a window in any context will + // use that DOMWindow's prototype chain. + JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, DOMWindow*); JSC::JSValue toJS(JSC::ExecState*, DOMWindow*); // Returns JSDOMWindow or 0 diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp index c095bf2f1..33ac7bbfd 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -359,7 +359,8 @@ JSValue JSDOMWindow::history(ExecState* exec) const if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), history)) return wrapper; - JSHistory* jsHistory = new (exec) JSHistory(getDOMStructure<JSHistory>(exec, const_cast<JSDOMWindow*>(this)), history); + JSDOMWindow* window = const_cast<JSDOMWindow*>(this); + JSHistory* jsHistory = new (exec) JSHistory(getDOMStructure<JSHistory>(exec, window), window, history); cacheDOMObjectWrapper(exec->globalData(), history, jsHistory); return jsHistory; } @@ -370,7 +371,8 @@ JSValue JSDOMWindow::location(ExecState* exec) const if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), location)) return wrapper; - JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, const_cast<JSDOMWindow*>(this)), location); + JSDOMWindow* window = const_cast<JSDOMWindow*>(this); + JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, window), window, location); cacheDOMObjectWrapper(exec->globalData(), location, jsLocation); return jsLocation; } @@ -443,12 +445,12 @@ JSValue JSDOMWindow::audio(ExecState* exec) const JSValue JSDOMWindow::webKitPoint(ExecState* exec) const { - return getDOMConstructor<JSWebKitPointConstructor>(exec); + return getDOMConstructor<JSWebKitPointConstructor>(exec, this); } JSValue JSDOMWindow::webKitCSSMatrix(ExecState* exec) const { - return getDOMConstructor<JSWebKitCSSMatrixConstructor>(exec); + return getDOMConstructor<JSWebKitCSSMatrixConstructor>(exec, this); } JSValue JSDOMWindow::xmlHttpRequest(ExecState* exec) const @@ -459,7 +461,7 @@ JSValue JSDOMWindow::xmlHttpRequest(ExecState* exec) const #if ENABLE(XSLT) JSValue JSDOMWindow::xsltProcessor(ExecState* exec) const { - return getDOMConstructor<JSXSLTProcessorConstructor>(exec); + return getDOMConstructor<JSXSLTProcessorConstructor>(exec, this); } #endif @@ -473,7 +475,7 @@ JSValue JSDOMWindow::messageChannel(ExecState* exec) const #if ENABLE(WORKERS) JSValue JSDOMWindow::worker(ExecState* exec) const { - return getDOMConstructor<JSWorkerConstructor>(exec); + return getDOMConstructor<JSWorkerConstructor>(exec, this); } #endif diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDataGridColumnListCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDataGridColumnListCustom.cpp index c7ffcde23..91b3d1546 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDataGridColumnListCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDataGridColumnListCustom.cpp @@ -46,7 +46,7 @@ bool JSDataGridColumnList::canGetItemsForName(ExecState*, DataGridColumnList* im JSValue JSDataGridColumnList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSDataGridColumnList* thisObj = static_cast<JSDataGridColumnList*>(asObject(slot.slotBase())); - return toJS(exec, thisObj->impl()->itemWithName(propertyName)); + return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(propertyName)); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDedicatedWorkerContextCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDedicatedWorkerContextCustom.cpp new file mode 100644 index 000000000..c45a6a34a --- /dev/null +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDedicatedWorkerContextCustom.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WORKERS) + +#include "JSDedicatedWorkerContext.h" + +using namespace JSC; + +namespace WebCore { + +void JSDedicatedWorkerContext::mark() +{ + Base::mark(); + + markIfNotNull(impl()->onmessage()); +} + +} // namespace WebCore + +#endif // ENABLE(WORKERS) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp index 956327a3e..493aaeaa8 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSDocumentCustom.cpp @@ -56,8 +56,7 @@ JSValue JSDocument::location(ExecState* exec) const if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec->globalData(), location)) return wrapper; - JSDOMWindow* window = static_cast<JSDOMWindow*>(exec->lexicalGlobalObject()); - JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, window), location); + JSLocation* jsLocation = new (exec) JSLocation(getDOMStructure<JSLocation>(exec, globalObject()), globalObject(), location); cacheDOMObjectWrapper(exec->globalData(), location, jsLocation); return jsLocation; } @@ -80,7 +79,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value) frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); } -JSValue toJS(ExecState* exec, Document* document) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Document* document) { if (!document) return jsNull(); @@ -90,13 +89,13 @@ JSValue toJS(ExecState* exec, Document* document) return wrapper; if (document->isHTMLDocument()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, HTMLDocument, document); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLDocument, document); #if ENABLE(SVG) else if (document->isSVGDocument()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, SVGDocument, document); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGDocument, document); #endif else - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, Document, document); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, Document, document); // Make sure the document is kept around by the window object, and works right with the // back/forward cache. diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSElementCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSElementCustom.cpp index b12c185cc..47793d0a8 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSElementCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSElementCustom.cpp @@ -53,7 +53,7 @@ using namespace HTMLNames; static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* element, const String& name, const String& value) { - if ((element->hasTagName(iframeTag) || element->hasTagName(frameTag)) && equalIgnoringCase(name, "src") && protocolIsJavaScript(parseURL(value))) { + if ((element->hasTagName(iframeTag) || element->hasTagName(frameTag)) && equalIgnoringCase(name, "src") && protocolIsJavaScript(deprecatedParseURL(value))) { HTMLFrameElementBase* frame = static_cast<HTMLFrameElementBase*>(element); if (!checkNodeSecurity(exec, frame->contentDocument())) return false; @@ -89,7 +89,7 @@ JSValue JSElement::setAttributeNode(ExecState* exec, const ArgList& args) if (!allowSettingSrcToJavascriptURL(exec, imp, newAttr->name(), newAttr->value())) return jsUndefined(); - JSValue result = toJS(exec, WTF::getPtr(imp->setAttributeNode(newAttr, ec))); + JSValue result = toJS(exec, globalObject(), WTF::getPtr(imp->setAttributeNode(newAttr, ec))); setDOMException(exec, ec); return result; } @@ -123,12 +123,12 @@ JSValue JSElement::setAttributeNodeNS(ExecState* exec, const ArgList& args) if (!allowSettingSrcToJavascriptURL(exec, imp, newAttr->name(), newAttr->value())) return jsUndefined(); - JSValue result = toJS(exec, WTF::getPtr(imp->setAttributeNodeNS(newAttr, ec))); + JSValue result = toJS(exec, globalObject(), WTF::getPtr(imp->setAttributeNodeNS(newAttr, ec))); setDOMException(exec, ec); return result; } -JSValue toJSNewlyCreated(ExecState* exec, Element* element) +JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Element* element) { if (!element) return jsNull(); @@ -137,15 +137,15 @@ JSValue toJSNewlyCreated(ExecState* exec, Element* element) JSNode* wrapper; if (element->isHTMLElement()) - wrapper = createJSHTMLWrapper(exec, static_cast<HTMLElement*>(element)); + wrapper = createJSHTMLWrapper(exec, globalObject, static_cast<HTMLElement*>(element)); #if ENABLE(SVG) else if (element->isSVGElement()) - wrapper = createJSSVGWrapper(exec, static_cast<SVGElement*>(element)); + wrapper = createJSSVGWrapper(exec, globalObject, static_cast<SVGElement*>(element)); #endif else - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Element, element); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Element, element); return wrapper; } - + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp index 03b97d8c8..257c25928 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventCustom.cpp @@ -32,6 +32,7 @@ #include "Clipboard.h" #include "Event.h" #include "JSClipboard.h" +#include "JSErrorEvent.h" #include "JSKeyboardEvent.h" #include "JSMessageEvent.h" #include "JSMouseEvent.h" @@ -44,6 +45,7 @@ #include "JSWebKitTransitionEvent.h" #include "JSWheelEvent.h" #include "JSXMLHttpRequestProgressEvent.h" +#include "ErrorEvent.h" #include "KeyboardEvent.h" #include "MessageEvent.h" #include "MouseEvent.h" @@ -74,12 +76,12 @@ namespace WebCore { JSValue JSEvent::clipboardData(ExecState* exec) const { - return impl()->isClipboardEvent() ? toJS(exec, impl()->clipboardData()) : jsUndefined(); + return impl()->isClipboardEvent() ? toJS(exec, globalObject(), impl()->clipboardData()) : jsUndefined(); } -JSValue toJS(ExecState* exec, Event* event) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); if (!event) return jsNull(); @@ -90,41 +92,45 @@ JSValue toJS(ExecState* exec, Event* event) if (event->isUIEvent()) { if (event->isKeyboardEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, KeyboardEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, KeyboardEvent, event); else if (event->isTextEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, TextEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, TextEvent, event); else if (event->isMouseEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, MouseEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, MouseEvent, event); else if (event->isWheelEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, WheelEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WheelEvent, event); #if ENABLE(SVG) else if (event->isSVGZoomEvent()) - wrapper = CREATE_SVG_OBJECT_WRAPPER(exec, SVGZoomEvent, event, 0); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGZoomEvent, event); #endif else - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, UIEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, UIEvent, event); } else if (event->isMutationEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, MutationEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, MutationEvent, event); else if (event->isOverflowEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, OverflowEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, OverflowEvent, event); else if (event->isMessageEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, MessageEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, MessageEvent, event); else if (event->isProgressEvent()) { if (event->isXMLHttpRequestProgressEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, XMLHttpRequestProgressEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, XMLHttpRequestProgressEvent, event); else - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, ProgressEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, ProgressEvent, event); } #if ENABLE(DOM_STORAGE) else if (event->isStorageEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, StorageEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, StorageEvent, event); #endif else if (event->isWebKitAnimationEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, WebKitAnimationEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WebKitAnimationEvent, event); else if (event->isWebKitTransitionEvent()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, WebKitTransitionEvent, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WebKitTransitionEvent, event); +#if ENABLE(WORKERS) + else if (event->isErrorEvent()) + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, ErrorEvent, event); +#endif else - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, Event, event); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, Event, event); return wrapper; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp index b9ed685a6..a659d3e36 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.cpp @@ -61,7 +61,7 @@ void JSEventListener::markJSFunction() void JSEventListener::handleEvent(Event* event, bool isWindowEvent) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSObject* jsFunction = this->jsFunction(); if (!jsFunction) @@ -71,6 +71,7 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) // Null check as clearGlobalObject() can clear this and we still get called back by // xmlhttprequest objects. See http://bugs.webkit.org/show_bug.cgi?id=13275 // FIXME: Is this check still necessary? Requests are supposed to be stopped before clearGlobalObject() is called. + ASSERT(globalObject); if (!globalObject) return; @@ -107,7 +108,7 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) ref(); MarkedArgumentBuffer args; - args.append(toJS(exec, event)); + args.append(toJS(exec, globalObject, event)); Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); @@ -127,7 +128,7 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) if (isWindowEvent) thisValue = globalObject->toThisObject(exec); else - thisValue = toJS(exec, event->currentTarget()); + thisValue = toJS(exec, globalObject, event->currentTarget()); globalObject->globalData()->timeoutChecker.start(); retval = call(exec, jsFunction, callType, callData, thisValue, args); } @@ -153,6 +154,53 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) } } +bool JSEventListener::reportError(const String& message, const String& url, int lineNumber) +{ + JSLock lock(SilenceAssertionsOnly); + + JSObject* jsFunction = this->jsFunction(); + if (!jsFunction) + return false; + + JSDOMGlobalObject* globalObject = m_globalObject; + if (!globalObject) + return false; + + ExecState* exec = globalObject->globalExec(); + + CallData callData; + CallType callType = jsFunction->getCallData(callData); + + if (callType == CallTypeNone) + return false; + + MarkedArgumentBuffer args; + args.append(jsString(exec, message)); + args.append(jsString(exec, url)); + args.append(jsNumber(exec, lineNumber)); + + // If this event handler is the first JavaScript to execute, then the + // dynamic global object should be set to the global object of the + // window in which the event occurred. + JSGlobalData* globalData = globalObject->globalData(); + DynamicGlobalObjectScope globalObjectScope(exec, globalData->dynamicGlobalObject ? globalData->dynamicGlobalObject : globalObject); + + JSValue thisValue = globalObject->toThisObject(exec); + + globalObject->globalData()->timeoutChecker.start(); + JSValue returnValue = call(exec, jsFunction, callType, callData, thisValue, args); + globalObject->globalData()->timeoutChecker.stop(); + + // If an error occurs while handling the script error, it should be bubbled up. + if (exec->hadException()) { + exec->clearException(); + return false; + } + + bool bubbleEvent; + return returnValue.getBoolean(bubbleEvent) && !bubbleEvent; +} + bool JSEventListener::virtualisAttribute() const { return m_isAttribute; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h index ce34832ea..24977502e 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventListener.h @@ -45,6 +45,7 @@ namespace WebCore { private: virtual void markJSFunction(); virtual void handleEvent(Event*, bool isWindowEvent); + virtual bool reportError(const String& message, const String& url, int lineNumber); virtual bool virtualisAttribute() const; void clearJSFunctionInline(); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp index 875e904ad..b75cccf6a 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.cpp @@ -50,10 +50,10 @@ #endif #if ENABLE(WORKERS) +#include "DedicatedWorkerContext.h" +#include "JSDedicatedWorkerContext.h" #include "JSWorker.h" -#include "JSWorkerContext.h" #include "Worker.h" -#include "WorkerContext.h" #endif #if ENABLE(SHARED_WORKERS) @@ -65,7 +65,7 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, EventTarget* target) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* target) { if (!target) return jsNull(); @@ -73,42 +73,40 @@ JSValue toJS(ExecState* exec, EventTarget* target) #if ENABLE(SVG) // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node. if (SVGElementInstance* instance = target->toSVGElementInstance()) - return toJS(exec, instance); + return toJS(exec, globalObject, instance); #endif if (Node* node = target->toNode()) - return toJS(exec, node); + return toJS(exec, globalObject, node); if (DOMWindow* domWindow = target->toDOMWindow()) - return toJS(exec, domWindow); + return toJS(exec, globalObject, domWindow); if (XMLHttpRequest* xhr = target->toXMLHttpRequest()) - // XMLHttpRequest is always created via JS, so we don't need to use cacheDOMObject() here. - return getCachedDOMObjectWrapper(exec->globalData(), xhr); + return toJS(exec, globalObject, xhr); if (XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload()) - return toJS(exec, upload); + return toJS(exec, globalObject, upload); #if ENABLE(OFFLINE_WEB_APPLICATIONS) if (DOMApplicationCache* cache = target->toDOMApplicationCache()) - // DOMApplicationCache is always created via JS, so we don't need to use cacheDOMObject() here. - return getCachedDOMObjectWrapper(exec->globalData(), cache); + return toJS(exec, globalObject, cache); #endif if (MessagePort* messagePort = target->toMessagePort()) - return toJS(exec, messagePort); + return toJS(exec, globalObject, messagePort); #if ENABLE(WORKERS) if (Worker* worker = target->toWorker()) - return toJS(exec, worker); + return toJS(exec, globalObject, worker); - if (WorkerContext* workerContext = target->toWorkerContext()) + if (DedicatedWorkerContext* workerContext = target->toDedicatedWorkerContext()) return toJSDOMGlobalObject(workerContext); #endif #if ENABLE(SHARED_WORKERS) if (SharedWorker* sharedWorker = target->toSharedWorker()) - return toJS(exec, sharedWorker); + return toJS(exec, globalObject, sharedWorker); #endif ASSERT_NOT_REACHED(); @@ -139,7 +137,7 @@ EventTarget* toEventTarget(JSC::JSValue value) #if ENABLE(WORKERS) CONVERT_TO_EVENT_TARGET(Worker) - CONVERT_TO_EVENT_TARGET(WorkerContext) + CONVERT_TO_EVENT_TARGET(DedicatedWorkerContext) #endif #if ENABLE(SHARED_WORKERS) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.h b/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.h index 05df0568d..ddd823241 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSEventTarget.h @@ -35,8 +35,9 @@ namespace JSC { namespace WebCore { class EventTarget; + class JSDOMGlobalObject; - JSC::JSValue toJS(JSC::ExecState*, EventTarget*); + JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, EventTarget*); EventTarget* toEventTarget(JSC::JSValue); } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h index d559d3b76..7363e5ce2 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLAllCollection.h @@ -35,8 +35,8 @@ namespace WebCore { class JSHTMLAllCollection : public JSHTMLCollection { public: - JSHTMLAllCollection(PassRefPtr<JSC::Structure> structure, PassRefPtr<HTMLCollection> collection) - : JSHTMLCollection(structure, collection) + JSHTMLAllCollection(PassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<HTMLCollection> collection) + : JSHTMLCollection(structure, globalObject, collection) { } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp index 410046899..dd9af749b 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLCollectionCustom.cpp @@ -35,18 +35,18 @@ using namespace JSC; namespace WebCore { -static JSValue getNamedItems(ExecState* exec, HTMLCollection* impl, const Identifier& propertyName) +static JSValue getNamedItems(ExecState* exec, JSHTMLCollection* collection, const Identifier& propertyName) { Vector<RefPtr<Node> > namedItems; - impl->namedItems(propertyName, namedItems); + collection->impl()->namedItems(propertyName, namedItems); if (namedItems.isEmpty()) return jsUndefined(); if (namedItems.size() == 1) - return toJS(exec, namedItems[0].get()); + return toJS(exec, collection->globalObject(), namedItems[0].get()); - return new (exec) JSNamedNodesCollection(exec, namedItems); + return new (exec) JSNamedNodesCollection(exec, collection->globalObject(), namedItems); } // HTMLCollections are strange objects, they support both get and call, @@ -57,7 +57,8 @@ static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* funct return jsUndefined(); // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case. - HTMLCollection* collection = static_cast<JSHTMLCollection*>(function)->impl(); + JSHTMLCollection* jsCollection = static_cast<JSHTMLCollection*>(function); + HTMLCollection* collection = jsCollection->impl(); // Also, do we need the TypeError test here ? @@ -67,10 +68,10 @@ static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* funct UString string = args.at(0).toString(exec); unsigned index = string.toUInt32(&ok, false); if (ok) - return toJS(exec, collection->item(index)); + return toJS(exec, jsCollection->globalObject(), collection->item(index)); // Support for document.images('<name>') etc. - return getNamedItems(exec, collection, Identifier(exec, string)); + return getNamedItems(exec, jsCollection, Identifier(exec, string)); } // The second arg, if set, is the index of the item we want @@ -82,7 +83,7 @@ static JSValue JSC_HOST_CALL callHTMLCollection(ExecState* exec, JSObject* funct Node* node = collection->namedItem(pstr); while (node) { if (!index) - return toJS(exec, node); + return toJS(exec, jsCollection->globalObject(), node); node = collection->nextNamedItem(pstr); --index; } @@ -97,15 +98,17 @@ CallType JSHTMLCollection::getCallData(CallData& callData) return CallTypeHost; } -bool JSHTMLCollection::canGetItemsForName(ExecState* exec, HTMLCollection* thisObj, const Identifier& propertyName) +bool JSHTMLCollection::canGetItemsForName(ExecState*, HTMLCollection* collection, const Identifier& propertyName) { - return !getNamedItems(exec, thisObj, propertyName).isUndefined(); + Vector<RefPtr<Node> > namedItems; + collection->namedItems(propertyName, namedItems); + return !namedItems.isEmpty(); } JSValue JSHTMLCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase())); - return getNamedItems(exec, thisObj->impl(), propertyName); + return getNamedItems(exec, thisObj, propertyName); } JSValue JSHTMLCollection::item(ExecState* exec, const ArgList& args) @@ -113,16 +116,16 @@ JSValue JSHTMLCollection::item(ExecState* exec, const ArgList& args) bool ok; uint32_t index = args.at(0).toString(exec).toUInt32(&ok, false); if (ok) - return toJS(exec, impl()->item(index)); - return getNamedItems(exec, impl(), Identifier(exec, args.at(0).toString(exec))); + return toJS(exec, globalObject(), impl()->item(index)); + return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec))); } JSValue JSHTMLCollection::namedItem(ExecState* exec, const ArgList& args) { - return getNamedItems(exec, impl(), Identifier(exec, args.at(0).toString(exec))); + return getNamedItems(exec, this, Identifier(exec, args.at(0).toString(exec))); } -JSValue toJS(ExecState* exec, HTMLCollection* collection) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, HTMLCollection* collection) { if (!collection) return jsNull(); @@ -134,14 +137,14 @@ JSValue toJS(ExecState* exec, HTMLCollection* collection) switch (collection->type()) { case SelectOptions: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, HTMLOptionsCollection, collection); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLOptionsCollection, collection); break; case DocAll: typedef HTMLCollection HTMLAllCollection; - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, HTMLAllCollection, collection); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLAllCollection, collection); break; default: - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, HTMLCollection, collection); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, HTMLCollection, collection); break; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLElementCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLElementCustom.cpp index 3345764f3..419465721 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLElementCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLElementCustom.cpp @@ -38,14 +38,14 @@ void JSHTMLElement::pushEventHandlerScope(ExecState* exec, ScopeChain& scope) co 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, element->ownerDocument()))); + 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, form))); + scope.push(asObject(toJS(exec, globalObject(), form))); // The element is on top, searched first. - scope.push(asObject(toJS(exec, element))); + scope.push(asObject(toJS(exec, globalObject(), element))); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFormElementCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFormElementCustom.cpp index e5b428a53..ffa2d5779 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFormElementCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFormElementCustom.cpp @@ -45,7 +45,8 @@ bool JSHTMLFormElement::canGetItemsForName(ExecState*, HTMLFormElement* form, co JSValue JSHTMLFormElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { - HTMLFormElement* form = static_cast<HTMLFormElement*>(static_cast<JSHTMLElement*>(asObject(slot.slotBase()))->impl()); + JSHTMLElement* jsForm = static_cast<JSHTMLFormElement*>(asObject(slot.slotBase())); + HTMLFormElement* form = static_cast<HTMLFormElement*>(jsForm->impl()); Vector<RefPtr<Node> > namedItems; form->getNamedElements(propertyName, namedItems); @@ -53,7 +54,7 @@ JSValue JSHTMLFormElement::nameGetter(ExecState* exec, const Identifier& propert if (namedItems.size() == 1) return toJS(exec, namedItems[0].get()); if (namedItems.size() > 1) - return new (exec) JSNamedNodesCollection(exec, namedItems); + return new (exec) JSNamedNodesCollection(exec, jsForm->globalObject(), namedItems); return jsUndefined(); } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp index 0a5d1f14b..c8aea9fea 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp @@ -40,7 +40,7 @@ namespace WebCore { static inline bool allowSettingJavascriptURL(ExecState* exec, HTMLFrameElement* imp, const String& value) { - if (protocolIsJavaScript(parseURL(value))) { + if (protocolIsJavaScript(deprecatedParseURL(value))) { if (!checkNodeSecurity(exec, imp->contentDocument())) return false; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp index afff977de..8e32381bc 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp @@ -44,7 +44,7 @@ void JSHTMLIFrameElement::setSrc(ExecState* exec, JSValue value) String srcValue = valueToStringWithNullCheck(exec, value); - if (protocolIsJavaScript(parseURL(srcValue))) { + if (protocolIsJavaScript(deprecatedParseURL(srcValue))) { if (!checkNodeSecurity(exec, imp->contentDocument())) return; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp index 460ba084a..7bca2db6b 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp @@ -91,7 +91,7 @@ JSValue JSHTMLOptionsCollection::add(ExecState* exec, const ArgList& args) JSValue JSHTMLOptionsCollection::remove(ExecState* exec, const ArgList& args) { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); - JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, imp->base()))); + JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, globalObject(), imp->base()))); return base->remove(exec, args); } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.cpp index 4a27bb4a2..faaaf41ed 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.cpp @@ -35,18 +35,9 @@ ASSERT_CLASS_FITS_IN_CELL(JSImageConstructor); const ClassInfo JSImageConstructor::s_info = { "ImageConstructor", 0, 0, 0 }; JSImageConstructor::JSImageConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMObject(JSImageConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) - , m_globalObject(globalObject) + : DOMConstructorWithDocument(JSImageConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - ASSERT(globalObject->scriptExecutionContext()); - ASSERT(globalObject->scriptExecutionContext()->isDocument()); - - putDirect(exec->propertyNames().prototype, JSHTMLImageElementPrototype::self(exec, exec->lexicalGlobalObject()), None); -} - -Document* JSImageConstructor::document() const -{ - return static_cast<Document*>(m_globalObject->scriptExecutionContext()); + putDirect(exec->propertyNames().prototype, JSHTMLImageElementPrototype::self(exec, globalObject), None); } static JSObject* constructImage(ExecState* exec, JSObject* constructor, const ArgList& args) @@ -64,21 +55,22 @@ static JSObject* constructImage(ExecState* exec, JSObject* constructor, const Ar height = args.at(1).toInt32(exec); } - Document* document = static_cast<JSImageConstructor*>(constructor)->document(); + JSImageConstructor* jsConstructor = static_cast<JSImageConstructor*>(constructor); + Document* document = jsConstructor->document(); if (!document) return throwError(exec, ReferenceError, "Image constructor associated document is unavailable"); // Calling toJS on the document causes the JS document wrapper to be // added to the window object. This is done to ensure that JSDocument::mark // will be called (which will cause the image element to be marked if necessary). - toJS(exec, document); + toJS(exec, jsConstructor->globalObject(), document); RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document); if (widthSet) image->setWidth(width); if (heightSet) image->setHeight(height); - return asObject(toJS(exec, image.release())); + return asObject(toJS(exec, jsConstructor->globalObject(), image.release())); } ConstructType JSImageConstructor::getConstructData(ConstructData& constructData) @@ -87,11 +79,4 @@ ConstructType JSImageConstructor::getConstructData(ConstructData& constructData) return ConstructTypeHost; } -void JSImageConstructor::mark() -{ - DOMObject::mark(); - if (!m_globalObject->marked()) - m_globalObject->mark(); -} - } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.h index 8dc7add2a..0525f5eac 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSImageConstructor.h @@ -25,19 +25,14 @@ namespace WebCore { - class JSImageConstructor : public DOMObject { + class JSImageConstructor : public DOMConstructorWithDocument { public: JSImageConstructor(JSC::ExecState*, JSDOMGlobalObject*); - Document* document() const; static const JSC::ClassInfo s_info; - - virtual void mark(); private: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - - JSDOMGlobalObject* m_globalObject; }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSImageDataCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSImageDataCustom.cpp index 32fe58bcf..fa3b1d5c0 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSImageDataCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSImageDataCustom.cpp @@ -36,7 +36,7 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, ImageData* imageData) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData* imageData) { if (!imageData) return jsNull(); @@ -45,7 +45,7 @@ JSValue toJS(ExecState* exec, ImageData* imageData) if (wrapper) return wrapper; - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, ImageData, imageData); + 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 }; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorControllerCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp index b06c9e980..b2eb2d17c 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorControllerCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSInspectorBackendCustom.cpp @@ -31,7 +31,7 @@ */ #include "config.h" -#include "JSInspectorController.h" +#include "JSInspectorBackend.h" #include "Console.h" #if ENABLE(DATABASE) @@ -41,6 +41,7 @@ #include "ExceptionCode.h" #include "Frame.h" #include "FrameLoader.h" +#include "InspectorBackend.h" #include "InspectorController.h" #include "InspectorResource.h" #include "JSDOMWindow.h" @@ -69,7 +70,7 @@ using namespace JSC; namespace WebCore { -JSValue JSInspectorController::highlightDOMNode(JSC::ExecState*, const JSC::ArgList& args) +JSValue JSInspectorBackend::highlightDOMNode(JSC::ExecState*, const JSC::ArgList& args) { if (args.size() < 1) return jsUndefined(); @@ -87,34 +88,7 @@ JSValue JSInspectorController::highlightDOMNode(JSC::ExecState*, const JSC::ArgL return jsUndefined(); } -JSValue JSInspectorController::getResourceDocumentNode(ExecState* exec, const ArgList& args) -{ - if (args.size() < 1) - return jsUndefined(); - - bool ok = false; - unsigned identifier = args.at(0).toUInt32(exec, ok); - if (!ok) - return jsUndefined(); - - RefPtr<InspectorResource> resource = impl()->resources().get(identifier); - ASSERT(resource); - if (!resource) - return jsUndefined(); - - Frame* frame = resource->frame(); - Document* document = frame->document(); - - if (document->isPluginDocument() || document->isImageDocument() || document->isMediaDocument()) - return jsUndefined(); - - ExecState* resourceExec = toJSDOMWindowShell(frame)->window()->globalExec(); - - JSLock lock(false); - return JSInspectedObjectWrapper::wrap(resourceExec, toJS(resourceExec, document)); -} - -JSValue JSInspectorController::search(ExecState* exec, const ArgList& args) +JSValue JSInspectorBackend::search(ExecState* exec, const ArgList& args) { if (args.size() < 2) return jsUndefined(); @@ -151,7 +125,7 @@ JSValue JSInspectorController::search(ExecState* exec, const ArgList& args) } #if ENABLE(DATABASE) -JSValue JSInspectorController::databaseTableNames(ExecState* exec, const ArgList& args) +JSValue JSInspectorBackend::databaseTableNames(ExecState* exec, const ArgList& args) { if (args.size() < 1) return jsUndefined(); @@ -175,13 +149,16 @@ JSValue JSInspectorController::databaseTableNames(ExecState* exec, const ArgList } #endif -JSValue JSInspectorController::inspectedWindow(ExecState*, const ArgList&) +JSValue JSInspectorBackend::inspectedWindow(ExecState*, const ArgList&) { - JSDOMWindow* inspectedWindow = toJSDOMWindow(impl()->inspectedPage()->mainFrame()); + InspectorController* ic = impl()->inspectorController(); + if (!ic) + return jsUndefined(); + JSDOMWindow* inspectedWindow = toJSDOMWindow(ic->inspectedPage()->mainFrame()); return JSInspectedObjectWrapper::wrap(inspectedWindow->globalExec(), inspectedWindow); } -JSValue JSInspectorController::setting(ExecState* exec, const ArgList& args) +JSValue JSInspectorBackend::setting(ExecState* exec, const ArgList& args) { if (args.size() < 1) return jsUndefined(); @@ -190,7 +167,10 @@ JSValue JSInspectorController::setting(ExecState* exec, const ArgList& args) if (exec->hadException()) return jsUndefined(); - const InspectorController::Setting& setting = impl()->setting(key); + InspectorController* ic = impl()->inspectorController(); + if (!ic) + return jsUndefined(); + const InspectorController::Setting& setting = ic->setting(key); switch (setting.type()) { default: @@ -215,7 +195,7 @@ JSValue JSInspectorController::setting(ExecState* exec, const ArgList& args) } } -JSValue JSInspectorController::setSetting(ExecState* exec, const ArgList& args) +JSValue JSInspectorBackend::setSetting(ExecState* exec, const ArgList& args) { if (args.size() < 2) return jsUndefined(); @@ -253,12 +233,14 @@ JSValue JSInspectorController::setSetting(ExecState* exec, const ArgList& args) if (exec->hadException()) return jsUndefined(); - impl()->setSetting(key, setting); + InspectorController* ic = impl()->inspectorController(); + if (ic) + ic->setSetting(key, setting); return jsUndefined(); } -JSValue JSInspectorController::wrapCallback(ExecState* exec, const ArgList& args) +JSValue JSInspectorBackend::wrapCallback(ExecState* exec, const ArgList& args) { if (args.size() < 1) return jsUndefined(); @@ -268,7 +250,7 @@ JSValue JSInspectorController::wrapCallback(ExecState* exec, const ArgList& args #if ENABLE(JAVASCRIPT_DEBUGGER) -JSValue JSInspectorController::currentCallFrame(ExecState* exec, const ArgList&) +JSValue JSInspectorBackend::currentCallFrame(ExecState* exec, const ArgList&) { JavaScriptCallFrame* callFrame = impl()->currentCallFrame(); if (!callFrame || !callFrame->isValid()) @@ -277,15 +259,18 @@ JSValue JSInspectorController::currentCallFrame(ExecState* exec, const ArgList&) // FIXME: I am not sure if this is actually needed. Can we just use exec? ExecState* globalExec = callFrame->scopeChain()->globalObject()->globalExec(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); return JSInspectedObjectWrapper::wrap(globalExec, toJS(exec, callFrame)); } -JSValue JSInspectorController::profiles(JSC::ExecState* exec, const JSC::ArgList&) +JSValue JSInspectorBackend::profiles(JSC::ExecState* exec, const JSC::ArgList&) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); MarkedArgumentBuffer result; - const Vector<RefPtr<Profile> >& profiles = impl()->profiles(); + InspectorController* ic = impl()->inspectorController(); + if (!ic) + return jsUndefined(); + const Vector<RefPtr<Profile> >& profiles = ic->profiles(); for (size_t i = 0; i < profiles.size(); ++i) result.append(toJS(exec, profiles[i].get())); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp index 891324395..7caff2b23 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSLazyEventListener.cpp @@ -117,7 +117,7 @@ void JSLazyEventListener::parseCode() const // (and the document, and the form - see JSHTMLElement::eventHandlerScope) ScopeChain scope = listenerAsFunction->scope(); - JSValue thisObj = toJS(exec, m_originalNode); + JSValue thisObj = toJS(exec, m_globalObject, m_originalNode); if (thisObj.isObject()) { static_cast<JSNode*>(asObject(thisObj))->pushEventHandlerScope(exec, scope); listenerAsFunction->setScope(scope); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.cpp index 495bd53a1..25a5cb2e8 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.cpp @@ -38,21 +38,15 @@ namespace WebCore { const ClassInfo JSMessageChannelConstructor::s_info = { "MessageChannelConstructor", 0, 0, 0 }; JSMessageChannelConstructor::JSMessageChannelConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMObject(JSMessageChannelConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) - , m_globalObject(globalObject) + : DOMConstructorObject(JSMessageChannelConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSMessageChannelPrototype::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, JSMessageChannelPrototype::self(exec, globalObject), None); } JSMessageChannelConstructor::~JSMessageChannelConstructor() { } -ScriptExecutionContext* JSMessageChannelConstructor::scriptExecutionContext() const -{ - return m_globalObject->scriptExecutionContext(); -} - ConstructType JSMessageChannelConstructor::getConstructData(ConstructData& constructData) { constructData.native.function = construct; @@ -61,18 +55,12 @@ ConstructType JSMessageChannelConstructor::getConstructData(ConstructData& const JSObject* JSMessageChannelConstructor::construct(ExecState* exec, JSObject* constructor, const ArgList&) { - ScriptExecutionContext* context = static_cast<JSMessageChannelConstructor*>(constructor)->scriptExecutionContext(); + JSMessageChannelConstructor* jsConstructor = static_cast<JSMessageChannelConstructor*>(constructor); + ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); if (!context) return throwError(exec, ReferenceError, "MessageChannel constructor associated document is unavailable"); - return asObject(toJS(exec, MessageChannel::create(context))); -} - -void JSMessageChannelConstructor::mark() -{ - DOMObject::mark(); - if (!m_globalObject->marked()) - m_globalObject->mark(); + return asObject(toJS(exec, jsConstructor->globalObject(), MessageChannel::create(context))); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.h index 90c29a3c1..d95876047 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelConstructor.h @@ -30,23 +30,16 @@ namespace WebCore { - class JSMessageChannelConstructor : public DOMObject { + class JSMessageChannelConstructor : public DOMConstructorObject { public: JSMessageChannelConstructor(JSC::ExecState*, JSDOMGlobalObject*); virtual ~JSMessageChannelConstructor(); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; - ScriptExecutionContext* scriptExecutionContext() const; - virtual bool implementsHasInstance() const { return true; } static JSC::JSObject* construct(JSC::ExecState*, JSC::JSObject*, const JSC::ArgList&); virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - - virtual void mark(); - - private: - JSDOMGlobalObject* m_globalObject; }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp index 70329e2c8..d3b58789a 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessageChannelCustom.cpp @@ -34,7 +34,7 @@ namespace WebCore { void JSMessageChannel::mark() { - DOMObject::mark(); + Base::mark(); if (MessagePort* port = m_impl->port1()) { DOMObject* wrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), port); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp index bfac37536..71472d5b7 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSMessagePortCustom.cpp @@ -40,7 +40,7 @@ namespace WebCore { void JSMessagePort::mark() { - DOMObject::mark(); + Base::mark(); markIfNotNull(m_impl->onmessage()); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.cpp index af1995bb3..f36a7d6a1 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.cpp @@ -42,10 +42,8 @@ const ClassInfo JSNamedNodesCollection::s_info = { "Collection", 0, 0, 0 }; // Such a collection is usually very short-lived, it only exists // for constructs like document.forms.<name>[1], // so it shouldn't be a problem that it's storing all the nodes (with the same name). (David) -JSNamedNodesCollection::JSNamedNodesCollection(ExecState* exec, const Vector<RefPtr<Node> >& nodes) - // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object - // we should use the global object from the nodes. - : DOMObject(deprecatedGetDOMStructure<JSNamedNodesCollection>(exec)) +JSNamedNodesCollection::JSNamedNodesCollection(ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<RefPtr<Node> >& nodes) + : DOMObjectWithGlobalPointer(getDOMStructure<JSNamedNodesCollection>(exec, globalObject), globalObject) , m_nodes(new Vector<RefPtr<Node> >(nodes)) { } @@ -88,7 +86,7 @@ bool JSNamedNodesCollection::getOwnPropertySlot(ExecState* exec, const Identifie } } - return DOMObject::getOwnPropertySlot(exec, propertyName, slot); + return DOMObjectWithGlobalPointer::getOwnPropertySlot(exec, propertyName, slot); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.h b/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.h index 3bbc102b9..cd6c2cb9f 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNamedNodesCollection.h @@ -35,9 +35,9 @@ namespace WebCore { // Internal class, used for the collection return by e.g. document.forms.myinput // when multiple nodes have the same name. - class JSNamedNodesCollection : public DOMObject { + class JSNamedNodesCollection : public DOMObjectWithGlobalPointer { public: - JSNamedNodesCollection(JSC::ExecState*, const Vector<RefPtr<Node> >&); + JSNamedNodesCollection(JSC::ExecState*, JSDOMGlobalObject*, const Vector<RefPtr<Node> >&); virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp index 79ac6b78c..2f080b8f9 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeCustom.cpp @@ -146,7 +146,7 @@ void JSNode::mark() // the document, we need to mark the document, but we don't need to explicitly // mark any other nodes. if (node->inDocument()) { - DOMObject::mark(); + Base::mark(); markEventListeners(node->eventListeners()); if (Document* doc = node->ownerDocument()) if (DOMObject* docWrapper = getCachedDOMObjectWrapper(*Heap::heap(this)->globalData(), doc)) @@ -164,7 +164,7 @@ void JSNode::mark() // Nodes in a subtree are marked by the tree's root, so, if the root is already // marking the tree, we don't need to explicitly mark any other nodes. if (root->inSubtreeMark()) { - DOMObject::mark(); + Base::mark(); markEventListeners(node->eventListeners()); return; } @@ -192,7 +192,7 @@ void JSNode::mark() ASSERT(marked()); } -static ALWAYS_INLINE JSValue createWrapper(ExecState* exec, Node* node) +static ALWAYS_INLINE JSValue createWrapper(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node) { ASSERT(node); ASSERT(!getCachedDOMNodeWrapper(node->document(), node)); @@ -201,63 +201,63 @@ static ALWAYS_INLINE JSValue createWrapper(ExecState* exec, Node* node) switch (node->nodeType()) { case Node::ELEMENT_NODE: if (node->isHTMLElement()) - wrapper = createJSHTMLWrapper(exec, static_cast<HTMLElement*>(node)); + wrapper = createJSHTMLWrapper(exec, globalObject, static_cast<HTMLElement*>(node)); #if ENABLE(SVG) else if (node->isSVGElement()) - wrapper = createJSSVGWrapper(exec, static_cast<SVGElement*>(node)); + wrapper = createJSSVGWrapper(exec, globalObject, static_cast<SVGElement*>(node)); #endif else - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Element, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Element, node); break; case Node::ATTRIBUTE_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Attr, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Attr, node); break; case Node::TEXT_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Text, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Text, node); break; case Node::CDATA_SECTION_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, CDATASection, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, CDATASection, node); break; case Node::ENTITY_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Entity, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Entity, node); break; case Node::PROCESSING_INSTRUCTION_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, ProcessingInstruction, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, ProcessingInstruction, node); break; case Node::COMMENT_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Comment, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Comment, node); break; case Node::DOCUMENT_NODE: // we don't want to cache the document itself in the per-document dictionary - return toJS(exec, static_cast<Document*>(node)); + return toJS(exec, globalObject, static_cast<Document*>(node)); case Node::DOCUMENT_TYPE_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, DocumentType, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, DocumentType, node); break; case Node::NOTATION_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Notation, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Notation, node); break; case Node::DOCUMENT_FRAGMENT_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, DocumentFragment, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, DocumentFragment, node); break; case Node::ENTITY_REFERENCE_NODE: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, EntityReference, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, EntityReference, node); break; default: - wrapper = CREATE_DOM_NODE_WRAPPER(exec, Node, node); + wrapper = CREATE_DOM_NODE_WRAPPER(exec, globalObject, Node, node); } return wrapper; } -JSValue toJSNewlyCreated(ExecState* exec, Node* node) +JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node) { if (!node) return jsNull(); - return createWrapper(exec, node); + return createWrapper(exec, globalObject, node); } -JSValue toJS(ExecState* exec, Node* node) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Node* node) { if (!node) return jsNull(); @@ -266,7 +266,7 @@ JSValue toJS(ExecState* exec, Node* node) if (wrapper) return wrapper; - return createWrapper(exec, node); + return createWrapper(exec, globalObject, node); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp index f5d4d5c36..2595af587 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCondition.cpp @@ -44,7 +44,7 @@ void JSNodeFilterCondition::mark() short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) const { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); CallData callData; CallType callType = m_filter.getCallData(callData); @@ -61,7 +61,9 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) return NodeFilter::FILTER_REJECT; MarkedArgumentBuffer args; - args.append(toJS(exec, filterNode)); + // FIXME: The node should have the prototype chain that came from its document, not + // whatever prototype chain might be on the window this filter came from. Bug 27662 + args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), filterNode)); if (exec->hadException()) return NodeFilter::FILTER_REJECT; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCustom.cpp index ecc12d55f..a48a59d65 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeFilterCustom.cpp @@ -38,7 +38,7 @@ namespace WebCore { void JSNodeFilter::mark() { impl()->mark(); - DOMObject::mark(); + Base::mark(); } JSValue JSNodeFilter::acceptNode(ExecState* exec, const ArgList& args) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeIteratorCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeIteratorCustom.cpp index 8fff82ea7..a2b96586b 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSNodeIteratorCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSNodeIteratorCustom.cpp @@ -34,7 +34,7 @@ void JSNodeIterator::mark() if (NodeFilter* filter = m_impl->filter()) filter->mark(); - DOMObject::mark(); + Base::mark(); } JSValue JSNodeIterator::nextNode(ExecState* exec, const ArgList&) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.cpp index 9e818ff68..2b8bd5d97 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.cpp @@ -35,24 +35,16 @@ ASSERT_CLASS_FITS_IN_CELL(JSOptionConstructor); const ClassInfo JSOptionConstructor::s_info = { "OptionConstructor", 0, 0, 0 }; JSOptionConstructor::JSOptionConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMObject(JSOptionConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) - , m_globalObject(globalObject) + : DOMConstructorWithDocument(JSOptionConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - ASSERT(globalObject->scriptExecutionContext()); - ASSERT(globalObject->scriptExecutionContext()->isDocument()); - - putDirect(exec->propertyNames().prototype, JSHTMLOptionElementPrototype::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, JSHTMLOptionElementPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 4), ReadOnly|DontDelete|DontEnum); } -Document* JSOptionConstructor::document() const -{ - return static_cast<Document*>(m_globalObject->scriptExecutionContext()); -} - static JSObject* constructHTMLOptionElement(ExecState* exec, JSObject* constructor, const ArgList& args) { - Document* document = static_cast<JSOptionConstructor*>(constructor)->document(); + JSOptionConstructor* jsConstructor = static_cast<JSOptionConstructor*>(constructor); + Document* document = jsConstructor->document(); if (!document) return throwError(exec, ReferenceError, "Option constructor associated document is unavailable"); @@ -76,7 +68,7 @@ static JSObject* constructHTMLOptionElement(ExecState* exec, JSObject* construct return 0; } - return asObject(toJS(exec, element.release())); + return asObject(toJS(exec, jsConstructor->globalObject(), element.release())); } ConstructType JSOptionConstructor::getConstructData(ConstructData& constructData) @@ -85,11 +77,5 @@ ConstructType JSOptionConstructor::getConstructData(ConstructData& constructData return ConstructTypeHost; } -void JSOptionConstructor::mark() -{ - DOMObject::mark(); - if (!m_globalObject->marked()) - m_globalObject->mark(); -} } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.h index 3c87c28f1..246e7fa6c 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSOptionConstructor.h @@ -26,19 +26,14 @@ namespace WebCore { - class JSOptionConstructor : public DOMObject { + class JSOptionConstructor : public DOMConstructorWithDocument { public: JSOptionConstructor(JSC::ExecState*, JSDOMGlobalObject*); - Document* document() const; static const JSC::ClassInfo s_info; - - virtual void mark(); private: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - - JSDOMGlobalObject* m_globalObject; }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSRGBColor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSRGBColor.cpp deleted file mode 100644 index c430d5fb1..000000000 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSRGBColor.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2000 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2006 James G. Speth (speth@end.com) - * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "JSRGBColor.h" - -#include "CSSPrimitiveValue.h" -#include "JSCSSPrimitiveValue.h" - -using namespace JSC; - -static JSValue jsRGBColorRed(ExecState*, const Identifier&, const PropertySlot&); -static JSValue jsRGBColorGreen(ExecState*, const Identifier&, const PropertySlot&); -static JSValue jsRGBColorBlue(ExecState*, const Identifier&, const PropertySlot&); - -/* -@begin JSRGBColorTable - red jsRGBColorRed DontDelete|ReadOnly - green jsRGBColorGreen DontDelete|ReadOnly - blue jsRGBColorBlue DontDelete|ReadOnly -@end -*/ - -#include "JSRGBColor.lut.h" - -namespace WebCore { - -ASSERT_CLASS_FITS_IN_CELL(JSRGBColor); - -const ClassInfo JSRGBColor::s_info = { "RGBColor", 0, &JSRGBColorTable, 0 }; - -JSRGBColor::JSRGBColor(ExecState* exec, unsigned color) - // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object - // This will be fixed when JSRGBColor wraps css/RGBColor instead of being custom. - : DOMObject(deprecatedGetDOMStructure<JSRGBColor>(exec)) - , m_color(color) -{ -} - -bool JSRGBColor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -{ - return getStaticValueSlot<JSRGBColor, DOMObject>(exec, &JSRGBColorTable, this, propertyName, slot); -} - -JSValue getJSRGBColor(ExecState* exec, unsigned color) -{ - return new (exec) JSRGBColor(exec, color); -} - -} // namespace WebCore - -using namespace WebCore; - -JSValue jsRGBColorRed(ExecState* exec, const Identifier&, const PropertySlot& slot) -{ - return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() >> 16) & 0xFF, CSSPrimitiveValue::CSS_NUMBER)); -} - -JSValue jsRGBColorGreen(ExecState* exec, const Identifier&, const PropertySlot& slot) -{ - return toJS(exec, CSSPrimitiveValue::create((static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() >> 8) & 0xFF, CSSPrimitiveValue::CSS_NUMBER)); -} - -JSValue jsRGBColorBlue(ExecState* exec, const Identifier&, const PropertySlot& slot) -{ - return toJS(exec, CSSPrimitiveValue::create(static_cast<JSRGBColor*>(asObject(slot.slotBase()))->impl() & 0xFF, CSSPrimitiveValue::CSS_NUMBER)); -} - diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSRGBColor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSRGBColor.h deleted file mode 100644 index cc2870f91..000000000 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSRGBColor.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2000 Harri Porten (porten@kde.org) - * Copyright (C) 2001 Peter Kelly (pmk@post.com) - * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef JSRGBColor_h -#define JSRGBColor_h - -#include "Color.h" -#include "JSDOMBinding.h" - -namespace WebCore { - - // FIXME: JSRGBColor should have a proper prototype and a constructor. - class JSRGBColor : public DOMObject { - public: - JSRGBColor(JSC::ExecState*, unsigned color); - - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); - - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - static const JSC::ClassInfo s_info; - - unsigned impl() const { return m_color; } - - static JSC::ObjectPrototype* createPrototype(JSC::ExecState*, JSC::JSGlobalObject* globalObject) - { - return globalObject->objectPrototype(); - } - - static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) - { - return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); - } - - private: - unsigned m_color; - }; - - JSC::JSValue getJSRGBColor(JSC::ExecState*, unsigned color); - -} // namespace WebCore - -#endif // JSRGBColor_h diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp index 2922740a5..055368e3a 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp @@ -39,7 +39,7 @@ namespace WebCore { void JSSVGElementInstance::mark() { - DOMObject::mark(); + Base::mark(); // Mark the wrapper for our corresponding element, so it can mark its event handlers. JSNode* correspondingWrapper = getCachedDOMNodeWrapper(impl()->correspondingElement()->document(), impl()->correspondingElement()); @@ -75,9 +75,9 @@ void JSSVGElementInstance::pushEventHandlerScope(ExecState*, ScopeChain&) const { } -JSC::JSValue toJS(JSC::ExecState* exec, SVGElementInstance* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, SVGElementInstance* object) { - JSValue result = getDOMObjectWrapper<JSSVGElementInstance>(exec, object); + JSValue result = getDOMObjectWrapper<JSSVGElementInstance>(exec, globalObject, object); // Ensure that our corresponding element has a JavaScript wrapper to keep its event handlers alive. if (object) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGMatrixCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGMatrixCustom.cpp index fc1e26612..35390b229 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGMatrixCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGMatrixCustom.cpp @@ -32,7 +32,7 @@ namespace WebCore { JSValue JSSVGMatrix::inverse(ExecState* exec, const ArgList&) { TransformationMatrix imp(*impl()); - JSC::JSValue result = toJS(exec, JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.inverse()).get(), m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.inverse()).get(), m_context.get()); if (!imp.isInvertible()) setDOMException(exec, SVGException::SVG_MATRIX_NOT_INVERTABLE); @@ -47,7 +47,7 @@ JSValue JSSVGMatrix::rotateFromVector(ExecState* exec, const ArgList& args) float x = args.at(0).toFloat(exec); float y = args.at(1).toFloat(exec); - JSC::JSValue result = toJS(exec, JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.rotateFromVector(x, y)).get(), m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.rotateFromVector(x, y)).get(), m_context.get()); if (x == 0.0 || y == 0.0) setDOMException(exec, SVGException::SVG_INVALID_VALUE_ERR); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegCustom.cpp index cb4687c83..42fa878fe 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegCustom.cpp @@ -59,7 +59,7 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, SVGPathSeg* object, SVGElement* context) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, SVGPathSeg* object, SVGElement* context) { if (!object) return jsNull(); @@ -69,46 +69,46 @@ JSValue toJS(ExecState* exec, SVGPathSeg* object, SVGElement* context) switch (object->pathSegType()) { case SVGPathSeg::PATHSEG_CLOSEPATH: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegClosePath, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegClosePath, object, context); case SVGPathSeg::PATHSEG_MOVETO_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegMovetoAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoAbs, object, context); case SVGPathSeg::PATHSEG_MOVETO_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegMovetoRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoRel, object, context); case SVGPathSeg::PATHSEG_LINETO_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegLinetoAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoAbs, object, context); case SVGPathSeg::PATHSEG_LINETO_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegLinetoRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoRel, object, context); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoCubicAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicAbs, object, context); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoCubicRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicRel, object, context); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoQuadraticAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticAbs, object, context); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoQuadraticRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticRel, object, context); case SVGPathSeg::PATHSEG_ARC_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegArcAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcAbs, object, context); case SVGPathSeg::PATHSEG_ARC_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegArcRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcRel, object, context); case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegLinetoHorizontalAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalAbs, object, context); case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegLinetoHorizontalRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalRel, object, context); case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegLinetoVerticalAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalAbs, object, context); case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegLinetoVerticalRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalRel, object, context); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoCubicSmoothAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothAbs, object, context); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoCubicSmoothRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothRel, object, context); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoQuadraticSmoothAbs, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothAbs, object, context); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSegCurvetoQuadraticSmoothRel, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothRel, object, context); case SVGPathSeg::PATHSEG_UNKNOWN: default: - return CREATE_SVG_OBJECT_WRAPPER(exec, SVGPathSeg, object, context); + return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSeg, object, context); } } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegListCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegListCustom.cpp index b6fc1166b..b71f3a641 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegListCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPathSegListCustom.cpp @@ -57,7 +57,7 @@ JSValue JSSVGPathSegList::initialize(ExecState* exec, const ArgList& args) SVGPathSeg* obj = WTF::getPtr(imp->initialize(newItem, ec)); - JSC::JSValue result = toJS(exec, obj, m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), obj, m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); @@ -78,7 +78,7 @@ JSValue JSSVGPathSegList::getItem(ExecState* exec, const ArgList& args) SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl()); SVGPathSeg* obj = WTF::getPtr(imp->getItem(index, ec)); - JSC::JSValue result = toJS(exec, obj, m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), obj, m_context.get()); setDOMException(exec, ec); return result; } @@ -97,7 +97,7 @@ JSValue JSSVGPathSegList::insertItemBefore(ExecState* exec, const ArgList& args) SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl()); - JSC::JSValue result = toJS(exec, WTF::getPtr(imp->insertItemBefore(newItem, index, ec)), m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), WTF::getPtr(imp->insertItemBefore(newItem, index, ec)), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); @@ -118,7 +118,7 @@ JSValue JSSVGPathSegList::replaceItem(ExecState* exec, const ArgList& args) SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl()); - JSC::JSValue result = toJS(exec, WTF::getPtr(imp->replaceItem(newItem, index, ec)), m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), WTF::getPtr(imp->replaceItem(newItem, index, ec)), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); @@ -140,7 +140,7 @@ JSValue JSSVGPathSegList::removeItem(ExecState* exec, const ArgList& args) RefPtr<SVGPathSeg> obj(imp->removeItem(index, ec)); - JSC::JSValue result = toJS(exec, obj.get(), m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), obj.get(), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); @@ -154,7 +154,7 @@ JSValue JSSVGPathSegList::appendItem(ExecState* exec, const ArgList& args) SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl()); - JSC::JSValue result = toJS(exec, WTF::getPtr(imp->appendItem(newItem, ec)), m_context.get()); + JSC::JSValue result = toJS(exec, deprecatedGlobalObjectForPrototype(exec), WTF::getPtr(imp->appendItem(newItem, ec)), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPointListCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPointListCustom.cpp index a18c2a269..1969fe284 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPointListCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGPointListCustom.cpp @@ -39,7 +39,7 @@ static JSValue finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* cont setDOMException(exec, ec); return jsUndefined(); } - return toJS(exec, JSSVGPODTypeWrapperCreatorForList<FloatPoint>::create(item.get(), list->associatedAttributeName()).get(), context); + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGPODTypeWrapperCreatorForList<FloatPoint>::create(item.get(), list->associatedAttributeName()).get(), context); } static JSValue finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem > item) @@ -50,7 +50,7 @@ static JSValue finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* cont } const QualifiedName& attributeName = list->associatedAttributeName(); context->svgAttributeChanged(attributeName); - return toJS(exec, JSSVGPODTypeWrapperCreatorForList<FloatPoint>::create(item.get(), attributeName).get(), context); + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGPODTypeWrapperCreatorForList<FloatPoint>::create(item.get(), attributeName).get(), context); } static JSValue finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem> item) @@ -60,7 +60,7 @@ static JSValue finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SV return jsUndefined(); } context->svgAttributeChanged(list->associatedAttributeName()); - return toJS(exec, JSSVGStaticPODTypeWrapper<FloatPoint>::create(*item).get(), context); + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<FloatPoint>::create(*item).get(), context); } JSValue JSSVGPointList::clear(ExecState* exec, const ArgList&) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGTransformListCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGTransformListCustom.cpp index 58b25ad0a..1a9110a9a 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSVGTransformListCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSVGTransformListCustom.cpp @@ -39,7 +39,7 @@ static JSValue finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* cont setDOMException(exec, ec); return jsUndefined(); } - return toJS(exec, JSSVGPODTypeWrapperCreatorForList<SVGTransform>::create(item.get(), list->associatedAttributeName()).get(), context); + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGPODTypeWrapperCreatorForList<SVGTransform>::create(item.get(), list->associatedAttributeName()).get(), context); } static JSValue finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) @@ -50,7 +50,7 @@ static JSValue finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* cont } const QualifiedName& attributeName = list->associatedAttributeName(); context->svgAttributeChanged(attributeName); - return toJS(exec, JSSVGPODTypeWrapperCreatorForList<SVGTransform>::create(item.get(), attributeName).get(), context); + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGPODTypeWrapperCreatorForList<SVGTransform>::create(item.get(), attributeName).get(), context); } static JSValue finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) @@ -60,7 +60,7 @@ static JSValue finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SV return jsUndefined(); } context->svgAttributeChanged(list->associatedAttributeName()); - return toJS(exec, JSSVGStaticPODTypeWrapper<SVGTransform>::create(*item).get(), context); + return toJS(exec, deprecatedGlobalObjectForPrototype(exec), JSSVGStaticPODTypeWrapper<SVGTransform>::create(*item).get(), context); } JSValue JSSVGTransformList::clear(ExecState* exec, const ArgList&) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.cpp index ead17ddeb..a3122258d 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.cpp @@ -45,7 +45,7 @@ namespace WebCore { const ClassInfo JSSharedWorkerConstructor::s_info = { "SharedWorkerConstructor", 0, 0, 0 }; JSSharedWorkerConstructor::JSSharedWorkerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMObject(JSSharedWorkerConstructor::createStructure(globalObject->objectPrototype())) + : DOMConstructorObject(JSSharedWorkerConstructor::createStructure(globalObject->objectPrototype())) { putDirect(exec->propertyNames().prototype, JSSharedWorkerPrototype::self(exec, globalObject), None); // Host functions have a length property describing the number of expected arguments. diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.h index be8b2b447..87baa388c 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSSharedWorkerConstructor.h @@ -37,7 +37,7 @@ namespace WebCore { - class JSSharedWorkerConstructor : public DOMObject { + class JSSharedWorkerConstructor : public DOMConstructorObject { public: JSSharedWorkerConstructor(JSC::ExecState*, JSDOMGlobalObject*); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSStyleSheetCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSStyleSheetCustom.cpp index f8146bdd5..00dacee1b 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSStyleSheetCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSStyleSheetCustom.cpp @@ -35,7 +35,7 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, StyleSheet* styleSheet) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, StyleSheet* styleSheet) { if (!styleSheet) return jsNull(); @@ -45,9 +45,9 @@ JSValue toJS(ExecState* exec, StyleSheet* styleSheet) return wrapper; if (styleSheet->isCSSStyleSheet()) - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSStyleSheet, styleSheet); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSStyleSheet, styleSheet); else - wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, StyleSheet, styleSheet); + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, StyleSheet, styleSheet); return wrapper; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSTextCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSTextCustom.cpp index 9e66826cb..2dc886ded 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSTextCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSTextCustom.cpp @@ -32,12 +32,12 @@ using namespace JSC; namespace WebCore { -JSValue toJSNewlyCreated(ExecState* exec, Text* text) +JSValue toJSNewlyCreated(ExecState* exec, JSDOMGlobalObject* globalObject, Text* text) { if (!text) return jsNull(); - return CREATE_DOM_NODE_WRAPPER(exec, Text, text); + return CREATE_DOM_NODE_WRAPPER(exec, globalObject, Text, text); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSTreeWalkerCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSTreeWalkerCustom.cpp index 636901769..58eea7252 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSTreeWalkerCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSTreeWalkerCustom.cpp @@ -34,7 +34,7 @@ void JSTreeWalker::mark() if (NodeFilter* filter = m_impl->filter()) filter->mark(); - DOMObject::mark(); + Base::mark(); } JSValue JSTreeWalker::parentNode(ExecState* exec, const ArgList&) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp index c7fe4a5c0..bc05250df 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp @@ -35,15 +35,16 @@ namespace WebCore { const ClassInfo JSWebKitCSSMatrixConstructor::s_info = { "WebKitCSSMatrixConstructor", 0, 0, 0 }; -JSWebKitCSSMatrixConstructor::JSWebKitCSSMatrixConstructor(ExecState* exec) - : DOMObject(JSWebKitCSSMatrixConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) +JSWebKitCSSMatrixConstructor::JSWebKitCSSMatrixConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSWebKitCSSMatrixConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebKitCSSMatrixPrototype::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, JSWebKitCSSMatrixPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); } -static JSObject* constructWebKitCSSMatrix(ExecState* exec, JSObject*, const ArgList& args) +static JSObject* constructWebKitCSSMatrix(ExecState* exec, JSObject* constructor, const ArgList& args) { + JSWebKitCSSMatrixConstructor* jsConstructor = static_cast<JSWebKitCSSMatrixConstructor*>(constructor); String s; if (args.size() >= 1) s = args.at(0).toString(exec); @@ -51,7 +52,7 @@ static JSObject* constructWebKitCSSMatrix(ExecState* exec, JSObject*, const ArgL ExceptionCode ec = 0; RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(s, ec); setDOMException(exec, ec); - return CREATE_DOM_OBJECT_WRAPPER(exec, WebKitCSSMatrix, matrix.get()); + return CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), WebKitCSSMatrix, matrix.get()); } ConstructType JSWebKitCSSMatrixConstructor::getConstructData(ConstructData& constructData) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h index d0e0bd1be..65b9050c3 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h @@ -31,9 +31,9 @@ namespace WebCore { -class JSWebKitCSSMatrixConstructor : public DOMObject { +class JSWebKitCSSMatrixConstructor : public DOMConstructorObject { public: - JSWebKitCSSMatrixConstructor(JSC::ExecState*); + JSWebKitCSSMatrixConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.cpp index c7d4e360c..27cc1db83 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.cpp @@ -36,15 +36,17 @@ using namespace JSC; const ClassInfo JSWebKitPointConstructor::s_info = { "WebKitPointConstructor", 0, 0, 0 }; -JSWebKitPointConstructor::JSWebKitPointConstructor(ExecState* exec) - : DOMObject(JSWebKitPointConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) +JSWebKitPointConstructor::JSWebKitPointConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSWebKitPointConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebKitPointPrototype::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, JSWebKitPointPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } -static JSObject* constructWebKitPoint(ExecState* exec, JSObject*, const ArgList& args) +static JSObject* constructWebKitPoint(ExecState* exec, JSObject* constructor, const ArgList& args) { + JSWebKitPointConstructor* jsConstructor = static_cast<JSWebKitPointConstructor*>(constructor); + float x = 0; float y = 0; if (args.size() >= 2) { @@ -55,7 +57,7 @@ static JSObject* constructWebKitPoint(ExecState* exec, JSObject*, const ArgList& if (isnan(y)) y = 0; } - return asObject(toJS(exec, WebKitPoint::create(x, y))); + return asObject(toJS(exec, jsConstructor->globalObject(), WebKitPoint::create(x, y))); } JSC::ConstructType JSWebKitPointConstructor::getConstructData(JSC::ConstructData& constructData) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.h index a5bb5c1b4..44c253d03 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWebKitPointConstructor.h @@ -31,9 +31,9 @@ namespace WebCore { -class JSWebKitPointConstructor : public DOMObject { +class JSWebKitPointConstructor : public DOMConstructorObject { public: - JSWebKitPointConstructor(JSC::ExecState*); + JSWebKitPointConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.cpp index 8ea671830..e1686f787 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.cpp @@ -41,15 +41,17 @@ namespace WebCore { const ClassInfo JSWorkerConstructor::s_info = { "WorkerConstructor", 0, 0, 0 }; -JSWorkerConstructor::JSWorkerConstructor(ExecState* exec) - : DOMObject(JSWorkerConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) +JSWorkerConstructor::JSWorkerConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSWorkerConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWorkerPrototype::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, JSWorkerPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); } -static JSObject* constructWorker(ExecState* exec, JSObject*, const ArgList& args) +static JSObject* constructWorker(ExecState* exec, JSObject* constructor, const ArgList& args) { + JSWorkerConstructor* jsConstructor = static_cast<JSWorkerConstructor*>(constructor); + if (args.size() == 0) return throwError(exec, SyntaxError, "Not enough arguments"); @@ -57,13 +59,12 @@ static JSObject* constructWorker(ExecState* exec, JSObject*, const ArgList& args if (exec->hadException()) return 0; + // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject. DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); - - ExceptionCode ec = 0; - RefPtr<Worker> worker = Worker::create(scriptURL, window->document(), ec); - setDOMException(exec, ec); - return asObject(toJS(exec, worker.release())); + RefPtr<Worker> worker = Worker::create(scriptURL, window->document()); + + return asObject(toJS(exec, jsConstructor->globalObject(), worker.release())); } ConstructType JSWorkerConstructor::getConstructData(ConstructData& constructData) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.h index d1df7eb94..c845fa628 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerConstructor.h @@ -32,9 +32,9 @@ namespace WebCore { - class JSWorkerConstructor : public DOMObject { + class JSWorkerConstructor : public DOMConstructorObject { public: - JSWorkerConstructor(JSC::ExecState*); + JSWorkerConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp index c71f45bd4..622da7056 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.cpp @@ -31,6 +31,7 @@ #include "JSWorkerContextBase.h" +#include "JSDedicatedWorkerContext.h" #include "JSWorkerContext.h" #include "WorkerContext.h" @@ -57,6 +58,11 @@ ScriptExecutionContext* JSWorkerContextBase::scriptExecutionContext() const return m_impl.get(); } +JSValue toJS(ExecState* exec, JSDOMGlobalObject*, WorkerContext* workerContext) +{ + return toJS(exec, workerContext); +} + JSValue toJS(ExecState*, WorkerContext* workerContext) { if (!workerContext) @@ -67,6 +73,22 @@ JSValue toJS(ExecState*, WorkerContext* workerContext) return script->workerContextWrapper(); } +JSDedicatedWorkerContext* toJSDedicatedWorkerContext(JSValue value) +{ + if (!value.isObject()) + return 0; + const ClassInfo* classInfo = asObject(value)->classInfo(); + if (classInfo == &JSDedicatedWorkerContext::s_info) + return static_cast<JSDedicatedWorkerContext*>(asObject(value)); + return 0; +} + +JSWorkerContext* toJSWorkerContext(JSValue value) +{ + // When we support shared workers, we'll add code to test for SharedWorkerContext too. + return toJSDedicatedWorkerContext(value); +} + } // namespace WebCore #endif // ENABLE(WORKERS) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.h b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.h index dcbc5c3ba..f7ad17f77 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextBase.h @@ -33,6 +33,8 @@ namespace WebCore { + class JSDedicatedWorkerContext; + class JSWorkerContext; class WorkerContext; class JSWorkerContextBase : public JSDOMGlobalObject { @@ -52,8 +54,13 @@ namespace WebCore { }; // Returns a JSWorkerContext or jsNull() + // Always ignores the execState and passed globalObject, WorkerContext is itself a globalObject and will always use its own prototype chain. + JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, WorkerContext*); JSC::JSValue toJS(JSC::ExecState*, WorkerContext*); + JSDedicatedWorkerContext* toJSDedicatedWorkerContext(JSC::JSValue); + JSWorkerContext* toJSWorkerContext(JSC::JSValue); + } // namespace WebCore #endif // ENABLE(WORKERS) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp index 06475f91d..6a7602d3d 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerContextCustom.cpp @@ -58,7 +58,7 @@ void JSWorkerContext::mark() markDOMObjectWrapper(globalData, impl()->optionalLocation()); markDOMObjectWrapper(globalData, impl()->optionalNavigator()); - markIfNotNull(impl()->onmessage()); + markIfNotNull(impl()->onerror()); typedef WorkerContext::EventListenersMap EventListenersMap; typedef WorkerContext::ListenerVector ListenerVector; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerCustom.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerCustom.cpp index 970751990..6010f8398 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerCustom.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSWorkerCustom.cpp @@ -30,8 +30,6 @@ #include "JSWorker.h" #include "JSDOMGlobalObject.h" -#include "JSEventListener.h" -#include "JSMessagePort.h" #include "Worker.h" using namespace JSC; @@ -40,42 +38,9 @@ namespace WebCore { void JSWorker::mark() { - DOMObject::mark(); + Base::mark(); - markIfNotNull(m_impl->onmessage()); - markIfNotNull(m_impl->onerror()); - - typedef Worker::EventListenersMap EventListenersMap; - typedef Worker::ListenerVector ListenerVector; - EventListenersMap& eventListeners = m_impl->eventListeners(); - for (EventListenersMap::iterator mapIter = eventListeners.begin(); mapIter != eventListeners.end(); ++mapIter) { - for (ListenerVector::iterator vecIter = mapIter->second.begin(); vecIter != mapIter->second.end(); ++vecIter) - (*vecIter)->markJSFunction(); - } -} - -JSValue JSWorker::addEventListener(ExecState* exec, const ArgList& args) -{ - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); - if (!globalObject) - return jsUndefined(); - RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(args.at(1)); - if (!listener) - return jsUndefined(); - impl()->addEventListener(args.at(0).toString(exec), listener.release(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSWorker::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); - if (!globalObject) - return jsUndefined(); - JSEventListener* listener = globalObject->findJSEventListener(args.at(1)); - if (!listener) - return jsUndefined(); - impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).toBoolean(exec)); - return jsUndefined(); + markIfNotNull(static_cast<Worker*>(impl())->onmessage()); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp index 65cdfc226..a644c9e8e 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp @@ -33,25 +33,20 @@ ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequestConstructor); const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, 0, 0 }; JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMObject(JSXMLHttpRequestConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) - , m_globalObject(globalObject) + : DOMConstructorObject(JSXMLHttpRequestConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec, exec->lexicalGlobalObject()), None); -} - -ScriptExecutionContext* JSXMLHttpRequestConstructor::scriptExecutionContext() const -{ - return m_globalObject->scriptExecutionContext(); + putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec, globalObject), None); } static JSObject* constructXMLHttpRequest(ExecState* exec, JSObject* constructor, const ArgList&) { - ScriptExecutionContext* context = static_cast<JSXMLHttpRequestConstructor*>(constructor)->scriptExecutionContext(); + JSXMLHttpRequestConstructor* jsConstructor = static_cast<JSXMLHttpRequestConstructor*>(constructor); + ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); if (!context) return throwError(exec, ReferenceError, "XMLHttpRequest constructor associated document is unavailable"); RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context); - return CREATE_DOM_OBJECT_WRAPPER(exec, XMLHttpRequest, xmlHttpRequest.get()); + return CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), XMLHttpRequest, xmlHttpRequest.get()); } ConstructType JSXMLHttpRequestConstructor::getConstructData(ConstructData& constructData) @@ -60,11 +55,4 @@ ConstructType JSXMLHttpRequestConstructor::getConstructData(ConstructData& const return ConstructTypeHost; } -void JSXMLHttpRequestConstructor::mark() -{ - DOMObject::mark(); - if (!m_globalObject->marked()) - m_globalObject->mark(); -} - } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.h index 978a9f056..2cc4fcf8e 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSXMLHttpRequestConstructor.h @@ -24,18 +24,13 @@ namespace WebCore { -class JSXMLHttpRequestConstructor : public DOMObject { +class JSXMLHttpRequestConstructor : public DOMConstructorObject { public: JSXMLHttpRequestConstructor(JSC::ExecState*, JSDOMGlobalObject*); - ScriptExecutionContext* scriptExecutionContext() const; static const JSC::ClassInfo s_info; - - virtual void mark(); private: virtual JSC::ConstructType getConstructData(JSC::ConstructData&); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - - JSDOMGlobalObject* m_globalObject; }; } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp b/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp index 807b017b3..07fec7226 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp @@ -41,15 +41,16 @@ ASSERT_CLASS_FITS_IN_CELL(JSXSLTProcessorConstructor); const ClassInfo JSXSLTProcessorConstructor::s_info = { "XSLTProcessorConsructor", 0, 0, 0 }; -JSXSLTProcessorConstructor::JSXSLTProcessorConstructor(ExecState* exec) - : DOMObject(JSXSLTProcessorConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) +JSXSLTProcessorConstructor::JSXSLTProcessorConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSXSLTProcessorConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSXSLTProcessorPrototype::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, JSXSLTProcessorPrototype::self(exec, globalObject), None); } -static JSObject* constructXSLTProcessor(ExecState* exec, JSObject*, const ArgList&) +static JSObject* constructXSLTProcessor(ExecState* exec, JSObject* constructor, const ArgList&) { - return CREATE_DOM_OBJECT_WRAPPER(exec, XSLTProcessor, XSLTProcessor::create().get()); + JSXSLTProcessorConstructor* jsConstructor = static_cast<JSXSLTProcessorConstructor*>(constructor); + return CREATE_DOM_OBJECT_WRAPPER(exec, jsConstructor->globalObject(), XSLTProcessor, XSLTProcessor::create().get()); } ConstructType JSXSLTProcessorConstructor::getConstructData(ConstructData& constructData) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.h b/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.h index 64ef9442b..96fa60722 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/JSXSLTProcessorConstructor.h @@ -32,9 +32,9 @@ namespace WebCore { - class JSXSLTProcessorConstructor : public DOMObject { + class JSXSLTProcessorConstructor : public DOMConstructorObject { public: - JSXSLTProcessorConstructor(JSC::ExecState*); + JSXSLTProcessorConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp index 91bece71b..9e64bceb9 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScheduledAction.cpp @@ -87,7 +87,7 @@ void ScheduledAction::execute(ScriptExecutionContext* context) void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSValue thisValue) { ASSERT(m_function); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); CallData callData; CallType callType = m_function.get().getCallData(callData); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptArray.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptArray.cpp new file mode 100644 index 000000000..016c7a702 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptArray.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptArray.h" + +#include <runtime/JSLock.h> + +using namespace JSC; + +namespace WebCore { + +ScriptArray::ScriptArray(JSArray* object) + : ScriptObject(object) +{ +} + +static bool handleException(ScriptState* scriptState) +{ + if (!scriptState->hadException()) + return true; + + reportException(scriptState, scriptState->exception()); + return false; +} + +bool ScriptArray::set(ScriptState* scriptState, unsigned index, const ScriptObject& value) +{ + JSLock lock(SilenceAssertionsOnly); + jsArray()->put(scriptState, index, value.jsObject()); + return handleException(scriptState); +} + +bool ScriptArray::set(ScriptState* scriptState, unsigned index, const String& value) +{ + JSLock lock(SilenceAssertionsOnly); + jsArray()->put(scriptState, index, jsString(scriptState, value)); + return handleException(scriptState); +} + +bool ScriptArray::set(ScriptState* scriptState, unsigned index, double value) +{ + JSLock lock(SilenceAssertionsOnly); + jsArray()->put(scriptState, index, jsNumber(scriptState, value)); + return handleException(scriptState); +} + +bool ScriptArray::set(ScriptState* scriptState, unsigned index, long long value) +{ + JSLock lock(SilenceAssertionsOnly); + jsArray()->put(scriptState, index, jsNumber(scriptState, value)); + return handleException(scriptState); +} + +bool ScriptArray::set(ScriptState* scriptState, unsigned index, int value) +{ + JSLock lock(SilenceAssertionsOnly); + jsArray()->put(scriptState, index, jsNumber(scriptState, value)); + return handleException(scriptState); +} + +bool ScriptArray::set(ScriptState* scriptState, unsigned index, bool value) +{ + JSLock lock(SilenceAssertionsOnly); + jsArray()->put(scriptState, index, jsBoolean(value)); + return handleException(scriptState); +} + +unsigned ScriptArray::length(ScriptState*) +{ + return jsArray()->length(); +} + +ScriptArray ScriptArray::createNew(ScriptState* scriptState) +{ + JSLock lock(SilenceAssertionsOnly); + return ScriptArray(constructEmptyArray(scriptState)); +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptArray.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptArray.h new file mode 100644 index 000000000..2ba307f2e --- /dev/null +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptArray.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScriptArray_h +#define ScriptArray_h + +#include "ScriptObject.h" +#include "ScriptState.h" + +#include <runtime/JSArray.h> + +namespace WebCore { + + class ScriptArray : public ScriptObject { + public: + ScriptArray(JSC::JSArray*); + ScriptArray() {} + JSC::JSArray* jsArray() const { return asArray(jsValue()); } + + bool set(ScriptState*, unsigned index, const ScriptObject&); + bool set(ScriptState*, unsigned index, const String&); + bool set(ScriptState*, unsigned index, double); + bool set(ScriptState*, unsigned index, long long); + bool set(ScriptState*, unsigned index, int); + bool set(ScriptState*, unsigned index, bool); + unsigned length(ScriptState*); + + static ScriptArray createNew(ScriptState*); + }; +} + +#endif // ScriptArray_h diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp index 213c70893..885261124 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp @@ -45,7 +45,7 @@ namespace WebCore { ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); ScriptController* scriptController = frame->script(); if (scriptController->haveWindowShell()) { @@ -67,7 +67,7 @@ void ScriptCachedFrameData::restore(Frame* frame) { Page* page = frame->page(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); ScriptController* scriptController = frame->script(); if (scriptController->haveWindowShell()) { @@ -84,7 +84,7 @@ void ScriptCachedFrameData::restore(Frame* frame) void ScriptCachedFrameData::clear() { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); if (!m_window) { m_window = 0; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp index 442205e2f..a1c43764d 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptController.cpp @@ -106,7 +106,7 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) const String* savedSourceURL = m_sourceURL; m_sourceURL = &sourceURL; - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); RefPtr<Frame> protect = m_frame; @@ -135,7 +135,7 @@ void ScriptController::clearWindowShell() if (!m_windowShell) return; - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); // Clear the debugger from the current window before setting the new window. attachDebugger(0); @@ -157,7 +157,7 @@ void ScriptController::initScript() if (m_windowShell) return; - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); m_windowShell = new JSDOMWindowShell(m_frame->domWindow()); m_windowShell->window()->updateDocument(); @@ -249,7 +249,7 @@ void ScriptController::updateDocument() if (!m_frame->document()) return; - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); if (m_windowShell) m_windowShell->window()->updateDocument(); } @@ -265,7 +265,7 @@ Bindings::RootObject* ScriptController::bindingRootObject() return 0; if (!m_bindingRootObject) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); m_bindingRootObject = Bindings::RootObject::create(0, globalObject()); } return m_bindingRootObject.get(); @@ -291,7 +291,7 @@ NPObject* ScriptController::windowScriptNPObject() if (isEnabled()) { // JavaScript is enabled, so there is a JavaScript window object. // Return an NPObject bound to the window object. - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); JSObject* win = windowShell()->window(); ASSERT(win); Bindings::RootObject* root = bindingRootObject(); @@ -325,9 +325,9 @@ JSObject* ScriptController::jsObjectForPluginElement(HTMLPlugInElement* plugin) return 0; // Create a JSObject bound to this element - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); ExecState* exec = globalObject()->globalExec(); - JSValue jsElementValue = toJS(exec, plugin); + JSValue jsElementValue = toJS(exec, globalObject(), plugin); if (!jsElementValue || !jsElementValue.isObject()) return 0; @@ -359,7 +359,7 @@ void ScriptController::cleanupScriptObjectsForPlugin(void* nativeHandle) void ScriptController::clearScriptObjects() { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); RootObjectMap::const_iterator end = m_rootObjects.end(); for (RootObjectMap::const_iterator it = m_rootObjects.begin(); it != end; ++it) diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerHaiku.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerHaiku.cpp new file mode 100644 index 000000000..b573b97e6 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerHaiku.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2008 Apple Computer, Inc. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptController.h" + +#include "PluginView.h" +#include "runtime_root.h" +#include "runtime.h" + + +namespace WebCore { + +PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(Widget* widget) +{ + if (!widget->isPluginView()) + return 0; + + return static_cast<PluginView*>(widget)->bindingInstance(); +} + +} // namespace WebCore + diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm index 502a504b9..e6a654f06 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptControllerMac.mm @@ -112,7 +112,7 @@ WebScriptObject* ScriptController::windowScriptObject() return 0; if (!m_windowScriptObject) { - JSC::JSLock lock(false); + JSC::JSLock lock(JSC::SilenceAssertionsOnly); JSC::Bindings::RootObject* root = bindingRootObject(); m_windowScriptObject = [WebScriptObject scriptObjectForJSObject:toRef(windowShell()) originRootObject:root rootObject:root]; } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp index e5be1d6f6..878c5353f 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptEventListener.cpp @@ -71,8 +71,9 @@ PassRefPtr<JSLazyEventListener> createAttributeEventListener(Node* node, Attribu // Ensure that 'node' has a JavaScript wrapper to mark the event listener we're creating. { - JSLock lock(false); - toJS(globalObject->globalExec(), node); + JSLock lock(SilenceAssertionsOnly); + // FIXME: Should pass the global object associated with the node + toJS(globalObject->globalExec(), globalObject, node); } return JSLazyEventListener::create(attr->localName().string(), eventParameterName(node->isSVGElement()), attr->value(), globalObject, node, scriptController->eventHandlerLineNumber()); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp index 1122931ad..ca6b03a9d 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptFunctionCall.cpp @@ -66,7 +66,7 @@ void ScriptFunctionCall::appendArgument(const ScriptValue& argument) void ScriptFunctionCall::appendArgument(const String& argument) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); m_arguments.append(jsString(m_exec, argument)); } @@ -82,19 +82,19 @@ void ScriptFunctionCall::appendArgument(JSC::JSValue argument) void ScriptFunctionCall::appendArgument(long long argument) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); m_arguments.append(jsNumber(m_exec, argument)); } void ScriptFunctionCall::appendArgument(unsigned int argument) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); m_arguments.append(jsNumber(m_exec, argument)); } void ScriptFunctionCall::appendArgument(int argument) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); m_arguments.append(jsNumber(m_exec, argument)); } @@ -107,7 +107,7 @@ ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) { JSObject* thisObject = m_thisObject.jsObject(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSValue function = thisObject->get(m_exec, Identifier(m_exec, m_name)); if (m_exec->hadException()) { @@ -145,7 +145,7 @@ ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExcept { JSObject* thisObject = m_thisObject.jsObject(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSObject* constructor = asObject(thisObject->get(m_exec, Identifier(m_exec, m_name))); if (m_exec->hadException()) { diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp index 7f6391dae..e66464532 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.cpp @@ -32,7 +32,7 @@ #include "ScriptObject.h" #include "JSDOMBinding.h" -#include "JSInspectorController.h" +#include "JSInspectorBackend.h" #include <runtime/JSLock.h> @@ -56,7 +56,7 @@ static bool handleException(ScriptState* scriptState) bool ScriptObject::set(ScriptState* scriptState, const String& name, const String& value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); PutPropertySlot slot; jsObject()->put(scriptState, Identifier(scriptState, name), jsString(scriptState, value), slot); return handleException(scriptState); @@ -64,7 +64,7 @@ bool ScriptObject::set(ScriptState* scriptState, const String& name, const Strin bool ScriptObject::set(ScriptState* scriptState, const char* name, const ScriptObject& value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); PutPropertySlot slot; jsObject()->put(scriptState, Identifier(scriptState, name), value.jsObject(), slot); return handleException(scriptState); @@ -72,7 +72,7 @@ bool ScriptObject::set(ScriptState* scriptState, const char* name, const ScriptO bool ScriptObject::set(ScriptState* scriptState, const char* name, const String& value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); PutPropertySlot slot; jsObject()->put(scriptState, Identifier(scriptState, name), jsString(scriptState, value), slot); return handleException(scriptState); @@ -80,7 +80,7 @@ bool ScriptObject::set(ScriptState* scriptState, const char* name, const String& bool ScriptObject::set(ScriptState* scriptState, const char* name, double value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); PutPropertySlot slot; jsObject()->put(scriptState, Identifier(scriptState, name), jsNumber(scriptState, value), slot); return handleException(scriptState); @@ -88,7 +88,7 @@ bool ScriptObject::set(ScriptState* scriptState, const char* name, double value) bool ScriptObject::set(ScriptState* scriptState, const char* name, long long value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); PutPropertySlot slot; jsObject()->put(scriptState, Identifier(scriptState, name), jsNumber(scriptState, value), slot); return handleException(scriptState); @@ -96,7 +96,7 @@ bool ScriptObject::set(ScriptState* scriptState, const char* name, long long val bool ScriptObject::set(ScriptState* scriptState, const char* name, int value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); PutPropertySlot slot; jsObject()->put(scriptState, Identifier(scriptState, name), jsNumber(scriptState, value), slot); return handleException(scriptState); @@ -104,7 +104,7 @@ bool ScriptObject::set(ScriptState* scriptState, const char* name, int value) bool ScriptObject::set(ScriptState* scriptState, const char* name, bool value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); PutPropertySlot slot; jsObject()->put(scriptState, Identifier(scriptState, name), jsBoolean(value), slot); return handleException(scriptState); @@ -112,27 +112,28 @@ bool ScriptObject::set(ScriptState* scriptState, const char* name, bool value) ScriptObject ScriptObject::createNew(ScriptState* scriptState) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); return ScriptObject(constructEmptyObject(scriptState)); } bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const ScriptObject& value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); scriptState->lexicalGlobalObject()->putDirect(Identifier(scriptState, name), value.jsObject()); return handleException(scriptState); } -bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorController* value) +bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorBackend* value) { - JSLock lock(false); - scriptState->lexicalGlobalObject()->putDirect(Identifier(scriptState, name), toJS(scriptState, value)); + JSLock lock(SilenceAssertionsOnly); + JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); + globalObject->putDirect(Identifier(scriptState, name), toJS(scriptState, globalObject, value)); return handleException(scriptState); } bool ScriptGlobalObject::get(ScriptState* scriptState, const char* name, ScriptObject& value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSValue jsValue = scriptState->lexicalGlobalObject()->get(scriptState, Identifier(scriptState, name)); if (!jsValue) return false; @@ -146,7 +147,7 @@ bool ScriptGlobalObject::get(ScriptState* scriptState, const char* name, ScriptO bool ScriptGlobalObject::remove(ScriptState* scriptState, const char* name) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); scriptState->lexicalGlobalObject()->deleteProperty(scriptState, Identifier(scriptState, name)); return handleException(scriptState); } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h index ed8665957..97022da09 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObject.h @@ -38,7 +38,7 @@ #include <runtime/Protect.h> namespace WebCore { - class InspectorController; + class InspectorBackend; class ScriptObject : public ScriptValue { public: @@ -60,7 +60,7 @@ namespace WebCore { class ScriptGlobalObject { public: static bool set(ScriptState*, const char* name, const ScriptObject&); - static bool set(ScriptState*, const char* name, InspectorController*); + static bool set(ScriptState*, const char* name, InspectorBackend*); static bool get(ScriptState*, const char* name, ScriptObject&); static bool remove(ScriptState*, const char* name); private: diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp index ab392bcc4..171883aa7 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptObjectQuarantine.cpp @@ -56,7 +56,7 @@ namespace WebCore { ScriptValue quarantineValue(ScriptState* scriptState, const ScriptValue& value) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); return ScriptValue(JSInspectedObjectWrapper::wrap(scriptState, value.jsValue())); } @@ -69,10 +69,11 @@ bool getQuarantinedScriptObject(Database* database, ScriptObject& quarantinedObj if (!frame) return false; - ExecState* exec = toJSDOMWindow(frame)->globalExec(); + JSDOMGlobalObject* globalObject = toJSDOMWindow(frame); + ExecState* exec = globalObject->globalExec(); - JSLock lock(false); - quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, database)))); + JSLock lock(SilenceAssertionsOnly); + quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, globalObject, database)))); return true; } @@ -84,10 +85,11 @@ bool getQuarantinedScriptObject(Frame* frame, Storage* storage, ScriptObject& qu ASSERT(frame); ASSERT(storage); - ExecState* exec = toJSDOMWindow(frame)->globalExec(); + JSDOMGlobalObject* globalObject = toJSDOMWindow(frame); + ExecState* exec = globalObject->globalExec(); - JSLock lock(false); - quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, storage)))); + JSLock lock(SilenceAssertionsOnly); + quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, globalObject, storage)))); return true; } @@ -99,8 +101,9 @@ bool getQuarantinedScriptObject(Node* node, ScriptObject& quarantinedObject) if (!exec) return false; - JSLock lock(false); - quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, node)))); + JSLock lock(SilenceAssertionsOnly); + // FIXME: Should use some sort of globalObjectFromNode() + quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, toJS(exec, deprecatedGlobalObjectForPrototype(exec), node)))); return true; } @@ -112,7 +115,7 @@ bool getQuarantinedScriptObject(DOMWindow* domWindow, ScriptObject& quarantinedO JSDOMWindow* window = toJSDOMWindow(domWindow->frame()); ExecState* exec = window->globalExec(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); quarantinedObject = ScriptObject(asObject(JSInspectedObjectWrapper::wrap(exec, window))); return true; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h index 0a16265ff..1b05dedb6 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceCode.h @@ -32,20 +32,24 @@ #define ScriptSourceCode_h #include "CachedScriptSourceProvider.h" +#include "ScriptSourceProvider.h" #include "StringSourceProvider.h" #include "KURL.h" +#include <wtf/RefPtr.h> namespace WebCore { class ScriptSourceCode { public: ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1) - : m_code(makeSource(source, url.isNull() ? String() : url.string(), startLine)) + : m_provider(StringSourceProvider::create(source, url.isNull() ? String() : url.string())) + , m_code(m_provider, startLine) { } ScriptSourceCode(CachedScript* cs) - : m_code(makeSource(cs)) + : m_provider(CachedScriptSourceProvider::create(cs)) + , m_code(m_provider) { } @@ -53,9 +57,11 @@ public: const JSC::SourceCode& jsSourceCode() const { return m_code; } - const String& source() const { return static_cast<StringSourceProvider*>(m_code.provider())->source(); } + const String& source() const { return m_provider->source(); } private: + RefPtr<ScriptSourceProvider> m_provider; + JSC::SourceCode m_code; }; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceProvider.h b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceProvider.h new file mode 100644 index 000000000..3fe3584e2 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptSourceProvider.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Daniel Bates (dbates@intudata.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScriptSourceProvider_h +#define ScriptSourceProvider_h + +#include <parser/SourceProvider.h> + +namespace WebCore { + + class String; + + class ScriptSourceProvider : public JSC::SourceProvider { + public: + ScriptSourceProvider(const JSC::UString& url, JSC::SourceBOMPresence hasBOMs = JSC::SourceCouldHaveBOMs) + : SourceProvider(url, hasBOMs) + { + } + + virtual const String& source() const = 0; + }; + +} // namespace WebCore + +#endif // ScriptSourceProvider_h diff --git a/src/3rdparty/webkit/WebCore/bindings/js/ScriptValue.cpp b/src/3rdparty/webkit/WebCore/bindings/js/ScriptValue.cpp index dfb46dabb..d427ceee2 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/ScriptValue.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/ScriptValue.cpp @@ -44,7 +44,7 @@ bool ScriptValue::getString(String& result) const { if (!m_value) return false; - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); UString ustring; if (!m_value.get().getString(ustring)) return false; diff --git a/src/3rdparty/webkit/WebCore/bindings/js/StringSourceProvider.h b/src/3rdparty/webkit/WebCore/bindings/js/StringSourceProvider.h index 89dfa6785..770c4fc74 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/StringSourceProvider.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/StringSourceProvider.h @@ -29,11 +29,12 @@ #ifndef StringSourceProvider_h #define StringSourceProvider_h +#include "ScriptSourceProvider.h" #include <parser/SourceCode.h> namespace WebCore { - class StringSourceProvider : public JSC::SourceProvider { + class StringSourceProvider : public ScriptSourceProvider { public: static PassRefPtr<StringSourceProvider> create(const String& source, const String& url) { return adoptRef(new StringSourceProvider(source, url)); } @@ -44,7 +45,7 @@ namespace WebCore { private: StringSourceProvider(const String& source, const String& url) - : SourceProvider(url) + : ScriptSourceProvider(url) , m_source(source) { } diff --git a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp index bcf107ba2..fc3de3c96 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp +++ b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.cpp @@ -31,10 +31,9 @@ #include "WorkerScriptController.h" #include "JSDOMBinding.h" -#include "JSWorkerContext.h" +#include "JSDedicatedWorkerContext.h" #include "ScriptSourceCode.h" #include "ScriptValue.h" -#include "WorkerContext.h" #include "WorkerObjectProxy.h" #include "WorkerThread.h" #include <interpreter/Interpreter.h> @@ -66,16 +65,20 @@ void WorkerScriptController::initScript() { ASSERT(!m_workerContextWrapper); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); // Explicitly protect the global object's prototype so it isn't collected // when we allocate the global object. (Once the global object is fully // constructed, it can mark its own prototype.) - RefPtr<Structure> prototypeStructure = JSWorkerContextPrototype::createStructure(jsNull()); - ProtectedPtr<JSWorkerContextPrototype> prototype = new (m_globalData.get()) JSWorkerContextPrototype(prototypeStructure.release()); + RefPtr<Structure> workerContextPrototypeStructure = JSWorkerContextPrototype::createStructure(jsNull()); + ProtectedPtr<JSWorkerContextPrototype> workerContextPrototype = new (m_globalData.get()) JSWorkerContextPrototype(workerContextPrototypeStructure.release()); - RefPtr<Structure> structure = JSWorkerContext::createStructure(prototype); - m_workerContextWrapper = new (m_globalData.get()) JSWorkerContext(structure.release(), m_workerContext); + // FIXME: When we add SharedWorkerContext, generate the correct wrapper here. + RefPtr<Structure> dedicatedContextPrototypeStructure = JSDedicatedWorkerContextPrototype::createStructure(workerContextPrototype); + ProtectedPtr<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype = new (m_globalData.get()) JSDedicatedWorkerContextPrototype(dedicatedContextPrototypeStructure.release()); + RefPtr<Structure> structure = JSDedicatedWorkerContext::createStructure(dedicatedContextPrototype); + + m_workerContextWrapper = new (m_globalData.get()) JSDedicatedWorkerContext(structure.release(), static_cast<DedicatedWorkerContext*>(m_workerContext)); } ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) @@ -88,7 +91,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) ScriptValue exception; ScriptValue result = evaluate(sourceCode, &exception); if (exception.jsValue()) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); reportException(m_workerContextWrapper->globalExec(), exception.jsValue()); } return result; @@ -103,7 +106,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, } initScriptIfNeeded(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); ExecState* exec = m_workerContextWrapper->globalExec(); m_workerContextWrapper->globalData()->timeoutChecker.start(); diff --git a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h index 045472156..bb33f6082 100644 --- a/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h +++ b/src/3rdparty/webkit/WebCore/bindings/js/WorkerScriptController.h @@ -45,7 +45,7 @@ namespace WebCore { class String; class WorkerContext; - class WorkerScriptController : Noncopyable { + class WorkerScriptController : public Noncopyable { public: WorkerScriptController(WorkerContext*); ~WorkerScriptController(); diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm index fe145f4ec..341c60798 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGenerator.pm @@ -40,7 +40,7 @@ my %primitiveTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1 "float" => 1, "double" => 1, "boolean" => 1, "void" => 1); -my %podTypeHash = ("RGBColor" => 1, "SVGNumber" => 1, "SVGTransform" => 1); +my %podTypeHash = ("SVGNumber" => 1, "SVGTransform" => 1); my %podTypesWithWritablePropertiesHash = ("SVGLength" => 1, "SVGMatrix" => 1, "SVGPoint" => 1, "SVGRect" => 1); my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1); diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm index 7e80a17a6..6641305a3 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorCOM.pm @@ -596,9 +596,15 @@ sub GenerateCPPAttribute # FIXME: CHECK EXCEPTION AND DO SOMETHING WITH IT - my $setterCall = " impl${implementationClassWithoutNamespace}()->${setterName}(" . join(", ", @setterParams) . ");\n"; - - push(@setterImplementation, $setterCall); + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $CPPImplementationWebCoreIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); + push(@setterImplementation, " impl${implementationClassWithoutNamespace}()->setAttribute(WebCore::HTMLNames::${contentAttributeName}Attr, " . join(", ", @setterParams) . ");\n"); + } else { + push(@setterImplementation, " impl${implementationClassWithoutNamespace}()->${setterName}(" . join(", ", @setterParams) . ");\n"); + } push(@setterImplementation, " return S_OK;\n"); push(@setterImplementation, "}\n\n"); @@ -611,7 +617,17 @@ sub GenerateCPPAttribute push(@getterImplementation, " if (!result)\n"); push(@getterImplementation, " return E_POINTER;\n\n"); - my $implementationGetter = "impl${implementationClassWithoutNamespace}()->" . $codeGenerator->WK_lcfirst($attributeName) . "(" . ($hasGetterException ? "ec" : ""). ")"; + my $implementationGetter; + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $implIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $attributeName : ($reflect || $reflectURL); + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $implementationGetter = "impl${implementationClassWithoutNamespace}()->${getAttributeFunctionName}(WebCore::HTMLNames::${contentAttributeName}Attr)"; + } else { + $implementationGetter = "impl${implementationClassWithoutNamespace}()->" . $codeGenerator->WK_lcfirst($attributeName) . "(" . ($hasGetterException ? "ec" : ""). ")"; + } push(@getterImplementation, " WebCore::ExceptionCode ec = 0;\n") if $hasGetterException; diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm index dbcfffffe..26cf3f596 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -119,7 +119,15 @@ sub GetParentClassName my $dataNode = shift; return $dataNode->extendedAttributes->{"LegacyParent"} if $dataNode->extendedAttributes->{"LegacyParent"}; - return "DOMObject" if @{$dataNode->parents} eq 0; + if (@{$dataNode->parents} eq 0) { + # FIXME: SVG types requiring a context() pointer do not have enough + # space to hold a globalObject pointer as well w/o hitting the CELL_SIZE limit. + # This could be fixed by moving context() into the various impl() classes. + # Until then, we special case these SVG bindings and allow them to return + # the wrong prototypes and constructors during x-frame access. See bug 27088. + return "DOMObjectWithSVGContext" if IsSVGTypeNeedingContextParameter($dataNode->name); + return "DOMObjectWithGlobalPointer"; + } return "JS" . $codeGenerator->StripModule($dataNode->parents(0)); } @@ -165,7 +173,7 @@ sub AddIncludesForType # When we're finished with the one-file-per-class # reorganization, we won't need these special cases. if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type) - or $type eq "DOMString" or $type eq "DOMObject" or $type eq "RGBColor" or $type eq "Array") { + or $type eq "DOMString" or $type eq "DOMObject" or $type eq "Array") { } elsif ($type =~ /SVGPathSeg/) { $joinedName = $type; $joinedName =~ s/Abs|Rel//; @@ -219,11 +227,13 @@ sub IsSVGTypeNeedingContextParameter { my $implClassName = shift; - if ($implClassName =~ /SVG/ and not $implClassName =~ /Element/) { - return 1 unless $implClassName =~ /SVGPaint/ or $implClassName =~ /SVGColor/ or $implClassName =~ /SVGDocument/; + return 0 unless $implClassName =~ /SVG/; + return 0 if $implClassName =~ /Element/; + my @noContextNeeded = ("SVGPaint", "SVGColor", "SVGDocument", "SVGZoomEvent"); + foreach (@noContextNeeded) { + return 0 if $implClassName eq $_; } - - return 0; + return 1; } sub HashValueForClassAndName @@ -358,6 +368,7 @@ sub GenerateHeader my $hasParent = $hasLegacyParent || $hasRealParent; my $parentClassName = GetParentClassName($dataNode); my $conditional = $dataNode->extendedAttributes->{"Conditional"}; + my $needsSVGContext = IsSVGTypeNeedingContextParameter($interfaceName); # - Add default header template @headerContentHeader = split("\r", $headerTemplate); @@ -375,7 +386,8 @@ sub GenerateHeader if ($hasParent) { $headerIncludes{"$parentClassName.h"} = 1; } else { - $headerIncludes{"JSDOMBinding.h"} = 1; + $headerIncludes{"DOMObjectWithSVGContext.h"} = $needsSVGContext; + $headerIncludes{"JSDOMBinding.h"} = !$needsSVGContext; $headerIncludes{"<runtime/JSGlobalObject.h>"} = 1; $headerIncludes{"<runtime/ObjectPrototype.h>"} = 1; } @@ -420,10 +432,12 @@ sub GenerateHeader # Constructor if ($interfaceName eq "DOMWindow") { push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>, JSDOMWindowShell*);\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>);\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>, SVGElement* context);\n"); + push(@headerContent, " $className(PassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<$implType>, SVGElement* context);\n"); } else { - push(@headerContent, " $className(PassRefPtr<JSC::Structure>, PassRefPtr<$implType>);\n"); + push(@headerContent, " $className(PassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<$implType>);\n"); } # Destructor @@ -520,7 +534,7 @@ sub GenerateHeader push(@headerContent, " virtual JSC::JSValue lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName);\n") if $dataNode->extendedAttributes->{"CustomLookupSetter"}; # Constructor object getter - push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"}; + push(@headerContent, " static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);\n") if $dataNode->extendedAttributes->{"GenerateConstructor"}; my $numCustomFunctions = 0; my $numCustomAttributes = 0; @@ -569,23 +583,11 @@ sub GenerateHeader } if (!$hasParent) { - if ($podType) { - push(@headerContent, " JSSVGPODTypeWrapper<$podType>* impl() const { return m_impl.get(); }\n"); - push(@headerContent, " SVGElement* context() const { return m_context.get(); }\n\n"); - push(@headerContent, "private:\n"); - push(@headerContent, " RefPtr<SVGElement> m_context;\n"); - push(@headerContent, " RefPtr<JSSVGPODTypeWrapper<$podType> > m_impl;\n"); - } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@headerContent, " $implClassName* impl() const { return m_impl.get(); }\n"); - push(@headerContent, " SVGElement* context() const { return m_context.get(); }\n\n"); - push(@headerContent, "private:\n"); - push(@headerContent, " RefPtr<SVGElement> m_context;\n"); - push(@headerContent, " RefPtr<$implClassName > m_impl;\n"); - } else { - push(@headerContent, " $implClassName* impl() const { return m_impl.get(); }\n\n"); - push(@headerContent, "private:\n"); - push(@headerContent, " RefPtr<$implClassName> m_impl;\n"); - } + # Extra space after JSSVGPODTypeWrapper<> to make RefPtr<Wrapper<> > compile. + my $implType = $podType ? "JSSVGPODTypeWrapper<$podType> " : $implClassName; + push(@headerContent, " $implType* impl() const { return m_impl.get(); }\n\n"); + push(@headerContent, "private:\n"); + push(@headerContent, " RefPtr<$implType> m_impl;\n"); } elsif ($dataNode->extendedAttributes->{"GenerateNativeConverter"}) { push(@headerContent, " $implClassName* impl() const\n"); push(@headerContent, " {\n"); @@ -623,11 +625,11 @@ sub GenerateHeader if (!$hasParent || $dataNode->extendedAttributes->{"GenerateToJS"} || $dataNode->extendedAttributes->{"CustomToJS"}) { if ($podType) { - push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSSVGPODTypeWrapper<$podType>*, SVGElement* context);\n"); + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, JSSVGPODTypeWrapper<$podType>*, SVGElement* context);\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, $implType*, SVGElement* context);\n"); + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $implType*, SVGElement* context);\n"); } else { - push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, $implType*);\n"); + push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $implType*);\n"); } } if (!$hasParent || $dataNode->extendedAttributes->{"GenerateNativeConverter"}) { @@ -640,7 +642,7 @@ sub GenerateHeader } } if ($interfaceName eq "Node" or $interfaceName eq "Element" or $interfaceName eq "Text" or $interfaceName eq "CDATASection") { - push(@headerContent, "JSC::JSValue toJSNewlyCreated(JSC::ExecState*, $interfaceName*);\n"); + push(@headerContent, "JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject*, $interfaceName*);\n"); } push(@headerContent, "\n"); @@ -651,7 +653,7 @@ sub GenerateHeader push(@headerContent, "public:\n"); if ($interfaceName eq "DOMWindow") { push(@headerContent, " void* operator new(size_t);\n"); - } elsif ($interfaceName eq "WorkerContext") { + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { push(@headerContent, " void* operator new(size_t, JSC::JSGlobalData*);\n"); } else { push(@headerContent, " static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*);\n"); @@ -901,7 +903,7 @@ sub GenerateImplementation push(@implContent, "{\n"); push(@implContent, " return JSDOMWindow::commonJSGlobalData()->heap.allocate(size);\n"); push(@implContent, "}\n\n"); - } elsif ($interfaceName eq "WorkerContext") { + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { push(@implContent, "void* ${className}Prototype::operator new(size_t size, JSGlobalData* globalData)\n"); push(@implContent, "{\n"); push(@implContent, " return globalData->heap.allocate(size);\n"); @@ -980,22 +982,18 @@ sub GenerateImplementation AddIncludesForType("JSDOMWindowShell"); push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, PassRefPtr<$implType> impl, JSDOMWindowShell* shell)\n"); push(@implContent, " : $parentClassName(structure, impl, shell)\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + AddIncludesForType($interfaceName); + push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, PassRefPtr<$implType> impl)\n"); + push(@implContent, " : $parentClassName(structure, impl)\n"); } else { - my $contextArg = ""; - if ($needsSVGContext) { - if ($hasParent && !$parentNeedsSVGContext) { - $contextArg = ", SVGElement*"; - } else { - $contextArg = ", SVGElement* context"; - } - } - push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, PassRefPtr<$implType> impl$contextArg)\n"); + my $contextArg = $needsSVGContext ? ", SVGElement* context" : ""; + push(@implContent, "${className}::$className(PassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<$implType> impl$contextArg)\n"); if ($hasParent) { - push(@implContent, " : $parentClassName(structure, impl" . ($parentNeedsSVGContext ? ", context" : "") . ")\n"); + push(@implContent, " : $parentClassName(structure, globalObject, impl" . ($parentNeedsSVGContext ? ", context" : "") . ")\n"); } else { - push(@implContent, " : $parentClassName(structure)\n"); - push(@implContent, " , m_context(context)\n") if $needsSVGContext; - push(@implContent, " , m_impl(impl)\n"); + push(@implContent, " : $parentClassName(structure, globalObject" . ($needsSVGContext ? ", context" : "") . ")\n"); + push(@implContent, " , m_impl(impl)\n"); } } push(@implContent, "{\n"); @@ -1096,6 +1094,7 @@ sub GenerateImplementation push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, const Identifier&, const PropertySlot& slot)\n"); push(@implContent, "{\n"); + push(@implContent, " ${className}* castedThis = static_cast<$className*>(asObject(slot.slotBase()));\n"); my $implClassNameForValueConversion = ""; if (!$podType and ($codeGenerator->IsSVGAnimatedType($implClassName) or $attribute->type !~ /^readonly/)) { @@ -1105,25 +1104,25 @@ sub GenerateImplementation if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckDomainSecurityOnGet"}) { - push(@implContent, " if (!static_cast<$className*>(asObject(slot.slotBase()))->allowsAccessFrom(exec))\n"); + push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n"); push(@implContent, " return jsUndefined();\n"); } if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) { - push(@implContent, " return static_cast<$className*>(asObject(slot.slotBase()))->$implGetterFunctionName(exec);\n"); + push(@implContent, " return castedThis->$implGetterFunctionName(exec);\n"); } elsif ($attribute->signature->extendedAttributes->{"CheckNodeSecurity"}) { $implIncludes{"JSDOMBinding.h"} = 1; - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " return checkNodeSecurity(exec, imp->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . " : jsUndefined();\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " return checkNodeSecurity(exec, imp->$implGetterFunctionName()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n"); } elsif ($attribute->signature->extendedAttributes->{"CheckFrameSecurity"}) { $implIncludes{"Document.h"} = 1; $implIncludes{"JSDOMBinding.h"} = 1; - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . " : jsUndefined();\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " return checkNodeSecurity(exec, imp->contentDocument()) ? " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName()", "castedThis") . " : jsUndefined();\n"); } elsif ($type eq "EventListener") { $implIncludes{"EventListener.h"} = 1; push(@implContent, " UNUSED_PARAM(exec);\n"); - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); push(@implContent, " if (EventListener* listener = imp->$implGetterFunctionName()) {\n"); push(@implContent, " if (JSObject* jsFunction = listener->jsFunction())\n"); push(@implContent, " return jsFunction;\n"); @@ -1132,19 +1131,20 @@ sub GenerateImplementation } elsif ($attribute->signature->type =~ /Constructor$/) { my $constructorType = $codeGenerator->StripModule($attribute->signature->type); $constructorType =~ s/Constructor$//; - push(@implContent, " UNUSED_PARAM(slot);\n"); - push(@implContent, " return JS" . $constructorType . "::getConstructor(exec);\n"); + # Constructor attribute is only used by DOMWindow.idl, so it's correct to pass castedThis as the global object + # Once DOMObjects have a back-pointer to the globalObject we can pass castedThis->globalObject() + push(@implContent, " return JS" . $constructorType . "::getConstructor(exec, castedThis);\n"); } elsif (!@{$attribute->getterExceptions}) { push(@implContent, " UNUSED_PARAM(exec);\n"); if ($podType) { - push(@implContent, " $podType imp(*static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); + push(@implContent, " $podType imp(*castedThis->impl());\n"); if ($podType eq "float") { # Special case for JSSVGNumber - push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp", "castedThis") . ";\n"); } else { - push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName()", "castedThis") . ";\n"); } } else { - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); my $value; my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; @@ -1156,23 +1156,22 @@ sub GenerateImplementation } else { $value = "imp->$implGetterFunctionName()"; } - my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, $value, "static_cast<$className*>(asObject(slot.slotBase()))"); + my $jsType = NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, $value, "castedThis"); if ($codeGenerator->IsSVGAnimatedType($type)) { push(@implContent, " RefPtr<$type> obj = $jsType;\n"); - push(@implContent, " return toJS(exec, obj.get(), imp);\n"); + push(@implContent, " return toJS(exec, castedThis->globalObject(), obj.get(), imp);\n"); } else { push(@implContent, " return $jsType;\n"); } } } else { - push(@implContent, " ExceptionCode ec = 0;\n"); - + push(@implContent, " ExceptionCode ec = 0;\n"); if ($podType) { - push(@implContent, " $podType imp(*static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName(ec)", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " $podType imp(*castedThis->impl());\n"); + push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, "", "imp.$implGetterFunctionName(ec)", "castedThis") . ";\n"); } else { - push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(asObject(slot.slotBase()))->impl());\n"); - push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName(ec)", "static_cast<$className*>(asObject(slot.slotBase()))") . ";\n"); + push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n"); + push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $implClassName, $implClassNameForValueConversion, "imp->$implGetterFunctionName(ec)", "castedThis") . ";\n"); } push(@implContent, " setDOMException(exec, ec);\n"); @@ -1193,7 +1192,15 @@ sub GenerateImplementation push(@implContent, "JSValue ${constructorFunctionName}(ExecState* exec, const Identifier&, const PropertySlot& slot)\n"); push(@implContent, "{\n"); - push(@implContent, " return static_cast<$className*>(asObject(slot.slotBase()))->getConstructor(exec);\n"); + if (IsSVGTypeNeedingContextParameter($interfaceName)) { + # FIXME: SVG bindings with a context pointer have no space to store a globalObject + # so we use deprecatedGlobalObjectForPrototype instead. + push(@implContent, " UNUSED_PARAM(slot);\n"); + push(@implContent, " return ${className}::getConstructor(exec, deprecatedGlobalObjectForPrototype(exec));\n"); + } else { + push(@implContent, " ${className}* domObject = static_cast<$className*>(asObject(slot.slotBase()));\n"); + push(@implContent, " return ${className}::getConstructor(exec, domObject->globalObject());\n"); + } push(@implContent, "}\n"); } } @@ -1338,8 +1345,8 @@ sub GenerateImplementation } if ($dataNode->extendedAttributes->{"GenerateConstructor"}) { - push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec)\n{\n"); - push(@implContent, " return getDOMConstructor<${className}Constructor>(exec);\n"); + push(@implContent, "JSValue ${className}::getConstructor(ExecState* exec, JSGlobalObject* globalObject)\n{\n"); + push(@implContent, " return getDOMConstructor<${className}Constructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));\n"); push(@implContent, "}\n\n"); } @@ -1361,6 +1368,10 @@ sub GenerateImplementation push(@implContent, " $className* castedThisObj = toJSDOMWindow(thisValue.toThisObject(exec));\n"); push(@implContent, " if (!castedThisObj)\n"); push(@implContent, " return throwError(exec, TypeError);\n"); + } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { + push(@implContent, " $className* castedThisObj = to${className}(thisValue.toThisObject(exec));\n"); + push(@implContent, " if (!castedThisObj)\n"); + push(@implContent, " return throwError(exec, TypeError);\n"); } else { push(@implContent, " if (!thisValue.isObject(&${className}::s_info))\n"); push(@implContent, " return throwError(exec, TypeError);\n"); @@ -1488,7 +1499,7 @@ sub GenerateImplementation $implIncludes{"KURL.h"} = 1; push(@implContent, " return jsStringOrNull(exec, thisObj->impl()->item(slot.index()));\n"); } else { - push(@implContent, " return toJS(exec, static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n"); + push(@implContent, " return toJS(exec, thisObj->globalObject(), static_cast<$implClassName*>(thisObj->impl())->item(slot.index()));\n"); } push(@implContent, "}\n"); if ($interfaceName eq "HTMLCollection") { @@ -1499,20 +1510,20 @@ sub GenerateImplementation if ((!$hasParent or $dataNode->extendedAttributes->{"GenerateToJS"}) and !$dataNode->extendedAttributes->{"CustomToJS"}) { if ($podType) { - push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSSVGPODTypeWrapper<$podType>* object, SVGElement* context)\n"); + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, JSSVGPODTypeWrapper<$podType>* object, SVGElement* context)\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, $implType* object, SVGElement* context)\n"); + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object, SVGElement* context)\n"); } else { - push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, $implType* object)\n"); + push(@implContent, "JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, $implType* object)\n"); } push(@implContent, "{\n"); if ($podType) { - push(@implContent, " return getDOMObjectWrapper<$className, JSSVGPODTypeWrapper<$podType> >(exec, object, context);\n"); + push(@implContent, " return getDOMObjectWrapper<$className, JSSVGPODTypeWrapper<$podType> >(exec, globalObject, object, context);\n"); } elsif (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@implContent, " return getDOMObjectWrapper<$className>(exec, object, context);\n"); + push(@implContent, " return getDOMObjectWrapper<$className>(exec, globalObject, object, context);\n"); } else { - push(@implContent, " return getDOMObjectWrapper<$className>(exec, object);\n"); + push(@implContent, " return getDOMObjectWrapper<$className>(exec, globalObject, object);\n"); } push(@implContent, "}\n"); } @@ -1688,11 +1699,9 @@ sub NativeToJSValue $implIncludes{"<runtime/JSString.h>"} = 1; return "jsString(exec, $value)"; } - - if ($type eq "RGBColor") { - $implIncludes{"JS$type.h"} = 1; - return "getJSRGBColor(exec, $value)"; - } + + # Some SVG bindings don't have space to store a globalObject pointer, for those, we use the deprecatedGlobalObjectForPrototype hack for now. + my $globalObject = IsSVGTypeNeedingContextParameter($implClassName) ? "deprecatedGlobalObjectForPrototype(exec)" : "$thisValue->globalObject()"; if ($codeGenerator->IsPodType($type)) { $implIncludes{"JS$type.h"} = 1; @@ -1711,24 +1720,25 @@ sub NativeToJSValue and $codeGenerator->IsPodTypeWithWriteableProperties($type) and not defined $signature->extendedAttributes->{"Immutable"}) { if ($codeGenerator->IsPodType($implClassName)) { - return "toJS(exec, JSSVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>::create($value, $thisValue->impl()).get(), $thisValue->context())"; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>::create($value, $thisValue->impl()).get(), $thisValue->context())"; } else { - return "toJS(exec, JSSVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>::create(imp, &${implClassName}::$getter, &${implClassName}::$setter).get(), imp)"; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>::create(imp, &${implClassName}::$getter, &${implClassName}::$setter).get(), imp)"; } } if ($implClassNameForValueConversion eq "") { - if (IsSVGTypeNeedingContextParameter($implClassName)) { - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), castedThisObj->context())" if $inFunctionCall eq 1; + # SVGZoomEvent has no context() pointer, and is also not an SVGElement. + # This is not a problem, because SVGZoomEvent has no read/write properties. + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), 0)" if $implClassName eq "SVGZoomEvent"; - # Special case: SVGZoomEvent - it doesn't have a context, but it's no problem, as there are no readwrite props - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), 0)" if $implClassName eq "SVGZoomEvent"; - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), $thisValue->context())"; + if (IsSVGTypeNeedingContextParameter($implClassName)) { + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), castedThisObj->context())" if $inFunctionCall; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), $thisValue->context())"; } else { - return "toJS(exec, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), imp)"; + return "toJS(exec, $globalObject, JSSVGStaticPODTypeWrapper<$nativeType>::create($value).get(), imp)"; } } else { # These classes, always have a m_context pointer! - return "toJS(exec, JSSVGDynamicPODTypeWrapperCache<$nativeType, $implClassNameForValueConversion>::lookupOrCreateWrapper(imp, &${implClassNameForValueConversion}::$getter, &${implClassNameForValueConversion}::$setter).get(), $thisValue->context())"; + return "toJS(exec, $globalObject, JSSVGDynamicPODTypeWrapperCache<$nativeType, $implClassNameForValueConversion>::lookupOrCreateWrapper(imp, &${implClassNameForValueConversion}::$getter, &${implClassNameForValueConversion}::$setter).get(), $thisValue->context())"; } } @@ -1761,18 +1771,15 @@ sub NativeToJSValue return $value if $codeGenerator->IsSVGAnimatedType($type); if (IsSVGTypeNeedingContextParameter($type)) { - if (IsSVGTypeNeedingContextParameter($implClassName)) { - return "toJS(exec, WTF::getPtr($value), $thisValue->context())"; - } else { - return "toJS(exec, WTF::getPtr($value), imp)"; - } + my $contextPtr = IsSVGTypeNeedingContextParameter($implClassName) ? "$thisValue->context()" : "imp"; + return "toJS(exec, $globalObject, WTF::getPtr($value), $contextPtr)"; } if ($signature->extendedAttributes->{"ReturnsNew"}) { - return "toJSNewlyCreated(exec, WTF::getPtr($value))"; + return "toJSNewlyCreated(exec, $globalObject, WTF::getPtr($value))"; } - return "toJS(exec, WTF::getPtr($value))"; + return "toJS(exec, $globalObject, WTF::getPtr($value))"; } sub ceilingToPowerOf2 @@ -2023,14 +2030,15 @@ sub constructorFor my $interfaceName = shift; my $visibleClassName = shift; my $canConstruct = shift; + my $constructorClassName = "${className}Constructor"; my $implContent = << "EOF"; -class ${className}Constructor : public DOMObject { +class ${constructorClassName} : public DOMConstructorObject { public: - ${className}Constructor(ExecState* exec) - : DOMObject(${className}Constructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) + ${constructorClassName}(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(${constructorClassName}::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, exec->lexicalGlobalObject()), None); + putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), None); } virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual const ClassInfo* classInfo() const { return &s_info; } @@ -2044,13 +2052,13 @@ EOF if ($canConstruct) { $implContent .= << "EOF"; - static JSObject* construct(ExecState* exec, JSObject*, const ArgList&) + static JSObject* construct${interfaceName}(ExecState* exec, JSObject* constructor, const ArgList&) { - return asObject(toJS(exec, ${interfaceName}::create())); + return asObject(toJS(exec, static_cast<${constructorClassName}*>(constructor)->globalObject(), ${interfaceName}::create())); } virtual ConstructType getConstructData(ConstructData& constructData) { - constructData.native.function = construct; + constructData.native.function = construct${interfaceName}; return ConstructTypeHost; } EOF @@ -2059,16 +2067,16 @@ EOF $implContent .= << "EOF"; }; -const ClassInfo ${className}Constructor::s_info = { "${visibleClassName}Constructor", 0, &${className}ConstructorTable, 0 }; +const ClassInfo ${constructorClassName}::s_info = { "${visibleClassName}Constructor", 0, &${constructorClassName}Table, 0 }; -bool ${className}Constructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +bool ${constructorClassName}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { - return getStaticValueSlot<${className}Constructor, DOMObject>(exec, &${className}ConstructorTable, this, propertyName, slot); + return getStaticValueSlot<${constructorClassName}, DOMObject>(exec, &${constructorClassName}Table, this, propertyName, slot); } EOF - $implJSCInclude{"JSNumberCell.h"} = 1; + $implJSCInclude{"JSNumberCell.h"} = 1; # FIXME: What is this for? return $implContent; } diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 10628b464..d46d88a72 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -515,15 +515,17 @@ sub AddIncludesForType { my $type = $codeGenerator->StripModule(shift); - return if $codeGenerator->IsNonPointerType($type) or IsNativeObjCType($type); + return if $codeGenerator->IsNonPointerType($type); - if ($codeGenerator->IsStringType($type)) { - $implIncludes{"KURL.h"} = 1; + if (IsNativeObjCType($type)) { + if ($type eq "Color") { + $implIncludes{"ColorMac.h"} = 1; + } return; } - if ($type eq "RGBColor") { - $implIncludes{"DOMRGBColorInternal.h"} = 1; + if ($codeGenerator->IsStringType($type)) { + $implIncludes{"KURL.h"} = 1; return; } @@ -924,8 +926,6 @@ sub GenerateHeader if ($codeGenerator->IsSVGAnimatedType($interfaceName)) { push(@internalHeaderContent, "#import <WebCore/SVGAnimatedTemplate.h>\n\n"); - } elsif ($interfaceName eq "RGBColor") { - push(@internalHeaderContent, "#import <WebCore/Color.h>\n\n"); } else { push(@internalHeaderContent, "namespace WebCore {\n"); $startedNamespace = 1; @@ -1198,6 +1198,9 @@ sub GenerateImplementation } elsif (IsProtocolType($idlType) and $idlType ne "EventTarget") { $getterContentHead = "kit($getterContentHead"; $getterContentTail .= ")"; + } elsif ($idlType eq "Color") { + $getterContentHead = "WebCore::nsColor($getterContentHead"; + $getterContentTail .= ")"; } elsif (ConversionNeeded($attribute->signature->type)) { $getterContentHead = "kit(WTF::getPtr($getterContentHead"; $getterContentTail .= "))"; diff --git a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm index cdadf8178..862649fb1 100644 --- a/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/src/3rdparty/webkit/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -113,7 +113,6 @@ sub WK_lcfirst sub IsPodType { my $type = shift; - return 0 if $type eq "RGBColor"; return $codeGenerator->IsPodType($type); } @@ -243,6 +242,18 @@ sub GetImplementationFileName return "${iface}.h"; } +# If the node has a [Conditional=XXX] attribute, returns an "ENABLE(XXX)" string for use in an #if. +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } else { + return ""; + } +} + sub GenerateHeader { my $object = shift; @@ -257,17 +268,12 @@ sub GenerateHeader $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode); my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; + my $conditionalString = GenerateConditionalString($dataNode); # - Add default header template @headerContent = split("\r", $headerTemplate); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@headerContent, "\n#if ${conditionalString}\n\n"); - } - + push(@headerContent, "\n#if ${conditionalString}\n\n") if $conditionalString; push(@headerContent, "\n#ifndef $className" . "_H"); push(@headerContent, "\n#define $className" . "_H\n\n"); @@ -310,7 +316,7 @@ END push(@headerContent, "}\n\n"); push(@headerContent, "#endif // $className" . "_H\n"); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional; + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; } @@ -422,17 +428,12 @@ END if ($classIndex eq "DOMWINDOW") { push(@implContentDecls, <<END); DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder()); - Frame* frame = window->frame(); - if (frame) { - // Get the proxy corresponding to the DOMWindow if possible to - // make sure that the constructor function is constructed in the - // context of the DOMWindow and not in the context of the caller. - return V8Proxy::retrieve(frame)->getConstructor(type); - } + // Get the proxy corresponding to the DOMWindow if possible to + // make sure that the constructor function is constructed in the + // context of the DOMWindow and not in the context of the caller. + return V8DOMWrapper::getConstructor(type, window); END - } - - if ($classIndex eq "WORKERCONTEXT") { + } elsif ($classIndex eq "DEDICATEDWORKERCONTEXT" or $classIndex eq "WORKERCONTEXT") { $implIncludes{"WorkerContextExecutionProxy.h"} = 1; push(@implContentDecls, <<END); return WorkerContextExecutionProxy::retrieve()->GetConstructor(type); @@ -547,54 +548,60 @@ END my $getterString; if ($getterStringUsesImp) { - $getterString = "imp->$getterFunc("; - $getterString .= "ec" if $useExceptions; - $getterString .= ")"; - if (IsRefPtrType($returnType)) { - $implIncludes{"wtf/GetPtr.h"} = 1; - $getterString = "WTF::getPtr(" . $getterString . ")"; - } - if ($nativeType eq "int" and - $attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $getterString .= ".toInt()"; - } + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $implIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL); + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $getterString = "imp->$getAttributeFunctionName(HTMLNames::${contentAttributeName}Attr"; } else { - $getterString = "imp_instance"; + $getterString = "imp->$getterFunc("; } - if ($nativeType eq "String") { - $getterString = "toString($getterString)"; + $getterString .= "ec" if $useExceptions; + $getterString .= ")"; + if ($nativeType eq "int" and $attribute->signature->extendedAttributes->{"ConvertFromString"}) { + $getterString .= ".toInt()"; } + } else { + $getterString = "imp_instance"; + } - my $result; - my $wrapper; + if ($nativeType eq "String") { + $getterString = "toString($getterString)"; + } - if ($attrIsPodType) { - $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; + my $result; + my $wrapper; + + if ($attrIsPodType) { + $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; - my $getter = $getterString; - $getter =~ s/imp->//; - $getter =~ s/\(\)//; - my $setter = "set" . WK_ucfirst($getter); + my $getter = $getterString; + $getter =~ s/imp->//; + $getter =~ s/\(\)//; + my $setter = "set" . WK_ucfirst($getter); - my $implClassIsAnimatedType = $codeGenerator->IsSVGAnimatedType($implClassName); - if (not $implClassIsAnimatedType - and $codeGenerator->IsPodTypeWithWriteableProperties($attrType) - and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { + my $implClassIsAnimatedType = $codeGenerator->IsSVGAnimatedType($implClassName); + if (not $implClassIsAnimatedType and $codeGenerator->IsPodTypeWithWriteableProperties($attrType) and not defined $attribute->signature->extendedAttributes->{"Immutable"}) { if (IsPodType($implClassName)) { - $wrapper = "new V8SVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>($getterString, imp_wrapper)"; + my $wrapper = "V8SVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName>::create($getterString, imp_wrapper)"; + push(@implContentDecls, " RefPtr<V8SVGStaticPODTypeWrapperWithPODTypeParent<$nativeType, $implClassName> > wrapper = $wrapper;\n"); } else { - $wrapper = "new V8SVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + my $wrapper = "V8SVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName>::create(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + push(@implContentDecls, " RefPtr<V8SVGStaticPODTypeWrapperWithParent<$nativeType, $implClassName> > wrapper = $wrapper;\n"); } } else { if ($implClassIsAnimatedType) { - $wrapper = "V8SVGDynamicPODTypeWrapperCache<$nativeType, $implClassName>::lookupOrCreateWrapper(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + my $wrapper = "V8SVGDynamicPODTypeWrapperCache<$nativeType, $implClassName>::lookupOrCreateWrapper(imp, &${implClassName}::$getter, &${implClassName}::$setter)"; + push(@implContentDecls, " RefPtr<V8SVGPODTypeWrapper<" . $nativeType . "> > wrapper = $wrapper;\n"); } else { - $wrapper = GenerateSVGStaticPodTypeWrapper($returnType, $getterString); + my $wrapper = GenerateSVGStaticPodTypeWrapper($returnType, $getterString); + push(@implContentDecls, " RefPtr<V8SVGStaticPODTypeWrapper<" . $nativeType . "> > wrapper = $wrapper;\n"); } } - push(@implContentDecls, " void* wrapper = $wrapper;\n"); - } elsif ($nativeType ne "RGBColor") { + } else { push(@implContentDecls, " $nativeType v = "); push(@implContentDecls, "$getterString;\n"); @@ -604,28 +611,22 @@ END } $result = "v"; - if (IsRefPtrType($returnType)) { - $result = "WTF::getPtr(" . $result . ")"; - } - } else { - # Special case: RGBColor is noncopyable - $result = $getterString; } - if (IsSVGTypeNeedingContextParameter($attrType) && !$skipContext) { my $resultObject = $result; if ($attrIsPodType) { $resultObject = "wrapper"; } - + $resultObject = "WTF::getPtr(" . $resultObject . ")"; push(@implContentDecls, GenerateSVGContextAssignment($implClassName, $resultObject, " ")); } if ($attrIsPodType) { my $classIndex = uc($attrType); - push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper);\n"); + push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"); } else { + $result .= ".release()" if (IsRefPtrType($attrType)); push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n"); } @@ -718,7 +719,16 @@ END if ($implClassName eq "double") { push(@implContentDecls, " *imp = $result;\n"); } else { - push(@implContentDecls, " imp->set" . WK_ucfirst($attrName) . "(" . $result); + my $implSetterFunctionName = WK_ucfirst($attrName); + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + $implIncludes{"HTMLNames.h"} = 1; + my $contentAttributeName = ($reflect || $reflectURL) eq "1" ? $attrName : ($reflect || $reflectURL); + push(@implContentDecls, " imp->setAttribute(HTMLNames::${contentAttributeName}Attr, $result"); + } else { + push(@implContentDecls, " imp->set$implSetterFunctionName(" . $result); + } push(@implContentDecls, ", ec") if $useExceptions; push(@implContentDecls, ");\n"); } @@ -800,7 +810,7 @@ sub GenerateFunctionCallback push(@implContentDecls, " $nativeClassName* imp = &imp_instance;\n"); } else { push(@implContentDecls, <<END); - v8::Handle<v8::Value> holder = args.Holder(); + v8::Handle<v8::Object> holder = args.Holder(); END HolderToNative($dataNode, $implClassName, $classIndex); } @@ -892,134 +902,138 @@ sub GenerateBatchedAttributeData $accessControl = "v8::ALL_CAN_WRITE"; } elsif ($attrExt->{"DoNotCheckDomainSecurity"}) { $accessControl = "v8::ALL_CAN_READ"; - if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) { - $accessControl .= "|v8::ALL_CAN_WRITE"; + if (!($attribute->type =~ /^readonly/) && !($attrExt->{"V8ReadOnly"})) { + $accessControl .= "|v8::ALL_CAN_WRITE"; + } } - } - if ($attrExt->{"V8DisallowShadowing"}) { - $accessControl .= "|v8::PROHIBITS_OVERWRITING"; - } - $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")"; - - my $customAccessor = - $attrExt->{"Custom"} || - $attrExt->{"CustomSetter"} || - $attrExt->{"CustomGetter"} || - $attrExt->{"V8Custom"} || - $attrExt->{"V8CustomSetter"} || - $attrExt->{"V8CustomGetter"} || - ""; - if ($customAccessor eq 1) { - # use the naming convension, interface + (capitalize) attr name - $customAccessor = $interfaceName . WK_ucfirst($attrName); - } - - my $getter; - my $setter; - my $propAttr = "v8::None"; - my $hasCustomSetter = 0; - - # Check attributes. - if ($attrExt->{"DontEnum"}) { - $propAttr .= "|v8::DontEnum"; - } - if ($attrExt->{"V8DisallowShadowing"}) { - $propAttr .= "|v8::DontDelete"; - } - - my $on_proto = "0 /* on instance */"; - my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */"; - - # Constructor - if ($attribute->signature->type =~ /Constructor$/) { - my $constructorType = $codeGenerator->StripModule($attribute->signature->type); - $constructorType =~ s/Constructor$//; - my $constructorIndex = uc($constructorType); - $data = "V8ClassIndex::${constructorIndex}"; - $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter"; - $setter = "0"; - $propAttr = "v8::ReadOnly"; - - # EventListeners - } elsif ($attribute->signature->type eq "EventListener") { - if ($interfaceName eq "DOMWindow") { - $getter = "V8Custom::v8DOMWindowEventHandlerAccessorGetter"; - $setter = "V8Custom::v8DOMWindowEventHandlerAccessorSetter"; - } elsif ($interfaceName eq "Element" || $interfaceName eq "Document" || $interfaceName eq "HTMLBodyElement" || $interfaceName eq "SVGElementInstance" || $interfaceName eq "HTMLFrameSetElement") { - $getter = "V8Custom::v8ElementEventHandlerAccessorGetter"; - $setter = "V8Custom::v8ElementEventHandlerAccessorSetter"; - } else { + if ($attrExt->{"V8DisallowShadowing"}) { + $accessControl .= "|v8::PROHIBITS_OVERWRITING"; + } + $accessControl = "static_cast<v8::AccessControl>(" . $accessControl . ")"; + + my $customAccessor = + $attrExt->{"Custom"} || + $attrExt->{"CustomSetter"} || + $attrExt->{"CustomGetter"} || + $attrExt->{"V8Custom"} || + $attrExt->{"V8CustomSetter"} || + $attrExt->{"V8CustomGetter"} || + ""; + if ($customAccessor eq 1) { + # use the naming convension, interface + (capitalize) attr name + $customAccessor = $interfaceName . WK_ucfirst($attrName); + } + + my $getter; + my $setter; + my $propAttr = "v8::None"; + my $hasCustomSetter = 0; + + # Check attributes. + if ($attrExt->{"DontEnum"}) { + $propAttr .= "|v8::DontEnum"; + } + if ($attrExt->{"V8DisallowShadowing"}) { + $propAttr .= "|v8::DontDelete"; + } + + my $on_proto = "0 /* on instance */"; + my $data = "V8ClassIndex::INVALID_CLASS_INDEX /* no data */"; + + # Constructor + if ($attribute->signature->type =~ /Constructor$/) { + my $constructorType = $codeGenerator->StripModule($attribute->signature->type); + $constructorType =~ s/Constructor$//; + my $constructorIndex = uc($constructorType); + $data = "V8ClassIndex::${constructorIndex}"; + $getter = "${interfaceName}Internal::${interfaceName}ConstructorGetter"; + $setter = "0"; + $propAttr = "v8::ReadOnly"; + + # EventListeners + } elsif ($attribute->signature->type eq "EventListener") { + if ($interfaceName eq "DOMWindow") { + $getter = "V8Custom::v8DOMWindowEventHandlerAccessorGetter"; + $setter = "V8Custom::v8DOMWindowEventHandlerAccessorSetter"; + } elsif ($interfaceName eq "Element" || $interfaceName eq "Document" || $interfaceName eq "HTMLBodyElement" || $interfaceName eq "SVGElementInstance" || $interfaceName eq "HTMLFrameSetElement") { + $getter = "V8Custom::v8ElementEventHandlerAccessorGetter"; + $setter = "V8Custom::v8ElementEventHandlerAccessorSetter"; + } else { + $getter = "V8Custom::v8${customAccessor}AccessorGetter"; + if ($interfaceName eq "WorkerContext" and $attrName eq "self") { + $setter = "0"; + $propAttr = "v8::ReadOnly"; + } else { + $setter = "V8Custom::v8${customAccessor}AccessorSetter"; + } + } + + # Custom Getter and Setter + } elsif ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { $getter = "V8Custom::v8${customAccessor}AccessorGetter"; if ($interfaceName eq "WorkerContext" and $attrName eq "self") { $setter = "0"; $propAttr = "v8::ReadOnly"; } else { + $hasCustomSetter = 1; $setter = "V8Custom::v8${customAccessor}AccessorSetter"; } - } - # Custom Getter and Setter - } elsif ($attrExt->{"Custom"} || $attrExt->{"V8Custom"}) { - $getter = "V8Custom::v8${customAccessor}AccessorGetter"; - if ($interfaceName eq "WorkerContext" and $attrName eq "self") { - $setter = "0"; - $propAttr = "v8::ReadOnly"; - } else { + # Custom Setter + } elsif ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"}) { $hasCustomSetter = 1; + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; $setter = "V8Custom::v8${customAccessor}AccessorSetter"; + + # Custom Getter + } elsif ($attrExt->{"CustomGetter"}) { + $getter = "V8Custom::v8${customAccessor}AccessorGetter"; + $setter = "${interfaceName}Internal::${attrName}AttrSetter"; + + # Replaceable + } elsif ($attrExt->{"Replaceable"}) { + # Replaceable accessor is put on instance template with ReadOnly attribute. + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; + $setter = "0"; + + # Mark to avoid duplicate v8::ReadOnly flags in output. + $hasCustomSetter = 1; + + # Handle the special case of window.top being marked upstream as Replaceable. + # FIXME: Investigate why [Replaceable] is not marked as ReadOnly + # upstream and reach parity. + if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) { + $propAttr .= "|v8::ReadOnly"; + } + + # Normal + } else { + $getter = "${interfaceName}Internal::${attrName}AttrGetter"; + $setter = "${interfaceName}Internal::${attrName}AttrSetter"; } - # Custom Setter - } elsif ($attrExt->{"CustomSetter"} || $attrExt->{"V8CustomSetter"}) { - $hasCustomSetter = 1; - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "V8Custom::v8${customAccessor}AccessorSetter"; - - # Custom Getter - } elsif ($attrExt->{"CustomGetter"}) { - $getter = "V8Custom::v8${customAccessor}AccessorGetter"; - $setter = "${interfaceName}Internal::${attrName}AttrSetter"; - - # Replaceable - } elsif ($attrExt->{"Replaceable"}) { - # Replaceable accessor is put on instance template with ReadOnly attribute. - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "0"; - - # Mark to avoid duplicate v8::ReadOnly flags in output. - $hasCustomSetter = 1; - - # Handle the special case of window.top being marked upstream as Replaceable. - # FIXME: Investigate why [Replaceable] is not marked as ReadOnly - # upstream and reach parity. - if (!($interfaceName eq "DOMWindow" and $attrName eq "top")) { + if ($attrExt->{"Replaceable"} && !$hasCustomSetter) { + $setter = "0"; $propAttr .= "|v8::ReadOnly"; } - # Normal - } else { - $getter = "${interfaceName}Internal::${attrName}AttrGetter"; - $setter = "${interfaceName}Internal::${attrName}AttrSetter"; - } - - if ($attrExt->{"Replaceable"} && !$hasCustomSetter) { - $setter = "0"; - $propAttr .= "|v8::ReadOnly"; - } + # Read only attributes + if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) { + $setter = "0"; + } - # Read only attributes - if ($attribute->type =~ /^readonly/ || $attrExt->{"V8ReadOnly"}) { - $setter = "0"; - } + # An accessor can be installed on the proto + if ($attrExt->{"v8OnProto"}) { + $on_proto = "1 /* on proto */"; + } - # An accessor can be installed on the proto - if ($attrExt->{"v8OnProto"}) { - $on_proto = "1 /* on proto */"; - } + my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . + "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; + + my $conditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString; - my $commentInfo = "Attribute '$attrName' (Type: '" . $attribute->type . - "' ExtAttr: '" . join(' ', keys(%{$attrExt})) . "')"; - push(@implContent, <<END); + push(@implContent, <<END); // $commentInfo { "$attrName", $getter, @@ -1029,6 +1043,7 @@ sub GenerateBatchedAttributeData static_cast<v8::PropertyAttribute>($propAttr), $on_proto }, END + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } } @@ -1043,7 +1058,7 @@ sub GenerateImplementation my $classIndex = uc($codeGenerator->StripModule($interfaceName)); my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; + my $conditionalString = GenerateConditionalString($dataNode); @allParents = $codeGenerator->FindParentsRecursively($dataNode); @@ -1056,11 +1071,7 @@ sub GenerateImplementation "#include \"V8Binding.h\"\n\n" . "#undef LOG\n\n"); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implFixedHeader, "\n#if ${conditionalString}\n\n"); - } + push(@implFixedHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; if ($className =~ /^V8SVGAnimated/) { AddIncludesForSVGAnimatedType($interfaceName); @@ -1376,7 +1387,7 @@ END } // namespace WebCore END - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional; + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } @@ -1466,13 +1477,6 @@ sub GenerateFunctionCallString() } $functionString .= ")"; - if ((IsRefPtrType($returnType) || $returnsListItemPodType) && !$nodeToReturn) { - # We don't use getPtr when $nodeToReturn because that situation is - # special-cased below to return a bool. - $implIncludes{"wtf/GetPtr.h"} = 1; - $functionString = "WTF::getPtr(" . $functionString . ")"; - } - if ($nodeToReturn) { # Special case for insertBefore, replaceChild, removeChild and # appendChild functions from Node. @@ -1502,18 +1506,14 @@ sub GenerateFunctionCallString() } my $return = "result"; - if (IsRefPtrType($returnType) || $returnsListItemPodType) { - $implIncludes{"wtf/GetPtr.h"} = 1; - $return = "WTF::getPtr(" . $return . ")"; - } # If the return type is a POD type, separate out the wrapper generation if ($returnsListItemPodType) { - $result .= $indent . "V8SVGPODTypeWrapper<" . $nativeReturnType . ">* wrapper = new "; - $result .= "V8SVGPODTypeWrapperCreatorForList<" . $nativeReturnType . ">($return, imp->associatedAttributeName());\n"; + $result .= $indent . "RefPtr<V8SVGPODTypeWrapper<" . $nativeReturnType . "> > wrapper = "; + $result .= "V8SVGPODTypeWrapperCreatorForList<" . $nativeReturnType . ">::create($return, imp->associatedAttributeName());\n"; $return = "wrapper"; } elsif ($returnsPodType) { - $result .= $indent . "V8SVGPODTypeWrapper<" . $nativeReturnType . ">* wrapper = "; + $result .= $indent . "RefPtr<V8SVGPODTypeWrapper<" . $nativeReturnType . "> > wrapper = "; $result .= GenerateSVGStaticPodTypeWrapper($returnType, $return) . ";\n"; $return = "wrapper"; } @@ -1521,7 +1521,7 @@ sub GenerateFunctionCallString() my $generatedSVGContextRetrieval = 0; # If the return type needs an SVG context, output it if (IsSVGTypeNeedingContextParameter($returnType)) { - $result .= GenerateSVGContextAssignment($implClassName, $return, $indent); + $result .= GenerateSVGContextAssignment($implClassName, $return . ".get()", $indent); $generatedSVGContextRetrieval = 1; } @@ -1547,8 +1547,9 @@ sub GenerateFunctionCallString() if ($returnsPodType) { my $classIndex = uc($returnType); - $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper);\n"; + $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"; } else { + $return .= ".release()" if (IsRefPtrType($returnType)); $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n"; } @@ -1688,7 +1689,6 @@ sub GetNativeType return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType"; return "DOMTimeStamp" if $type eq "DOMTimeStamp"; return "unsigned" if $type eq "unsigned int"; - return "unsigned" if $type eq "RGBColor"; return "Node*" if $type eq "EventTarget" and $isParameter; return "String" if $type eq "DOMUserData"; # FIXME: Temporary hack? @@ -1828,7 +1828,7 @@ sub JSValueToNative $implIncludes{"V8Node.h"} = 1; # EventTarget is not in DOM hierarchy, but all Nodes are EventTarget. - return "V8Node::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<Node>($value) : 0"; + return "V8Node::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast($value)) : 0"; } AddIncludesForType($type); @@ -1839,7 +1839,7 @@ sub JSValueToNative # Perform type checks on the parameter, if it is expected Node type, # return NULL. - return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<${type}>($value) : 0"; + return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<${type}>(v8::Handle<v8::Object>::Cast($value)) : 0"; } else { # TODO: Temporary to avoid Window name conflict. my $classIndex = uc($type); @@ -1858,7 +1858,7 @@ sub JSValueToNative # Perform type checks on the parameter, if it is expected Node type, # return NULL. - return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertToNativeObject<${implClassName}>(V8ClassIndex::${classIndex}, $value) : 0"; + return "V8${type}::HasInstance($value) ? V8DOMWrapper::convertToNativeObject<${implClassName}>(V8ClassIndex::${classIndex}, v8::Handle<v8::Object>::Cast($value)) : 0"; } } @@ -2028,13 +2028,12 @@ sub ReturnNativeToJSValue return "return V8DOMWrapper::convertEventListenerToV8Object($value)"; } - if ($type eq "RGBColor") { - my $construct = "RefPtr<RGBColor> rgbcolor = RGBColor::create($value);\n"; - my $convert = "V8DOMWrapper::convertToV8Object(V8ClassIndex::RGBCOLOR, WTF::getPtr(rgbcolor))"; - return $construct . $indent . "return " . $convert; + if ($type eq "DedicatedWorkerContext" or $type eq "WorkerContext") { + $implIncludes{"WorkerContextExecutionProxy.h"} = 1; + return "return WorkerContextExecutionProxy::WorkerContextToV8Object($value)"; } - if ($type eq "WorkerContext" or $type eq "WorkerLocation" or $type eq "WorkerNavigator") { + if ($type eq "WorkerLocation" or $type eq "WorkerNavigator") { $implIncludes{"WorkerContextExecutionProxy.h"} = 1; my $classIndex = uc($type); @@ -2044,6 +2043,7 @@ sub ReturnNativeToJSValue else { $implIncludes{"wtf/RefCounted.h"} = 1; $implIncludes{"wtf/RefPtr.h"} = 1; + $implIncludes{"wtf/GetPtr.h"} = 1; my $classIndex = uc($type); if (IsPodType($type)) { @@ -2062,7 +2062,7 @@ sub GenerateSVGStaticPodTypeWrapper { $implIncludes{"V8SVGPODTypeWrapper.h"} = 1; my $nativeType = GetNativeType($type); - return "new V8SVGStaticPODTypeWrapper<$nativeType>($value)"; + return "V8SVGStaticPODTypeWrapper<$nativeType>::create($value)"; } # Internal helper @@ -2122,7 +2122,7 @@ sub GenerateSVGContextAssignment my $indent = shift; $result = GenerateSVGContextRetrieval($srcType, $indent); - $result .= $indent . "V8Proxy::setSVGContext($value, context);\n"; + $result .= $indent . "V8Proxy::setSVGContext($value, context);\n"; return $result; } |