diff options
Diffstat (limited to 'WebCore/bindings/js')
147 files changed, 2893 insertions, 1662 deletions
diff --git a/WebCore/bindings/js/CachedScriptSourceProvider.h b/WebCore/bindings/js/CachedScriptSourceProvider.h new file mode 100644 index 0000000..e943fa5 --- /dev/null +++ b/WebCore/bindings/js/CachedScriptSourceProvider.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CachedScriptSourceProvider_h +#define CachedScriptSourceProvider_h + +#include "CachedResourceClient.h" +#include "CachedResourceHandle.h" +#include "CachedScript.h" +#include <parser/SourceCode.h> + +namespace WebCore { + + class CachedScriptSourceProvider : public JSC::SourceProvider, public CachedResourceClient { + public: + static PassRefPtr<CachedScriptSourceProvider> create(CachedScript* cachedScript) { return adoptRef(new CachedScriptSourceProvider(cachedScript)); } + + virtual ~CachedScriptSourceProvider() + { + m_cachedScript->removeClient(this); + } + + 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(); } + + private: + CachedScriptSourceProvider(CachedScript* cachedScript) + : SourceProvider(cachedScript->url()) + , m_cachedScript(cachedScript) + { + m_cachedScript->addClient(this); + } + + CachedResourceHandle<CachedScript> m_cachedScript; + }; + + inline JSC::SourceCode makeSource(CachedScript* cachedScript) + { + return JSC::SourceCode(CachedScriptSourceProvider::create(cachedScript)); + } + +} // namespace WebCore + +#endif // CachedScriptSourceProvider_h diff --git a/WebCore/bindings/js/GCController.cpp b/WebCore/bindings/js/GCController.cpp index fc8a778..ceb7928 100644 --- a/WebCore/bindings/js/GCController.cpp +++ b/WebCore/bindings/js/GCController.cpp @@ -29,7 +29,8 @@ #include "JSDOMWindow.h" #include <runtime/JSGlobalData.h> #include <runtime/JSLock.h> -#include <kjs/collector.h> +#include <runtime/Collector.h> +#include <wtf/StdLibExtras.h> #if USE(PTHREADS) #include <pthread.h> @@ -52,7 +53,7 @@ static void* collect(void*) GCController& gcController() { - static GCController staticGCController; + DEFINE_STATIC_LOCAL(GCController, staticGCController, ()); return staticGCController; } diff --git a/WebCore/bindings/js/JSAttrCustom.cpp b/WebCore/bindings/js/JSAttrCustom.cpp index 0cf5705..a97d039 100644 --- a/WebCore/bindings/js/JSAttrCustom.cpp +++ b/WebCore/bindings/js/JSAttrCustom.cpp @@ -40,7 +40,7 @@ namespace WebCore { using namespace HTMLNames; -void JSAttr::setValue(ExecState* exec, JSValue* value) +void JSAttr::setValue(ExecState* exec, JSValuePtr value) { Attr* imp = static_cast<Attr*>(impl()); String attrValue = valueToStringWithNullCheck(exec, value); diff --git a/WebCore/bindings/js/JSAudioConstructor.cpp b/WebCore/bindings/js/JSAudioConstructor.cpp index f342cea..f0bdbe8 100644 --- a/WebCore/bindings/js/JSAudioConstructor.cpp +++ b/WebCore/bindings/js/JSAudioConstructor.cpp @@ -30,6 +30,7 @@ #include "JSAudioConstructor.h" #include "HTMLAudioElement.h" +#include "HTMLNames.h" #include "JSHTMLAudioElement.h" #include "ScriptExecutionContext.h" #include "Text.h" @@ -41,7 +42,7 @@ namespace WebCore { const ClassInfo JSAudioConstructor::s_info = { "AudioConstructor", 0, 0, 0 }; JSAudioConstructor::JSAudioConstructor(ExecState* exec, ScriptExecutionContext* context) - : DOMObject(JSAudioConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype())) + : DOMObject(JSAudioConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) { ASSERT(context->isDocument()); m_document = static_cast<JSDocument*>(asObject(toJS(exec, static_cast<Document*>(context)))); @@ -53,9 +54,9 @@ static JSObject* constructAudio(ExecState* exec, JSObject* constructor, const Ar { // FIXME: Why doesn't this need the call toJS on the document like JSImageConstructor? - RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(static_cast<JSAudioConstructor*>(constructor)->document()); + RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, static_cast<JSAudioConstructor*>(constructor)->document()); if (args.size() > 0) { - audio->setSrc(args.at(exec, 0)->toString(exec)); + audio->setSrc(args.at(exec, 0).toString(exec)); audio->scheduleLoad(); } return asObject(toJS(exec, audio.release())); diff --git a/WebCore/bindings/js/JSCanvasPixelArrayCustom.h b/WebCore/bindings/js/JSCDATASectionCustom.cpp index 9bdcccd..68180f1 100644 --- a/WebCore/bindings/js/JSCanvasPixelArrayCustom.h +++ b/WebCore/bindings/js/JSCDATASectionCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,41 +10,34 @@ * 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 + * 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 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "JSCanvasPixelArray.h" +#include "config.h" +#include "JSCDATASection.h" -#include "CanvasPixelArray.h" +#include "CDATASection.h" using namespace JSC; namespace WebCore { + +JSValuePtr toJSNewlyCreated(ExecState* exec, CDATASection* section) +{ + if (!section) + return jsNull(); - inline JSValue* JSCanvasPixelArray::getByIndex(ExecState* exec, unsigned index) - { - unsigned char result; - if (!impl()->get(index, result)) - return jsUndefined(); - return JSImmediate::from(result); - } - - inline void JSCanvasPixelArray::indexSetter(ExecState* exec, unsigned index, JSValue* value) - { - double pixelValue = value->toNumber(exec); - if (exec->hadException()) - return; - m_impl->set(index, pixelValue); - } - + return CREATE_DOM_NODE_WRAPPER(exec, CDATASection, section); +} + } // namespace WebCore diff --git a/WebCore/bindings/js/JSCSSRuleCustom.cpp b/WebCore/bindings/js/JSCSSRuleCustom.cpp index 1e0fac3..32462fa 100644 --- a/WebCore/bindings/js/JSCSSRuleCustom.cpp +++ b/WebCore/bindings/js/JSCSSRuleCustom.cpp @@ -49,7 +49,7 @@ using namespace JSC; namespace WebCore { -JSValue* toJS(ExecState* exec, CSSRule* rule) +JSValuePtr toJS(ExecState* exec, CSSRule* rule) { if (!rule) return jsNull(); diff --git a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp index 13b6379..6c46ae4 100644 --- a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp +++ b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp @@ -127,7 +127,7 @@ bool JSCSSStyleDeclaration::canGetItemsForName(ExecState*, CSSStyleDeclaration*, // FIXME: You can get these properties, and set them (see customPut below), // but you should also be able to enumerate them. -JSValue* JSCSSStyleDeclaration::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSCSSStyleDeclaration::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(asObject(slot.slotBase())); @@ -156,7 +156,7 @@ JSValue* JSCSSStyleDeclaration::nameGetter(ExecState* exec, const Identifier& pr } -bool JSCSSStyleDeclaration::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot&) +bool JSCSSStyleDeclaration::customPut(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot&) { if (!isCSSPropertyName(propertyName)) return false; diff --git a/WebCore/bindings/js/JSCSSValueCustom.cpp b/WebCore/bindings/js/JSCSSValueCustom.cpp index 85868c3..9e31304 100644 --- a/WebCore/bindings/js/JSCSSValueCustom.cpp +++ b/WebCore/bindings/js/JSCSSValueCustom.cpp @@ -44,7 +44,7 @@ using namespace JSC; namespace WebCore { -JSValue* toJS(ExecState* exec, CSSValue* value) +JSValuePtr toJS(ExecState* exec, CSSValue* value) { if (!value) return jsNull(); diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp index a2f4f65..ae48440 100644 --- a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp +++ b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp @@ -40,7 +40,7 @@ using namespace JSC; namespace WebCore { -static JSValue* toJS(ExecState* exec, CanvasStyle* style) +static JSValuePtr toJS(ExecState* exec, CanvasStyle* style) { if (style->canvasGradient()) return toJS(exec, style->canvasGradient()); @@ -49,11 +49,11 @@ static JSValue* toJS(ExecState* exec, CanvasStyle* style) return jsString(exec, style->color()); } -static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState* exec, JSValue* value) +static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState*, JSValuePtr value) { - if (value->isString()) + if (value.isString()) return CanvasStyle::create(asString(value)->value()); - if (!value->isObject()) + if (!value.isObject()) return 0; JSObject* object = asObject(value); if (object->inherits(&JSCanvasGradient::s_info)) @@ -63,27 +63,27 @@ static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState* exec, JSValue* value return 0; } -JSValue* JSCanvasRenderingContext2D::strokeStyle(ExecState* exec) const +JSValuePtr JSCanvasRenderingContext2D::strokeStyle(ExecState* exec) const { return toJS(exec, impl()->strokeStyle()); } -void JSCanvasRenderingContext2D::setStrokeStyle(ExecState* exec, JSValue* value) +void JSCanvasRenderingContext2D::setStrokeStyle(ExecState* exec, JSValuePtr value) { impl()->setStrokeStyle(toHTMLCanvasStyle(exec, value)); } -JSValue* JSCanvasRenderingContext2D::fillStyle(ExecState* exec) const +JSValuePtr JSCanvasRenderingContext2D::fillStyle(ExecState* exec) const { return toJS(exec, impl()->fillStyle()); } -void JSCanvasRenderingContext2D::setFillStyle(ExecState* exec, JSValue* value) +void JSCanvasRenderingContext2D::setFillStyle(ExecState* exec, JSValuePtr value) { impl()->setFillStyle(toHTMLCanvasStyle(exec, value)); } -JSValue* JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); @@ -95,24 +95,24 @@ JSValue* JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgList // 5 args = c, m, y, k, a switch (args.size()) { case 1: - if (args.at(exec, 0)->isString()) + if (args.at(exec, 0).isString()) context->setFillColor(asString(args.at(exec, 0))->value()); else - context->setFillColor(args.at(exec, 0)->toFloat(exec)); + context->setFillColor(args.at(exec, 0).toFloat(exec)); break; case 2: - if (args.at(exec, 0)->isString()) - context->setFillColor(asString(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec)); + if (args.at(exec, 0).isString()) + context->setFillColor(asString(args.at(exec, 0))->value(), args.at(exec, 1).toFloat(exec)); else - context->setFillColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec)); + context->setFillColor(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec)); break; case 4: - context->setFillColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec)); + context->setFillColor(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec)); break; case 5: - context->setFillColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec)); + context->setFillColor(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec)); break; default: return throwError(exec, SyntaxError); @@ -120,7 +120,7 @@ JSValue* JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgList return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); @@ -132,24 +132,24 @@ JSValue* JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgLi // 5 args = c, m, y, k, a switch (args.size()) { case 1: - if (args.at(exec, 0)->isString()) + if (args.at(exec, 0).isString()) context->setStrokeColor(asString(args.at(exec, 0))->value()); else - context->setStrokeColor(args.at(exec, 0)->toFloat(exec)); + context->setStrokeColor(args.at(exec, 0).toFloat(exec)); break; case 2: - if (args.at(exec, 0)->isString()) - context->setStrokeColor(asString(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec)); + if (args.at(exec, 0).isString()) + context->setStrokeColor(asString(args.at(exec, 0))->value(), args.at(exec, 1).toFloat(exec)); else - context->setStrokeColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec)); + context->setStrokeColor(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec)); break; case 4: - context->setStrokeColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec)); + context->setStrokeColor(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec)); break; case 5: - context->setStrokeColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec)); + context->setStrokeColor(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec)); break; default: return throwError(exec, SyntaxError); @@ -158,21 +158,21 @@ JSValue* JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgLi return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::strokeRect(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::strokeRect(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); if (args.size() <= 4) - context->strokeRect(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec)); + context->strokeRect(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec)); else - context->strokeRect(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec)); + context->strokeRect(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec)); return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); @@ -182,8 +182,8 @@ JSValue* JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& a // drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh) // Composite operation is specified with globalCompositeOperation. // The img parameter can be a <img> or <canvas> element. - JSValue* value = args.at(exec, 0); - if (!value->isObject()) + JSValuePtr value = args.at(exec, 0); + if (!value.isObject()) return throwError(exec, TypeError); JSObject* o = asObject(value); @@ -192,18 +192,18 @@ JSValue* JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& a HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl()); switch (args.size()) { case 3: - context->drawImage(imgElt, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec)); + context->drawImage(imgElt, args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec)); break; case 5: - context->drawImage(imgElt, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), - args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec), ec); + context->drawImage(imgElt, args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), + args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec), ec); setDOMException(exec, ec); break; case 9: - context->drawImage(imgElt, FloatRect(args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), - args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec)), - FloatRect(args.at(exec, 5)->toFloat(exec), args.at(exec, 6)->toFloat(exec), - args.at(exec, 7)->toFloat(exec), args.at(exec, 8)->toFloat(exec)), ec); + context->drawImage(imgElt, FloatRect(args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), + args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec)), + FloatRect(args.at(exec, 5).toFloat(exec), args.at(exec, 6).toFloat(exec), + args.at(exec, 7).toFloat(exec), args.at(exec, 8).toFloat(exec)), ec); setDOMException(exec, ec); break; default: @@ -213,18 +213,18 @@ JSValue* JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& a HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(o)->impl()); switch (args.size()) { case 3: - context->drawImage(canvas, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec)); + context->drawImage(canvas, args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec)); break; case 5: - context->drawImage(canvas, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), - args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec), ec); + context->drawImage(canvas, args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), + args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec), ec); setDOMException(exec, ec); break; case 9: - context->drawImage(canvas, FloatRect(args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), - args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec)), - FloatRect(args.at(exec, 5)->toFloat(exec), args.at(exec, 6)->toFloat(exec), - args.at(exec, 7)->toFloat(exec), args.at(exec, 8)->toFloat(exec)), ec); + context->drawImage(canvas, FloatRect(args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), + args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec)), + FloatRect(args.at(exec, 5).toFloat(exec), args.at(exec, 6).toFloat(exec), + args.at(exec, 7).toFloat(exec), args.at(exec, 8).toFloat(exec)), ec); setDOMException(exec, ec); break; default: @@ -237,64 +237,64 @@ JSValue* JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& a return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::drawImageFromRect(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::drawImageFromRect(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); - JSValue* value = args.at(exec, 0); - if (!value->isObject()) + JSValuePtr value = args.at(exec, 0); + if (!value.isObject()) return throwError(exec, TypeError); JSObject* o = asObject(value); if (!o->inherits(&JSHTMLImageElement::s_info)) return throwError(exec, TypeError); context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl()), - args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), - args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec), - args.at(exec, 5)->toFloat(exec), args.at(exec, 6)->toFloat(exec), - args.at(exec, 7)->toFloat(exec), args.at(exec, 8)->toFloat(exec), - args.at(exec, 9)->toString(exec)); + args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), + args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec), + args.at(exec, 5).toFloat(exec), args.at(exec, 6).toFloat(exec), + args.at(exec, 7).toFloat(exec), args.at(exec, 8).toFloat(exec), + args.at(exec, 9).toString(exec)); return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); switch (args.size()) { case 3: - context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec)); + context->setShadow(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec)); break; case 4: - if (args.at(exec, 3)->isString()) - context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), asString(args.at(exec, 3))->value()); + if (args.at(exec, 3).isString()) + context->setShadow(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), asString(args.at(exec, 3))->value()); else - context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec)); + context->setShadow(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec)); break; case 5: - if (args.at(exec, 3)->isString()) - context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), asString(args.at(exec, 3))->value(), - args.at(exec, 4)->toFloat(exec)); + if (args.at(exec, 3).isString()) + context->setShadow(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), asString(args.at(exec, 3))->value(), + args.at(exec, 4).toFloat(exec)); else - context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec), - args.at(exec, 4)->toFloat(exec)); + context->setShadow(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec), + args.at(exec, 4).toFloat(exec)); break; case 7: - context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec), - args.at(exec, 4)->toFloat(exec), args.at(exec, 5)->toFloat(exec), - args.at(exec, 6)->toFloat(exec)); + context->setShadow(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec), + args.at(exec, 4).toFloat(exec), args.at(exec, 5).toFloat(exec), + args.at(exec, 6).toFloat(exec)); break; case 8: - context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec), - args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec), - args.at(exec, 4)->toFloat(exec), args.at(exec, 5)->toFloat(exec), - args.at(exec, 6)->toFloat(exec), args.at(exec, 7)->toFloat(exec)); + context->setShadow(args.at(exec, 0).toFloat(exec), args.at(exec, 1).toFloat(exec), + args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec), + args.at(exec, 4).toFloat(exec), args.at(exec, 5).toFloat(exec), + args.at(exec, 6).toFloat(exec), args.at(exec, 7).toFloat(exec)); break; default: return throwError(exec, SyntaxError); @@ -303,18 +303,18 @@ JSValue* JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList& a return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::createPattern(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::createPattern(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); - JSValue* value = args.at(exec, 0); - if (!value->isObject()) + JSValuePtr value = args.at(exec, 0); + if (!value.isObject()) return throwError(exec, TypeError); JSObject* o = asObject(value); if (o->inherits(&JSHTMLImageElement::s_info)) { ExceptionCode ec; - JSValue* pattern = toJS(exec, + JSValuePtr pattern = toJS(exec, context->createPattern(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl()), valueToStringWithNullCheck(exec, args.at(exec, 1)), ec).get()); setDOMException(exec, ec); @@ -322,7 +322,7 @@ JSValue* JSCanvasRenderingContext2D::createPattern(ExecState* exec, const ArgLis } if (o->inherits(&JSHTMLCanvasElement::s_info)) { ExceptionCode ec; - JSValue* pattern = toJS(exec, + JSValuePtr pattern = toJS(exec, context->createPattern(static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(o)->impl()), valueToStringWithNullCheck(exec, args.at(exec, 1)), ec).get()); setDOMException(exec, ec); @@ -332,7 +332,7 @@ JSValue* JSCanvasRenderingContext2D::createPattern(ExecState* exec, const ArgLis return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::putImageData(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::putImageData(ExecState* exec, const ArgList& args) { // putImageData has two variants // putImageData(ImageData, x, y) @@ -341,16 +341,16 @@ JSValue* JSCanvasRenderingContext2D::putImageData(ExecState* exec, const ArgList ExceptionCode ec = 0; if (args.size() >= 7) - context->putImageData(toImageData(args.at(exec, 0)), args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), - args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec), args.at(exec, 5)->toFloat(exec), args.at(exec, 6)->toFloat(exec), ec); + context->putImageData(toImageData(args.at(exec, 0)), args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), + args.at(exec, 3).toFloat(exec), args.at(exec, 4).toFloat(exec), args.at(exec, 5).toFloat(exec), args.at(exec, 6).toFloat(exec), ec); else - context->putImageData(toImageData(args.at(exec, 0)), args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), ec); + context->putImageData(toImageData(args.at(exec, 0)), args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), ec); setDOMException(exec, ec); return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::fillText(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::fillText(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); @@ -362,13 +362,13 @@ JSValue* JSCanvasRenderingContext2D::fillText(ExecState* exec, const ArgList& ar return throwError(exec, SyntaxError); if (args.size() == 4) - context->fillText(args.at(exec, 0)->toString(exec), args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec)); + context->fillText(args.at(exec, 0).toString(exec), args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec)); else - context->fillText(args.at(exec, 0)->toString(exec), args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec)); + context->fillText(args.at(exec, 0).toString(exec), args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec)); return jsUndefined(); } -JSValue* JSCanvasRenderingContext2D::strokeText(ExecState* exec, const ArgList& args) +JSValuePtr JSCanvasRenderingContext2D::strokeText(ExecState* exec, const ArgList& args) { CanvasRenderingContext2D* context = impl(); @@ -380,9 +380,9 @@ JSValue* JSCanvasRenderingContext2D::strokeText(ExecState* exec, const ArgList& return throwError(exec, SyntaxError); if (args.size() == 4) - context->strokeText(args.at(exec, 0)->toString(exec), args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec)); + context->strokeText(args.at(exec, 0).toString(exec), args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec), args.at(exec, 3).toFloat(exec)); else - context->strokeText(args.at(exec, 0)->toString(exec), args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec)); + context->strokeText(args.at(exec, 0).toString(exec), args.at(exec, 1).toFloat(exec), args.at(exec, 2).toFloat(exec)); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSClipboardCustom.cpp b/WebCore/bindings/js/JSClipboardCustom.cpp index bdcb074..373ba8a 100644 --- a/WebCore/bindings/js/JSClipboardCustom.cpp +++ b/WebCore/bindings/js/JSClipboardCustom.cpp @@ -48,7 +48,7 @@ namespace WebCore { using namespace HTMLNames; -JSValue* JSClipboard::types(ExecState* exec) const +JSValuePtr JSClipboard::types(ExecState* exec) const { Clipboard* clipboard = impl(); @@ -63,7 +63,7 @@ JSValue* JSClipboard::types(ExecState* exec) const return constructArray(exec, list); } -JSValue* JSClipboard::clearData(ExecState* exec, const ArgList& args) +JSValuePtr JSClipboard::clearData(ExecState* exec, const ArgList& args) { Clipboard* clipboard = impl(); @@ -73,7 +73,7 @@ JSValue* JSClipboard::clearData(ExecState* exec, const ArgList& args) } if (args.size() == 1) { - clipboard->clearData(args.at(exec, 0)->toString(exec)); + clipboard->clearData(args.at(exec, 0).toString(exec)); return jsUndefined(); } @@ -81,7 +81,7 @@ JSValue* JSClipboard::clearData(ExecState* exec, const ArgList& args) return throwError(exec, SyntaxError, "clearData: Invalid number of arguments"); } -JSValue* JSClipboard::getData(ExecState* exec, const ArgList& args) +JSValuePtr JSClipboard::getData(ExecState* exec, const ArgList& args) { // FIXME: It does not match the rest of the JS bindings to throw on invalid number of arguments. if (args.size() != 1) @@ -90,14 +90,14 @@ JSValue* JSClipboard::getData(ExecState* exec, const ArgList& args) Clipboard* clipboard = impl(); bool success; - String result = clipboard->getData(args.at(exec, 0)->toString(exec), success); + String result = clipboard->getData(args.at(exec, 0).toString(exec), success); if (!success) return jsUndefined(); return jsString(exec, result); } -JSValue* JSClipboard::setData(ExecState* exec, const ArgList& args) +JSValuePtr JSClipboard::setData(ExecState* exec, const ArgList& args) { Clipboard* clipboard = impl(); @@ -105,10 +105,10 @@ JSValue* JSClipboard::setData(ExecState* exec, const ArgList& args) if (args.size() != 2) return throwError(exec, SyntaxError, "setData: Invalid number of arguments"); - return jsBoolean(clipboard->setData(args.at(exec, 0)->toString(exec), args.at(exec, 1)->toString(exec))); + return jsBoolean(clipboard->setData(args.at(exec, 0).toString(exec), args.at(exec, 1).toString(exec))); } -JSValue* JSClipboard::setDragImage(ExecState* exec, const ArgList& args) +JSValuePtr JSClipboard::setDragImage(ExecState* exec, const ArgList& args) { Clipboard* clipboard = impl(); @@ -119,8 +119,8 @@ JSValue* JSClipboard::setDragImage(ExecState* exec, const ArgList& args) if (args.size() != 3) return throwError(exec, SyntaxError, "setDragImage: Invalid number of arguments"); - int x = args.at(exec, 1)->toInt32(exec); - int y = args.at(exec, 2)->toInt32(exec); + int x = args.at(exec, 1).toInt32(exec); + int y = args.at(exec, 2).toInt32(exec); // See if they passed us a node Node* node = toNode(args.at(exec, 0)); diff --git a/WebCore/bindings/js/JSConsoleCustom.cpp b/WebCore/bindings/js/JSConsoleCustom.cpp index 6131cb6..ddfe4f7 100644 --- a/WebCore/bindings/js/JSConsoleCustom.cpp +++ b/WebCore/bindings/js/JSConsoleCustom.cpp @@ -36,7 +36,7 @@ namespace WebCore { typedef Vector<RefPtr<JSC::Profile> > ProfilesArray; -JSValue* JSConsole::profiles(ExecState* exec) const +JSValuePtr JSConsole::profiles(ExecState* exec) const { const ProfilesArray& profiles = impl()->profiles(); ArgList list; @@ -48,91 +48,4 @@ JSValue* JSConsole::profiles(ExecState* exec) const return constructArray(exec, list); } -JSValue* JSConsole::debug(ExecState* exec, const ArgList& arguments) -{ - impl()->debug(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::error(ExecState* exec, const ArgList& arguments) -{ - impl()->error(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::info(ExecState* exec, const ArgList& arguments) -{ - impl()->info(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::log(ExecState* exec, const ArgList& arguments) -{ - impl()->log(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::warn(ExecState* exec, const ArgList& arguments) -{ - impl()->warn(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::dir(ExecState* exec, const ArgList& arguments) -{ - impl()->dir(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::dirxml(ExecState* exec, const ArgList& arguments) -{ - impl()->dirxml(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::trace(ExecState* exec, const ArgList&) -{ - impl()->trace(exec); - return jsUndefined(); -} - -JSValue* JSConsole::assertCondition(ExecState* exec, const ArgList& arguments) -{ - ArgList messageParameters; - arguments.getSlice(1, messageParameters); - - impl()->assertCondition(arguments.at(exec, 0)->toBoolean(exec), exec, messageParameters); - return jsUndefined(); -} - -JSValue* JSConsole::count(ExecState* exec, const ArgList& arguments) -{ - impl()->count(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::timeEnd(ExecState* exec, const ArgList& arguments) -{ - impl()->timeEnd(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::profile(ExecState* exec, const ArgList& arguments) -{ - impl()->profile(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::profileEnd(ExecState* exec, const ArgList& arguments) -{ - impl()->profileEnd(exec, arguments); - return jsUndefined(); -} - -JSValue* JSConsole::group(ExecState* exec, const ArgList& arguments) -{ - impl()->group(exec, arguments); - return jsUndefined(); -} - } // namespace WebCore diff --git a/WebCore/bindings/js/JSCustomPositionCallback.cpp b/WebCore/bindings/js/JSCustomPositionCallback.cpp index 5a5e6b0..cae1e1e 100644 --- a/WebCore/bindings/js/JSCustomPositionCallback.cpp +++ b/WebCore/bindings/js/JSCustomPositionCallback.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "JSCustomPositionCallback.h" -#include "Console.h" #include "CString.h" #include "Frame.h" #include "JSGeoposition.h" @@ -57,9 +56,9 @@ void JSCustomPositionCallback::handleEvent(Geoposition* geoposition, bool& raise JSC::JSLock lock(false); - JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent")); + JSValuePtr function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; - CallType callType = function->getCallData(callData); + CallType callType = function.getCallData(callData); if (callType == CallTypeNone) { callType = m_callback->getCallData(callData); if (callType == CallTypeNone) { @@ -79,7 +78,7 @@ void JSCustomPositionCallback::handleEvent(Geoposition* geoposition, bool& raise globalObject->stopTimeoutCheck(); if (exec->hadException()) { - m_frame->domWindow()->console()->reportCurrentException(exec); + reportCurrentException(exec); raisedException = true; } } diff --git a/WebCore/bindings/js/JSCustomPositionCallback.h b/WebCore/bindings/js/JSCustomPositionCallback.h index 96e6177..6c0d306 100644 --- a/WebCore/bindings/js/JSCustomPositionCallback.h +++ b/WebCore/bindings/js/JSCustomPositionCallback.h @@ -28,7 +28,7 @@ #include "PositionCallback.h" #include <runtime/JSObject.h> -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/Forward.h> namespace JSC { diff --git a/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp b/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp index 2cd41d7..766f698 100644 --- a/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp +++ b/WebCore/bindings/js/JSCustomPositionErrorCallback.cpp @@ -26,7 +26,6 @@ #include "config.h" #include "JSCustomPositionErrorCallback.h" -#include "Console.h" #include "CString.h" #include "Frame.h" #include "JSPositionError.h" @@ -57,9 +56,9 @@ void JSCustomPositionErrorCallback::handleEvent(PositionError* positionError) JSC::JSLock lock(false); - JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent")); + JSValuePtr function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; - CallType callType = function->getCallData(callData); + CallType callType = function.getCallData(callData); if (callType == CallTypeNone) { callType = m_callback->getCallData(callData); if (callType == CallTypeNone) { @@ -79,7 +78,7 @@ void JSCustomPositionErrorCallback::handleEvent(PositionError* positionError) globalObject->stopTimeoutCheck(); if (exec->hadException()) - m_frame->domWindow()->console()->reportCurrentException(exec); + reportCurrentException(exec); } } // namespace WebCore diff --git a/WebCore/bindings/js/JSCustomPositionErrorCallback.h b/WebCore/bindings/js/JSCustomPositionErrorCallback.h index 190e5a4..9f143a2 100644 --- a/WebCore/bindings/js/JSCustomPositionErrorCallback.h +++ b/WebCore/bindings/js/JSCustomPositionErrorCallback.h @@ -28,7 +28,7 @@ #include "PositionErrorCallback.h" #include <runtime/JSObject.h> -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/Forward.h> namespace JSC { diff --git a/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp b/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp index 4787440..f61306c 100644 --- a/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp +++ b/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp @@ -30,7 +30,6 @@ #include "JSCustomSQLStatementCallback.h" #include "CString.h" -#include "Console.h" #include "DOMWindow.h" #include "Frame.h" #include "ScriptController.h" @@ -60,10 +59,10 @@ void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR ExecState* exec = globalObject->globalExec(); JSC::JSLock lock(false); - - JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent")); + + JSValuePtr function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; - CallType callType = function->getCallData(callData); + CallType callType = function.getCallData(callData); if (callType == CallTypeNone) { callType = m_callback->getCallData(callData); if (callType == CallTypeNone) { @@ -72,9 +71,9 @@ void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR } function = m_callback; } - + RefPtr<JSCustomSQLStatementCallback> protect(this); - + ArgList args; args.append(toJS(exec, transaction)); args.append(toJS(exec, resultSet)); @@ -82,14 +81,14 @@ void JSCustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR globalObject->startTimeoutCheck(); call(exec, function, callType, callData, m_callback, args); globalObject->stopTimeoutCheck(); - + if (exec->hadException()) { - m_frame->domWindow()->console()->reportCurrentException(exec); - + reportCurrentException(exec); + raisedException = true; } - + Document::updateDocumentsRendering(); } - + } diff --git a/WebCore/bindings/js/JSCustomSQLStatementCallback.h b/WebCore/bindings/js/JSCustomSQLStatementCallback.h index d4fd6ec..3a3ae21 100644 --- a/WebCore/bindings/js/JSCustomSQLStatementCallback.h +++ b/WebCore/bindings/js/JSCustomSQLStatementCallback.h @@ -32,7 +32,7 @@ #include "SQLStatementCallback.h" #include <runtime/JSObject.h> -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/Forward.h> namespace JSC { diff --git a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp index f301704..0d27de7 100644 --- a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp +++ b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp @@ -30,7 +30,6 @@ #include "JSCustomSQLStatementErrorCallback.h" #include "CString.h" -#include "Console.h" #include "DOMWindow.h" #include "Frame.h" #include "ScriptController.h" @@ -61,9 +60,9 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, JSC::JSLock lock(false); - JSValue* handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent")); + JSValuePtr handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData handleEventCallData; - CallType handleEventCallType = handleEventFunction->getCallData(handleEventCallData); + CallType handleEventCallType = handleEventFunction.getCallData(handleEventCallData); CallData callbackCallData; CallType callbackCallType = CallTypeNone; @@ -81,7 +80,7 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, args.append(toJS(exec, transaction)); args.append(toJS(exec, error)); - JSValue* result; + JSValuePtr result; globalObject->startTimeoutCheck(); if (handleEventCallType != CallTypeNone) result = call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_callback, args); @@ -90,7 +89,7 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, globalObject->stopTimeoutCheck(); if (exec->hadException()) { - m_frame->domWindow()->console()->reportCurrentException(exec); + reportCurrentException(exec); // The spec says: // "If the error callback returns false, then move on to the next statement..." @@ -101,7 +100,7 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, Document::updateDocumentsRendering(); - return result->toBoolean(exec); + return result.toBoolean(exec); } } diff --git a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h index e235f23..2847114 100644 --- a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h +++ b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h @@ -32,7 +32,7 @@ #include "SQLStatementErrorCallback.h" #include <runtime/JSObject.h> -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/Forward.h> namespace JSC { diff --git a/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp b/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp index 3e3bcce..d6187bc 100644 --- a/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp +++ b/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp @@ -30,7 +30,6 @@ #include "JSCustomSQLTransactionCallback.h" #include "CString.h" -#include "Console.h" #include "DOMWindow.h" #include "Frame.h" #include "Logging.h" @@ -102,9 +101,9 @@ void JSCustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo JSC::JSLock lock(false); - JSValue* handleEventFunction = m_data->callback()->get(exec, Identifier(exec, "handleEvent")); + JSValuePtr handleEventFunction = m_data->callback()->get(exec, Identifier(exec, "handleEvent")); CallData handleEventCallData; - CallType handleEventCallType = handleEventFunction->getCallData(handleEventCallData); + CallType handleEventCallType = handleEventFunction.getCallData(handleEventCallData); CallData callbackCallData; CallType callbackCallType = CallTypeNone; @@ -129,7 +128,7 @@ void JSCustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo globalObject->stopTimeoutCheck(); if (exec->hadException()) { - m_data->frame()->domWindow()->console()->reportCurrentException(exec); + reportCurrentException(exec); raisedException = true; } diff --git a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp b/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp index 097f809..5c8b8d4 100644 --- a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp +++ b/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp @@ -30,7 +30,6 @@ #include "JSCustomSQLTransactionErrorCallback.h" #include "CString.h" -#include "Console.h" #include "DOMWindow.h" #include "Frame.h" #include "ScriptController.h" @@ -60,9 +59,9 @@ bool JSCustomSQLTransactionErrorCallback::handleEvent(SQLError* error) JSC::JSLock lock(false); - JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent")); + JSValuePtr function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; - CallType callType = function->getCallData(callData); + CallType callType = function.getCallData(callData); if (callType == CallTypeNone) { callType = m_callback->getCallData(callData); if (callType == CallTypeNone) { @@ -77,17 +76,17 @@ bool JSCustomSQLTransactionErrorCallback::handleEvent(SQLError* error) ArgList args; args.append(toJS(exec, error)); - JSValue* result; + JSValuePtr result; globalObject->startTimeoutCheck(); result = call(exec, function, callType, callData, m_callback, args); globalObject->stopTimeoutCheck(); if (exec->hadException()) - m_frame->domWindow()->console()->reportCurrentException(exec); + reportCurrentException(exec); Document::updateDocumentsRendering(); - return result->toBoolean(exec); + return result.toBoolean(exec); } } diff --git a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h b/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h index bfbb1e2..122224f 100644 --- a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h +++ b/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h @@ -32,7 +32,7 @@ #include "SQLTransactionErrorCallback.h" #include <runtime/JSObject.h> -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/Forward.h> namespace JSC { diff --git a/WebCore/bindings/js/JSCustomVoidCallback.cpp b/WebCore/bindings/js/JSCustomVoidCallback.cpp index a838e95..60b3777 100644 --- a/WebCore/bindings/js/JSCustomVoidCallback.cpp +++ b/WebCore/bindings/js/JSCustomVoidCallback.cpp @@ -30,7 +30,6 @@ #include "JSCustomVoidCallback.h" #include "CString.h" -#include "Console.h" #include "DOMWindow.h" #include "Frame.h" #include "JSDOMWindowCustom.h" @@ -61,9 +60,9 @@ void JSCustomVoidCallback::handleEvent() JSC::JSLock lock(false); - JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent")); + JSValuePtr function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; - CallType callType = function->getCallData(callData); + CallType callType = function.getCallData(callData); if (callType == CallTypeNone) { callType = m_callback->getCallData(callData); if (callType == CallTypeNone) { @@ -82,14 +81,14 @@ void JSCustomVoidCallback::handleEvent() globalObject->stopTimeoutCheck(); if (exec->hadException()) - m_frame->domWindow()->console()->reportCurrentException(exec); + reportCurrentException(exec); Document::updateDocumentsRendering(); } -PassRefPtr<VoidCallback> toVoidCallback(ExecState* exec, JSValue* value) +PassRefPtr<VoidCallback> toVoidCallback(ExecState* exec, JSValuePtr value) { - JSObject* object = value->getObject(); + JSObject* object = value.getObject(); if (!object) return 0; diff --git a/WebCore/bindings/js/JSCustomVoidCallback.h b/WebCore/bindings/js/JSCustomVoidCallback.h index 9931631..f54ddb6 100644 --- a/WebCore/bindings/js/JSCustomVoidCallback.h +++ b/WebCore/bindings/js/JSCustomVoidCallback.h @@ -32,7 +32,7 @@ #include "VoidCallback.h" #include <runtime/JSObject.h> -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/Forward.h> namespace WebCore { @@ -55,7 +55,7 @@ namespace WebCore { RefPtr<Frame> m_frame; }; - PassRefPtr<VoidCallback> toVoidCallback(JSC::ExecState*, JSC::JSValue*); + PassRefPtr<VoidCallback> toVoidCallback(JSC::ExecState*, JSC::JSValuePtr); } // namespace WebCore diff --git a/WebCore/bindings/js/JSCustomXPathNSResolver.cpp b/WebCore/bindings/js/JSCustomXPathNSResolver.cpp index 45c2c18..6796af6 100644 --- a/WebCore/bindings/js/JSCustomXPathNSResolver.cpp +++ b/WebCore/bindings/js/JSCustomXPathNSResolver.cpp @@ -43,12 +43,12 @@ namespace WebCore { using namespace JSC; -PassRefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(JSC::ExecState* exec, JSC::JSValue* value) +PassRefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(JSC::ExecState* exec, JSC::JSValuePtr value) { - if (value->isUndefinedOrNull()) + if (value.isUndefinedOrNull()) return 0; - JSObject* resolverObject = value->getObject(); + JSObject* resolverObject = value.getObject(); if (!resolverObject) { setDOMException(exec, TYPE_MISMATCH_ERR); return 0; @@ -81,9 +81,9 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix) JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); - JSValue* function = m_customResolver->get(exec, Identifier(exec, "lookupNamespaceURI")); + JSValuePtr function = m_customResolver->get(exec, Identifier(exec, "lookupNamespaceURI")); CallData callData; - CallType callType = function->getCallData(callData); + CallType callType = function.getCallData(callData); if (callType == CallTypeNone) { callType = m_customResolver->getCallData(callData); if (callType == CallTypeNone) { @@ -100,15 +100,15 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix) args.append(jsString(exec, prefix)); globalObject->startTimeoutCheck(); - JSValue* retval = call(exec, function, callType, callData, m_customResolver, args); + JSValuePtr retval = call(exec, function, callType, callData, m_customResolver, args); globalObject->stopTimeoutCheck(); String result; if (exec->hadException()) - m_frame->domWindow()->console()->reportCurrentException(exec); + reportCurrentException(exec); else { - if (!retval->isUndefinedOrNull()) - result = retval->toString(exec); + if (!retval.isUndefinedOrNull()) + result = retval.toString(exec); } Document::updateDocumentsRendering(); diff --git a/WebCore/bindings/js/JSCustomXPathNSResolver.h b/WebCore/bindings/js/JSCustomXPathNSResolver.h index bb8aed8..fecbb61 100644 --- a/WebCore/bindings/js/JSCustomXPathNSResolver.h +++ b/WebCore/bindings/js/JSCustomXPathNSResolver.h @@ -44,7 +44,7 @@ namespace WebCore { class JSCustomXPathNSResolver : public XPathNSResolver { public: - static PassRefPtr<JSCustomXPathNSResolver> create(JSC::ExecState*, JSC::JSValue*); + static PassRefPtr<JSCustomXPathNSResolver> create(JSC::ExecState*, JSC::JSValuePtr); virtual ~JSCustomXPathNSResolver(); diff --git a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp index c79b0d9..980d795 100644 --- a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp +++ b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp @@ -67,6 +67,9 @@ void JSDOMApplicationCache::mark() if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(m_impl->oncached())) listener->mark(); + if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(m_impl->onobsolete())) + listener->mark(); + typedef DOMApplicationCache::EventListenersMap EventListenersMap; typedef DOMApplicationCache::ListenerVector ListenerVector; EventListenersMap& eventListeners = m_impl->eventListeners(); @@ -78,12 +81,27 @@ void JSDOMApplicationCache::mark() } } -JSValue* JSDOMApplicationCache::add(ExecState* exec, const ArgList& args) +#if ENABLE(APPLICATION_CAHE_DYNAMIC_ENTRIES) + +JSValuePtr JSDOMApplicationCache::hasItem(ExecState* exec, const ArgList& args) { Frame* frame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); if (!frame) return jsUndefined(); - const KURL& url = frame->loader()->completeURL(args.at(exec, 0)->toString(exec)); + const KURL& url = frame->loader()->completeURL(args.at(exec, 0).toString(exec)); + + ExceptionCode ec = 0; + bool result = impl()->hasItem(url, ec); + setDOMException(exec, ec); + return jsBoolean(result); +} + +JSValuePtr JSDOMApplicationCache::add(ExecState* exec, const ArgList& args) +{ + Frame* frame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); + if (!frame) + return jsUndefined(); + const KURL& url = frame->loader()->completeURL(args.at(exec, 0).toString(exec)); ExceptionCode ec = 0; impl()->add(url, ec); @@ -91,12 +109,12 @@ JSValue* JSDOMApplicationCache::add(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSDOMApplicationCache::remove(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMApplicationCache::remove(ExecState* exec, const ArgList& args) { Frame* frame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); if (!frame) return jsUndefined(); - const KURL& url = frame->loader()->completeURL(args.at(exec, 0)->toString(exec)); + const KURL& url = frame->loader()->completeURL(args.at(exec, 0).toString(exec)); ExceptionCode ec = 0; impl()->remove(url, ec); @@ -104,7 +122,9 @@ JSValue* JSDOMApplicationCache::remove(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList& args) +#endif + +JSValuePtr JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -112,11 +132,11 @@ JSValue* JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList& RefPtr<JSUnprotectedEventListener> listener = globalObject->findOrCreateJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec)); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } -JSValue* JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -124,7 +144,7 @@ JSValue* JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgLi JSUnprotectedEventListener* listener = globalObject->findJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp index 8676146..6e27dc1 100644 --- a/WebCore/bindings/js/JSDOMBinding.cpp +++ b/WebCore/bindings/js/JSDOMBinding.cpp @@ -46,6 +46,7 @@ #include "ScriptController.h" #include "XMLHttpRequestException.h" #include <runtime/PrototypeFunction.h> +#include <wtf/StdLibExtras.h> #if ENABLE(SVG) #include "JSSVGException.h" @@ -97,10 +98,10 @@ static inline void removeWrappers(const JSWrapperCache&) static HashSet<DOMObject*>& wrapperSet() { #if ENABLE(WORKERS) - static ThreadSpecific<HashSet<DOMObject*> > staticWrapperSet; + DEFINE_STATIC_LOCAL(ThreadSpecific<HashSet<DOMObject*> >, staticWrapperSet, ()); return *staticWrapperSet; #else - static HashSet<DOMObject*> staticWrapperSet; + DEFINE_STATIC_LOCAL(HashSet<DOMObject*>, staticWrapperSet, ()); return staticWrapperSet; #endif } @@ -289,16 +290,18 @@ void markDOMNodesForDocument(Document* doc) void markActiveObjectsForContext(JSGlobalData& globalData, ScriptExecutionContext* scriptExecutionContext) { - // If an element has pending activity that may result in listeners being called - // (e.g. an XMLHttpRequest), we need to keep all JS wrappers alive. + // If an element has pending activity that may result in event listeners being called + // (e.g. an XMLHttpRequest), we need to keep JS wrappers alive. const HashMap<ActiveDOMObject*, void*>& activeObjects = scriptExecutionContext->activeDOMObjects(); HashMap<ActiveDOMObject*, void*>::const_iterator activeObjectsEnd = activeObjects.end(); for (HashMap<ActiveDOMObject*, void*>::const_iterator iter = activeObjects.begin(); iter != activeObjectsEnd; ++iter) { if (iter->first->hasPendingActivity()) { DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, iter->second); - // An object with pending activity must have a wrapper to mark its listeners, so no null check. - if (!wrapper->marked()) + // Generally, an active object with pending activity must have a wrapper to mark its listeners. + // However, some ActiveDOMObjects don't have JS wrappers (timers created by setTimeout is one example). + // FIXME: perhaps need to make sure even timers have a markable 'wrapper'. + if (wrapper && !wrapper->marked()) wrapper->mark(); } } @@ -308,45 +311,13 @@ void markActiveObjectsForContext(JSGlobalData& globalData, ScriptExecutionContex for (HashSet<MessagePort*>::const_iterator iter = messagePorts.begin(); iter != portsEnd; ++iter) { if ((*iter)->hasPendingActivity()) { DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, *iter); - // An object with pending activity must have a wrapper to mark its listeners, so no null check. + // A port with pending activity must have a wrapper to mark its listeners, so no null check. if (!wrapper->marked()) wrapper->mark(); } } } -void markCrossHeapDependentObjectsForContext(JSGlobalData& globalData, ScriptExecutionContext* scriptExecutionContext) -{ - const HashSet<MessagePort*>& messagePorts = scriptExecutionContext->messagePorts(); - HashSet<MessagePort*>::const_iterator portsEnd = messagePorts.end(); - for (HashSet<MessagePort*>::const_iterator iter = messagePorts.begin(); iter != portsEnd; ++iter) { - MessagePort* port = *iter; - RefPtr<MessagePort> entangledPort = port->entangledPort(); - if (entangledPort) { - // No wrapper, or wrapper is already marked - no need to examine cross-heap dependencies. - DOMObject* wrapper = getCachedDOMObjectWrapper(globalData, port); - if (!wrapper || wrapper->marked()) - continue; - - // Don't use cross-heap model of marking on same-heap pairs. Otherwise, they will never be destroyed, because a port will mark its entangled one, - // and it will never get a chance to be marked as inaccessible. So, the port will keep getting marked in this function. - if ((port->scriptExecutionContext() == entangledPort->scriptExecutionContext()) || (port->scriptExecutionContext()->isDocument() && entangledPort->scriptExecutionContext()->isDocument())) - continue; - - // If the wrapper hasn't been marked during the mark phase of GC, then the port shouldn't protect its entangled one. - // It's important not to call this when there is no wrapper. E.g., if GC is triggered after a MessageChannel is created, but before its ports are used from JS, - // irreversibly telling the object that its (not yet existing) wrapper is inaccessible would be wrong. Similarly, ports posted via postMessage() may not - // have wrappers until delivered. - port->setJSWrapperIsInaccessible(); - - // If the port is protected by its entangled one, mark it. - // This is an atomic read of a boolean value, no synchronization between threads is required (at least on platforms that guarantee cache coherency). - if (!entangledPort->jsWrapperIsInaccessible()) - wrapper->mark(); - } - } -} - void updateDOMNodeDocument(Node* node, Document* oldDocument, Document* newDocument) { ASSERT(oldDocument != newDocument); @@ -369,67 +340,86 @@ void markDOMObjectWrapper(JSGlobalData& globalData, void* object) wrapper->mark(); } -JSValue* jsStringOrNull(ExecState* exec, const String& s) +JSValuePtr jsStringOrNull(ExecState* exec, const String& s) { if (s.isNull()) return jsNull(); return jsString(exec, s); } -JSValue* jsOwnedStringOrNull(ExecState* exec, const UString& s) +JSValuePtr jsOwnedStringOrNull(ExecState* exec, const UString& s) { if (s.isNull()) return jsNull(); return jsOwnedString(exec, s); } -JSValue* jsStringOrUndefined(ExecState* exec, const String& s) +JSValuePtr jsStringOrUndefined(ExecState* exec, const String& s) { if (s.isNull()) return jsUndefined(); return jsString(exec, s); } -JSValue* jsStringOrFalse(ExecState* exec, const String& s) +JSValuePtr jsStringOrFalse(ExecState* exec, const String& s) { if (s.isNull()) return jsBoolean(false); return jsString(exec, s); } -JSValue* jsStringOrNull(ExecState* exec, const KURL& url) +JSValuePtr jsStringOrNull(ExecState* exec, const KURL& url) { if (url.isNull()) return jsNull(); return jsString(exec, url.string()); } -JSValue* jsStringOrUndefined(ExecState* exec, const KURL& url) +JSValuePtr jsStringOrUndefined(ExecState* exec, const KURL& url) { if (url.isNull()) return jsUndefined(); return jsString(exec, url.string()); } -JSValue* jsStringOrFalse(ExecState* exec, const KURL& url) +JSValuePtr jsStringOrFalse(ExecState* exec, const KURL& url) { if (url.isNull()) return jsBoolean(false); return jsString(exec, url.string()); } -UString valueToStringWithNullCheck(ExecState* exec, JSValue* value) +UString valueToStringWithNullCheck(ExecState* exec, JSValuePtr value) { - if (value->isNull()) + if (value.isNull()) return UString(); - return value->toString(exec); + return value.toString(exec); } -UString valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue* value) +UString valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValuePtr value) { - if (value->isUndefinedOrNull()) + if (value.isUndefinedOrNull()) return UString(); - return value->toString(exec); + return value.toString(exec); +} + +void reportException(JSC::ExecState* exec, JSValuePtr exception) +{ + UString errorMessage = exception.toString(exec); + JSObject* exceptionObject = exception.toObject(exec); + int lineNumber = exceptionObject->get(exec, Identifier(exec, "line")).toInt32(exec); + UString exceptionSourceURL = exceptionObject->get(exec, Identifier(exec, "sourceURL")).toString(exec); + exec->clearException(); + + ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); + scriptExecutionContext->reportException(errorMessage, lineNumber, exceptionSourceURL); +} + +void reportCurrentException(JSC::ExecState* exec) +{ + JSValuePtr exception = exec->exception(); + exec->clearException(); + reportException(exec, exception); } void setDOMException(ExecState* exec, ExceptionCode ec) @@ -440,7 +430,7 @@ void setDOMException(ExecState* exec, ExceptionCode ec) ExceptionCodeDescription description; getExceptionCodeDescription(ec, description); - JSValue* errorObject = noValue(); + JSValuePtr errorObject = noValue(); switch (description.type) { case DOMExceptionType: errorObject = toJS(exec, DOMCoreException::create(description)); @@ -499,12 +489,12 @@ void printErrorMessageForFrame(Frame* frame, const String& message) window->printErrorMessage(message); } -JSValue* objectToStringFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) +JSValuePtr objectToStringFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 0, propertyName, objectProtoFuncToString); } -ExecState* execStateFromNode(Node* node) +ScriptState* scriptStateFromNode(Node* node) { if (!node) return 0; @@ -519,17 +509,17 @@ ExecState* execStateFromNode(Node* node) return frame->script()->globalObject()->globalExec(); } -StructureID* getCachedDOMStructure(ExecState* exec, const ClassInfo* classInfo) +Structure* getCachedDOMStructure(ExecState* exec, const ClassInfo* classInfo) { JSDOMStructureMap& structures = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->structures(); return structures.get(classInfo).get(); } -StructureID* cacheDOMStructure(ExecState* exec, PassRefPtr<StructureID> structureID, const ClassInfo* classInfo) +Structure* cacheDOMStructure(ExecState* exec, PassRefPtr<Structure> structure, const ClassInfo* classInfo) { JSDOMStructureMap& structures = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->structures(); ASSERT(!structures.contains(classInfo)); - return structures.set(classInfo, structureID).first->second.get(); + return structures.set(classInfo, structure).first->second.get(); } JSObject* getCachedDOMConstructor(ExecState* exec, const ClassInfo* classInfo) diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h index e8040f2..71da21b 100644 --- a/WebCore/bindings/js/JSDOMBinding.h +++ b/WebCore/bindings/js/JSDOMBinding.h @@ -22,9 +22,10 @@ #define JSDOMBinding_h #include "JSDOMGlobalObject.h" -#include <kjs/interpreter.h> -#include <kjs/lookup.h> +#include <runtime/Completion.h> +#include <runtime/Lookup.h> #include <runtime/JSFunction.h> +#include "ScriptState.h" #include <wtf/Noncopyable.h> namespace JSC { @@ -49,8 +50,8 @@ namespace WebCore { // Base class for all objects in this binding except Window. class DOMObject : public JSC::JSObject { protected: - explicit DOMObject(PassRefPtr<JSC::StructureID> structureID) - : JSObject(structureID) + explicit DOMObject(PassRefPtr<JSC::Structure> structure) + : JSObject(structure) { } @@ -71,19 +72,18 @@ namespace WebCore { void markDOMNodesForDocument(Document*); void markActiveObjectsForContext(JSC::JSGlobalData&, ScriptExecutionContext*); void markDOMObjectWrapper(JSC::JSGlobalData& globalData, void* object); - void markCrossHeapDependentObjectsForContext(JSC::JSGlobalData&, ScriptExecutionContext*); - JSC::StructureID* getCachedDOMStructure(JSC::ExecState*, const JSC::ClassInfo*); - JSC::StructureID* cacheDOMStructure(JSC::ExecState*, PassRefPtr<JSC::StructureID>, const JSC::ClassInfo*); + JSC::Structure* getCachedDOMStructure(JSC::ExecState*, const JSC::ClassInfo*); + JSC::Structure* cacheDOMStructure(JSC::ExecState*, PassRefPtr<JSC::Structure>, const JSC::ClassInfo*); JSC::JSObject* getCachedDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*); void cacheDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*, JSC::JSObject* constructor); - template<class WrapperClass> inline JSC::StructureID* getDOMStructure(JSC::ExecState* exec) + template<class WrapperClass> inline JSC::Structure* getDOMStructure(JSC::ExecState* exec) { - if (JSC::StructureID* structure = getCachedDOMStructure(exec, &WrapperClass::s_info)) + if (JSC::Structure* structure = getCachedDOMStructure(exec, &WrapperClass::s_info)) return structure; - return cacheDOMStructure(exec, WrapperClass::createStructureID(WrapperClass::createPrototype(exec)), &WrapperClass::s_info); + return cacheDOMStructure(exec, WrapperClass::createStructure(WrapperClass::createPrototype(exec)), &WrapperClass::s_info); } template<class WrapperClass> inline JSC::JSObject* getDOMPrototype(JSC::ExecState* exec) { @@ -98,7 +98,7 @@ namespace WebCore { 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::JSValuePtr getDOMObjectWrapper(JSC::ExecState* exec, DOMClass* object) { if (!object) return JSC::jsNull(); @@ -117,7 +117,7 @@ namespace WebCore { 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::JSValuePtr getDOMObjectWrapper(JSC::ExecState* exec, DOMClass* object, SVGElement* context) { if (!object) return JSC::jsNull(); @@ -136,7 +136,7 @@ namespace WebCore { 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::JSValuePtr getDOMNodeWrapper(JSC::ExecState* exec, DOMClass* node) { if (!node) return JSC::jsNull(); @@ -147,26 +147,29 @@ namespace WebCore { const JSC::HashTable* getHashTableForGlobalData(JSC::JSGlobalData&, const JSC::HashTable* staticTable); + void reportException(JSC::ExecState*, JSC::JSValuePtr exception); + void reportCurrentException(JSC::ExecState*); + // Convert a DOM implementation exception code into a JavaScript exception in the execution state. void setDOMException(JSC::ExecState*, ExceptionCode); - JSC::JSValue* jsStringOrNull(JSC::ExecState*, const String&); // null if the string is null - JSC::JSValue* jsStringOrNull(JSC::ExecState*, const KURL&); // null if the URL is null + JSC::JSValuePtr jsStringOrNull(JSC::ExecState*, const String&); // null if the string is null + JSC::JSValuePtr jsStringOrNull(JSC::ExecState*, const KURL&); // null if the URL is null - JSC::JSValue* jsStringOrUndefined(JSC::ExecState*, const String&); // undefined if the string is null - JSC::JSValue* jsStringOrUndefined(JSC::ExecState*, const KURL&); // undefined if the URL is null + JSC::JSValuePtr jsStringOrUndefined(JSC::ExecState*, const String&); // undefined if the string is null + JSC::JSValuePtr jsStringOrUndefined(JSC::ExecState*, const KURL&); // undefined if the URL is null - JSC::JSValue* jsStringOrFalse(JSC::ExecState*, const String&); // boolean false if the string is null - JSC::JSValue* jsStringOrFalse(JSC::ExecState*, const KURL&); // boolean false if the URL is null + JSC::JSValuePtr jsStringOrFalse(JSC::ExecState*, const String&); // boolean false if the string is null + JSC::JSValuePtr jsStringOrFalse(JSC::ExecState*, const KURL&); // boolean false if the URL is null // See JavaScriptCore for explanation: Should be used for any UString that is already owned by another // object, to let the engine know that collecting the JSString wrapper is unlikely to save memory. - JSC::JSValue* jsOwnedStringOrNull(JSC::ExecState*, const JSC::UString&); + JSC::JSValuePtr jsOwnedStringOrNull(JSC::ExecState*, const JSC::UString&); - 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 + JSC::UString valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValuePtr); // null if the value is null + JSC::UString valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValuePtr); // 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()); } + template <typename T> inline JSC::JSValuePtr toJS(JSC::ExecState* exec, PassRefPtr<T> ptr) { return toJS(exec, ptr.get()); } bool checkNodeSecurity(JSC::ExecState*, Node*); @@ -176,9 +179,9 @@ namespace WebCore { bool allowsAccessFromFrame(JSC::ExecState*, Frame*); bool allowsAccessFromFrame(JSC::ExecState*, Frame*, String& message); void printErrorMessageForFrame(Frame*, const String& message); - JSC::JSValue* objectToStringFunctionGetter(JSC::ExecState*, const JSC::Identifier& propertyName, const JSC::PropertySlot&); + JSC::JSValuePtr objectToStringFunctionGetter(JSC::ExecState*, const JSC::Identifier& propertyName, const JSC::PropertySlot&); - JSC::ExecState* execStateFromNode(Node*); + ScriptState* scriptStateFromNode(Node*); } // namespace WebCore diff --git a/WebCore/bindings/js/JSDOMGlobalObject.cpp b/WebCore/bindings/js/JSDOMGlobalObject.cpp index d9dae37..27dbf84 100644 --- a/WebCore/bindings/js/JSDOMGlobalObject.cpp +++ b/WebCore/bindings/js/JSDOMGlobalObject.cpp @@ -30,6 +30,12 @@ #include "Document.h" #include "JSDOMWindow.h" #include "JSEventListener.h" +#ifdef ANDROID_FIX // these are generated files, need to check ENABLE(WORKERS) +#if ENABLE(WORKERS) +#include "JSWorkerContext.h" +#endif +#endif +#include "WorkerContext.h" using namespace JSC; @@ -40,7 +46,7 @@ JSDOMGlobalObject::JSDOMGlobalObjectData::JSDOMGlobalObjectData() { } -JSDOMGlobalObject::JSDOMGlobalObject(PassRefPtr<StructureID> structure, JSDOMGlobalObject::JSDOMGlobalObjectData* data, JSObject* thisValue) +JSDOMGlobalObject::JSDOMGlobalObject(PassRefPtr<Structure> structure, JSDOMGlobalObject::JSDOMGlobalObjectData* data, JSObject* thisValue) : JSGlobalObject(structure, data, thisValue) { } @@ -84,42 +90,42 @@ void JSDOMGlobalObject::mark() } } -JSEventListener* JSDOMGlobalObject::findJSEventListener(JSValue* val, bool isInline) +JSEventListener* JSDOMGlobalObject::findJSEventListener(JSValuePtr val, bool isInline) { - if (!val->isObject()) + if (!val.isObject()) return 0; JSObject* object = asObject(val); ListenersMap& listeners = isInline ? d()->jsInlineEventListeners : d()->jsEventListeners; return listeners.get(object); } -PassRefPtr<JSEventListener> JSDOMGlobalObject::findOrCreateJSEventListener(ExecState* exec, JSValue* val, bool isInline) +PassRefPtr<JSEventListener> JSDOMGlobalObject::findOrCreateJSEventListener(ExecState*, JSValuePtr val, bool isInline) { if (JSEventListener* listener = findJSEventListener(val, isInline)) return listener; - if (!val->isObject()) + if (!val.isObject()) return 0; // The JSEventListener constructor adds it to our jsEventListeners map. return JSEventListener::create(asObject(val), this, isInline).get(); } -JSUnprotectedEventListener* JSDOMGlobalObject::findJSUnprotectedEventListener(ExecState* exec, JSValue* val, bool isInline) +JSUnprotectedEventListener* JSDOMGlobalObject::findJSUnprotectedEventListener(ExecState*, JSValuePtr val, bool isInline) { - if (!val->isObject()) + if (!val.isObject()) return 0; UnprotectedListenersMap& listeners = isInline ? d()->jsUnprotectedInlineEventListeners : d()->jsUnprotectedEventListeners; return listeners.get(asObject(val)); } -PassRefPtr<JSUnprotectedEventListener> JSDOMGlobalObject::findOrCreateJSUnprotectedEventListener(ExecState* exec, JSValue* val, bool isInline) +PassRefPtr<JSUnprotectedEventListener> JSDOMGlobalObject::findOrCreateJSUnprotectedEventListener(ExecState* exec, JSValuePtr val, bool isInline) { if (JSUnprotectedEventListener* listener = findJSUnprotectedEventListener(exec, val, isInline)) return listener; - if (!val->isObject()) + if (!val.isObject()) return 0; // The JSUnprotectedEventListener constructor adds it to our jsUnprotectedEventListeners map. @@ -161,7 +167,12 @@ JSDOMGlobalObject* toJSDOMGlobalObject(ScriptExecutionContext* scriptExecutionCo if (scriptExecutionContext->isDocument()) return toJSDOMWindow(static_cast<Document*>(scriptExecutionContext)->frame()); - // Not implemented yet. +#if ENABLE(WORKERS) + if (scriptExecutionContext->isWorkerContext()) + return static_cast<WorkerContext*>(scriptExecutionContext)->script()->workerContextWrapper(); +#endif + + ASSERT_NOT_REACHED(); return 0; } diff --git a/WebCore/bindings/js/JSDOMGlobalObject.h b/WebCore/bindings/js/JSDOMGlobalObject.h index 3c210bb..fbb3eb9 100644 --- a/WebCore/bindings/js/JSDOMGlobalObject.h +++ b/WebCore/bindings/js/JSDOMGlobalObject.h @@ -36,7 +36,7 @@ namespace WebCore { class JSUnprotectedEventListener; class ScriptExecutionContext; - typedef HashMap<const JSC::ClassInfo*, RefPtr<JSC::StructureID> > JSDOMStructureMap; + typedef HashMap<const JSC::ClassInfo*, RefPtr<JSC::Structure> > JSDOMStructureMap; typedef HashMap<const JSC::ClassInfo*, JSC::JSObject*> JSDOMConstructorMap; class JSDOMGlobalObject : public JSC::JSGlobalObject { @@ -44,7 +44,7 @@ namespace WebCore { protected: struct JSDOMGlobalObjectData; - JSDOMGlobalObject(PassRefPtr<JSC::StructureID>, JSDOMGlobalObjectData*, JSC::JSObject* thisValue); + JSDOMGlobalObject(PassRefPtr<JSC::Structure>, JSDOMGlobalObjectData*, JSC::JSObject* thisValue); virtual ~JSDOMGlobalObject(); public: @@ -54,16 +54,16 @@ namespace WebCore { virtual ScriptExecutionContext* scriptExecutionContext() const = 0; // Finds a wrapper of a JS EventListener, returns 0 if no existing one. - JSEventListener* findJSEventListener(JSC::JSValue*, bool isInline = false); + JSEventListener* findJSEventListener(JSC::JSValuePtr, bool isInline = false); // Finds or creates a wrapper of a JS EventListener. JS EventListener object is GC-protected. - PassRefPtr<JSEventListener> findOrCreateJSEventListener(JSC::ExecState*, JSC::JSValue*, bool isInline = false); + PassRefPtr<JSEventListener> findOrCreateJSEventListener(JSC::ExecState*, JSC::JSValuePtr, bool isInline = false); // Finds a wrapper of a GC-unprotected JS EventListener, returns 0 if no existing one. - JSUnprotectedEventListener* findJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValue*, bool isInline = false); + JSUnprotectedEventListener* findJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValuePtr, bool isInline = false); // Finds or creates a wrapper of a JS EventListener. JS EventListener object is *NOT* GC-protected. - PassRefPtr<JSUnprotectedEventListener> findOrCreateJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValue*, bool isInline = false); + PassRefPtr<JSUnprotectedEventListener> findOrCreateJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValuePtr, bool isInline = false); typedef HashMap<JSC::JSObject*, JSEventListener*> ListenersMap; typedef HashMap<JSC::JSObject*, JSUnprotectedEventListener*> UnprotectedListenersMap; diff --git a/WebCore/bindings/js/JSDOMStringListCustom.cpp b/WebCore/bindings/js/JSDOMStringListCustom.cpp new file mode 100644 index 0000000..d1ea663 --- /dev/null +++ b/WebCore/bindings/js/JSDOMStringListCustom.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2009 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSDOMStringList.h" + +#include "DOMStringList.h" + +using namespace JSC; + +namespace WebCore { + +JSValuePtr JSDOMStringList::getByIndex(ExecState* exec, unsigned index) +{ + return jsString(exec, impl()->item(index)); +} + +JSValuePtr JSDOMStringList::item(ExecState* exec, const ArgList& args) +{ + unsigned index = args.at(exec, 0).toUInt32(exec); + if (index >= impl()->length()) + return jsNull(); + + return jsString(exec, impl()->item(index)); +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/JSDOMWindowBase.cpp b/WebCore/bindings/js/JSDOMWindowBase.cpp index 4ec39cd..83bc202 100644 --- a/WebCore/bindings/js/JSDOMWindowBase.cpp +++ b/WebCore/bindings/js/JSDOMWindowBase.cpp @@ -25,6 +25,7 @@ #include "CString.h" #include "Console.h" +#include "DOMTimer.h" #include "DOMWindow.h" #include "Element.h" #include "EventListener.h" @@ -38,7 +39,6 @@ #include "HTMLDocument.h" #include "InspectorController.h" #include "JSAudioConstructor.h" -#include "JSDedicatedWorkerConstructor.h" #include "JSDOMWindowCustom.h" #include "JSEvent.h" #include "JSEventListener.h" @@ -46,13 +46,14 @@ #include "JSImageConstructor.h" #include "JSMessageChannelConstructor.h" #include "JSNode.h" +#include "JSWebKitCSSMatrixConstructor.h" #include "JSOptionConstructor.h" +#include "JSWorkerConstructor.h" #include "JSXMLHttpRequestConstructor.h" #include "JSXSLTProcessorConstructor.h" #include "Logging.h" #include "MediaPlayer.h" #include "Page.h" -#include "PausedTimeouts.h" #include "PlatformScreen.h" #include "PluginInfoStore.h" #include "RenderView.h" @@ -69,73 +70,36 @@ using namespace JSC; -static JSValue* windowProtoFuncOpen(ExecState*, JSObject*, JSValue*, const ArgList&); -static JSValue* windowProtoFuncShowModalDialog(ExecState*, JSObject*, JSValue*, const ArgList&); -static JSValue* windowProtoFuncNotImplemented(ExecState*, JSObject*, JSValue*, const ArgList&); +static JSValuePtr windowProtoFuncOpen(ExecState*, JSObject*, JSValuePtr, const ArgList&); +static JSValuePtr windowProtoFuncShowModalDialog(ExecState*, JSObject*, JSValuePtr, const ArgList&); +static JSValuePtr windowProtoFuncNotImplemented(ExecState*, JSObject*, JSValuePtr, const ArgList&); -static JSValue* jsDOMWindowBaseCrypto(ExecState*, const Identifier&, const PropertySlot&); -static JSValue* jsDOMWindowBaseEvent(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseEvent(ExecState*, JSObject*, JSValue*); +static JSValuePtr jsDOMWindowBaseCrypto(ExecState*, const Identifier&, const PropertySlot&); +static JSValuePtr jsDOMWindowBaseEvent(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseEvent(ExecState*, JSObject*, JSValuePtr); // Constructors -static JSValue* jsDOMWindowBaseAudio(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseAudio(ExecState*, JSObject*, JSValue*); -static JSValue* jsDOMWindowBaseImage(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseImage(ExecState*, JSObject*, JSValue*); -static JSValue* jsDOMWindowBaseMessageChannel(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseMessageChannel(ExecState*, JSObject*, JSValue*); -static JSValue* jsDOMWindowBaseWorker(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseWorker(ExecState*, JSObject*, JSValue*); -static JSValue* jsDOMWindowBaseOption(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseOption(ExecState*, JSObject*, JSValue*); -static JSValue* jsDOMWindowBaseXMLHttpRequest(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseXMLHttpRequest(ExecState*, JSObject*, JSValue*); -static JSValue* jsDOMWindowBaseXSLTProcessor(ExecState*, const Identifier&, const PropertySlot&); -static void setJSDOMWindowBaseXSLTProcessor(ExecState*, JSObject*, JSValue*); +static JSValuePtr jsDOMWindowBaseAudio(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseAudio(ExecState*, JSObject*, JSValuePtr); +static JSValuePtr jsDOMWindowBaseImage(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseImage(ExecState*, JSObject*, JSValuePtr); +static JSValuePtr jsDOMWindowBaseMessageChannel(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseMessageChannel(ExecState*, JSObject*, JSValuePtr); +static JSValuePtr jsDOMWindowBaseWorker(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseWorker(ExecState*, JSObject*, JSValuePtr); +static JSValuePtr jsDOMWindowBaseOption(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseOption(ExecState*, JSObject*, JSValuePtr); +static JSValuePtr jsDOMWindowBaseWebKitCSSMatrix(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseWebKitCSSMatrix(ExecState*, JSObject*, JSValuePtr); +static JSValuePtr jsDOMWindowBaseXMLHttpRequest(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseXMLHttpRequest(ExecState*, JSObject*, JSValuePtr); +static JSValuePtr jsDOMWindowBaseXSLTProcessor(ExecState*, const Identifier&, const PropertySlot&); +static void setJSDOMWindowBaseXSLTProcessor(ExecState*, JSObject*, JSValuePtr); #include "JSDOMWindowBase.lut.h" namespace WebCore { -static int lastUsedTimeoutId; - -static int timerNestingLevel = 0; -const int cMaxTimerNestingLevel = 5; -const double cMinimumTimerInterval = 0.010; - -class DOMWindowTimer : public TimerBase { -public: - DOMWindowTimer(int timeoutId, int nestingLevel, JSDOMWindowBase* object, ScheduledAction* action) - : m_timeoutId(timeoutId) - , m_nestingLevel(nestingLevel) - , m_object(object) - , m_action(action) - { - } - - virtual ~DOMWindowTimer() - { - JSLock lock(false); - delete m_action; - } - - int timeoutId() const { return m_timeoutId; } - - int nestingLevel() const { return m_nestingLevel; } - void setNestingLevel(int n) { m_nestingLevel = n; } - - ScheduledAction* action() const { return m_action; } - ScheduledAction* takeAction() { ScheduledAction* a = m_action; m_action = 0; return a; } - -private: - virtual void fired(); - - int m_timeoutId; - int m_nestingLevel; - JSDOMWindowBase* m_object; - ScheduledAction* m_action; -}; - ////////////////////// JSDOMWindowBase Object //////////////////////// const ClassInfo JSDOMWindowBase::s_info = { "Window", 0, &JSDOMWindowBaseTable, 0 }; @@ -156,6 +120,7 @@ const ClassInfo JSDOMWindowBase::s_info = { "Window", 0, &JSDOMWindowBaseTable, Image jsDOMWindowBaseImage DontDelete MessageChannel jsDOMWindowBaseMessageChannel DontDelete Option jsDOMWindowBaseOption DontDelete + WebKitCSSMatrix jsDOMWindowBaseWebKitCSSMatrix DontDelete Worker jsDOMWindowBaseWorker DontDelete XMLHttpRequest jsDOMWindowBaseXMLHttpRequest DontDelete XSLTProcessor jsDOMWindowBaseXSLTProcessor DontDelete @@ -169,7 +134,7 @@ JSDOMWindowBase::JSDOMWindowBaseData::JSDOMWindowBaseData(PassRefPtr<DOMWindow> { } -JSDOMWindowBase::JSDOMWindowBase(PassRefPtr<StructureID> structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell) +JSDOMWindowBase::JSDOMWindowBase(PassRefPtr<Structure> structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell) : JSDOMGlobalObject(structure, new JSDOMWindowBaseData(window, shell), shell) { // Time in milliseconds before the script timeout handler kicks in. @@ -194,8 +159,6 @@ JSDOMWindowBase::~JSDOMWindowBase() { if (d()->impl->frame()) d()->impl->frame()->script()->clearFormerWindow(asJSDOMWindow(this)); - - clearAllTimeouts(); } ScriptExecutionContext* JSDOMWindowBase::scriptExecutionContext() const @@ -246,7 +209,7 @@ static HashMap<String, String> parseModalDialogFeatures(const String& featuresAr } static Frame* createWindow(ExecState* exec, Frame* openerFrame, const String& url, - const String& frameName, const WindowFeatures& windowFeatures, JSValue* dialogArgs) + const String& frameName, const WindowFeatures& windowFeatures, JSValuePtr dialogArgs) { Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); ASSERT(activeFrame); @@ -285,9 +248,9 @@ static Frame* createWindow(ExecState* exec, Frame* openerFrame, const String& ur bool userGesture = activeFrame->script()->processingUserGesture(); if (created) - newFrame->loader()->changeLocation(completedURL, activeFrame->loader()->outgoingReferrer(), false, userGesture); + newFrame->loader()->changeLocation(completedURL, activeFrame->loader()->outgoingReferrer(), false, false, userGesture); else if (!url.isEmpty()) - newFrame->loader()->scheduleLocationChange(completedURL.string(), activeFrame->loader()->outgoingReferrer(), false, userGesture); + newFrame->loader()->scheduleLocationChange(completedURL.string(), activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); } return newFrame; @@ -298,16 +261,11 @@ static bool canShowModalDialog(const Frame* frame) if (!frame) return false; -#ifdef ANDROID_FIX - // Note for integration: this fix came from Webkit Page* page = frame->page(); if (!page) return false; return page->chrome()->canRunModal(); -#else - return frame->page()->chrome()->canRunModal(); -#endif } static bool canShowModalDialogNow(const Frame* frame) @@ -315,19 +273,14 @@ static bool canShowModalDialogNow(const Frame* frame) if (!frame) return false; -#ifdef ANDROID_FIX - // Note for integration: this fix came from Webkit Page* page = frame->page(); if (!page) return false; return page->chrome()->canRunModalNow(); -#else - return frame->page()->chrome()->canRunModalNow(); -#endif } -static JSValue* showModalDialog(ExecState* exec, Frame* frame, const String& url, JSValue* dialogArgs, const String& featureArgs) +static JSValuePtr showModalDialog(ExecState* exec, Frame* frame, const String& url, JSValuePtr dialogArgs, const String& featureArgs) { if (!canShowModalDialogNow(frame) || !allowPopUp(exec)) return jsUndefined(); @@ -388,7 +341,7 @@ static JSValue* showModalDialog(ExecState* exec, Frame* frame, const String& url // Get the return value either just before clearing the dialog window's // properties (in JSDOMWindowBase::clear), or when on return from runModal. - JSValue* returnValue = noValue(); + JSValuePtr returnValue = noValue(); dialogWindow->setReturnValueSlot(&returnValue); dialogFrame->page()->chrome()->runModal(); dialogWindow->setReturnValueSlot(0); @@ -406,12 +359,12 @@ static JSValue* showModalDialog(ExecState* exec, Frame* frame, const String& url using namespace WebCore; -JSValue* jsDOMWindowBaseCrypto(ExecState*, const Identifier&, const PropertySlot&) +JSValuePtr jsDOMWindowBaseCrypto(ExecState*, const Identifier&, const PropertySlot&) { return jsUndefined(); // FIXME: implement this } -JSValue* jsDOMWindowBaseEvent(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr jsDOMWindowBaseEvent(ExecState* exec, const Identifier&, const PropertySlot& slot) { if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) return jsUndefined(); @@ -420,35 +373,53 @@ JSValue* jsDOMWindowBaseEvent(ExecState* exec, const Identifier&, const Property return toJS(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->currentEvent()); } -JSValue* jsDOMWindowBaseImage(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr jsDOMWindowBaseImage(ExecState* exec, const Identifier&, const PropertySlot& slot) { if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) return jsUndefined(); return getDOMConstructor<JSImageConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))); } -JSValue* jsDOMWindowBaseMessageChannel(ExecState* exec, const Identifier&, const PropertySlot& slot) +#if !ENABLE(CHANNEL_MESSAGING) + +JSValuePtr jsDOMWindowBaseMessageChannel(ExecState*, const Identifier&, const PropertySlot&) +{ + return jsUndefined(); +} + +#else + +JSValuePtr jsDOMWindowBaseMessageChannel(ExecState* exec, const Identifier&, const PropertySlot& slot) { if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) return jsUndefined(); return getDOMConstructor<JSMessageChannelConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))); } -JSValue* jsDOMWindowBaseOption(ExecState* exec, const Identifier&, const PropertySlot& slot) +#endif + +JSValuePtr jsDOMWindowBaseOption(ExecState* exec, const Identifier&, const PropertySlot& slot) { if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) return jsUndefined(); return getDOMConstructor<JSOptionConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))); } -JSValue* jsDOMWindowBaseXMLHttpRequest(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr jsDOMWindowBaseWebKitCSSMatrix(ExecState* exec, const Identifier&, const PropertySlot& slot) +{ + if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) + return jsUndefined(); + return getDOMConstructor<JSWebKitCSSMatrixConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))); +} + +JSValuePtr jsDOMWindowBaseXMLHttpRequest(ExecState* exec, const Identifier&, const PropertySlot& slot) { if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) return jsUndefined(); return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))); } -JSValue* jsDOMWindowBaseAudio(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr jsDOMWindowBaseAudio(ExecState* exec, const Identifier&, const PropertySlot& slot) { #if ENABLE(VIDEO) if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) @@ -461,18 +432,18 @@ JSValue* jsDOMWindowBaseAudio(ExecState* exec, const Identifier&, const Property #endif } -JSValue* jsDOMWindowBaseWorker(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr jsDOMWindowBaseWorker(ExecState* exec, const Identifier&, const PropertySlot& slot) { #if ENABLE(WORKERS) if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) return jsUndefined(); - return getDOMConstructor<JSDedicatedWorkerConstructor>(exec); + return getDOMConstructor<JSWorkerConstructor>(exec); #else return jsUndefined(); #endif } -JSValue* jsDOMWindowBaseXSLTProcessor(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr jsDOMWindowBaseXSLTProcessor(ExecState* exec, const Identifier&, const PropertySlot& slot) { #if ENABLE(XSLT) if (!static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->allowsAccessFrom(exec)) @@ -483,19 +454,91 @@ JSValue* jsDOMWindowBaseXSLTProcessor(ExecState* exec, const Identifier&, const #endif } +void setJSDOMWindowBaseEvent(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "Event"), value); +} + +void setJSDOMWindowBaseAudio(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "Audio"), value); +} + +void setJSDOMWindowBaseImage(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "Image"), value); +} + +void setJSDOMWindowBaseMessageChannel(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "MessageChannel"), value); +} + +void setJSDOMWindowBaseOption(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "Option"), value); +} + +void setJSDOMWindowBaseWorker(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "Worker"), value); +} + +void setJSDOMWindowBaseWebKitCSSMatrix(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "WebKitCSSMatrix"), value); +} + +void setJSDOMWindowBaseXMLHttpRequest(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "XMLHttpRequest"), value); +} + +void setJSDOMWindowBaseXSLTProcessor(ExecState* exec, JSObject* thisObject, JSValuePtr value) +{ + if (!static_cast<JSDOMWindowBase*>(thisObject)->allowsAccessFrom(exec)) + return; + // Shadowing a built-in constructor + static_cast<JSDOMWindowBase*>(thisObject)->putDirect(Identifier(exec, "XSLTProcessor"), value); +} + namespace WebCore { -JSValue* JSDOMWindowBase::childFrameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSDOMWindowBase::childFrameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { return toJS(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->impl()->frame()->tree()->child(AtomicString(propertyName))->domWindow()); } -JSValue* JSDOMWindowBase::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr JSDOMWindowBase::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) { return toJS(exec, static_cast<JSDOMWindowBase*>(asObject(slot.slotBase()))->impl()->frame()->tree()->child(slot.index())->domWindow()); } -JSValue* JSDOMWindowBase::namedItemGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSDOMWindowBase::namedItemGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSDOMWindowBase* thisObj = static_cast<JSDOMWindowBase*>(asObject(slot.slotBase())); Document* doc = thisObj->impl()->frame()->document(); @@ -509,15 +552,6 @@ JSValue* JSDOMWindowBase::namedItemGetter(ExecState* exec, const Identifier& pro return toJS(exec, collection.get()); } -void JSDOMWindowBase::markCrossHeapDependentObjects() -{ - Document* document = impl()->document(); - if (!document) - return; - - markCrossHeapDependentObjectsForContext(*globalData(), document); -} - bool JSDOMWindowBase::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { // Check for child frames by name before built-in properties to @@ -548,8 +582,8 @@ bool JSDOMWindowBase::getOwnPropertySlot(ExecState* exec, const Identifier& prop // Do prototype lookup early so that functions and attributes in the prototype can have // precedence over the index and name getters. - JSValue* proto = prototype(); - if (proto->isObject()) { + JSValuePtr proto = prototype(); + if (proto.isObject()) { if (asObject(proto)->getPropertySlot(exec, propertyName, slot)) { if (!allowsAccessFrom(exec)) slot.setUndefined(); @@ -586,7 +620,7 @@ bool JSDOMWindowBase::getOwnPropertySlot(ExecState* exec, const Identifier& prop return Base::getOwnPropertySlot(exec, propertyName, slot); } -void JSDOMWindowBase::put(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot) +void JSDOMWindowBase::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) { const HashEntry* entry = JSDOMWindowBaseTable.entry(exec, propertyName); if (entry) { @@ -597,69 +631,12 @@ void JSDOMWindowBase::put(ExecState* exec, const Identifier& propertyName, JSVal } if (entry->attributes() & ReadOnly) return; - - // Don't call the put function for replacable properties. - if (!(entry->propertyPutter() == setJSDOMWindowBaseEvent - || entry->propertyPutter() == setJSDOMWindowBaseAudio - || entry->propertyPutter() == setJSDOMWindowBaseImage - || entry->propertyPutter() == setJSDOMWindowBaseOption - || entry->propertyPutter() == setJSDOMWindowBaseMessageChannel - || entry->propertyPutter() == setJSDOMWindowBaseWorker - || entry->propertyPutter() == setJSDOMWindowBaseXMLHttpRequest - || entry->propertyPutter() == setJSDOMWindowBaseXSLTProcessor)) { - entry->propertyPutter()(exec, this, value); - return; - } } if (allowsAccessFrom(exec)) Base::put(exec, propertyName, value, slot); } -} // namespace WebCore - -void setJSDOMWindowBaseEvent(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -void setJSDOMWindowBaseAudio(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -void setJSDOMWindowBaseImage(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -void setJSDOMWindowBaseMessageChannel(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -void setJSDOMWindowBaseOption(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -void setJSDOMWindowBaseWorker(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -void setJSDOMWindowBaseXMLHttpRequest(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -void setJSDOMWindowBaseXSLTProcessor(ExecState*, JSObject*, JSValue*) -{ - ASSERT_NOT_REACHED(); -} - -namespace WebCore { - String JSDOMWindowBase::crossDomainAccessErrorMessage(const JSGlobalObject* other) const { KURL originURL = asJSDOMWindow(other)->impl()->url(); @@ -743,7 +720,6 @@ void JSDOMWindowBase::clear() if (d()->returnValueSlot && !*d()->returnValueSlot) *d()->returnValueSlot = getDirect(Identifier(globalExec(), "returnValue")); - clearAllTimeouts(); clearHelperObjectProperties(); } @@ -767,7 +743,7 @@ JSGlobalData* JSDOMWindowBase::commonJSGlobalData() using namespace WebCore; -JSValue* windowProtoFuncOpen(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) +JSValuePtr windowProtoFuncOpen(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args) { JSDOMWindow* window = toJSDOMWindow(thisValue); if (!window) @@ -785,7 +761,7 @@ JSValue* windowProtoFuncOpen(ExecState* exec, JSObject*, JSValue* thisValue, con Page* page = frame->page(); String urlString = valueToStringWithUndefinedOrNullCheck(exec, args.at(exec, 0)); - AtomicString frameName = args.at(exec, 1)->isUndefinedOrNull() ? "_blank" : AtomicString(args.at(exec, 1)->toString(exec)); + AtomicString frameName = args.at(exec, 1).isUndefinedOrNull() ? "_blank" : AtomicString(args.at(exec, 1).toString(exec)); // Because FrameTree::find() returns true for empty strings, we must check for empty framenames. // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker. @@ -814,7 +790,7 @@ JSValue* windowProtoFuncOpen(ExecState* exec, JSObject*, JSValue* thisValue, con const JSDOMWindow* targetedWindow = toJSDOMWindow(frame); if (!completedURL.isEmpty() && (!protocolIs(completedURL, "javascript") || (targetedWindow && targetedWindow->allowsAccessFrom(exec)))) { bool userGesture = activeFrame->script()->processingUserGesture(); - frame->loader()->scheduleLocationChange(completedURL, activeFrame->loader()->outgoingReferrer(), false, userGesture); + frame->loader()->scheduleLocationChange(completedURL, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); } return toJS(exec, frame->domWindow()); } @@ -838,7 +814,7 @@ JSValue* windowProtoFuncOpen(ExecState* exec, JSObject*, JSValue* thisValue, con return toJS(exec, frame->domWindow()); // global object } -JSValue* windowProtoFuncShowModalDialog(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) +JSValuePtr windowProtoFuncShowModalDialog(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList& args) { JSDOMWindow* window = toJSDOMWindow(thisValue); if (!window) @@ -853,7 +829,7 @@ JSValue* windowProtoFuncShowModalDialog(ExecState* exec, JSObject*, JSValue* thi return showModalDialog(exec, frame, valueToStringWithUndefinedOrNullCheck(exec, args.at(exec, 0)), args.at(exec, 1), valueToStringWithUndefinedOrNullCheck(exec, args.at(exec, 2))); } -JSValue* windowProtoFuncNotImplemented(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) +JSValuePtr windowProtoFuncNotImplemented(ExecState* exec, JSObject*, JSValuePtr thisValue, const ArgList&) { if (!toJSDOMWindow(thisValue)) return throwError(exec, TypeError); @@ -862,42 +838,16 @@ JSValue* windowProtoFuncNotImplemented(ExecState* exec, JSObject*, JSValue* this namespace WebCore { -void JSDOMWindowBase::setReturnValueSlot(JSValue** slot) +void JSDOMWindowBase::setReturnValueSlot(JSValuePtr* slot) { d()->returnValueSlot = slot; } ////////////////////// timeouts //////////////////////// -void JSDOMWindowBase::clearAllTimeouts() -{ - deleteAllValues(d()->timeouts); - d()->timeouts.clear(); -} - int JSDOMWindowBase::installTimeout(ScheduledAction* a, int t, bool singleShot) { - int timeoutId = ++lastUsedTimeoutId; - - // avoid wraparound going negative on us - if (timeoutId <= 0) - timeoutId = 1; - - int nestLevel = timerNestingLevel + 1; - DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, nestLevel, this, a); - ASSERT(!d()->timeouts.get(timeoutId)); - d()->timeouts.set(timeoutId, timer); - // Use a minimum interval of 10 ms to match other browsers, but only once we've - // nested enough to notice that we're repeating. - // Faster timers might be "better", but they're incompatible. - double interval = max(0.001, t * 0.001); - if (interval < cMinimumTimerInterval && nestLevel >= cMaxTimerNestingLevel) - interval = cMinimumTimerInterval; - if (singleShot) - timer->startOneShot(interval); - else - timer->startRepeating(interval); - return timeoutId; + return DOMTimer::install(scriptExecutionContext(), a, t, singleShot); } int JSDOMWindowBase::installTimeout(const UString& handler, int t, bool singleShot) @@ -905,109 +855,21 @@ int JSDOMWindowBase::installTimeout(const UString& handler, int t, bool singleSh return installTimeout(new ScheduledAction(handler), t, singleShot); } -int JSDOMWindowBase::installTimeout(ExecState* exec, JSValue* func, const ArgList& args, int t, bool singleShot) +int JSDOMWindowBase::installTimeout(ExecState* exec, JSValuePtr func, const ArgList& args, int t, bool singleShot) { return installTimeout(new ScheduledAction(exec, func, args), t, singleShot); } -void JSDOMWindowBase::pauseTimeouts(OwnPtr<PausedTimeouts>& result) +void JSDOMWindowBase::removeTimeout(int timeoutId) { - size_t timeoutsCount = d()->timeouts.size(); - if (!timeoutsCount) { - result.clear(); - return; - } - - PausedTimeout* t = new PausedTimeout[timeoutsCount]; - result.set(new PausedTimeouts(t, timeoutsCount)); - - JSDOMWindowBaseData::TimeoutsMap::iterator it = d()->timeouts.begin(); - for (size_t i = 0; i != timeoutsCount; ++i, ++it) { - int timeoutId = it->first; - DOMWindowTimer* timer = it->second; - t[i].timeoutId = timeoutId; - t[i].nestingLevel = timer->nestingLevel(); - t[i].nextFireInterval = timer->nextFireInterval(); - t[i].repeatInterval = timer->repeatInterval(); - t[i].action = timer->takeAction(); - } - ASSERT(it == d()->timeouts.end()); - - deleteAllValues(d()->timeouts); - d()->timeouts.clear(); -} - -void JSDOMWindowBase::resumeTimeouts(OwnPtr<PausedTimeouts>& timeouts) -{ - if (!timeouts) - return; - size_t count = timeouts->numTimeouts(); - PausedTimeout* array = timeouts->takeTimeouts(); - for (size_t i = 0; i != count; ++i) { - int timeoutId = array[i].timeoutId; - DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, array[i].nestingLevel, this, array[i].action); - d()->timeouts.set(timeoutId, timer); - timer->start(array[i].nextFireInterval, array[i].repeatInterval); - } - delete [] array; - timeouts.clear(); -} - -void JSDOMWindowBase::removeTimeout(int timeoutId, bool delAction) -{ - // timeout IDs have to be positive, and 0 and -1 are unsafe to - // even look up since they are the empty and deleted value - // respectively - if (timeoutId <= 0) - return; - - delete d()->timeouts.take(timeoutId); -} - -void JSDOMWindowBase::timerFired(DOMWindowTimer* timer) -{ - // Simple case for non-one-shot timers. - if (timer->isActive()) { - int timeoutId = timer->timeoutId(); - - timer->action()->execute(shell()); - // The DOMWindowTimer object may have been deleted or replaced during execution, - // so we re-fetch it. - timer = d()->timeouts.get(timeoutId); - if (!timer) - return; - - if (timer->repeatInterval() && timer->repeatInterval() < cMinimumTimerInterval) { - timer->setNestingLevel(timer->nestingLevel() + 1); - if (timer->nestingLevel() >= cMaxTimerNestingLevel) - timer->augmentRepeatInterval(cMinimumTimerInterval - timer->repeatInterval()); - } - return; - } - - // Delete timer before executing the action for one-shot timers. - ScheduledAction* action = timer->takeAction(); - d()->timeouts.remove(timer->timeoutId()); - delete timer; - action->execute(shell()); - - JSLock lock(false); - delete action; + DOMTimer::removeById(scriptExecutionContext(), timeoutId); } void JSDOMWindowBase::disconnectFrame() { - clearAllTimeouts(); -} - -void DOMWindowTimer::fired() -{ - timerNestingLevel = m_nestingLevel; - m_object->timerFired(this); - timerNestingLevel = 0; } -JSValue* toJS(ExecState*, DOMWindow* domWindow) +JSValuePtr toJS(ExecState*, DOMWindow* domWindow) { if (!domWindow) return jsNull(); @@ -1024,9 +886,9 @@ JSDOMWindow* toJSDOMWindow(Frame* frame) return frame->script()->windowShell()->window(); } -JSDOMWindow* toJSDOMWindow(JSValue* value) +JSDOMWindow* toJSDOMWindow(JSValuePtr value) { - if (!value->isObject()) + if (!value.isObject()) return 0; const ClassInfo* classInfo = asObject(value)->classInfo(); if (classInfo == &JSDOMWindow::s_info) diff --git a/WebCore/bindings/js/JSDOMWindowBase.h b/WebCore/bindings/js/JSDOMWindowBase.h index f345f47..2398172 100644 --- a/WebCore/bindings/js/JSDOMWindowBase.h +++ b/WebCore/bindings/js/JSDOMWindowBase.h @@ -22,7 +22,7 @@ #include "PlatformString.h" #include "JSDOMBinding.h" -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> @@ -30,7 +30,6 @@ namespace WebCore { class AtomicString; class DOMWindow; - class DOMWindowTimer; class Event; class Frame; class JSDOMWindow; @@ -38,7 +37,6 @@ namespace WebCore { class JSEventListener; class JSLocation; class JSUnprotectedEventListener; - class PausedTimeouts; class ScheduledAction; class SecurityOrigin; @@ -50,7 +48,7 @@ namespace WebCore { friend class ScheduledAction; protected: - JSDOMWindowBase(PassRefPtr<JSC::StructureID>, PassRefPtr<DOMWindow>, JSDOMWindowShell*); + JSDOMWindowBase(PassRefPtr<JSC::Structure>, PassRefPtr<DOMWindow>, JSDOMWindowShell*); public: virtual ~JSDOMWindowBase(); @@ -62,24 +60,17 @@ namespace WebCore { void disconnectFrame(); - virtual void markCrossHeapDependentObjects(); - virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); - virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue*, JSC::PutPropertySlot&); + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValuePtr, JSC::PutPropertySlot&); int installTimeout(const JSC::UString& handler, int t, bool singleShot); - int installTimeout(JSC::ExecState*, JSC::JSValue* function, const JSC::ArgList& args, int t, bool singleShot); - void removeTimeout(int timerId, bool delAction = true); - - void pauseTimeouts(OwnPtr<PausedTimeouts>&); - void resumeTimeouts(OwnPtr<PausedTimeouts>&); - - void timerFired(DOMWindowTimer*); + int installTimeout(JSC::ExecState*, JSC::JSValuePtr function, const JSC::ArgList& args, int t, bool singleShot); + void removeTimeout(int timeoutId); void clear(); // Set a place to put a dialog return value when the window is cleared. - void setReturnValueSlot(JSC::JSValue** slot); + void setReturnValueSlot(JSC::JSValuePtr* slot); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } static const JSC::ClassInfo s_info; @@ -104,24 +95,19 @@ namespace WebCore { static JSC::JSGlobalData* commonJSGlobalData(); - void clearAllTimeouts(); - private: struct JSDOMWindowBaseData : public JSDOMGlobalObjectData { JSDOMWindowBaseData(PassRefPtr<DOMWindow>, JSDOMWindowShell*); RefPtr<DOMWindow> impl; - JSC::JSValue** returnValueSlot; + JSC::JSValuePtr* returnValueSlot; JSDOMWindowShell* shell; - - typedef HashMap<int, DOMWindowTimer*> TimeoutsMap; - TimeoutsMap timeouts; }; - static JSC::JSValue* childFrameGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); - static JSC::JSValue* indexGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); - static JSC::JSValue* namedItemGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + static JSC::JSValuePtr childFrameGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + static JSC::JSValuePtr indexGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + static JSC::JSValuePtr namedItemGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); void clearHelperObjectProperties(); int installTimeout(ScheduledAction*, int interval, bool singleShot); @@ -133,11 +119,11 @@ namespace WebCore { }; // Returns a JSDOMWindow or jsNull() - JSC::JSValue* toJS(JSC::ExecState*, DOMWindow*); + JSC::JSValuePtr toJS(JSC::ExecState*, DOMWindow*); // Returns JSDOMWindow or 0 JSDOMWindow* toJSDOMWindow(Frame*); - JSDOMWindow* toJSDOMWindow(JSC::JSValue*); + JSDOMWindow* toJSDOMWindow(JSC::JSValuePtr); } // namespace WebCore diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 4b5f386..562e661 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -108,7 +108,7 @@ void JSDOMWindow::defineSetter(ExecState* exec, const Identifier& propertyName, Base::defineSetter(exec, propertyName, setterFunction); } -JSValue* JSDOMWindow::lookupGetter(ExecState* exec, const Identifier& propertyName) +JSValuePtr JSDOMWindow::lookupGetter(ExecState* exec, const Identifier& propertyName) { // Only allow looking-up getters by frames in the same origin. if (!allowsAccessFrom(exec)) @@ -116,7 +116,7 @@ JSValue* JSDOMWindow::lookupGetter(ExecState* exec, const Identifier& propertyNa return Base::lookupGetter(exec, propertyName); } -JSValue* JSDOMWindow::lookupSetter(ExecState* exec, const Identifier& propertyName) +JSValuePtr JSDOMWindow::lookupSetter(ExecState* exec, const Identifier& propertyName) { // Only allow looking-up setters by frames in the same origin. if (!allowsAccessFrom(exec)) @@ -124,7 +124,7 @@ JSValue* JSDOMWindow::lookupSetter(ExecState* exec, const Identifier& propertyNa return Base::lookupSetter(exec, propertyName); } -void JSDOMWindow::setLocation(ExecState* exec, JSValue* value) +void JSDOMWindow::setLocation(ExecState* exec, JSValuePtr value) { Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); if (!activeFrame) @@ -144,20 +144,20 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue* value) if (!activeFrame->loader()->shouldAllowNavigation(impl()->frame())) return; - String dstUrl = activeFrame->loader()->completeURL(value->toString(exec)).string(); + String dstUrl = activeFrame->loader()->completeURL(value.toString(exec)).string(); if (!protocolIs(dstUrl, "javascript") || allowsAccessFrom(exec)) { bool userGesture = activeFrame->script()->processingUserGesture(); // We want a new history item if this JS was called via a user gesture - impl()->frame()->loader()->scheduleLocationChange(dstUrl, activeFrame->loader()->outgoingReferrer(), false, userGesture); + impl()->frame()->loader()->scheduleLocationChange(dstUrl, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); } } -JSValue* JSDOMWindow::postMessage(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::postMessage(ExecState* exec, const ArgList& args) { DOMWindow* window = impl(); DOMWindow* source = asJSDOMWindow(exec->dynamicGlobalObject())->impl(); - String message = args.at(exec, 0)->toString(exec); + String message = args.at(exec, 0).toString(exec); if (exec->hadException()) return jsUndefined(); @@ -175,52 +175,52 @@ JSValue* JSDOMWindow::postMessage(ExecState* exec, const ArgList& args) return jsUndefined(); } -static JSValue* setTimeoutOrInterval(ExecState* exec, JSDOMWindow* window, const ArgList& args, bool timeout) +static JSValuePtr setTimeoutOrInterval(ExecState* exec, JSDOMWindow* window, const ArgList& args, bool timeout) { - JSValue* v = args.at(exec, 0); - int delay = args.at(exec, 1)->toInt32(exec); - if (v->isString()) + JSValuePtr v = args.at(exec, 0); + int delay = args.at(exec, 1).toInt32(exec); + if (v.isString()) return jsNumber(exec, window->installTimeout(asString(v)->value(), delay, timeout)); CallData callData; - if (v->getCallData(callData) == CallTypeNone) + if (v.getCallData(callData) == CallTypeNone) return jsUndefined(); ArgList argsTail; args.getSlice(2, argsTail); return jsNumber(exec, window->installTimeout(exec, v, argsTail, delay, timeout)); } -JSValue* JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args) { return setTimeoutOrInterval(exec, this, args, true); } -JSValue* JSDOMWindow::clearTimeout(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::clearTimeout(ExecState* exec, const ArgList& args) { - removeTimeout(args.at(exec, 0)->toInt32(exec)); + removeTimeout(args.at(exec, 0).toInt32(exec)); return jsUndefined(); } -JSValue* JSDOMWindow::setInterval(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::setInterval(ExecState* exec, const ArgList& args) { return setTimeoutOrInterval(exec, this, args, false); } -JSValue* JSDOMWindow::clearInterval(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::clearInterval(ExecState* exec, const ArgList& args) { - removeTimeout(args.at(exec, 0)->toInt32(exec)); + removeTimeout(args.at(exec, 0).toInt32(exec)); return jsUndefined(); } -JSValue* JSDOMWindow::atob(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::atob(ExecState* exec, const ArgList& args) { if (args.size() < 1) return throwError(exec, SyntaxError, "Not enough arguments"); - JSValue* v = args.at(exec, 0); - if (v->isNull()) + JSValuePtr v = args.at(exec, 0); + if (v.isNull()) return jsEmptyString(exec); - UString s = v->toString(exec); + UString s = v.toString(exec); if (!s.is8Bit()) { setDOMException(exec, INVALID_CHARACTER_ERR); return jsUndefined(); @@ -237,16 +237,16 @@ JSValue* JSDOMWindow::atob(ExecState* exec, const ArgList& args) return jsString(exec, String(out.data(), out.size())); } -JSValue* JSDOMWindow::btoa(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::btoa(ExecState* exec, const ArgList& args) { if (args.size() < 1) return throwError(exec, SyntaxError, "Not enough arguments"); - JSValue* v = args.at(exec, 0); - if (v->isNull()) + JSValuePtr v = args.at(exec, 0); + if (v.isNull()) return jsEmptyString(exec); - UString s = v->toString(exec); + UString s = v.toString(exec); if (!s.is8Bit()) { setDOMException(exec, INVALID_CHARACTER_ERR); return jsUndefined(); @@ -262,7 +262,7 @@ JSValue* JSDOMWindow::btoa(ExecState* exec, const ArgList& args) return jsString(exec, String(out.data(), out.size())); } -JSValue* JSDOMWindow::addEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::addEventListener(ExecState* exec, const ArgList& args) { Frame* frame = impl()->frame(); if (!frame) @@ -270,13 +270,13 @@ JSValue* JSDOMWindow::addEventListener(ExecState* exec, const ArgList& args) if (RefPtr<JSEventListener> listener = findOrCreateJSEventListener(exec, args.at(exec, 1))) { if (Document* doc = frame->document()) - doc->addWindowEventListener(AtomicString(args.at(exec, 0)->toString(exec)), listener.release(), args.at(exec, 2)->toBoolean(exec)); + doc->addWindowEventListener(AtomicString(args.at(exec, 0).toString(exec)), listener.release(), args.at(exec, 2).toBoolean(exec)); } return jsUndefined(); } -JSValue* JSDOMWindow::removeEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSDOMWindow::removeEventListener(ExecState* exec, const ArgList& args) { Frame* frame = impl()->frame(); if (!frame) @@ -284,15 +284,15 @@ JSValue* JSDOMWindow::removeEventListener(ExecState* exec, const ArgList& args) if (JSEventListener* listener = findJSEventListener(args.at(exec, 1))) { if (Document* doc = frame->document()) - doc->removeWindowEventListener(AtomicString(args.at(exec, 0)->toString(exec)), listener, args.at(exec, 2)->toBoolean(exec)); + doc->removeWindowEventListener(AtomicString(args.at(exec, 0).toString(exec)), listener, args.at(exec, 2).toBoolean(exec)); } return jsUndefined(); } -DOMWindow* toDOMWindow(JSValue* value) +DOMWindow* toDOMWindow(JSValuePtr value) { - if (!value->isObject()) + if (!value.isObject()) return 0; JSObject* object = asObject(value); if (object->inherits(&JSDOMWindow::s_info)) @@ -302,22 +302,22 @@ DOMWindow* toDOMWindow(JSValue* value) return 0; } -JSValue* nonCachingStaticCloseFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr nonCachingStaticCloseFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 0, propertyName, jsDOMWindowPrototypeFunctionClose); } -JSValue* nonCachingStaticBlurFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr nonCachingStaticBlurFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 0, propertyName, jsDOMWindowPrototypeFunctionBlur); } -JSValue* nonCachingStaticFocusFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr nonCachingStaticFocusFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 0, propertyName, jsDOMWindowPrototypeFunctionFocus); } -JSValue* nonCachingStaticPostMessageFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr nonCachingStaticPostMessageFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 2, propertyName, jsDOMWindowPrototypeFunctionPostMessage); } diff --git a/WebCore/bindings/js/JSDOMWindowCustom.h b/WebCore/bindings/js/JSDOMWindowCustom.h index c8ce088..838abab 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.h +++ b/WebCore/bindings/js/JSDOMWindowCustom.h @@ -35,10 +35,10 @@ inline const JSDOMWindow* asJSDOMWindow(const JSC::JSGlobalObject* globalObject) return static_cast<const JSDOMWindow*>(globalObject); } -JSC::JSValue* nonCachingStaticCloseFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); -JSC::JSValue* nonCachingStaticBlurFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); -JSC::JSValue* nonCachingStaticFocusFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); -JSC::JSValue* nonCachingStaticPostMessageFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +JSC::JSValuePtr nonCachingStaticCloseFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +JSC::JSValuePtr nonCachingStaticBlurFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +JSC::JSValuePtr nonCachingStaticFocusFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); +JSC::JSValuePtr nonCachingStaticPostMessageFunctionGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); ALWAYS_INLINE bool JSDOMWindow::customGetOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) { @@ -123,7 +123,7 @@ ALWAYS_INLINE bool JSDOMWindow::customGetOwnPropertySlot(JSC::ExecState* exec, c return false; } -inline bool JSDOMWindow::customPut(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValue* value, JSC::PutPropertySlot& slot) +inline bool JSDOMWindow::customPut(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::JSValuePtr value, JSC::PutPropertySlot& slot) { if (!impl()->frame()) return true; diff --git a/WebCore/bindings/js/JSDOMWindowShell.cpp b/WebCore/bindings/js/JSDOMWindowShell.cpp index ee4a76f..d54611e 100644 --- a/WebCore/bindings/js/JSDOMWindowShell.cpp +++ b/WebCore/bindings/js/JSDOMWindowShell.cpp @@ -44,7 +44,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSDOMWindowShell) const ClassInfo JSDOMWindowShell::s_info = { "JSDOMWindowShell", 0, 0, 0 }; JSDOMWindowShell::JSDOMWindowShell(PassRefPtr<DOMWindow> window) - : Base(JSDOMWindowShell::createStructureID(jsNull())) + : Base(JSDOMWindowShell::createStructure(jsNull())) , m_window(0) { setWindow(window); @@ -56,8 +56,8 @@ JSDOMWindowShell::~JSDOMWindowShell() void JSDOMWindowShell::setWindow(PassRefPtr<DOMWindow> window) { - RefPtr<StructureID> prototypeStructure = JSDOMWindowPrototype::createStructureID(jsNull()); - RefPtr<StructureID> structure = JSDOMWindow::createStructureID(new JSDOMWindowPrototype(prototypeStructure.release())); + RefPtr<Structure> prototypeStructure = JSDOMWindowPrototype::createStructure(jsNull()); + RefPtr<Structure> structure = JSDOMWindow::createStructure(new JSDOMWindowPrototype(prototypeStructure.release())); setWindow(new (JSDOMWindow::commonJSGlobalData()) JSDOMWindow(structure.release(), window, this)); } @@ -82,12 +82,12 @@ bool JSDOMWindowShell::getOwnPropertySlot(ExecState* exec, const Identifier& pro return m_window->getOwnPropertySlot(exec, propertyName, slot); } -void JSDOMWindowShell::put(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot) +void JSDOMWindowShell::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) { m_window->put(exec, propertyName, value, slot); } -void JSDOMWindowShell::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue* value, unsigned attributes) +void JSDOMWindowShell::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValuePtr value, unsigned attributes) { m_window->putWithAttributes(exec, propertyName, value, attributes); } @@ -117,17 +117,17 @@ void JSDOMWindowShell::defineSetter(ExecState* exec, const Identifier& propertyN m_window->defineSetter(exec, propertyName, setterFunction); } -JSValue* JSDOMWindowShell::lookupGetter(ExecState* exec, const Identifier& propertyName) +JSValuePtr JSDOMWindowShell::lookupGetter(ExecState* exec, const Identifier& propertyName) { return m_window->lookupGetter(exec, propertyName); } -JSValue* JSDOMWindowShell::lookupSetter(ExecState* exec, const Identifier& propertyName) +JSValuePtr JSDOMWindowShell::lookupSetter(ExecState* exec, const Identifier& propertyName) { return m_window->lookupSetter(exec, propertyName); } -JSGlobalObject* JSDOMWindowShell::toGlobalObject(ExecState*) const +JSObject* JSDOMWindowShell::unwrappedObject() { return m_window; } @@ -160,7 +160,7 @@ void* JSDOMWindowShell::operator new(size_t size) // Conversion methods // ---- -JSValue* toJS(ExecState*, Frame* frame) +JSValuePtr toJS(ExecState*, Frame* frame) { if (!frame) return jsNull(); diff --git a/WebCore/bindings/js/JSDOMWindowShell.h b/WebCore/bindings/js/JSDOMWindowShell.h index 7cda4d4..931a256 100644 --- a/WebCore/bindings/js/JSDOMWindowShell.h +++ b/WebCore/bindings/js/JSDOMWindowShell.h @@ -60,31 +60,31 @@ namespace WebCore { void* operator new(size_t); - static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* prototype) + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValuePtr prototype) { - return JSC::StructureID::create(prototype, JSC::TypeInfo(JSC::ObjectType)); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); } private: virtual void mark(); virtual JSC::UString className() const; virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); - virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue*, JSC::PutPropertySlot&); - virtual void putWithAttributes(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue*, unsigned attributes); + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValuePtr, JSC::PutPropertySlot&); + virtual void putWithAttributes(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValuePtr, unsigned attributes); virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier& propertyName); virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); virtual bool getPropertyAttributes(JSC::ExecState*, const JSC::Identifier& propertyName, unsigned& attributes) const; virtual void defineGetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction); virtual void defineSetter(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction); - virtual JSC::JSValue* lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName); - virtual JSC::JSValue* lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName); - virtual JSC::JSGlobalObject* toGlobalObject(JSC::ExecState*) const; + virtual JSC::JSValuePtr lookupGetter(JSC::ExecState*, const JSC::Identifier& propertyName); + virtual JSC::JSValuePtr lookupSetter(JSC::ExecState*, const JSC::Identifier& propertyName); + virtual JSC::JSObject* unwrappedObject(); virtual const JSC::ClassInfo* classInfo() const { return &s_info; } JSDOMWindow* m_window; }; - JSC::JSValue* toJS(JSC::ExecState*, Frame*); + JSC::JSValuePtr toJS(JSC::ExecState*, Frame*); JSDOMWindowShell* toJSDOMWindowShell(Frame*); } // namespace WebCore diff --git a/WebCore/bindings/js/JSDatabaseCustom.cpp b/WebCore/bindings/js/JSDatabaseCustom.cpp index f17340c..9ee61a5 100644 --- a/WebCore/bindings/js/JSDatabaseCustom.cpp +++ b/WebCore/bindings/js/JSDatabaseCustom.cpp @@ -45,17 +45,17 @@ namespace WebCore { using namespace JSC; -JSValue* JSDatabase::changeVersion(ExecState* exec, const ArgList& args) +JSValuePtr JSDatabase::changeVersion(ExecState* exec, const ArgList& args) { - String oldVersion = args.at(exec, 0)->toString(exec); - String newVersion = args.at(exec, 1)->toString(exec); + String oldVersion = args.at(exec, 0).toString(exec); + String newVersion = args.at(exec, 1).toString(exec); Frame* frame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); if (!frame) return jsUndefined(); - JSObject *object; - if (!(object = args.at(exec, 2)->getObject())) { + JSObject* object; + if (!(object = args.at(exec, 2).getObject())) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } @@ -63,8 +63,8 @@ JSValue* JSDatabase::changeVersion(ExecState* exec, const ArgList& args) RefPtr<SQLTransactionCallback> callback(JSCustomSQLTransactionCallback::create(object, frame)); RefPtr<SQLTransactionErrorCallback> errorCallback; - if (!args.at(exec, 3)->isNull()) { - if (!(object = args.at(exec, 3)->getObject())) { + if (!args.at(exec, 3).isNull()) { + if (!(object = args.at(exec, 3).getObject())) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } @@ -73,7 +73,7 @@ JSValue* JSDatabase::changeVersion(ExecState* exec, const ArgList& args) } RefPtr<VoidCallback> successCallback; - if (!args.at(exec, 4)->isNull()) { + if (!args.at(exec, 4).isNull()) { successCallback = toVoidCallback(exec, args.at(exec, 4)); if (!successCallback) { setDOMException(exec, TYPE_MISMATCH_ERR); @@ -86,11 +86,11 @@ JSValue* JSDatabase::changeVersion(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSDatabase::transaction(ExecState* exec, const ArgList& args) +JSValuePtr JSDatabase::transaction(ExecState* exec, const ArgList& args) { JSObject* object; - if (!(object = args.at(exec, 0)->getObject())) { + if (!(object = args.at(exec, 0).getObject())) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } @@ -102,8 +102,8 @@ JSValue* JSDatabase::transaction(ExecState* exec, const ArgList& args) RefPtr<SQLTransactionCallback> callback(JSCustomSQLTransactionCallback::create(object, frame)); RefPtr<SQLTransactionErrorCallback> errorCallback; - if (args.size() > 1 && !args.at(exec, 1)->isNull()) { - if (!(object = args.at(exec, 1)->getObject())) { + if (args.size() > 1 && !args.at(exec, 1).isNull()) { + if (!(object = args.at(exec, 1).getObject())) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } @@ -112,7 +112,7 @@ JSValue* JSDatabase::transaction(ExecState* exec, const ArgList& args) } RefPtr<VoidCallback> successCallback; - if (args.size() > 2 && !args.at(exec, 2)->isNull()) { + if (args.size() > 2 && !args.at(exec, 2).isNull()) { successCallback = toVoidCallback(exec, args.at(exec, 2)); if (!successCallback) { setDOMException(exec, TYPE_MISMATCH_ERR); diff --git a/WebCore/bindings/js/JSDedicatedWorkerCustom.cpp b/WebCore/bindings/js/JSDedicatedWorkerCustom.cpp deleted file mode 100644 index d70f55a..0000000 --- a/WebCore/bindings/js/JSDedicatedWorkerCustom.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(WORKERS) - -#include "JSDedicatedWorker.h" - -#include "DedicatedWorker.h" -#include "Document.h" -#include "JSDOMWindowCustom.h" -#include "JSEventListener.h" -#include "JSMessagePort.h" -#include "MessagePort.h" - -using namespace JSC; - -namespace WebCore { - -void JSDedicatedWorker::mark() -{ - DOMObject::mark(); - - if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(m_impl->onMessageListener())) - listener->mark(); - - if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(m_impl->onCloseListener())) - listener->mark(); - - if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(m_impl->onErrorListener())) - listener->mark(); -} - -JSValue* JSDedicatedWorker::startConversation(ExecState* exec, const ArgList& args) -{ - DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); - const UString& message = args.at(exec, 0)->toString(exec); - - return toJS(exec, impl()->startConversation(window->document(), message).get()); -} - -void JSDedicatedWorker::setOnmessage(ExecState* exec, JSValue* value) -{ - Document* document = impl()->document(); - if (!document) - return; - JSDOMWindow* window = toJSDOMWindow(document->frame()); - if (!window) - return; - impl()->setOnMessageListener(window->findOrCreateJSUnprotectedEventListener(exec, value, true)); -} - -JSValue* JSDedicatedWorker::onmessage(ExecState*) const -{ - if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(impl()->onMessageListener())) - if (JSObject* listenerObj = listener->listenerObj()) - return listenerObj; - return jsNull(); -} - -void JSDedicatedWorker::setOnclose(ExecState* exec, JSValue* value) -{ - Document* document = impl()->document(); - if (!document) - return; - JSDOMWindow* window = toJSDOMWindow(document->frame()); - if (!window) - return; - impl()->setOnCloseListener(window->findOrCreateJSUnprotectedEventListener(exec, value, true)); -} - -JSValue* JSDedicatedWorker::onclose(ExecState*) const -{ - if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(impl()->onCloseListener())) - if (JSObject* listenerObj = listener->listenerObj()) - return listenerObj; - return jsNull(); -} - -void JSDedicatedWorker::setOnerror(ExecState* exec, JSValue* value) -{ - Document* document = impl()->document(); - if (!document) - return; - JSDOMWindow* window = toJSDOMWindow(document->frame()); - if (!window) - return; - impl()->setOnErrorListener(window->findOrCreateJSUnprotectedEventListener(exec, value, true)); -} - -JSValue* JSDedicatedWorker::onerror(ExecState*) const -{ - if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(impl()->onErrorListener())) - if (JSObject* listenerObj = listener->listenerObj()) - return listenerObj; - return jsNull(); -} - -} // namespace WebCore - -#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp index 661dbed..fff0ea5 100644 --- a/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/WebCore/bindings/js/JSDocumentCustom.cpp @@ -49,7 +49,7 @@ void JSDocument::mark() markActiveObjectsForContext(*Heap::heap(this)->globalData(), impl()); } -JSValue* JSDocument::location(ExecState* exec) const +JSValuePtr JSDocument::location(ExecState* exec) const { Frame* frame = static_cast<Document*>(impl())->frame(); if (!frame) @@ -58,13 +58,13 @@ JSValue* JSDocument::location(ExecState* exec) const return toJS(exec, frame->domWindow()->location()); } -void JSDocument::setLocation(ExecState* exec, JSValue* value) +void JSDocument::setLocation(ExecState* exec, JSValuePtr value) { Frame* frame = static_cast<Document*>(impl())->frame(); if (!frame) return; - String str = value->toString(exec); + String str = value.toString(exec); // IE and Mozilla both resolve the URL relative to the source frame, // not the target frame. @@ -73,10 +73,10 @@ void JSDocument::setLocation(ExecState* exec, JSValue* value) str = activeFrame->document()->completeURL(str).string(); bool userGesture = activeFrame->script()->processingUserGesture(); - frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), false, userGesture); + frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); } -JSValue* toJS(ExecState* exec, Document* document) +JSValuePtr toJS(ExecState* exec, Document* document) { if (!document) return jsNull(); diff --git a/WebCore/bindings/js/JSElementCustom.cpp b/WebCore/bindings/js/JSElementCustom.cpp index 22480a2..f5ef4be 100644 --- a/WebCore/bindings/js/JSElementCustom.cpp +++ b/WebCore/bindings/js/JSElementCustom.cpp @@ -61,11 +61,11 @@ static inline bool allowSettingSrcToJavascriptURL(ExecState* exec, Element* elem return true; } -JSValue* JSElement::setAttribute(ExecState* exec, const ArgList& args) +JSValuePtr JSElement::setAttribute(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; - AtomicString name = args.at(exec, 0)->toString(exec); - AtomicString value = args.at(exec, 1)->toString(exec); + AtomicString name = args.at(exec, 0).toString(exec); + AtomicString value = args.at(exec, 1).toString(exec); Element* imp = impl(); if (!allowSettingSrcToJavascriptURL(exec, imp, name, value)) @@ -76,7 +76,7 @@ JSValue* JSElement::setAttribute(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSElement::setAttributeNode(ExecState* exec, const ArgList& args) +JSValuePtr JSElement::setAttributeNode(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; Attr* newAttr = toAttr(args.at(exec, 0)); @@ -89,17 +89,17 @@ 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))); + JSValuePtr result = toJS(exec, WTF::getPtr(imp->setAttributeNode(newAttr, ec))); setDOMException(exec, ec); return result; } -JSValue* JSElement::setAttributeNS(ExecState* exec, const ArgList& args) +JSValuePtr JSElement::setAttributeNS(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; AtomicString namespaceURI = valueToStringWithNullCheck(exec, args.at(exec, 0)); - AtomicString qualifiedName = args.at(exec, 1)->toString(exec); - AtomicString value = args.at(exec, 2)->toString(exec); + AtomicString qualifiedName = args.at(exec, 1).toString(exec); + AtomicString value = args.at(exec, 2).toString(exec); Element* imp = impl(); if (!allowSettingSrcToJavascriptURL(exec, imp, qualifiedName, value)) @@ -110,7 +110,7 @@ JSValue* JSElement::setAttributeNS(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSElement::setAttributeNodeNS(ExecState* exec, const ArgList& args) +JSValuePtr JSElement::setAttributeNodeNS(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; Attr* newAttr = toAttr(args.at(exec, 0)); @@ -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))); + JSValuePtr result = toJS(exec, WTF::getPtr(imp->setAttributeNodeNS(newAttr, ec))); setDOMException(exec, ec); return result; } -JSValue* toJSNewlyCreated(ExecState* exec, Element* element) +JSValuePtr toJSNewlyCreated(ExecState* exec, Element* element) { if (!element) return jsNull(); diff --git a/WebCore/bindings/js/JSEventCustom.cpp b/WebCore/bindings/js/JSEventCustom.cpp index 9c7d7a0..613e46d 100644 --- a/WebCore/bindings/js/JSEventCustom.cpp +++ b/WebCore/bindings/js/JSEventCustom.cpp @@ -77,12 +77,12 @@ using namespace JSC; namespace WebCore { -JSValue* JSEvent::clipboardData(ExecState* exec) const +JSValuePtr JSEvent::clipboardData(ExecState* exec) const { return impl()->isClipboardEvent() ? toJS(exec, impl()->clipboardData()) : jsUndefined(); } -JSValue* toJS(ExecState* exec, Event* event) +JSValuePtr toJS(ExecState* exec, Event* event) { JSLock lock(false); diff --git a/WebCore/bindings/js/JSEventListener.cpp b/WebCore/bindings/js/JSEventListener.cpp index e72af16..4eb00fa 100644 --- a/WebCore/bindings/js/JSEventListener.cpp +++ b/WebCore/bindings/js/JSEventListener.cpp @@ -61,10 +61,9 @@ void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent) if (!scriptExecutionContext) return; - Frame* frame = 0; if (scriptExecutionContext->isDocument()) { JSDOMWindow* window = static_cast<JSDOMWindow*>(globalObject); - frame = window->impl()->frame(); + Frame* frame = window->impl()->frame(); if (!frame) return; // The window must still be active in its frame. See <https://bugs.webkit.org/show_bug.cgi?id=21921>. @@ -79,9 +78,9 @@ void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent) ExecState* exec = globalObject->globalExec(); - JSValue* handleEventFunction = listener->get(exec, Identifier(exec, "handleEvent")); + JSValuePtr handleEventFunction = listener->get(exec, Identifier(exec, "handleEvent")); CallData callData; - CallType callType = handleEventFunction->getCallData(callData); + CallType callType = handleEventFunction.getCallData(callData); if (callType == CallTypeNone) { handleEventFunction = noValue(); callType = listener->getCallData(callData); @@ -96,12 +95,18 @@ void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent) Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); - JSValue* retval; + // 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); + + JSValuePtr retval; if (handleEventFunction) { globalObject->startTimeoutCheck(); retval = call(exec, handleEventFunction, callType, callData, listener, args); } else { - JSValue* thisValue; + JSValuePtr thisValue; if (isWindowEvent) thisValue = globalObject->toThisObject(exec); else @@ -113,21 +118,20 @@ void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent) globalObject->setCurrentEvent(savedEvent); - if (exec->hadException()) { - // FIXME: Report exceptions in non-Document contexts. - if (frame) - frame->domWindow()->console()->reportCurrentException(exec); - } else { - if (!retval->isUndefinedOrNull() && event->storesResultAsString()) - event->storeResult(retval->toString(exec)); + if (exec->hadException()) + reportCurrentException(exec); + else { + if (!retval.isUndefinedOrNull() && event->storesResultAsString()) + event->storeResult(retval.toString(exec)); if (m_isInline) { bool retvalbool; - if (retval->getBoolean(retvalbool) && !retvalbool) + if (retval.getBoolean(retvalbool) && !retvalbool) event->preventDefault(); } } - Document::updateDocumentsRendering(); + if (scriptExecutionContext->isDocument()) + Document::updateDocumentsRendering(); deref(); } } @@ -259,7 +263,7 @@ JSObject* JSLazyEventListener::listenerObj() const } // Helper function -inline JSValue* eventParameterName(JSLazyEventListener::LazyEventListenerType type, ExecState* exec) +inline JSValuePtr eventParameterName(JSLazyEventListener::LazyEventListenerType type, ExecState* exec) { switch (type) { case JSLazyEventListener::HTMLLazyEventListener: @@ -279,10 +283,9 @@ void JSLazyEventListener::parseCode() const if (m_parsed) return; - Frame* frame = 0; if (globalObject()->scriptExecutionContext()->isDocument()) { JSDOMWindow* window = static_cast<JSDOMWindow*>(globalObject()); - frame = window->impl()->frame(); + Frame* frame = window->impl()->frame(); if (!frame) return; // FIXME: Is this check needed for non-Document contexts? @@ -316,8 +319,8 @@ void JSLazyEventListener::parseCode() const // (and the document, and the form - see JSHTMLElement::eventHandlerScope) ScopeChain scope = listenerAsFunction->scope(); - JSValue* thisObj = toJS(exec, m_originalNode); - if (thisObj->isObject()) { + JSValuePtr thisObj = toJS(exec, m_originalNode); + if (thisObj.isObject()) { static_cast<JSEventTargetNode*>(asObject(thisObj))->pushEventHandlerScope(exec, scope); listenerAsFunction->setScope(scope); } diff --git a/WebCore/bindings/js/JSEventListener.h b/WebCore/bindings/js/JSEventListener.h index 3c9edd0..859d5d4 100644 --- a/WebCore/bindings/js/JSEventListener.h +++ b/WebCore/bindings/js/JSEventListener.h @@ -22,7 +22,7 @@ #include "EventListener.h" #include "PlatformString.h" -#include <kjs/protect.h> +#include <runtime/Protect.h> namespace WebCore { diff --git a/WebCore/bindings/js/JSEventTarget.cpp b/WebCore/bindings/js/JSEventTarget.cpp index 185756d..fb72ce7 100644 --- a/WebCore/bindings/js/JSEventTarget.cpp +++ b/WebCore/bindings/js/JSEventTarget.cpp @@ -30,7 +30,15 @@ #include "JSEventListener.h" #include "JSEventTargetNode.h" #include "JSMessagePort.h" +#ifdef ANDROID_FIX // these are generated files, need to check ENABLE(WORKERS) +#if ENABLE(WORKERS) +#include "JSWorker.h" +#include "JSWorkerContext.h" +#endif +#endif #include "JSXMLHttpRequestUpload.h" +#include "Worker.h" +#include "WorkerContext.h" #if ENABLE(SVG) #include "SVGElementInstance.h" @@ -41,7 +49,7 @@ using namespace JSC; namespace WebCore { -JSValue* toJS(ExecState* exec, EventTarget* target) +JSValuePtr toJS(ExecState* exec, EventTarget* target) { if (!target) return jsNull(); @@ -70,7 +78,15 @@ JSValue* toJS(ExecState* exec, EventTarget* target) if (MessagePort* messagePort = target->toMessagePort()) return toJS(exec, messagePort); - + +#if ENABLE(WORKERS) + if (Worker* worker = target->toWorker()) + return toJS(exec, worker); + + if (WorkerContext* workerContext = target->toWorkerContext()) + return toJSDOMGlobalObject(workerContext); +#endif + ASSERT_NOT_REACHED(); return jsNull(); } diff --git a/WebCore/bindings/js/JSEventTarget.h b/WebCore/bindings/js/JSEventTarget.h index 1ee854f..00dd848 100644 --- a/WebCore/bindings/js/JSEventTarget.h +++ b/WebCore/bindings/js/JSEventTarget.h @@ -36,7 +36,7 @@ namespace WebCore { class EventTarget; - JSC::JSValue* toJS(JSC::ExecState*, EventTarget*); + JSC::JSValuePtr toJS(JSC::ExecState*, EventTarget*); } // namespace WebCore diff --git a/WebCore/bindings/js/JSEventTargetBase.h b/WebCore/bindings/js/JSEventTargetBase.h index e1395d3..b841ee9 100644 --- a/WebCore/bindings/js/JSEventTargetBase.h +++ b/WebCore/bindings/js/JSEventTargetBase.h @@ -80,13 +80,13 @@ /* #endif */ \ #define EVENT_LISTENER_GETTER(specificEventTarget, name, event) \ -JSC::JSValue* js##specificEventTarget##name(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot& slot) \ +JSC::JSValuePtr js##specificEventTarget##name(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot& slot) \ { \ return static_cast<JS##specificEventTarget*>(slot.slotBase())->getListener(event); \ } \ #define EVENT_LISTENER_SETTER(specificEventTarget, name, event) \ -void setJS##specificEventTarget##name(JSC::ExecState* exec, JSC::JSObject* baseObject, JSC::JSValue* value) \ +void setJS##specificEventTarget##name(JSC::ExecState* exec, JSC::JSObject* baseObject, JSC::JSValuePtr value) \ { \ static_cast<JS##specificEventTarget*>(baseObject)->setListener(exec, event, value); \ } \ diff --git a/WebCore/bindings/js/JSEventTargetNodeCustom.cpp b/WebCore/bindings/js/JSEventTargetNodeCustom.cpp index 7e80f70..3193272 100644 --- a/WebCore/bindings/js/JSEventTargetNodeCustom.cpp +++ b/WebCore/bindings/js/JSEventTargetNodeCustom.cpp @@ -40,26 +40,26 @@ using namespace JSC; namespace WebCore { -JSValue* JSEventTargetNode::addEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSEventTargetNode::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); if (RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(exec, args.at(exec, 1))) - impl()->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec)); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } -JSValue* JSEventTargetNode::removeEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSEventTargetNode::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); if (JSEventListener* listener = globalObject->findJSEventListener(args.at(exec, 1))) - impl()->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSGeolocationCustom.cpp b/WebCore/bindings/js/JSGeolocationCustom.cpp index 9c11172..1b9bce8 100644 --- a/WebCore/bindings/js/JSGeolocationCustom.cpp +++ b/WebCore/bindings/js/JSGeolocationCustom.cpp @@ -33,17 +33,41 @@ #include "JSCustomPositionCallback.h" #include "JSCustomPositionErrorCallback.h" #include "JSDOMWindow.h" -#include "JSPositionOptions.h" +#include "PositionOptions.h" using namespace JSC; namespace WebCore { -JSValue* JSGeolocation::getCurrentPosition(ExecState* exec, const ArgList& args) +static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValuePtr value) +{ + if (!value.isObject()) + return 0; + + JSObject* object = asObject(value); + + JSValuePtr enableHighAccuracyValue = object->get(exec, Identifier(exec, "enableHighAccuracy")); + if (exec->hadException()) + return 0; + bool enableHighAccuracy = enableHighAccuracyValue.toBoolean(exec); + if (exec->hadException()) + return 0; + + JSValuePtr timeoutValue = object->get(exec, Identifier(exec, "timeout")); + if (exec->hadException()) + return 0; + unsigned timeout = timeoutValue.toUInt32(exec); + if (exec->hadException()) + return 0; + + return PositionOptions::create(enableHighAccuracy, timeout); +} + +JSValuePtr JSGeolocation::getCurrentPosition(ExecState* exec, const ArgList& args) { // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions RefPtr<PositionCallback> positionCallback; - JSObject* object = args.at(exec, 0)->getObject(); + JSObject* object = args.at(exec, 0).getObject(); if (exec->hadException()) return jsUndefined(); if (!object) { @@ -55,8 +79,8 @@ JSValue* JSGeolocation::getCurrentPosition(ExecState* exec, const ArgList& args) positionCallback = JSCustomPositionCallback::create(object, frame); RefPtr<PositionErrorCallback> positionErrorCallback; - if (!args.at(exec, 1)->isUndefinedOrNull()) { - JSObject* object = args.at(exec, 1)->getObject(); + if (!args.at(exec, 1).isUndefinedOrNull()) { + JSObject* object = args.at(exec, 1).getObject(); if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -67,19 +91,22 @@ JSValue* JSGeolocation::getCurrentPosition(ExecState* exec, const ArgList& args) } RefPtr<PositionOptions> positionOptions; - if (!args.at(exec, 2)->isUndefinedOrNull()) - positionOptions = toPositionOptions(args.at(exec, 2)); - + if (!args.at(exec, 2).isUndefinedOrNull()) { + positionOptions = createPositionOptions(exec, args.at(exec, 2)); + if (exec->hadException()) + return jsUndefined(); + } + m_impl->getCurrentPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.get()); return jsUndefined(); } -JSValue* JSGeolocation::watchPosition(ExecState* exec, const ArgList& args) +JSValuePtr JSGeolocation::watchPosition(ExecState* exec, const ArgList& args) { // Arguments: PositionCallback, (optional)PositionErrorCallback, (optional)PositionOptions RefPtr<PositionCallback> positionCallback; - JSObject* object = args.at(exec, 0)->getObject(); + JSObject* object = args.at(exec, 0).getObject(); if (exec->hadException()) return jsUndefined(); if (!object) { @@ -91,8 +118,8 @@ JSValue* JSGeolocation::watchPosition(ExecState* exec, const ArgList& args) positionCallback = JSCustomPositionCallback::create(object, frame); RefPtr<PositionErrorCallback> positionErrorCallback; - if (!args.at(exec, 1)->isUndefinedOrNull()) { - JSObject* object = args.at(exec, 1)->getObject(); + if (!args.at(exec, 1).isUndefinedOrNull()) { + JSObject* object = args.at(exec, 1).getObject(); if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -103,9 +130,12 @@ JSValue* JSGeolocation::watchPosition(ExecState* exec, const ArgList& args) } RefPtr<PositionOptions> positionOptions; - if (!args.at(exec, 2)->isUndefinedOrNull()) - positionOptions = toPositionOptions(args.at(exec, 2)); - + if (!args.at(exec, 2).isUndefinedOrNull()) { + positionOptions = createPositionOptions(exec, args.at(exec, 2)); + if (exec->hadException()) + return jsUndefined(); + } + int watchID = m_impl->watchPosition(positionCallback.release(), positionErrorCallback.release(), positionOptions.get()); return jsNumber(exec, watchID); } diff --git a/WebCore/bindings/js/JSHTMLAllCollection.h b/WebCore/bindings/js/JSHTMLAllCollection.h index f85c997..511c9d7 100644 --- a/WebCore/bindings/js/JSHTMLAllCollection.h +++ b/WebCore/bindings/js/JSHTMLAllCollection.h @@ -35,14 +35,14 @@ namespace WebCore { class JSHTMLAllCollection : public JSHTMLCollection { public: - JSHTMLAllCollection(PassRefPtr<JSC::StructureID> structure, PassRefPtr<HTMLCollection> collection) + JSHTMLAllCollection(PassRefPtr<JSC::Structure> structure, PassRefPtr<HTMLCollection> collection) : JSHTMLCollection(structure, collection) { } - static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* proto) + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValuePtr proto) { - return JSC::StructureID::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::MasqueradesAsUndefined)); + return JSC::Structure::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::MasqueradesAsUndefined)); } static const JSC::ClassInfo s_info; diff --git a/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp b/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp index ca9e08e..a99a36d 100644 --- a/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp @@ -38,7 +38,7 @@ bool JSHTMLAppletElement::customGetOwnPropertySlot(ExecState* exec, const Identi return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this); } -bool JSHTMLAppletElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot) +bool JSHTMLAppletElement::customPut(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) { return runtimeObjectCustomPut(exec, propertyName, value, impl(), slot); } @@ -53,7 +53,7 @@ bool JSHTMLAppletElement::canGetItemsForName(ExecState*, HTMLAppletElement*, con return propertyName == "__apple_runtime_object"; } -JSValue* JSHTMLAppletElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSHTMLAppletElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { return runtimeObjectGetter(exec, propertyName, slot); } diff --git a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp index 3e98194..e9f12bf 100644 --- a/WebCore/bindings/js/JSHTMLCollectionCustom.cpp +++ b/WebCore/bindings/js/JSHTMLCollectionCustom.cpp @@ -35,7 +35,7 @@ using namespace JSC; namespace WebCore { -static JSValue* getNamedItems(ExecState* exec, HTMLCollection* impl, const Identifier& propertyName) +static JSValuePtr getNamedItems(ExecState* exec, HTMLCollection* impl, const Identifier& propertyName) { Vector<RefPtr<Node> > namedItems; impl->namedItems(propertyName, namedItems); @@ -51,7 +51,7 @@ static JSValue* getNamedItems(ExecState* exec, HTMLCollection* impl, const Ident // HTMLCollections are strange objects, they support both get and call, // so that document.forms.item(0) and document.forms(0) both work. -static JSValue* callHTMLCollection(ExecState* exec, JSObject* function, JSValue*, const ArgList& args) +static JSValuePtr callHTMLCollection(ExecState* exec, JSObject* function, JSValuePtr, const ArgList& args) { if (args.size() < 1) return jsUndefined(); @@ -64,7 +64,7 @@ static JSValue* callHTMLCollection(ExecState* exec, JSObject* function, JSValue* if (args.size() == 1) { // Support for document.all(<index>) etc. bool ok; - UString string = args.at(exec, 0)->toString(exec); + UString string = args.at(exec, 0).toString(exec); unsigned index = string.toUInt32(&ok, false); if (ok) return toJS(exec, collection->item(index)); @@ -75,8 +75,8 @@ static JSValue* callHTMLCollection(ExecState* exec, JSObject* function, JSValue* // The second arg, if set, is the index of the item we want bool ok; - UString string = args.at(exec, 0)->toString(exec); - unsigned index = args.at(exec, 1)->toString(exec).toUInt32(&ok, false); + UString string = args.at(exec, 0).toString(exec); + unsigned index = args.at(exec, 1).toString(exec).toUInt32(&ok, false); if (ok) { String pstr = string; Node* node = collection->namedItem(pstr); @@ -99,30 +99,30 @@ CallType JSHTMLCollection::getCallData(CallData& callData) bool JSHTMLCollection::canGetItemsForName(ExecState* exec, HTMLCollection* thisObj, const Identifier& propertyName) { - return !getNamedItems(exec, thisObj, propertyName)->isUndefined(); + return !getNamedItems(exec, thisObj, propertyName).isUndefined(); } -JSValue* JSHTMLCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSHTMLCollection::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slot.slotBase())); return getNamedItems(exec, thisObj->impl(), propertyName); } -JSValue* JSHTMLCollection::item(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLCollection::item(ExecState* exec, const ArgList& args) { bool ok; - uint32_t index = args.at(exec, 0)->toString(exec).toUInt32(&ok, false); + uint32_t index = args.at(exec, 0).toString(exec).toUInt32(&ok, false); if (ok) return toJS(exec, impl()->item(index)); - return getNamedItems(exec, impl(), Identifier(exec, args.at(exec, 0)->toString(exec))); + return getNamedItems(exec, impl(), Identifier(exec, args.at(exec, 0).toString(exec))); } -JSValue* JSHTMLCollection::namedItem(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLCollection::namedItem(ExecState* exec, const ArgList& args) { - return getNamedItems(exec, impl(), Identifier(exec, args.at(exec, 0)->toString(exec))); + return getNamedItems(exec, impl(), Identifier(exec, args.at(exec, 0).toString(exec))); } -JSValue* toJS(ExecState* exec, HTMLCollection* collection) +JSValuePtr toJS(ExecState* exec, HTMLCollection* collection) { if (!collection) return jsNull(); diff --git a/WebCore/bindings/js/JSHTMLDocumentCustom.cpp b/WebCore/bindings/js/JSHTMLDocumentCustom.cpp index be57a3d..be2d158 100644 --- a/WebCore/bindings/js/JSHTMLDocumentCustom.cpp +++ b/WebCore/bindings/js/JSHTMLDocumentCustom.cpp @@ -51,7 +51,7 @@ bool JSHTMLDocument::canGetItemsForName(ExecState*, HTMLDocument* document, cons return atomicPropertyName && (document->hasNamedItem(atomicPropertyName) || document->hasExtraNamedItem(atomicPropertyName)); } -JSValue* JSHTMLDocument::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSHTMLDocument::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSHTMLDocument* thisObj = static_cast<JSHTMLDocument*>(asObject(slot.slotBase())); HTMLDocument* document = static_cast<HTMLDocument*>(thisObj->impl()); @@ -78,16 +78,17 @@ JSValue* JSHTMLDocument::nameGetter(ExecState* exec, const Identifier& propertyN // Custom attributes -JSValue* JSHTMLDocument::all(ExecState* exec) const +JSValuePtr JSHTMLDocument::all(ExecState* exec) const { // If "all" has been overwritten, return the overwritten value - if (JSValue* v = getDirect(Identifier(exec, "all"))) + JSValuePtr v = getDirect(Identifier(exec, "all")); + if (v) return v; return toJS(exec, static_cast<HTMLDocument*>(impl())->all().get()); } -void JSHTMLDocument::setAll(ExecState* exec, JSValue* value) +void JSHTMLDocument::setAll(ExecState* exec, JSValuePtr value) { // Add "all" to the property map. putDirect(Identifier(exec, "all"), value); @@ -95,7 +96,7 @@ void JSHTMLDocument::setAll(ExecState* exec, JSValue* value) // Custom functions -JSValue* JSHTMLDocument::open(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLDocument::open(ExecState* exec, const ArgList& args) { // For compatibility with other browsers, pass open calls with more than 2 parameters to the window. if (args.size() > 2) { @@ -103,9 +104,9 @@ JSValue* JSHTMLDocument::open(ExecState* exec, const ArgList& args) if (frame) { JSDOMWindowShell* wrapper = toJSDOMWindowShell(frame); if (wrapper) { - JSValue* function = wrapper->get(exec, Identifier(exec, "open")); + JSValuePtr function = wrapper->get(exec, Identifier(exec, "open")); CallData callData; - CallType callType = function->getCallData(callData); + CallType callType = function.getCallData(callData); if (callType == CallTypeNone) return throwError(exec, TypeError); return call(exec, function, callType, callData, wrapper, args); @@ -120,7 +121,7 @@ JSValue* JSHTMLDocument::open(ExecState* exec, const ArgList& args) // In the case of two parameters or fewer, do a normal document open. static_cast<HTMLDocument*>(impl())->open(activeDocument); - return jsUndefined(); + return this; } static String writeHelper(ExecState* exec, const ArgList& args) @@ -130,22 +131,22 @@ static String writeHelper(ExecState* exec, const ArgList& args) unsigned size = args.size(); if (size == 1) - return args.at(exec, 0)->toString(exec); + return args.at(exec, 0).toString(exec); Vector<UChar> result; for (unsigned i = 0; i < size; ++i) - append(result, args.at(exec, i)->toString(exec)); + append(result, args.at(exec, i).toString(exec)); return String::adopt(result); } -JSValue* JSHTMLDocument::write(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLDocument::write(ExecState* exec, const ArgList& args) { Document* activeDocument = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->document(); static_cast<HTMLDocument*>(impl())->write(writeHelper(exec, args), activeDocument); return jsUndefined(); } -JSValue* JSHTMLDocument::writeln(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLDocument::writeln(ExecState* exec, const ArgList& args) { Document* activeDocument = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->document(); static_cast<HTMLDocument*>(impl())->write(writeHelper(exec, args) + "\n", activeDocument); diff --git a/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp b/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp index ae9ebf6..2856393 100644 --- a/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp @@ -38,7 +38,7 @@ bool JSHTMLEmbedElement::customGetOwnPropertySlot(ExecState* exec, const Identif return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this); } -bool JSHTMLEmbedElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot) +bool JSHTMLEmbedElement::customPut(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) { return runtimeObjectCustomPut(exec, propertyName, value, impl(), slot); } @@ -53,7 +53,7 @@ bool JSHTMLEmbedElement::canGetItemsForName(ExecState*, HTMLEmbedElement*, const return propertyName == "__apple_runtime_object"; } -JSValue* JSHTMLEmbedElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSHTMLEmbedElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { return runtimeObjectGetter(exec, propertyName, slot); } diff --git a/WebCore/bindings/js/JSHTMLFormElementCustom.cpp b/WebCore/bindings/js/JSHTMLFormElementCustom.cpp index 196cb6d..68b727b 100644 --- a/WebCore/bindings/js/JSHTMLFormElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLFormElementCustom.cpp @@ -26,22 +26,24 @@ #include "config.h" #include "JSHTMLFormElement.h" +#include "Frame.h" #include "HTMLCollection.h" #include "HTMLFormElement.h" +#include "JSDOMWindowCustom.h" #include "JSNamedNodesCollection.h" using namespace JSC; namespace WebCore { -bool JSHTMLFormElement::canGetItemsForName(ExecState* exec, HTMLFormElement* form, const Identifier& propertyName) +bool JSHTMLFormElement::canGetItemsForName(ExecState*, HTMLFormElement* form, const Identifier& propertyName) { Vector<RefPtr<Node> > namedItems; form->getNamedElements(propertyName, namedItems); return namedItems.size(); } -JSValue* JSHTMLFormElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSHTMLFormElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { HTMLFormElement* form = static_cast<HTMLFormElement*>(static_cast<JSHTMLElement*>(asObject(slot.slotBase()))->impl()); @@ -55,4 +57,13 @@ JSValue* JSHTMLFormElement::nameGetter(ExecState* exec, const Identifier& proper return jsUndefined(); } +JSValuePtr JSHTMLFormElement::submit(ExecState* exec, const ArgList&) +{ + Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); + if (!activeFrame) + return jsUndefined(); + static_cast<HTMLFormElement*>(impl())->submit(0, false, !activeFrame->script()->anyPageIsProcessingUserGesture(), false); + return jsUndefined(); +} + } diff --git a/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp b/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp index 594349a..a97a72a 100644 --- a/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLFrameElementCustom.cpp @@ -47,7 +47,7 @@ static inline bool allowSettingJavascriptURL(ExecState* exec, HTMLFrameElement* return true; } -void JSHTMLFrameElement::setSrc(ExecState* exec, JSValue* value) +void JSHTMLFrameElement::setSrc(ExecState* exec, JSValuePtr value) { HTMLFrameElement* imp = static_cast<HTMLFrameElement*>(impl()); String srcValue = valueToStringWithNullCheck(exec, value); @@ -59,7 +59,7 @@ void JSHTMLFrameElement::setSrc(ExecState* exec, JSValue* value) return; } -void JSHTMLFrameElement::setLocation(ExecState* exec, JSValue* value) +void JSHTMLFrameElement::setLocation(ExecState* exec, JSValuePtr value) { HTMLFrameElement* imp = static_cast<HTMLFrameElement*>(impl()); String locationValue = valueToStringWithNullCheck(exec, value); diff --git a/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp b/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp index 126ad8b..f17cb89 100644 --- a/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLFrameSetElementCustom.cpp @@ -46,7 +46,7 @@ bool JSHTMLFrameSetElement::canGetItemsForName(ExecState*, HTMLFrameSetElement* return frame && frame->hasTagName(frameTag); } -JSValue* JSHTMLFrameSetElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSHTMLFrameSetElement::nameGetter(ExecState*, const Identifier& propertyName, const PropertySlot& slot) { JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slot.slotBase())); HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl()); diff --git a/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp b/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp index 3f27462..1a0fc1c 100644 --- a/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLIFrameElementCustom.cpp @@ -38,7 +38,7 @@ using namespace JSC; namespace WebCore { -void JSHTMLIFrameElement::setSrc(ExecState* exec, JSValue* value) +void JSHTMLIFrameElement::setSrc(ExecState* exec, JSValuePtr value) { HTMLIFrameElement* imp = static_cast<HTMLIFrameElement*>(impl()); diff --git a/WebCore/bindings/js/JSHTMLInputElementCustom.cpp b/WebCore/bindings/js/JSHTMLInputElementCustom.cpp index f097e1e..d59ef92 100644 --- a/WebCore/bindings/js/JSHTMLInputElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLInputElementCustom.cpp @@ -51,7 +51,7 @@ bool JSHTMLInputElement::customGetOwnPropertySlot(ExecState* exec, const Identif return false; } -JSValue* JSHTMLInputElement::selectionStart(ExecState* exec) const +JSValuePtr JSHTMLInputElement::selectionStart(ExecState* exec) const { HTMLInputElement* input = static_cast<HTMLInputElement*>(impl()); if (!input->canHaveSelection()) @@ -60,7 +60,7 @@ JSValue* JSHTMLInputElement::selectionStart(ExecState* exec) const return jsNumber(exec, input->selectionStart()); } -JSValue* JSHTMLInputElement::selectionEnd(ExecState* exec) const +JSValuePtr JSHTMLInputElement::selectionEnd(ExecState* exec) const { HTMLInputElement* input = static_cast<HTMLInputElement*>(impl()); if (!input->canHaveSelection()) diff --git a/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp b/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp index 9208af0..5ad3454 100644 --- a/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp @@ -38,7 +38,7 @@ bool JSHTMLObjectElement::customGetOwnPropertySlot(ExecState* exec, const Identi return runtimeObjectCustomGetOwnPropertySlot(exec, propertyName, slot, this); } -bool JSHTMLObjectElement::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot) +bool JSHTMLObjectElement::customPut(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) { return runtimeObjectCustomPut(exec, propertyName, value, impl(), slot); } @@ -53,7 +53,7 @@ bool JSHTMLObjectElement::canGetItemsForName(ExecState*, HTMLObjectElement*, con return propertyName == "__apple_runtime_object"; } -JSValue* JSHTMLObjectElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSHTMLObjectElement::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { return runtimeObjectGetter(exec, propertyName, slot); } diff --git a/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp b/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp index 2b3c04e..b6e53de 100644 --- a/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp +++ b/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp @@ -35,18 +35,18 @@ using namespace JSC; namespace WebCore { -JSValue* JSHTMLOptionsCollection::length(ExecState* exec) const +JSValuePtr JSHTMLOptionsCollection::length(ExecState* exec) const { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); return jsNumber(exec, imp->length()); } -void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue* value) +void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValuePtr value) { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); ExceptionCode ec = 0; unsigned newLength = 0; - double lengthValue = value->toNumber(exec); + double lengthValue = value.toNumber(exec); if (!isnan(lengthValue) && !isinf(lengthValue)) { if (lengthValue < 0.0) ec = INDEX_SIZE_ERR; @@ -60,14 +60,14 @@ void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue* value) setDOMException(exec, ec); } -void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue* value) +void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValuePtr value) { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base()); selectIndexSetter(base, exec, index, value); } -JSValue* JSHTMLOptionsCollection::add(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLOptionsCollection::add(ExecState* exec, const ArgList& args) { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); HTMLOptionElement* option = toHTMLOptionElement(args.at(exec, 0)); @@ -76,7 +76,7 @@ JSValue* JSHTMLOptionsCollection::add(ExecState* exec, const ArgList& args) imp->add(option, ec); else { bool ok; - int index = args.at(exec, 1)->toInt32(exec, ok); + int index = args.at(exec, 1).toInt32(exec, ok); if (exec->hadException()) return jsUndefined(); if (!ok) @@ -88,7 +88,7 @@ JSValue* JSHTMLOptionsCollection::add(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSHTMLOptionsCollection::remove(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLOptionsCollection::remove(ExecState* exec, const ArgList& args) { HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl()); JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(asObject(toJS(exec, imp->base()))); diff --git a/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp b/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp index 06789ac..755aec5 100644 --- a/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp @@ -32,7 +32,7 @@ namespace WebCore { using namespace JSC; using namespace HTMLNames; -JSValue* JSHTMLSelectElement::remove(ExecState* exec, const ArgList& args) +JSValuePtr JSHTMLSelectElement::remove(ExecState* exec, const ArgList& args) { HTMLSelectElement& select = *static_cast<HTMLSelectElement*>(impl()); @@ -41,14 +41,14 @@ JSValue* JSHTMLSelectElement::remove(ExecState* exec, const ArgList& args) if (element && element->hasTagName(optionTag)) select.remove(static_cast<HTMLOptionElement*>(element)->index()); else - select.remove(args.at(exec, 0)->toInt32(exec)); + select.remove(args.at(exec, 0).toInt32(exec)); return jsUndefined(); } -void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValue* value) +void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValuePtr value) { - if (value->isUndefinedOrNull()) + if (value.isUndefinedOrNull()) select->remove(index); else { ExceptionCode ec = 0; @@ -61,7 +61,7 @@ void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned } } -void JSHTMLSelectElement::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue* value) +void JSHTMLSelectElement::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValuePtr value) { selectIndexSetter(static_cast<HTMLSelectElement*>(impl()), exec, index, value); } diff --git a/WebCore/bindings/js/JSHTMLSelectElementCustom.h b/WebCore/bindings/js/JSHTMLSelectElementCustom.h index de32c72..87344b5 100644 --- a/WebCore/bindings/js/JSHTMLSelectElementCustom.h +++ b/WebCore/bindings/js/JSHTMLSelectElementCustom.h @@ -33,7 +33,7 @@ namespace WebCore { -void selectIndexSetter(HTMLSelectElement*, JSC::ExecState*, unsigned index, JSC::JSValue*); +void selectIndexSetter(HTMLSelectElement*, JSC::ExecState*, unsigned index, JSC::JSValuePtr); } diff --git a/WebCore/bindings/js/JSHistoryCustom.cpp b/WebCore/bindings/js/JSHistoryCustom.cpp index 31699a0..e83ac40 100644 --- a/WebCore/bindings/js/JSHistoryCustom.cpp +++ b/WebCore/bindings/js/JSHistoryCustom.cpp @@ -37,17 +37,17 @@ using namespace JSC; namespace WebCore { -JSValue* nonCachingStaticBackFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +static JSValuePtr nonCachingStaticBackFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 0, propertyName, jsHistoryPrototypeFunctionBack); } -JSValue* nonCachingStaticForwardFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +static JSValuePtr nonCachingStaticForwardFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 0, propertyName, jsHistoryPrototypeFunctionForward); } -JSValue* nonCachingStaticGoFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +static JSValuePtr nonCachingStaticGoFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 1, propertyName, jsHistoryPrototypeFunctionGo); } @@ -92,7 +92,7 @@ bool JSHistory::customGetOwnPropertySlot(ExecState* exec, const Identifier& prop return true; } -bool JSHistory::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot&) +bool JSHistory::customPut(ExecState* exec, const Identifier&, JSValuePtr, PutPropertySlot&) { // Only allow putting by frames in the same origin. if (!allowsAccessFromFrame(exec, impl()->frame())) diff --git a/WebCore/bindings/js/JSImageConstructor.cpp b/WebCore/bindings/js/JSImageConstructor.cpp index c1e4630..0dc55b4 100644 --- a/WebCore/bindings/js/JSImageConstructor.cpp +++ b/WebCore/bindings/js/JSImageConstructor.cpp @@ -21,6 +21,7 @@ #include "JSImageConstructor.h" #include "HTMLImageElement.h" +#include "HTMLNames.h" #include "JSNode.h" #include "ScriptExecutionContext.h" @@ -33,7 +34,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSImageConstructor) const ClassInfo JSImageConstructor::s_info = { "ImageConstructor", 0, 0, 0 }; JSImageConstructor::JSImageConstructor(ExecState* exec, ScriptExecutionContext* context) - : DOMObject(JSImageConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype())) + : DOMObject(JSImageConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) { ASSERT(context->isDocument()); m_document = static_cast<JSDocument*>(asObject(toJS(exec, static_cast<Document*>(context)))); @@ -47,11 +48,11 @@ static JSObject* constructImage(ExecState* exec, JSObject* constructor, const Ar int height = 0; if (args.size() > 0) { widthSet = true; - width = args.at(exec, 0)->toInt32(exec); + width = args.at(exec, 0).toInt32(exec); } if (args.size() > 1) { heightSet = true; - height = args.at(exec, 1)->toInt32(exec); + height = args.at(exec, 1).toInt32(exec); } Document* document = static_cast<JSImageConstructor*>(constructor)->document(); @@ -61,7 +62,7 @@ static JSObject* constructImage(ExecState* exec, JSObject* constructor, const Ar // will be called (which will cause the image element to be marked if necessary). toJS(exec, document); - RefPtr<HTMLImageElement> image = new HTMLImageElement(document); + RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document); if (widthSet) image->setWidth(width); if (heightSet) diff --git a/WebCore/bindings/js/JSImageDataCustom.cpp b/WebCore/bindings/js/JSImageDataCustom.cpp index 50f237a..06c5d1b 100644 --- a/WebCore/bindings/js/JSImageDataCustom.cpp +++ b/WebCore/bindings/js/JSImageDataCustom.cpp @@ -27,11 +27,16 @@ #include "JSImageData.h" #include "ImageData.h" +#include "PlatformString.h" + +#include <runtime/JSByteArray.h> +#include <wtf/StdLibExtras.h> + using namespace JSC; namespace WebCore { -JSValue* toJS(ExecState* exec, ImageData* imageData) +JSValuePtr toJS(ExecState* exec, ImageData* imageData) { if (!imageData) return jsNull(); @@ -41,7 +46,10 @@ JSValue* toJS(ExecState* exec, ImageData* imageData) return wrapper; wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, ImageData, imageData); - + Identifier dataName(exec, "data"); + DEFINE_STATIC_LOCAL(RefPtr<Structure>, cpaStructure, (JSByteArray::createStructure(jsNull()))); + static const ClassInfo cpaClassInfo = { "CanvasPixelArray", 0, 0, 0 }; + wrapper->putDirect(dataName, new (exec) JSByteArray(exec, cpaStructure, imageData->data()->data(), &cpaClassInfo), DontDelete | ReadOnly); exec->heap()->reportExtraMemoryCost(imageData->data()->length()); return wrapper; diff --git a/WebCore/bindings/js/JSInspectedObjectWrapper.cpp b/WebCore/bindings/js/JSInspectedObjectWrapper.cpp index 9bc7e7d..09ad9f4 100644 --- a/WebCore/bindings/js/JSInspectedObjectWrapper.cpp +++ b/WebCore/bindings/js/JSInspectedObjectWrapper.cpp @@ -28,6 +28,7 @@ #include "JSInspectorCallbackWrapper.h" #include <runtime/JSGlobalObject.h> +#include <wtf/StdLibExtras.h> using namespace JSC; @@ -40,15 +41,15 @@ typedef HashMap<JSGlobalObject*, WrapperMap*> GlobalObjectWrapperMap; static GlobalObjectWrapperMap& wrappers() { - static GlobalObjectWrapperMap map; + DEFINE_STATIC_LOCAL(GlobalObjectWrapperMap, map, ()); return map; } const ClassInfo JSInspectedObjectWrapper::s_info = { "JSInspectedObjectWrapper", &JSQuarantinedObjectWrapper::s_info, 0, 0 }; -JSValue* JSInspectedObjectWrapper::wrap(ExecState* unwrappedExec, JSValue* unwrappedValue) +JSValuePtr JSInspectedObjectWrapper::wrap(ExecState* unwrappedExec, JSValuePtr unwrappedValue) { - if (!unwrappedValue->isObject()) + if (!unwrappedValue.isObject()) return unwrappedValue; JSObject* unwrappedObject = asObject(unwrappedValue); @@ -60,16 +61,16 @@ JSValue* JSInspectedObjectWrapper::wrap(ExecState* unwrappedExec, JSValue* unwra if (JSInspectedObjectWrapper* wrapper = wrapperMap->get(unwrappedObject)) return wrapper; - JSValue* prototype = unwrappedObject->prototype(); - ASSERT(prototype->isNull() || prototype->isObject()); + JSValuePtr prototype = unwrappedObject->prototype(); + ASSERT(prototype.isNull() || prototype.isObject()); - if (prototype->isNull()) - return new (unwrappedExec) JSInspectedObjectWrapper(unwrappedExec, unwrappedObject, JSQuarantinedObjectWrapper::createStructureID(jsNull())); - return new (unwrappedExec) JSInspectedObjectWrapper(unwrappedExec, unwrappedObject, JSQuarantinedObjectWrapper::createStructureID(asObject(wrap(unwrappedExec, prototype)))); + if (prototype.isNull()) + return new (unwrappedExec) JSInspectedObjectWrapper(unwrappedExec, unwrappedObject, JSQuarantinedObjectWrapper::createStructure(jsNull())); + return new (unwrappedExec) JSInspectedObjectWrapper(unwrappedExec, unwrappedObject, JSQuarantinedObjectWrapper::createStructure(asObject(wrap(unwrappedExec, prototype)))); } -JSInspectedObjectWrapper::JSInspectedObjectWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<StructureID> structureID) - : JSQuarantinedObjectWrapper(unwrappedExec, unwrappedObject, structureID) +JSInspectedObjectWrapper::JSInspectedObjectWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<Structure> structure) + : JSQuarantinedObjectWrapper(unwrappedExec, unwrappedObject, structure) { WrapperMap* wrapperMap = wrappers().get(unwrappedGlobalObject()); if (!wrapperMap) { @@ -95,11 +96,11 @@ JSInspectedObjectWrapper::~JSInspectedObjectWrapper() } } -JSValue* JSInspectedObjectWrapper::prepareIncomingValue(ExecState*, JSValue* value) const +JSValuePtr JSInspectedObjectWrapper::prepareIncomingValue(ExecState*, JSValuePtr value) const { // The Inspector is only allowed to pass primitive values and wrapped objects to objects from the inspected page. - if (!value->isObject()) + if (!value.isObject()) return value; JSQuarantinedObjectWrapper* wrapper = asWrapper(value); diff --git a/WebCore/bindings/js/JSInspectedObjectWrapper.h b/WebCore/bindings/js/JSInspectedObjectWrapper.h index 1c6f2db..273c0b0 100644 --- a/WebCore/bindings/js/JSInspectedObjectWrapper.h +++ b/WebCore/bindings/js/JSInspectedObjectWrapper.h @@ -32,13 +32,13 @@ namespace WebCore { class JSInspectedObjectWrapper : public JSQuarantinedObjectWrapper { public: - static JSC::JSValue* wrap(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue); + static JSC::JSValuePtr wrap(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue); virtual ~JSInspectedObjectWrapper(); static const JSC::ClassInfo s_info; private: - JSInspectedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::StructureID>); + JSInspectedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::Structure>); virtual bool allowsGetProperty() const { return true; } virtual bool allowsSetProperty() const { return true; } @@ -48,8 +48,8 @@ namespace WebCore { virtual bool allowsCallAsFunction() const { return true; } virtual bool allowsGetPropertyNames() const { return true; } - virtual JSC::JSValue* prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const; - virtual JSC::JSValue* wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const { return wrap(unwrappedExec, unwrappedValue); } + virtual JSC::JSValuePtr prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue) const; + virtual JSC::JSValuePtr wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue) const { return wrap(unwrappedExec, unwrappedValue); } virtual const JSC::ClassInfo* classInfo() const { return &s_info; } }; diff --git a/WebCore/bindings/js/JSInspectorCallbackWrapper.cpp b/WebCore/bindings/js/JSInspectorCallbackWrapper.cpp index 8440a1f..7ccf312 100644 --- a/WebCore/bindings/js/JSInspectorCallbackWrapper.cpp +++ b/WebCore/bindings/js/JSInspectorCallbackWrapper.cpp @@ -27,6 +27,7 @@ #include "JSInspectorCallbackWrapper.h" #include "JSInspectedObjectWrapper.h" +#include <wtf/StdLibExtras.h> using namespace JSC; @@ -38,23 +39,23 @@ typedef HashMap<JSObject*, JSInspectorCallbackWrapper*> WrapperMap; static WrapperMap& wrappers() { - static WrapperMap map; + DEFINE_STATIC_LOCAL(WrapperMap, map, ()); return map; } const ClassInfo JSInspectorCallbackWrapper::s_info = { "JSInspectorCallbackWrapper", &JSQuarantinedObjectWrapper::s_info, 0, 0 }; -static StructureID* leakInspectorCallbackWrapperStructure() +static Structure* leakInspectorCallbackWrapperStructure() { - StructureID::startIgnoringLeaks(); - StructureID* structure = JSInspectorCallbackWrapper::createStructureID(jsNull()).releaseRef(); - StructureID::stopIgnoringLeaks(); + Structure::startIgnoringLeaks(); + Structure* structure = JSInspectorCallbackWrapper::createStructure(jsNull()).releaseRef(); + Structure::stopIgnoringLeaks(); return structure; } -JSValue* JSInspectorCallbackWrapper::wrap(ExecState* unwrappedExec, JSValue* unwrappedValue) +JSValuePtr JSInspectorCallbackWrapper::wrap(ExecState* unwrappedExec, JSValuePtr unwrappedValue) { - if (!unwrappedValue->isObject()) + if (!unwrappedValue.isObject()) return unwrappedValue; JSObject* unwrappedObject = asObject(unwrappedValue); @@ -65,18 +66,18 @@ JSValue* JSInspectorCallbackWrapper::wrap(ExecState* unwrappedExec, JSValue* unw if (JSInspectorCallbackWrapper* wrapper = wrappers().get(unwrappedObject)) return wrapper; - JSValue* prototype = unwrappedObject->prototype(); - ASSERT(prototype->isNull() || prototype->isObject()); + JSValuePtr prototype = unwrappedObject->prototype(); + ASSERT(prototype.isNull() || prototype.isObject()); - if (prototype->isNull()) { - static StructureID* structure = leakInspectorCallbackWrapperStructure(); + if (prototype.isNull()) { + static Structure* structure = leakInspectorCallbackWrapperStructure(); return new (unwrappedExec) JSInspectorCallbackWrapper(unwrappedExec, unwrappedObject, structure); } return new (unwrappedExec) JSInspectorCallbackWrapper(unwrappedExec, unwrappedObject, asObject(wrap(unwrappedExec, prototype))->inheritorID()); } -JSInspectorCallbackWrapper::JSInspectorCallbackWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<StructureID> structureID) - : JSQuarantinedObjectWrapper(unwrappedExec, unwrappedObject, structureID) +JSInspectorCallbackWrapper::JSInspectorCallbackWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<Structure> structure) + : JSQuarantinedObjectWrapper(unwrappedExec, unwrappedObject, structure) { ASSERT(!wrappers().contains(unwrappedObject)); wrappers().set(unwrappedObject, this); @@ -87,7 +88,7 @@ JSInspectorCallbackWrapper::~JSInspectorCallbackWrapper() wrappers().remove(unwrappedObject()); } -JSValue* JSInspectorCallbackWrapper::prepareIncomingValue(ExecState* unwrappedExec, JSValue* unwrappedValue) const +JSValuePtr JSInspectorCallbackWrapper::prepareIncomingValue(ExecState* unwrappedExec, JSValuePtr unwrappedValue) const { if (JSQuarantinedObjectWrapper* wrapper = asWrapper(unwrappedValue)) { // The only time a wrapper should be passed into a JSInspectorCallbackWrapper is when a client-side storage callback diff --git a/WebCore/bindings/js/JSInspectorCallbackWrapper.h b/WebCore/bindings/js/JSInspectorCallbackWrapper.h index 5238add..49157c0 100644 --- a/WebCore/bindings/js/JSInspectorCallbackWrapper.h +++ b/WebCore/bindings/js/JSInspectorCallbackWrapper.h @@ -32,7 +32,7 @@ namespace WebCore { class JSInspectorCallbackWrapper : public JSQuarantinedObjectWrapper { public: - static JSC::JSValue* wrap(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue); + static JSC::JSValuePtr wrap(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue); virtual ~JSInspectorCallbackWrapper(); @@ -40,12 +40,12 @@ namespace WebCore { static const JSC::ClassInfo s_info; protected: - JSInspectorCallbackWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::StructureID>); + JSInspectorCallbackWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::Structure>); virtual bool allowsCallAsFunction() const { return true; } - virtual JSC::JSValue* prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const; - virtual JSC::JSValue* wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const { return wrap(unwrappedExec, unwrappedValue); } + virtual JSC::JSValuePtr prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue) const; + virtual JSC::JSValuePtr wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue) const { return wrap(unwrappedExec, unwrappedValue); } }; } // namespace WebCore diff --git a/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp b/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp index ce16b31..7c99120 100644 --- a/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp +++ b/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp @@ -33,10 +33,10 @@ using namespace JSC; namespace WebCore { -JSValue* JSJavaScriptCallFrame::evaluate(ExecState* exec, const ArgList& args) +JSValuePtr JSJavaScriptCallFrame::evaluate(ExecState* exec, const ArgList& args) { - JSValue* exception = noValue(); - JSValue* result = impl()->evaluate(args.at(exec, 0)->toString(exec), exception); + JSValuePtr exception = noValue(); + JSValuePtr result = impl()->evaluate(args.at(exec, 0).toString(exec), exception); if (exception) exec->setException(exception); @@ -44,12 +44,12 @@ JSValue* JSJavaScriptCallFrame::evaluate(ExecState* exec, const ArgList& args) return result; } -JSValue* JSJavaScriptCallFrame::thisObject(ExecState* exec) const +JSValuePtr JSJavaScriptCallFrame::thisObject(ExecState*) const { return impl()->thisObject() ? impl()->thisObject() : jsNull(); } -JSValue* JSJavaScriptCallFrame::type(ExecState* exec) const +JSValuePtr JSJavaScriptCallFrame::type(ExecState* exec) const { switch (impl()->type()) { case DebuggerCallFrame::FunctionType: @@ -62,7 +62,7 @@ JSValue* JSJavaScriptCallFrame::type(ExecState* exec) const return jsNull(); } -JSValue* JSJavaScriptCallFrame::scopeChain(ExecState* exec) const +JSValuePtr JSJavaScriptCallFrame::scopeChain(ExecState* exec) const { if (!impl()->scopeChain()) return jsNull(); diff --git a/WebCore/bindings/js/JSLocationCustom.cpp b/WebCore/bindings/js/JSLocationCustom.cpp index a5ad179..a99a105 100644 --- a/WebCore/bindings/js/JSLocationCustom.cpp +++ b/WebCore/bindings/js/JSLocationCustom.cpp @@ -37,17 +37,17 @@ using namespace JSC; namespace WebCore { -JSValue* nonCachingStaticReplaceFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +static JSValuePtr nonCachingStaticReplaceFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 1, propertyName, jsLocationPrototypeFunctionReplace); } -JSValue* nonCachingStaticReloadFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +static JSValuePtr nonCachingStaticReloadFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 0, propertyName, jsLocationPrototypeFunctionReload); } -JSValue* nonCachingStaticAssignFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +static JSValuePtr nonCachingStaticAssignFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot&) { return new (exec) PrototypeFunction(exec, 1, propertyName, jsLocationPrototypeFunctionAssign); } @@ -76,7 +76,7 @@ bool JSLocation::customGetOwnPropertySlot(ExecState* exec, const Identifier& pro slot.setCustom(this, nonCachingStaticReplaceFunctionGetter); return true; } else if (entry->function() == jsLocationPrototypeFunctionReload) { - slot.setCustom(this, nonCachingStaticReplaceFunctionGetter); + slot.setCustom(this, nonCachingStaticReloadFunctionGetter); return true; } else if (entry->function() == jsLocationPrototypeFunctionAssign) { slot.setCustom(this, nonCachingStaticAssignFunctionGetter); @@ -93,7 +93,7 @@ bool JSLocation::customGetOwnPropertySlot(ExecState* exec, const Identifier& pro return true; } -bool JSLocation::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot) +bool JSLocation::customPut(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) { Frame* frame = impl()->frame(); if (!frame) @@ -133,16 +133,16 @@ bool JSLocation::customGetPropertyNames(ExecState* exec, PropertyNameArray&) return false; } -static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bool lockHistory) +static void navigateIfAllowed(ExecState* exec, Frame* frame, const KURL& url, bool lockHistory, bool lockBackForwardList) { Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); if (!url.protocolIs("javascript") || allowsAccessFromFrame(exec, frame)) { bool userGesture = activeFrame->script()->processingUserGesture(); - frame->loader()->scheduleLocationChange(url.string(), activeFrame->loader()->outgoingReferrer(), lockHistory, userGesture); + frame->loader()->scheduleLocationChange(url.string(), activeFrame->loader()->outgoingReferrer(), lockHistory, lockBackForwardList, userGesture); } } -void JSLocation::setHref(ExecState* exec, JSValue* value) +void JSLocation::setHref(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); @@ -153,99 +153,99 @@ void JSLocation::setHref(ExecState* exec, JSValue* value) if (!activeFrame->loader()->shouldAllowNavigation(frame)) return; - KURL url = activeFrame->loader()->completeURL(value->toString(exec)); - navigateIfAllowed(exec, frame, url, false); + KURL url = activeFrame->loader()->completeURL(value.toString(exec)); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -void JSLocation::setProtocol(ExecState* exec, JSValue* value) +void JSLocation::setProtocol(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); - url.setProtocol(value->toString(exec)); + url.setProtocol(value.toString(exec)); - navigateIfAllowed(exec, frame, url, false); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -void JSLocation::setHost(ExecState* exec, JSValue* value) +void JSLocation::setHost(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); - url.setHostAndPort(value->toString(exec)); + url.setHostAndPort(value.toString(exec)); - navigateIfAllowed(exec, frame, url, false); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -void JSLocation::setHostname(ExecState* exec, JSValue* value) +void JSLocation::setHostname(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); - url.setHost(value->toString(exec)); + url.setHost(value.toString(exec)); - navigateIfAllowed(exec, frame, url, false); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -void JSLocation::setPort(ExecState* exec, JSValue* value) +void JSLocation::setPort(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); // FIXME: Could make this a little less ugly if String provided a toUnsignedShort function. - const UString& portString = value->toString(exec); + const UString& portString = value.toString(exec); int port = charactersToInt(portString.data(), portString.size()); if (port < 0 || port > 0xFFFF) port = 0; url.setPort(port); - navigateIfAllowed(exec, frame, url, false); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -void JSLocation::setPathname(ExecState* exec, JSValue* value) +void JSLocation::setPathname(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); - url.setPath(value->toString(exec)); + url.setPath(value.toString(exec)); - navigateIfAllowed(exec, frame, url, false); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -void JSLocation::setSearch(ExecState* exec, JSValue* value) +void JSLocation::setSearch(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); - url.setQuery(value->toString(exec)); + url.setQuery(value.toString(exec)); - navigateIfAllowed(exec, frame, url, false); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -void JSLocation::setHash(ExecState* exec, JSValue* value) +void JSLocation::setHash(ExecState* exec, JSValuePtr value) { Frame* frame = impl()->frame(); ASSERT(frame); KURL url = frame->loader()->url(); String oldRef = url.ref(); - String str = value->toString(exec); + String str = value.toString(exec); if (str.startsWith("#")) str = str.substring(1); if (oldRef == str || (oldRef.isNull() && str.isEmpty())) return; url.setRef(str); - navigateIfAllowed(exec, frame, url, false); + navigateIfAllowed(exec, frame, url, !frame->script()->anyPageIsProcessingUserGesture(), false); } -JSValue* JSLocation::replace(ExecState* exec, const ArgList& args) +JSValuePtr JSLocation::replace(ExecState* exec, const ArgList& args) { Frame* frame = impl()->frame(); if (!frame) @@ -257,11 +257,11 @@ JSValue* JSLocation::replace(ExecState* exec, const ArgList& args) if (!activeFrame->loader()->shouldAllowNavigation(frame)) return jsUndefined(); - navigateIfAllowed(exec, frame, activeFrame->loader()->completeURL(args.at(exec, 0)->toString(exec)), true); + navigateIfAllowed(exec, frame, activeFrame->loader()->completeURL(args.at(exec, 0).toString(exec)), true, true); return jsUndefined(); } -JSValue* JSLocation::reload(ExecState* exec, const ArgList& args) +JSValuePtr JSLocation::reload(ExecState* exec, const ArgList&) { Frame* frame = impl()->frame(); if (!frame) @@ -278,7 +278,7 @@ JSValue* JSLocation::reload(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSLocation::assign(ExecState* exec, const ArgList& args) +JSValuePtr JSLocation::assign(ExecState* exec, const ArgList& args) { Frame* frame = impl()->frame(); if (!frame) @@ -291,11 +291,11 @@ JSValue* JSLocation::assign(ExecState* exec, const ArgList& args) return jsUndefined(); // We want a new history item if this JS was called via a user gesture - navigateIfAllowed(exec, frame, activeFrame->loader()->completeURL(args.at(exec, 0)->toString(exec)), false); + navigateIfAllowed(exec, frame, activeFrame->loader()->completeURL(args.at(exec, 0).toString(exec)), !frame->script()->anyPageIsProcessingUserGesture(), false); return jsUndefined(); } -JSValue* JSLocation::toString(ExecState* exec, const ArgList&) +JSValuePtr JSLocation::toString(ExecState* exec, const ArgList&) { Frame* frame = impl()->frame(); if (!frame) diff --git a/WebCore/bindings/js/JSMessageChannelConstructor.cpp b/WebCore/bindings/js/JSMessageChannelConstructor.cpp index 0151128..8da9f6d 100644 --- a/WebCore/bindings/js/JSMessageChannelConstructor.cpp +++ b/WebCore/bindings/js/JSMessageChannelConstructor.cpp @@ -29,6 +29,11 @@ #include "Document.h" #include "JSDocument.h" #include "JSMessageChannel.h" +#ifdef ANDROID_FIX // these are generated files, need to check ENABLE(WORKERS) +#if ENABLE(WORKERS) +#include "JSWorkerContext.h" +#endif +#endif #include "MessageChannel.h" using namespace JSC; @@ -38,13 +43,15 @@ namespace WebCore { const ClassInfo JSMessageChannelConstructor::s_info = { "MessageChannelConstructor", 0, 0, 0 }; JSMessageChannelConstructor::JSMessageChannelConstructor(ExecState* exec, ScriptExecutionContext* scriptExecutionContext) - : DOMObject(JSMessageChannelConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype())) + : DOMObject(JSMessageChannelConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) , m_scriptExecutionContext(scriptExecutionContext) { if (m_scriptExecutionContext->isDocument()) m_contextWrapper = toJS(exec, static_cast<Document*>(scriptExecutionContext)); +#if ENABLE(WORKERS) else if (m_scriptExecutionContext->isWorkerContext()) - ; // Not yet implemented. + m_contextWrapper = toJSDOMGlobalObject(scriptExecutionContext); +#endif else ASSERT_NOT_REACHED(); @@ -69,8 +76,8 @@ JSObject* JSMessageChannelConstructor::construct(ExecState* exec, JSObject* cons void JSMessageChannelConstructor::mark() { DOMObject::mark(); - if (!m_contextWrapper->marked()) - m_contextWrapper->mark(); + if (!m_contextWrapper.marked()) + m_contextWrapper.mark(); } } // namespace WebCore diff --git a/WebCore/bindings/js/JSMessageChannelConstructor.h b/WebCore/bindings/js/JSMessageChannelConstructor.h index 0d26b4e..614f6ae 100644 --- a/WebCore/bindings/js/JSMessageChannelConstructor.h +++ b/WebCore/bindings/js/JSMessageChannelConstructor.h @@ -47,7 +47,7 @@ namespace WebCore { private: ScriptExecutionContext* m_scriptExecutionContext; - JSC::JSValue* m_contextWrapper; + JSC::JSValuePtr m_contextWrapper; }; } // namespace WebCore diff --git a/WebCore/bindings/js/JSMessagePortCustom.cpp b/WebCore/bindings/js/JSMessagePortCustom.cpp index 5768b0f..d30b14c 100644 --- a/WebCore/bindings/js/JSMessagePortCustom.cpp +++ b/WebCore/bindings/js/JSMessagePortCustom.cpp @@ -65,15 +65,15 @@ void JSMessagePort::mark() } } -JSValue* JSMessagePort::startConversation(ExecState* exec, const ArgList& args) +JSValuePtr JSMessagePort::startConversation(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject()); - const UString& message = args.at(exec, 0)->toString(exec); + const UString& message = args.at(exec, 0).toString(exec); return toJS(exec, impl()->startConversation(globalObject->scriptExecutionContext(), message).get()); } -JSValue* JSMessagePort::addEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSMessagePort::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -81,11 +81,11 @@ JSValue* JSMessagePort::addEventListener(ExecState* exec, const ArgList& args) RefPtr<JSUnprotectedEventListener> listener = globalObject->findOrCreateJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec)); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } -JSValue* JSMessagePort::removeEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSMessagePort::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -93,7 +93,7 @@ JSValue* JSMessagePort::removeEventListener(ExecState* exec, const ArgList& args JSUnprotectedEventListener* listener = globalObject->findJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSMimeTypeArrayCustom.cpp b/WebCore/bindings/js/JSMimeTypeArrayCustom.cpp index 7cbba53..5338d5b 100644 --- a/WebCore/bindings/js/JSMimeTypeArrayCustom.cpp +++ b/WebCore/bindings/js/JSMimeTypeArrayCustom.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 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 @@ -20,6 +21,7 @@ #include "JSMimeTypeArray.h" #include "AtomicString.h" +#include "JSMimeType.h" #include "MimeTypeArray.h" namespace WebCore { @@ -31,10 +33,10 @@ bool JSMimeTypeArray::canGetItemsForName(ExecState*, MimeTypeArray* mimeTypeArra return mimeTypeArray->canGetItemsForName(propertyName); } -JSValue* JSMimeTypeArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSMimeTypeArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSMimeTypeArray* thisObj = static_cast<JSMimeTypeArray*>(asObject(slot.slotBase())); - return toJS(exec, thisObj->impl()->nameGetter(propertyName)); + return toJS(exec, thisObj->impl()->namedItem(propertyName)); } -} +} // namespace WebCore diff --git a/WebCore/bindings/js/JSNamedNodeMapCustom.cpp b/WebCore/bindings/js/JSNamedNodeMapCustom.cpp index 1930b6b..e7b0764 100644 --- a/WebCore/bindings/js/JSNamedNodeMapCustom.cpp +++ b/WebCore/bindings/js/JSNamedNodeMapCustom.cpp @@ -41,7 +41,7 @@ bool JSNamedNodeMap::canGetItemsForName(ExecState*, NamedNodeMap* impl, const Id return impl->getNamedItem(propertyName); } -JSValue* JSNamedNodeMap::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSNamedNodeMap::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSNamedNodeMap* thisObj = static_cast<JSNamedNodeMap*>(asObject(slot.slotBase())); return toJS(exec, thisObj->impl()->getNamedItem(propertyName)); diff --git a/WebCore/bindings/js/JSNamedNodesCollection.cpp b/WebCore/bindings/js/JSNamedNodesCollection.cpp index ccf90f7..8a7ee0e 100644 --- a/WebCore/bindings/js/JSNamedNodesCollection.cpp +++ b/WebCore/bindings/js/JSNamedNodesCollection.cpp @@ -48,13 +48,13 @@ JSNamedNodesCollection::JSNamedNodesCollection(ExecState* exec, const Vector<Ref { } -JSValue* JSNamedNodesCollection::lengthGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSNamedNodesCollection::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSNamedNodesCollection* thisObj = static_cast<JSNamedNodesCollection*>(asObject(slot.slotBase())); return jsNumber(exec, thisObj->m_nodes->size()); } -JSValue* JSNamedNodesCollection::indexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSNamedNodesCollection::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSNamedNodesCollection *thisObj = static_cast<JSNamedNodesCollection*>(asObject(slot.slotBase())); return toJS(exec, (*thisObj->m_nodes)[slot.index()].get()); diff --git a/WebCore/bindings/js/JSNamedNodesCollection.h b/WebCore/bindings/js/JSNamedNodesCollection.h index e929400..19f194b 100644 --- a/WebCore/bindings/js/JSNamedNodesCollection.h +++ b/WebCore/bindings/js/JSNamedNodesCollection.h @@ -49,14 +49,14 @@ namespace WebCore { return exec->lexicalGlobalObject()->objectPrototype(); } - static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* prototype) + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValuePtr prototype) { - return JSC::StructureID::create(prototype, JSC::TypeInfo(JSC::ObjectType)); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); } private: - static JSC::JSValue* lengthGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); - static JSC::JSValue* indexGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + static JSC::JSValuePtr lengthGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + static JSC::JSValuePtr indexGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); OwnPtr<Vector<RefPtr<Node> > > m_nodes; }; diff --git a/WebCore/bindings/js/JSNavigatorCustom.cpp b/WebCore/bindings/js/JSNavigatorCustom.cpp index a85eb93..2287426 100644 --- a/WebCore/bindings/js/JSNavigatorCustom.cpp +++ b/WebCore/bindings/js/JSNavigatorCustom.cpp @@ -54,7 +54,7 @@ static bool needsYouTubeQuirk(ExecState* exec, Frame* frame) JSFunction* function = exec->function(); if (!function) return false; - static const Identifier& isWindowsFunctionName = *new Identifier(exec, "isWindows"); + DEFINE_STATIC_LOCAL(const Identifier, isWindowsFunctionName, (exec, "isWindows")); if (function->functionName() != isWindowsFunctionName) return false; @@ -70,8 +70,8 @@ static bool needsYouTubeQuirk(ExecState* exec, Frame* frame) JSObject* thisObject = callingExec->thisValue(); if (!thisObject) return false; - static const Identifier& isSafariFunctionName = *new Identifier(exec, "isSafari"); - JSValue* isSafariFunction = thisObject->getDirect(isSafariFunctionName); + DEFINE_STATIC_LOCAL(const Identifier, isSafariFunction, (exec, "isSafari")); + JSValuePtr isSafariFunction = thisObject->getDirect(isSafariFunctionName); if (isSafariFunction != callingFunction) return false; @@ -101,7 +101,7 @@ static bool needsYouTubeQuirk(ExecState* exec, Frame* frame) #endif -JSValue* JSNavigator::appVersion(ExecState* exec) const +JSValuePtr JSNavigator::appVersion(ExecState* exec) const { Navigator* imp = static_cast<Navigator*>(impl()); Frame* frame = imp->frame(); diff --git a/WebCore/bindings/js/JSNodeCustom.cpp b/WebCore/bindings/js/JSNodeCustom.cpp index c40777b..2b4d6d4 100644 --- a/WebCore/bindings/js/JSNodeCustom.cpp +++ b/WebCore/bindings/js/JSNodeCustom.cpp @@ -66,7 +66,7 @@ namespace WebCore { typedef int ExpectionCode; -JSValue* JSNode::insertBefore(ExecState* exec, const ArgList& args) +JSValuePtr JSNode::insertBefore(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; bool ok = impl()->insertBefore(toNode(args.at(exec, 0)), toNode(args.at(exec, 1)), ec, true); @@ -76,7 +76,7 @@ JSValue* JSNode::insertBefore(ExecState* exec, const ArgList& args) return jsNull(); } -JSValue* JSNode::replaceChild(ExecState* exec, const ArgList& args) +JSValuePtr JSNode::replaceChild(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; bool ok = impl()->replaceChild(toNode(args.at(exec, 0)), toNode(args.at(exec, 1)), ec, true); @@ -86,7 +86,7 @@ JSValue* JSNode::replaceChild(ExecState* exec, const ArgList& args) return jsNull(); } -JSValue* JSNode::removeChild(ExecState* exec, const ArgList& args) +JSValuePtr JSNode::removeChild(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; bool ok = impl()->removeChild(toNode(args.at(exec, 0)), ec); @@ -96,7 +96,7 @@ JSValue* JSNode::removeChild(ExecState* exec, const ArgList& args) return jsNull(); } -JSValue* JSNode::appendChild(ExecState* exec, const ArgList& args) +JSValuePtr JSNode::appendChild(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; bool ok = impl()->appendChild(toNode(args.at(exec, 0)), ec, true); @@ -112,7 +112,7 @@ void JSNode::mark() Node* node = m_impl.get(); - // Nodes in the document are kept alive by ScriptInterpreter::mark, + // Nodes in the document are kept alive by JSDocument::mark, // so we have no special responsibilities and can just call the base class here. if (node->inDocument()) { // But if the document isn't marked we have to mark it to ensure that @@ -161,7 +161,7 @@ void JSNode::mark() ASSERT(marked()); } -static ALWAYS_INLINE JSValue* createWrapper(ExecState* exec, Node* node) +static ALWAYS_INLINE JSValuePtr createWrapper(ExecState* exec, Node* node) { ASSERT(node); ASSERT(!getCachedDOMNodeWrapper(node->document(), node)); @@ -218,7 +218,7 @@ static ALWAYS_INLINE JSValue* createWrapper(ExecState* exec, Node* node) return wrapper; } -JSValue* toJSNewlyCreated(ExecState* exec, Node* node) +JSValuePtr toJSNewlyCreated(ExecState* exec, Node* node) { if (!node) return jsNull(); @@ -226,7 +226,7 @@ JSValue* toJSNewlyCreated(ExecState* exec, Node* node) return createWrapper(exec, node); } -JSValue* toJS(ExecState* exec, Node* node) +JSValuePtr toJS(ExecState* exec, Node* node) { if (!node) return jsNull(); diff --git a/WebCore/bindings/js/JSNodeFilterCondition.cpp b/WebCore/bindings/js/JSNodeFilterCondition.cpp index bc5f01d..1e4151b 100644 --- a/WebCore/bindings/js/JSNodeFilterCondition.cpp +++ b/WebCore/bindings/js/JSNodeFilterCondition.cpp @@ -31,15 +31,15 @@ using namespace JSC; ASSERT_CLASS_FITS_IN_CELL(JSNodeFilterCondition) -JSNodeFilterCondition::JSNodeFilterCondition(JSValue* filter) +JSNodeFilterCondition::JSNodeFilterCondition(JSValuePtr filter) : m_filter(filter) { } void JSNodeFilterCondition::mark() { - if (!m_filter->marked()) - m_filter->mark(); + if (!m_filter.marked()) + m_filter.mark(); } short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) const @@ -47,7 +47,7 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) JSLock lock(false); CallData callData; - CallType callType = m_filter->getCallData(callData); + CallType callType = m_filter.getCallData(callData); if (callType == CallTypeNone) return NodeFilter::FILTER_ACCEPT; @@ -65,11 +65,11 @@ short JSNodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* filterNode) if (exec->hadException()) return NodeFilter::FILTER_REJECT; - JSValue* result = call(exec, m_filter, callType, callData, m_filter, args); + JSValuePtr result = call(exec, m_filter, callType, callData, m_filter, args); if (exec->hadException()) return NodeFilter::FILTER_REJECT; - int intResult = result->toInt32(exec); + int intResult = result.toInt32(exec); if (exec->hadException()) return NodeFilter::FILTER_REJECT; diff --git a/WebCore/bindings/js/JSNodeFilterCondition.h b/WebCore/bindings/js/JSNodeFilterCondition.h index e39d094..b6be44b 100644 --- a/WebCore/bindings/js/JSNodeFilterCondition.h +++ b/WebCore/bindings/js/JSNodeFilterCondition.h @@ -30,18 +30,18 @@ namespace WebCore { class JSNodeFilterCondition : public NodeFilterCondition { public: - static PassRefPtr<JSNodeFilterCondition> create(JSC::JSValue* filter) + static PassRefPtr<JSNodeFilterCondition> create(JSC::JSValuePtr filter) { return adoptRef(new JSNodeFilterCondition(filter)); } private: - JSNodeFilterCondition(JSC::JSValue* filter); + JSNodeFilterCondition(JSC::JSValuePtr filter); - virtual short acceptNode(JSC::ExecState*, Node*) const; + virtual short acceptNode(ScriptState*, Node*) const; virtual void mark(); - JSC::JSValue* m_filter; + mutable JSC::JSValuePtr m_filter; }; } // namespace WebCore diff --git a/WebCore/bindings/js/JSNodeFilterCustom.cpp b/WebCore/bindings/js/JSNodeFilterCustom.cpp index 351062b..61fd0e2 100644 --- a/WebCore/bindings/js/JSNodeFilterCustom.cpp +++ b/WebCore/bindings/js/JSNodeFilterCustom.cpp @@ -41,14 +41,14 @@ void JSNodeFilter::mark() DOMObject::mark(); } -JSValue* JSNodeFilter::acceptNode(ExecState* exec, const ArgList& args) +JSValuePtr JSNodeFilter::acceptNode(ExecState* exec, const ArgList& args) { return jsNumber(exec, impl()->acceptNode(exec, toNode(args.at(exec, 0)))); } -PassRefPtr<NodeFilter> toNodeFilter(JSValue* value) +PassRefPtr<NodeFilter> toNodeFilter(JSValuePtr value) { - if (value->isObject(&JSNodeFilter::s_info)) + if (value.isObject(&JSNodeFilter::s_info)) return static_cast<JSNodeFilter*>(asObject(value))->impl(); return NodeFilter::create(JSNodeFilterCondition::create(value)); diff --git a/WebCore/bindings/js/JSNodeIteratorCustom.cpp b/WebCore/bindings/js/JSNodeIteratorCustom.cpp index 445c8cb..6498a7c 100644 --- a/WebCore/bindings/js/JSNodeIteratorCustom.cpp +++ b/WebCore/bindings/js/JSNodeIteratorCustom.cpp @@ -37,7 +37,7 @@ void JSNodeIterator::mark() DOMObject::mark(); } -JSValue* JSNodeIterator::nextNode(ExecState* exec, const ArgList& args) +JSValuePtr JSNodeIterator::nextNode(ExecState* exec, const ArgList&) { ExceptionCode ec = 0; RefPtr<Node> node = impl()->nextNode(exec, ec); @@ -52,7 +52,7 @@ JSValue* JSNodeIterator::nextNode(ExecState* exec, const ArgList& args) return toJS(exec, node.get()); } -JSValue* JSNodeIterator::previousNode(ExecState* exec, const ArgList& args) +JSValuePtr JSNodeIterator::previousNode(ExecState* exec, const ArgList&) { ExceptionCode ec = 0; RefPtr<Node> node = impl()->previousNode(exec, ec); diff --git a/WebCore/bindings/js/JSNodeListCustom.cpp b/WebCore/bindings/js/JSNodeListCustom.cpp index 973538e..386a756 100644 --- a/WebCore/bindings/js/JSNodeListCustom.cpp +++ b/WebCore/bindings/js/JSNodeListCustom.cpp @@ -36,10 +36,10 @@ using namespace JSC; namespace WebCore { // Need to support call so that list(0) works. -static JSValue* callNodeList(ExecState* exec, JSObject* function, JSValue*, const ArgList& args) +static JSValuePtr callNodeList(ExecState* exec, JSObject* function, JSValuePtr, const ArgList& args) { bool ok; - unsigned index = args.at(exec, 0)->toString(exec).toUInt32(&ok); + unsigned index = args.at(exec, 0).toString(exec).toUInt32(&ok); if (!ok) return jsUndefined(); return toJS(exec, static_cast<JSNodeList*>(function)->impl()->item(index)); @@ -56,7 +56,7 @@ bool JSNodeList::canGetItemsForName(ExecState*, NodeList* impl, const Identifier return impl->itemWithName(propertyName); } -JSValue* JSNodeList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSNodeList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSNodeList* thisObj = static_cast<JSNodeList*>(asObject(slot.slotBase())); return toJS(exec, thisObj->impl()->itemWithName(propertyName)); diff --git a/WebCore/bindings/js/JSOptionConstructor.cpp b/WebCore/bindings/js/JSOptionConstructor.cpp index 8fffb55..0030594 100644 --- a/WebCore/bindings/js/JSOptionConstructor.cpp +++ b/WebCore/bindings/js/JSOptionConstructor.cpp @@ -34,7 +34,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSOptionConstructor) const ClassInfo JSOptionConstructor::s_info = { "OptionConstructor", 0, 0, 0 }; JSOptionConstructor::JSOptionConstructor(ExecState* exec, ScriptExecutionContext* context) - : DOMObject(JSOptionConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype())) + : DOMObject(JSOptionConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) { ASSERT(context->isDocument()); m_document = static_cast<JSDocument*>(asObject(toJS(exec, static_cast<Document*>(context)))); @@ -52,16 +52,16 @@ static JSObject* constructHTMLOptionElement(ExecState* exec, JSObject* construct RefPtr<Text> text; if (ec == 0) text = document->createTextNode(""); - if (ec == 0 && !args.at(exec, 0)->isUndefined()) - text->setData(args.at(exec, 0)->toString(exec), ec); + if (ec == 0 && !args.at(exec, 0).isUndefined()) + text->setData(args.at(exec, 0).toString(exec), ec); if (ec == 0) element->appendChild(text.release(), ec); - if (ec == 0 && !args.at(exec, 1)->isUndefined()) - element->setValue(args.at(exec, 1)->toString(exec)); + if (ec == 0 && !args.at(exec, 1).isUndefined()) + element->setValue(args.at(exec, 1).toString(exec)); if (ec == 0) - element->setDefaultSelected(args.at(exec, 2)->toBoolean(exec)); + element->setDefaultSelected(args.at(exec, 2).toBoolean(exec)); if (ec == 0) - element->setSelected(args.at(exec, 3)->toBoolean(exec)); + element->setSelected(args.at(exec, 3).toBoolean(exec)); if (ec) { setDOMException(exec, ec); diff --git a/WebCore/bindings/js/JSPluginArrayCustom.cpp b/WebCore/bindings/js/JSPluginArrayCustom.cpp index eb379a7..5e82942 100644 --- a/WebCore/bindings/js/JSPluginArrayCustom.cpp +++ b/WebCore/bindings/js/JSPluginArrayCustom.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * Copyright (C) 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 @@ -20,6 +21,7 @@ #include "JSPluginArray.h" #include "AtomicString.h" +#include "JSPlugin.h" #include "PluginArray.h" namespace WebCore { @@ -31,10 +33,10 @@ bool JSPluginArray::canGetItemsForName(ExecState*, PluginArray* pluginArray, con return pluginArray->canGetItemsForName(propertyName); } -JSValue* JSPluginArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSPluginArray::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSPluginArray* thisObj = static_cast<JSPluginArray*>(asObject(slot.slotBase())); - return toJS(exec, thisObj->impl()->nameGetter(propertyName)); + return toJS(exec, thisObj->impl()->namedItem(propertyName)); } -} +} // namespace WebCore diff --git a/WebCore/bindings/js/JSPluginCustom.cpp b/WebCore/bindings/js/JSPluginCustom.cpp index 5cc4a92..2cc3bae 100644 --- a/WebCore/bindings/js/JSPluginCustom.cpp +++ b/WebCore/bindings/js/JSPluginCustom.cpp @@ -20,6 +20,7 @@ #include "JSPlugin.h" #include "AtomicString.h" +#include "JSMimeType.h" #include "Plugin.h" namespace WebCore { @@ -31,10 +32,10 @@ bool JSPlugin::canGetItemsForName(ExecState*, Plugin* plugin, const Identifier& return plugin->canGetItemsForName(propertyName); } -JSValue* JSPlugin::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSPlugin::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSPlugin* thisObj = static_cast<JSPlugin*>(asObject(slot.slotBase())); - return toJS(exec, thisObj->impl()->nameGetter(propertyName)); + return toJS(exec, thisObj->impl()->namedItem(propertyName)); } -} +} // namespace WebCore diff --git a/WebCore/bindings/js/JSPluginElementFunctions.cpp b/WebCore/bindings/js/JSPluginElementFunctions.cpp index 94e9806..4003efb 100644 --- a/WebCore/bindings/js/JSPluginElementFunctions.cpp +++ b/WebCore/bindings/js/JSPluginElementFunctions.cpp @@ -46,7 +46,8 @@ static Instance* pluginInstance(Node* node) if (!(node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag))) return 0; HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node); - Instance* instance = plugInElement->getInstance(); + // The plugin element holds an owning reference, so we don't have to. + Instance* instance = plugInElement->getInstance().get(); if (!instance || !instance->rootObject()) return 0; return instance; @@ -57,10 +58,10 @@ static RuntimeObjectImp* getRuntimeObject(ExecState* exec, Node* node) Instance* instance = pluginInstance(node); if (!instance) return 0; - return JSC::Bindings::Instance::createRuntimeObject(exec, instance); + return instance->createRuntimeObject(exec); } -JSValue* runtimeObjectGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr runtimeObjectGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slot.slotBase())); HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl()); @@ -68,7 +69,7 @@ JSValue* runtimeObjectGetter(ExecState* exec, const Identifier& propertyName, co return runtimeObject ? runtimeObject : jsUndefined(); } -JSValue* runtimeObjectPropertyGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr runtimeObjectPropertyGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSHTMLElement* thisObj = static_cast<JSHTMLElement*>(asObject(slot.slotBase())); HTMLElement* element = static_cast<HTMLElement*>(thisObj->impl()); @@ -89,7 +90,7 @@ bool runtimeObjectCustomGetOwnPropertySlot(ExecState* exec, const Identifier& pr return true; } -bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSValue* value, HTMLElement* element, PutPropertySlot& slot) +bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSValuePtr value, HTMLElement* element, PutPropertySlot& slot) { RuntimeObjectImp* runtimeObject = getRuntimeObject(exec, element); if (!runtimeObject) @@ -100,11 +101,11 @@ bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSV return true; } -static JSValue* callPlugin(ExecState* exec, JSObject* function, JSValue*, const ArgList& args) +static JSValuePtr callPlugin(ExecState* exec, JSObject* function, JSValuePtr, const ArgList& args) { Instance* instance = pluginInstance(static_cast<JSHTMLElement*>(function)->impl()); instance->begin(); - JSValue* result = instance->invokeDefaultMethod(exec, args); + JSValuePtr result = instance->invokeDefaultMethod(exec, args); instance->end(); return result; } diff --git a/WebCore/bindings/js/JSPluginElementFunctions.h b/WebCore/bindings/js/JSPluginElementFunctions.h index 280ffb7..a1a86c0 100644 --- a/WebCore/bindings/js/JSPluginElementFunctions.h +++ b/WebCore/bindings/js/JSPluginElementFunctions.h @@ -30,10 +30,10 @@ namespace WebCore { // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement. - JSC::JSValue* runtimeObjectGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); - JSC::JSValue* runtimeObjectPropertyGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + JSC::JSValuePtr runtimeObjectGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + JSC::JSValuePtr runtimeObjectPropertyGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); bool runtimeObjectCustomGetOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&, JSHTMLElement*); - bool runtimeObjectCustomPut(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue*, HTMLElement*, JSC::PutPropertySlot&); + bool runtimeObjectCustomPut(JSC::ExecState*, const JSC::Identifier&, JSC::JSValuePtr, HTMLElement*, JSC::PutPropertySlot&); JSC::CallType runtimeObjectGetCallData(HTMLElement*, JSC::CallData&); } // namespace WebCore diff --git a/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp b/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp index 7bb0c79..b1b0c92 100644 --- a/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp +++ b/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp @@ -36,9 +36,9 @@ ASSERT_CLASS_FITS_IN_CELL(JSQuarantinedObjectWrapper) const ClassInfo JSQuarantinedObjectWrapper::s_info = { "JSQuarantinedObjectWrapper", 0, 0, 0 }; -JSQuarantinedObjectWrapper* JSQuarantinedObjectWrapper::asWrapper(JSValue* value) +JSQuarantinedObjectWrapper* JSQuarantinedObjectWrapper::asWrapper(JSValuePtr value) { - if (!value->isObject()) + if (!value.isObject()) return 0; JSObject* object = asObject(value); @@ -49,21 +49,21 @@ JSQuarantinedObjectWrapper* JSQuarantinedObjectWrapper::asWrapper(JSValue* value return static_cast<JSQuarantinedObjectWrapper*>(object); } -JSValue* JSQuarantinedObjectWrapper::cachedValueGetter(ExecState*, const Identifier&, const PropertySlot& slot) +JSValuePtr JSQuarantinedObjectWrapper::cachedValueGetter(ExecState*, const Identifier&, const PropertySlot& slot) { - JSValue* v = slot.slotBase(); + JSValuePtr v = slot.slotBase(); ASSERT(v); return v; } -JSQuarantinedObjectWrapper::JSQuarantinedObjectWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<StructureID> structureID) - : JSObject(structureID) +JSQuarantinedObjectWrapper::JSQuarantinedObjectWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<Structure> structure) + : JSObject(structure) , m_unwrappedGlobalObject(unwrappedExec->dynamicGlobalObject()) , m_unwrappedObject(unwrappedObject) { ASSERT_ARG(unwrappedExec, unwrappedExec); ASSERT_ARG(unwrappedObject, unwrappedObject); - ASSERT(this->structureID()); + ASSERT(this->structure()); } JSQuarantinedObjectWrapper::~JSQuarantinedObjectWrapper() @@ -111,7 +111,7 @@ bool JSQuarantinedObjectWrapper::getOwnPropertySlot(ExecState* exec, const Ident PropertySlot unwrappedSlot(m_unwrappedObject); bool result = m_unwrappedObject->getOwnPropertySlot(unwrappedExecState(), identifier, unwrappedSlot); if (result) { - JSValue* unwrappedValue = unwrappedSlot.getValue(unwrappedExecState(), identifier); + JSValuePtr unwrappedValue = unwrappedSlot.getValue(unwrappedExecState(), identifier); slot.setCustom(wrapOutgoingValue(unwrappedExecState(), unwrappedValue), cachedValueGetter); } @@ -130,7 +130,7 @@ bool JSQuarantinedObjectWrapper::getOwnPropertySlot(ExecState* exec, unsigned id PropertySlot unwrappedSlot(m_unwrappedObject); bool result = m_unwrappedObject->getOwnPropertySlot(unwrappedExecState(), identifier, unwrappedSlot); if (result) { - JSValue* unwrappedValue = unwrappedSlot.getValue(unwrappedExecState(), identifier); + JSValuePtr unwrappedValue = unwrappedSlot.getValue(unwrappedExecState(), identifier); slot.setCustom(wrapOutgoingValue(unwrappedExecState(), unwrappedValue), cachedValueGetter); } @@ -139,7 +139,7 @@ bool JSQuarantinedObjectWrapper::getOwnPropertySlot(ExecState* exec, unsigned id return result; } -void JSQuarantinedObjectWrapper::put(ExecState* exec, const Identifier& identifier, JSValue* value, PutPropertySlot& slot) +void JSQuarantinedObjectWrapper::put(ExecState* exec, const Identifier& identifier, JSValuePtr value, PutPropertySlot& slot) { if (!allowsSetProperty()) return; @@ -149,7 +149,7 @@ void JSQuarantinedObjectWrapper::put(ExecState* exec, const Identifier& identifi transferExceptionToExecState(exec); } -void JSQuarantinedObjectWrapper::put(ExecState* exec, unsigned identifier, JSValue* value) +void JSQuarantinedObjectWrapper::put(ExecState* exec, unsigned identifier, JSValuePtr value) { if (!allowsSetProperty()) return; @@ -197,10 +197,10 @@ JSObject* JSQuarantinedObjectWrapper::construct(ExecState* exec, JSObject* const ConstructType unwrappedConstructType = wrapper->m_unwrappedObject->getConstructData(unwrappedConstructData); ASSERT(unwrappedConstructType != ConstructTypeNone); - JSValue* unwrappedResult = JSC::construct(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedConstructType, unwrappedConstructData, preparedArgs); + JSValuePtr unwrappedResult = JSC::construct(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedConstructType, unwrappedConstructData, preparedArgs); - JSValue* resultValue = wrapper->wrapOutgoingValue(wrapper->unwrappedExecState(), unwrappedResult); - ASSERT(resultValue->isObject()); + JSValuePtr resultValue = wrapper->wrapOutgoingValue(wrapper->unwrappedExecState(), unwrappedResult); + ASSERT(resultValue.isObject()); JSObject* result = asObject(resultValue); wrapper->transferExceptionToExecState(exec); @@ -219,7 +219,7 @@ ConstructType JSQuarantinedObjectWrapper::getConstructData(ConstructData& constr return ConstructTypeHost; } -bool JSQuarantinedObjectWrapper::hasInstance(ExecState* exec, JSValue* value, JSValue* proto) +bool JSQuarantinedObjectWrapper::hasInstance(ExecState* exec, JSValuePtr value, JSValuePtr proto) { if (!allowsHasInstance()) return false; @@ -231,11 +231,11 @@ bool JSQuarantinedObjectWrapper::hasInstance(ExecState* exec, JSValue* value, JS return result; } -JSValue* JSQuarantinedObjectWrapper::call(ExecState* exec, JSObject* function, JSValue* thisValue, const ArgList& args) +JSValuePtr JSQuarantinedObjectWrapper::call(ExecState* exec, JSObject* function, JSValuePtr thisValue, const ArgList& args) { JSQuarantinedObjectWrapper* wrapper = static_cast<JSQuarantinedObjectWrapper*>(function); - JSValue* preparedThisValue = wrapper->prepareIncomingValue(exec, thisValue); + JSValuePtr preparedThisValue = wrapper->prepareIncomingValue(exec, thisValue); ArgList preparedArgs; for (size_t i = 0; i < args.size(); ++i) @@ -247,9 +247,9 @@ JSValue* JSQuarantinedObjectWrapper::call(ExecState* exec, JSObject* function, J CallType unwrappedCallType = wrapper->m_unwrappedObject->getCallData(unwrappedCallData); ASSERT(unwrappedCallType != CallTypeNone); - JSValue* unwrappedResult = JSC::call(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedCallType, unwrappedCallData, preparedThisValue, preparedArgs); + JSValuePtr unwrappedResult = JSC::call(wrapper->unwrappedExecState(), wrapper->m_unwrappedObject, unwrappedCallType, unwrappedCallData, preparedThisValue, preparedArgs); - JSValue* result = wrapper->wrapOutgoingValue(wrapper->unwrappedExecState(), unwrappedResult); + JSValuePtr result = wrapper->wrapOutgoingValue(wrapper->unwrappedExecState(), unwrappedResult); wrapper->transferExceptionToExecState(exec); @@ -267,7 +267,7 @@ CallType JSQuarantinedObjectWrapper::getCallData(CallData& callData) return CallTypeHost; } -void JSQuarantinedObjectWrapper::getPropertyNames(ExecState* exec, PropertyNameArray& array) +void JSQuarantinedObjectWrapper::getPropertyNames(ExecState*, PropertyNameArray& array) { if (!allowsGetPropertyNames()) return; diff --git a/WebCore/bindings/js/JSQuarantinedObjectWrapper.h b/WebCore/bindings/js/JSQuarantinedObjectWrapper.h index ff684bf..d66dc46 100644 --- a/WebCore/bindings/js/JSQuarantinedObjectWrapper.h +++ b/WebCore/bindings/js/JSQuarantinedObjectWrapper.h @@ -32,11 +32,12 @@ namespace WebCore { class JSQuarantinedObjectWrapper : public JSC::JSObject { public: - static JSQuarantinedObjectWrapper* asWrapper(JSC::JSValue*); + static JSQuarantinedObjectWrapper* asWrapper(JSC::JSValuePtr); virtual ~JSQuarantinedObjectWrapper(); - JSC::JSObject* unwrappedObject() const { return m_unwrappedObject; } + virtual JSC::JSObject* unwrappedObject() { return m_unwrappedObject; } + JSC::JSGlobalObject* unwrappedGlobalObject() const { return m_unwrappedGlobalObject; }; JSC::ExecState* unwrappedExecState() const; @@ -44,13 +45,13 @@ namespace WebCore { static const JSC::ClassInfo s_info; - static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* proto) + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValuePtr proto) { - return JSC::StructureID::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance | JSC::OverridesHasInstance)); + return JSC::Structure::create(proto, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance | JSC::OverridesHasInstance)); } protected: - JSQuarantinedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::StructureID>); + JSQuarantinedObjectWrapper(JSC::ExecState* unwrappedExec, JSC::JSObject* unwrappedObject, PassRefPtr<JSC::Structure>); virtual void mark(); @@ -58,8 +59,8 @@ namespace WebCore { virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned, JSC::PropertySlot&); - virtual void put(JSC::ExecState*, const JSC::Identifier&, JSC::JSValue*, JSC::PutPropertySlot&); - virtual void put(JSC::ExecState*, unsigned, JSC::JSValue*); + virtual void put(JSC::ExecState*, const JSC::Identifier&, JSC::JSValuePtr, JSC::PutPropertySlot&); + virtual void put(JSC::ExecState*, unsigned, JSC::JSValuePtr); virtual bool deleteProperty(JSC::ExecState*, const JSC::Identifier&); virtual bool deleteProperty(JSC::ExecState*, unsigned); @@ -67,7 +68,7 @@ namespace WebCore { virtual JSC::CallType getCallData(JSC::CallData&); virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual bool hasInstance(JSC::ExecState*, JSC::JSValue*, JSC::JSValue* proto); + virtual bool hasInstance(JSC::ExecState*, JSC::JSValuePtr, JSC::JSValuePtr proto); virtual void getPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&); @@ -81,14 +82,14 @@ namespace WebCore { virtual bool allowsCallAsFunction() const { return false; } virtual bool allowsGetPropertyNames() const { return false; } - virtual JSC::JSValue* prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const = 0; - virtual JSC::JSValue* wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValue* unwrappedValue) const = 0; + virtual JSC::JSValuePtr prepareIncomingValue(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue) const = 0; + virtual JSC::JSValuePtr wrapOutgoingValue(JSC::ExecState* unwrappedExec, JSC::JSValuePtr unwrappedValue) const = 0; - static JSC::JSValue* cachedValueGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); + static JSC::JSValuePtr cachedValueGetter(JSC::ExecState*, const JSC::Identifier&, const JSC::PropertySlot&); void transferExceptionToExecState(JSC::ExecState*) const; - static JSC::JSValue* call(JSC::ExecState*, JSC::JSObject* function, JSC::JSValue* thisValue, const JSC::ArgList&); + static JSC::JSValuePtr call(JSC::ExecState*, JSC::JSObject* function, JSC::JSValuePtr thisValue, const JSC::ArgList&); static JSC::JSObject* construct(JSC::ExecState*, JSC::JSObject*, const JSC::ArgList&); JSC::JSGlobalObject* m_unwrappedGlobalObject; diff --git a/WebCore/bindings/js/JSRGBColor.cpp b/WebCore/bindings/js/JSRGBColor.cpp index 4541bfa..91fe4b3 100644 --- a/WebCore/bindings/js/JSRGBColor.cpp +++ b/WebCore/bindings/js/JSRGBColor.cpp @@ -28,9 +28,9 @@ 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&); +static JSValuePtr jsRGBColorRed(ExecState*, const Identifier&, const PropertySlot&); +static JSValuePtr jsRGBColorGreen(ExecState*, const Identifier&, const PropertySlot&); +static JSValuePtr jsRGBColorBlue(ExecState*, const Identifier&, const PropertySlot&); /* @begin JSRGBColorTable @@ -59,7 +59,7 @@ bool JSRGBColor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyN return getStaticValueSlot<JSRGBColor, DOMObject>(exec, &JSRGBColorTable, this, propertyName, slot); } -JSValue* getJSRGBColor(ExecState* exec, unsigned color) +JSValuePtr getJSRGBColor(ExecState* exec, unsigned color) { return new (exec) JSRGBColor(exec, color); } @@ -68,17 +68,17 @@ JSValue* getJSRGBColor(ExecState* exec, unsigned color) using namespace WebCore; -JSValue* jsRGBColorRed(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValuePtr 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) +JSValuePtr 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) +JSValuePtr 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/WebCore/bindings/js/JSRGBColor.h b/WebCore/bindings/js/JSRGBColor.h index afd5264..d5acff3 100644 --- a/WebCore/bindings/js/JSRGBColor.h +++ b/WebCore/bindings/js/JSRGBColor.h @@ -43,16 +43,16 @@ namespace WebCore { return exec->lexicalGlobalObject()->objectPrototype(); } - static PassRefPtr<JSC::StructureID> createStructureID(JSC::JSValue* prototype) + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValuePtr prototype) { - return JSC::StructureID::create(prototype, JSC::TypeInfo(JSC::ObjectType)); + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType)); } private: unsigned m_color; }; - JSC::JSValue* getJSRGBColor(JSC::ExecState*, unsigned color); + JSC::JSValuePtr getJSRGBColor(JSC::ExecState*, unsigned color); } // namespace WebCore diff --git a/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp b/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp index 14e9baa..fc643ad 100644 --- a/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp +++ b/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp @@ -37,10 +37,10 @@ using namespace JSC; namespace WebCore { -JSValue* JSSQLResultSetRowList::item(ExecState* exec, const ArgList& args) +JSValuePtr JSSQLResultSetRowList::item(ExecState* exec, const ArgList& args) { bool indexOk; - int index = args.at(exec, 0)->toInt32(exec, indexOk); + int index = args.at(exec, 0).toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -56,7 +56,7 @@ JSValue* JSSQLResultSetRowList::item(ExecState* exec, const ArgList& args) unsigned valuesIndex = index * numColumns; for (unsigned i = 0; i < numColumns; i++) { const SQLValue& value = m_impl->values()[valuesIndex + i]; - JSValue* jsValue = noValue(); + JSValuePtr jsValue = noValue(); switch (value.type()) { case SQLValue::StringValue: diff --git a/WebCore/bindings/js/JSSQLTransactionCustom.cpp b/WebCore/bindings/js/JSSQLTransactionCustom.cpp index 5138517..a0f173f 100644 --- a/WebCore/bindings/js/JSSQLTransactionCustom.cpp +++ b/WebCore/bindings/js/JSSQLTransactionCustom.cpp @@ -40,40 +40,40 @@ using namespace JSC; namespace WebCore { -JSValue* JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) +JSValuePtr JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) { - String sqlStatement = args.at(exec, 0)->toString(exec); + String sqlStatement = args.at(exec, 0).toString(exec); if (exec->hadException()) return jsUndefined(); // Now assemble the list of SQL arguments Vector<SQLValue> sqlValues; - if (!args.at(exec, 1)->isUndefinedOrNull()) { - JSObject* object = args.at(exec, 1)->getObject(); + if (!args.at(exec, 1).isUndefinedOrNull()) { + JSObject* object = args.at(exec, 1).getObject(); if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } - JSValue* lengthValue = object->get(exec, exec->propertyNames().length); + JSValuePtr lengthValue = object->get(exec, exec->propertyNames().length); if (exec->hadException()) return jsUndefined(); - unsigned length = lengthValue->toUInt32(exec); + unsigned length = lengthValue.toUInt32(exec); if (exec->hadException()) return jsUndefined(); for (unsigned i = 0 ; i < length; ++i) { - JSValue* value = object->get(exec, i); + JSValuePtr value = object->get(exec, i); if (exec->hadException()) return jsUndefined(); - if (value->isNull()) + if (value.isNull()) sqlValues.append(SQLValue()); - else if (value->isNumber()) - sqlValues.append(value->getNumber()); + else if (value.isNumber()) + sqlValues.append(value.uncheckedGetNumber()); else { // Convert the argument to a string and append it - sqlValues.append(value->toString(exec)); + sqlValues.append(value.toString(exec)); if (exec->hadException()) return jsUndefined(); } @@ -81,8 +81,8 @@ JSValue* JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) } RefPtr<SQLStatementCallback> callback; - if (!args.at(exec, 2)->isUndefinedOrNull()) { - JSObject* object = args.at(exec, 2)->getObject(); + if (!args.at(exec, 2).isUndefinedOrNull()) { + JSObject* object = args.at(exec, 2).getObject(); if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -93,8 +93,8 @@ JSValue* JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) } RefPtr<SQLStatementErrorCallback> errorCallback; - if (!args.at(exec, 3)->isUndefinedOrNull()) { - JSObject* object = args.at(exec, 3)->getObject(); + if (!args.at(exec, 3).isUndefinedOrNull()) { + JSObject* object = args.at(exec, 3).getObject(); if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); diff --git a/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp b/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp index 471486b..6309f4a 100644 --- a/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp +++ b/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp @@ -36,26 +36,26 @@ using namespace JSC; namespace WebCore { -JSValue* JSSVGElementInstance::addEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGElementInstance::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); if (RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(exec, args.at(exec, 1))) - impl()->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec)); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } -JSValue* JSSVGElementInstance::removeEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGElementInstance::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) return jsUndefined(); if (JSEventListener* listener = globalObject->findJSEventListener(args.at(exec, 1))) - impl()->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSSVGLengthCustom.cpp b/WebCore/bindings/js/JSSVGLengthCustom.cpp index f199517..edba220 100644 --- a/WebCore/bindings/js/JSSVGLengthCustom.cpp +++ b/WebCore/bindings/js/JSSVGLengthCustom.cpp @@ -26,18 +26,18 @@ using namespace JSC; namespace WebCore { -JSValue* JSSVGLength::value(ExecState* exec) const +JSValuePtr JSSVGLength::value(ExecState* exec) const { SVGLength imp(*impl()); return jsNumber(exec, imp.value(context())); } -JSValue* JSSVGLength::convertToSpecifiedUnits(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGLength::convertToSpecifiedUnits(ExecState* exec, const ArgList& args) { JSSVGPODTypeWrapper<SVGLength>* wrapper = impl(); SVGLength imp(*wrapper); - imp.convertToSpecifiedUnits(args.at(exec, 0)->toInt32(exec), context()); + imp.convertToSpecifiedUnits(args.at(exec, 0).toInt32(exec), context()); wrapper->commitChange(imp, context()); return jsUndefined(); diff --git a/WebCore/bindings/js/JSSVGMatrixCustom.cpp b/WebCore/bindings/js/JSSVGMatrixCustom.cpp index d20a55e..0dd086d 100644 --- a/WebCore/bindings/js/JSSVGMatrixCustom.cpp +++ b/WebCore/bindings/js/JSSVGMatrixCustom.cpp @@ -22,25 +22,17 @@ #if ENABLE(SVG) #include "JSSVGMatrix.h" -#include "AffineTransform.h" +#include "TransformationMatrix.h" #include "SVGException.h" using namespace JSC; namespace WebCore { -JSValue* JSSVGMatrix::multiply(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGMatrix::inverse(ExecState* exec, const ArgList&) { - AffineTransform imp(*impl()); - - AffineTransform secondMatrix = toSVGMatrix(args.at(exec, 0)); - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.multiply(secondMatrix)).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::inverse(ExecState* exec, const ArgList&) -{ - AffineTransform imp(*impl()); - JSC::JSValue* result = toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.inverse()).get(), m_context.get()); + TransformationMatrix imp(*impl()); + JSC::JSValuePtr result = toJS(exec, JSSVGStaticPODTypeWrapper<TransformationMatrix>::create(imp.inverse()).get(), m_context.get()); if (!imp.isInvertible()) setDOMException(exec, SVGException::SVG_MATRIX_NOT_INVERTABLE); @@ -48,50 +40,14 @@ JSValue* JSSVGMatrix::inverse(ExecState* exec, const ArgList&) return result; } -JSValue* JSSVGMatrix::translate(ExecState* exec, const ArgList& args) -{ - AffineTransform imp(*impl()); - - float x = args.at(exec, 0)->toFloat(exec); - float y = args.at(exec, 1)->toFloat(exec); - - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.translate(x, y)).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::scale(ExecState* exec, const ArgList& args) -{ - AffineTransform imp(*impl()); - - float scaleFactor = args.at(exec, 0)->toFloat(exec); - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.scale(scaleFactor)).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::scaleNonUniform(ExecState* exec, const ArgList& args) -{ - AffineTransform imp(*impl()); - - float scaleFactorX = args.at(exec, 0)->toFloat(exec); - float scaleFactorY = args.at(exec, 1)->toFloat(exec); - - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.scaleNonUniform(scaleFactorX, scaleFactorY)).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::rotate(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGMatrix::rotateFromVector(ExecState* exec, const ArgList& args) { - AffineTransform imp(*impl()); - - float angle = args.at(exec, 0)->toFloat(exec); - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.rotate(angle)).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::rotateFromVector(ExecState* exec, const ArgList& args) -{ - AffineTransform imp(*impl()); + TransformationMatrix imp(*impl()); - float x = args.at(exec, 0)->toFloat(exec); - float y = args.at(exec, 1)->toFloat(exec); + float x = args.at(exec, 0).toFloat(exec); + float y = args.at(exec, 1).toFloat(exec); - JSC::JSValue* result = toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.rotateFromVector(x, y)).get(), m_context.get()); + JSC::JSValuePtr result = toJS(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); @@ -99,34 +55,6 @@ JSValue* JSSVGMatrix::rotateFromVector(ExecState* exec, const ArgList& args) return result; } -JSValue* JSSVGMatrix::flipX(ExecState* exec, const ArgList&) -{ - AffineTransform imp(*impl()); - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.flipX()).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::flipY(ExecState* exec, const ArgList&) -{ - AffineTransform imp(*impl()); - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.flipY()).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::skewX(ExecState* exec, const ArgList& args) -{ - AffineTransform imp(*impl()); - - float angle = args.at(exec, 0)->toFloat(exec); - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.skewX(angle)).get(), m_context.get()); -} - -JSValue* JSSVGMatrix::skewY(ExecState* exec, const ArgList& args) -{ - AffineTransform imp(*impl()); - - float angle = args.at(exec, 0)->toFloat(exec); - return toJS(exec, JSSVGStaticPODTypeWrapper<AffineTransform>::create(imp.skewY(angle)).get(), m_context.get()); -} - } #endif // ENABLE(SVG) diff --git a/WebCore/bindings/js/JSSVGPODTypeWrapper.h b/WebCore/bindings/js/JSSVGPODTypeWrapper.h index 7eb665a..c30f97f 100644 --- a/WebCore/bindings/js/JSSVGPODTypeWrapper.h +++ b/WebCore/bindings/js/JSSVGPODTypeWrapper.h @@ -30,6 +30,7 @@ #if ENABLE(SVG) #include "Frame.h" #include "SVGElement.h" +#include <wtf/StdLibExtras.h> namespace WebCore { @@ -43,13 +44,13 @@ public: }; // This file contains JS wrapper objects for SVG datatypes, that are passed around by value -// in WebCore/svg (aka. 'POD types'). For instance SVGMatrix is mapped to AffineTransform, and +// in WebCore/svg (aka. 'POD types'). For instance SVGMatrix is mapped to TransformationMatrix, and // passed around as const reference. SVG DOM demands these objects to be "live", changes to any // of the writable attributes of SVGMatrix need to be reflected in the object which exposed the // SVGMatrix object (ie. 'someElement.transform.matrix.a = 50.0', in that case 'SVGTransform'). -// The SVGTransform class stores its "AffineTransform m_matrix" object on the stack. If it would +// The SVGTransform class stores its "TransformationMatrix m_matrix" object on the stack. If it would // be stored as pointer we could just build an auto-generated JSSVG* wrapper object around it -// and all changes to that object would automatically affect the AffineTransform* object stored +// and all changes to that object would automatically affect the TransformationMatrix* object stored // in the SVGTransform object. For the sake of efficiency and memory we don't pass around any // primitive values as pointers, so a custom JS wrapper object is needed for all SVG types, that // are internally represented by POD types (SVGRect <-> FloatRect, SVGPoint <-> FloatPoint, ...). @@ -190,7 +191,7 @@ public: return (m_parent.get()->*m_getter)(); } - virtual void commitChange(PODType type, SVGElement* context) + virtual void commitChange(PODType type, SVGElement*) { (m_parent.get()->*m_setter)(type); } @@ -282,6 +283,8 @@ struct PODTypeWrapperCacheInfo { // Deleted value PODTypeWrapperCacheInfo(WTF::HashTableDeletedValueType) : creator(reinterpret_cast<PODTypeCreator*>(-1)) + , getter(0) + , setter(0) { } bool isHashTableDeletedValue() const @@ -334,7 +337,7 @@ struct PODTypeWrapperCacheInfoTraits : WTF::GenericHashTraits<PODTypeWrapperCach static const CacheInfo& emptyValue() { - static CacheInfo key; + DEFINE_STATIC_LOCAL(CacheInfo, key, ()); return key; } @@ -366,7 +369,7 @@ public: static DynamicWrapperHashMap& dynamicWrapperHashMap() { - static DynamicWrapperHashMap s_dynamicWrapperHashMap; + DEFINE_STATIC_LOCAL(DynamicWrapperHashMap, s_dynamicWrapperHashMap, ()); return s_dynamicWrapperHashMap; } diff --git a/WebCore/bindings/js/JSSVGPathSegCustom.cpp b/WebCore/bindings/js/JSSVGPathSegCustom.cpp index 8c0a4ef..b7490e7 100644 --- a/WebCore/bindings/js/JSSVGPathSegCustom.cpp +++ b/WebCore/bindings/js/JSSVGPathSegCustom.cpp @@ -59,7 +59,7 @@ using namespace JSC; namespace WebCore { -JSValue* toJS(ExecState* exec, SVGPathSeg* object, SVGElement* context) +JSValuePtr toJS(ExecState* exec, SVGPathSeg* object, SVGElement* context) { if (!object) return jsNull(); diff --git a/WebCore/bindings/js/JSSVGPathSegListCustom.cpp b/WebCore/bindings/js/JSSVGPathSegListCustom.cpp index 95b60aa..69fb3b5 100644 --- a/WebCore/bindings/js/JSSVGPathSegListCustom.cpp +++ b/WebCore/bindings/js/JSSVGPathSegListCustom.cpp @@ -35,7 +35,7 @@ using namespace JSC; namespace WebCore { -JSValue* JSSVGPathSegList::clear(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPathSegList::clear(ExecState* exec, const ArgList&) { ExceptionCode ec = 0; @@ -48,7 +48,7 @@ JSValue* JSSVGPathSegList::clear(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSSVGPathSegList::initialize(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPathSegList::initialize(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGPathSeg* newItem = toSVGPathSeg(args.at(exec, 0)); @@ -57,19 +57,19 @@ 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::JSValuePtr result = toJS(exec, obj, m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); return result; } -JSValue* JSSVGPathSegList::getItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPathSegList::getItem(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; bool indexOk; - unsigned index = args.at(exec, 0)->toInt32(exec, indexOk); + unsigned index = args.at(exec, 0).toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -78,18 +78,18 @@ 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::JSValuePtr result = toJS(exec, obj, m_context.get()); setDOMException(exec, ec); return result; } -JSValue* JSSVGPathSegList::insertItemBefore(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPathSegList::insertItemBefore(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGPathSeg* newItem = toSVGPathSeg(args.at(exec, 0)); bool indexOk; - unsigned index = args.at(exec, 1)->toInt32(exec, indexOk); + unsigned index = args.at(exec, 1).toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -97,20 +97,20 @@ 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::JSValuePtr result = toJS(exec, WTF::getPtr(imp->insertItemBefore(newItem, index, ec)), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); return result; } -JSValue* JSSVGPathSegList::replaceItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPathSegList::replaceItem(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGPathSeg* newItem = toSVGPathSeg(args.at(exec, 0)); bool indexOk; - unsigned index = args.at(exec, 1)->toInt32(exec, indexOk); + unsigned index = args.at(exec, 1).toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -118,19 +118,19 @@ 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::JSValuePtr result = toJS(exec, WTF::getPtr(imp->replaceItem(newItem, index, ec)), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); return result; } -JSValue* JSSVGPathSegList::removeItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPathSegList::removeItem(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; bool indexOk; - unsigned index = args.at(exec, 0)->toInt32(exec, indexOk); + unsigned index = args.at(exec, 0).toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -140,21 +140,21 @@ 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::JSValuePtr result = toJS(exec, obj.get(), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); return result; } -JSValue* JSSVGPathSegList::appendItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPathSegList::appendItem(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGPathSeg* newItem = toSVGPathSeg(args.at(exec, 0)); SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl()); - JSC::JSValue* result = toJS(exec, WTF::getPtr(imp->appendItem(newItem, ec)), m_context.get()); + JSC::JSValuePtr result = toJS(exec, WTF::getPtr(imp->appendItem(newItem, ec)), m_context.get()); setDOMException(exec, ec); m_context->svgAttributeChanged(imp->associatedAttributeName()); diff --git a/WebCore/bindings/js/JSSVGPointListCustom.cpp b/WebCore/bindings/js/JSSVGPointListCustom.cpp index 6c13123..580b56f 100644 --- a/WebCore/bindings/js/JSSVGPointListCustom.cpp +++ b/WebCore/bindings/js/JSSVGPointListCustom.cpp @@ -33,7 +33,7 @@ namespace WebCore { typedef SVGPODListItem<FloatPoint> PODListItem; typedef SVGList<RefPtr<PODListItem> > SVGPointListBase; -static JSValue* finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem > item) +static JSValuePtr finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem > item) { if (ec) { setDOMException(exec, ec); @@ -42,7 +42,7 @@ static JSValue* finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* con return toJS(exec, JSSVGPODTypeWrapperCreatorForList<FloatPoint>::create(item.get(), list->associatedAttributeName()).get(), context); } -static JSValue* finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem > item) +static JSValuePtr finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem > item) { if (ec) { setDOMException(exec, ec); @@ -53,7 +53,7 @@ static JSValue* finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* con return toJS(exec, JSSVGPODTypeWrapperCreatorForList<FloatPoint>::create(item.get(), attributeName).get(), context); } -static JSValue* finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem> item) +static JSValuePtr finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGPointList* list, PassRefPtr<PODListItem> item) { if (ec) { setDOMException(exec, ec); @@ -63,7 +63,7 @@ static JSValue* finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, S return toJS(exec, JSSVGStaticPODTypeWrapper<FloatPoint>::create(*item).get(), context); } -JSValue* JSSVGPointList::clear(ExecState* exec, const ArgList&) +JSValuePtr JSSVGPointList::clear(ExecState* exec, const ArgList&) { ExceptionCode ec = 0; impl()->clear(ec); @@ -72,7 +72,7 @@ JSValue* JSSVGPointList::clear(ExecState* exec, const ArgList&) return jsUndefined(); } -JSValue* JSSVGPointList::initialize(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPointList::initialize(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGPointListBase* listImp = impl(); @@ -80,10 +80,10 @@ JSValue* JSSVGPointList::initialize(ExecState* exec, const ArgList& args) listImp->initialize(PODListItem::copy(toSVGPoint(args.at(exec, 0))), ec)); } -JSValue* JSSVGPointList::getItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPointList::getItem(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 0)->toUInt32(exec, indexOk); + unsigned index = args.at(exec, 0).toUInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -95,10 +95,10 @@ JSValue* JSSVGPointList::getItem(ExecState* exec, const ArgList& args) listImp->getItem(index, ec)); } -JSValue* JSSVGPointList::insertItemBefore(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPointList::insertItemBefore(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 1)->toUInt32(exec, indexOk); + unsigned index = args.at(exec, 1).toUInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -110,10 +110,10 @@ JSValue* JSSVGPointList::insertItemBefore(ExecState* exec, const ArgList& args) listImp->insertItemBefore(PODListItem::copy(toSVGPoint(args.at(exec, 0))), index, ec)); } -JSValue* JSSVGPointList::replaceItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPointList::replaceItem(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 1)->toInt32(exec, indexOk); + unsigned index = args.at(exec, 1).toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -125,10 +125,10 @@ JSValue* JSSVGPointList::replaceItem(ExecState* exec, const ArgList& args) listImp->replaceItem(PODListItem::copy(toSVGPoint(args.at(exec, 0))), index, ec)); } -JSValue* JSSVGPointList::removeItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPointList::removeItem(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 0)->toInt32(exec, indexOk); + unsigned index = args.at(exec, 0).toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -140,7 +140,7 @@ JSValue* JSSVGPointList::removeItem(ExecState* exec, const ArgList& args) listImp->removeItem(index, ec)); } -JSValue* JSSVGPointList::appendItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGPointList::appendItem(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGPointListBase* listImp = impl(); diff --git a/WebCore/bindings/js/JSSVGTransformListCustom.cpp b/WebCore/bindings/js/JSSVGTransformListCustom.cpp index 57cc662..3bdb2e0 100644 --- a/WebCore/bindings/js/JSSVGTransformListCustom.cpp +++ b/WebCore/bindings/js/JSSVGTransformListCustom.cpp @@ -33,7 +33,7 @@ namespace WebCore { typedef SVGPODListItem<SVGTransform> PODListItem; typedef SVGList<RefPtr<PODListItem> > SVGTransformListBase; -static JSValue* finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) +static JSValuePtr finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) { if (ec) { setDOMException(exec, ec); @@ -42,7 +42,7 @@ static JSValue* finishGetter(ExecState* exec, ExceptionCode& ec, SVGElement* con return toJS(exec, JSSVGPODTypeWrapperCreatorForList<SVGTransform>::create(item.get(), list->associatedAttributeName()).get(), context); } -static JSValue* finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) +static JSValuePtr finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) { if (ec) { setDOMException(exec, ec); @@ -53,7 +53,7 @@ static JSValue* finishSetter(ExecState* exec, ExceptionCode& ec, SVGElement* con return toJS(exec, JSSVGPODTypeWrapperCreatorForList<SVGTransform>::create(item.get(), attributeName).get(), context); } -static JSValue* finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) +static JSValuePtr finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, SVGElement* context, SVGTransformList* list, PassRefPtr<PODListItem> item) { if (ec) { setDOMException(exec, ec); @@ -63,7 +63,7 @@ static JSValue* finishSetterReadOnlyResult(ExecState* exec, ExceptionCode& ec, S return toJS(exec, JSSVGStaticPODTypeWrapper<SVGTransform>::create(*item).get(), context); } -JSValue* JSSVGTransformList::clear(ExecState* exec, const ArgList&) +JSValuePtr JSSVGTransformList::clear(ExecState* exec, const ArgList&) { ExceptionCode ec = 0; impl()->clear(ec); @@ -72,7 +72,7 @@ JSValue* JSSVGTransformList::clear(ExecState* exec, const ArgList&) return jsUndefined(); } -JSValue* JSSVGTransformList::initialize(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGTransformList::initialize(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGTransformListBase* listImp = impl(); @@ -80,10 +80,10 @@ JSValue* JSSVGTransformList::initialize(ExecState* exec, const ArgList& args) listImp->initialize(PODListItem::copy(toSVGTransform(args.at(exec, 0))), ec)); } -JSValue* JSSVGTransformList::getItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGTransformList::getItem(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 0)->toUInt32(exec, indexOk); + unsigned index = args.at(exec, 0).toUInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -95,10 +95,10 @@ JSValue* JSSVGTransformList::getItem(ExecState* exec, const ArgList& args) listImp->getItem(index, ec)); } -JSValue* JSSVGTransformList::insertItemBefore(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGTransformList::insertItemBefore(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 1)->toUInt32(exec, indexOk); + unsigned index = args.at(exec, 1).toUInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -110,10 +110,10 @@ JSValue* JSSVGTransformList::insertItemBefore(ExecState* exec, const ArgList& ar listImp->insertItemBefore(PODListItem::copy(toSVGTransform(args.at(exec, 0))), index, ec)); } -JSValue* JSSVGTransformList::replaceItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGTransformList::replaceItem(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 1)->toUInt32(exec, indexOk); + unsigned index = args.at(exec, 1).toUInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -125,10 +125,10 @@ JSValue* JSSVGTransformList::replaceItem(ExecState* exec, const ArgList& args) listImp->replaceItem(PODListItem::copy(toSVGTransform(args.at(exec, 0))), index, ec)); } -JSValue* JSSVGTransformList::removeItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGTransformList::removeItem(ExecState* exec, const ArgList& args) { bool indexOk; - unsigned index = args.at(exec, 0)->toUInt32(exec, indexOk); + unsigned index = args.at(exec, 0).toUInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); @@ -140,7 +140,7 @@ JSValue* JSSVGTransformList::removeItem(ExecState* exec, const ArgList& args) listImp->removeItem(index, ec)); } -JSValue* JSSVGTransformList::appendItem(ExecState* exec, const ArgList& args) +JSValuePtr JSSVGTransformList::appendItem(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; SVGTransformListBase* listImp = impl(); diff --git a/WebCore/bindings/js/JSStorageCustom.cpp b/WebCore/bindings/js/JSStorageCustom.cpp index 1966392..a72898e 100644 --- a/WebCore/bindings/js/JSStorageCustom.cpp +++ b/WebCore/bindings/js/JSStorageCustom.cpp @@ -41,7 +41,7 @@ bool JSStorage::canGetItemsForName(ExecState*, Storage* impl, const Identifier& return impl->contains(propertyName); } -JSValue* JSStorage::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSStorage::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSStorage* thisObj = static_cast<JSStorage*>(asObject(slot.slotBase())); return jsStringOrNull(exec, thisObj->impl()->getItem(propertyName)); @@ -56,8 +56,8 @@ bool JSStorage::deleteProperty(ExecState* exec, const Identifier& propertyName) if (getStaticValueSlot<JSStorage, Base>(exec, s_info.propHashTable(exec), this, propertyName, slot)) return false; - JSValue* prototype = this->prototype(); - if (prototype->isObject() && asObject(prototype)->hasProperty(exec, propertyName)) + JSValuePtr prototype = this->prototype(); + if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName)) return false; m_impl->removeItem(propertyName); @@ -74,7 +74,7 @@ bool JSStorage::customGetPropertyNames(ExecState* exec, PropertyNameArray& prope return false; } -bool JSStorage::customPut(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot&) +bool JSStorage::customPut(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot&) { // Only perform the custom put if the object doesn't have a native property by this name. // Since hasProperty() would end up calling canGetItemsForName() and be fooled, we need to check @@ -83,8 +83,8 @@ bool JSStorage::customPut(ExecState* exec, const Identifier& propertyName, JSVal if (getStaticValueSlot<JSStorage, Base>(exec, s_info.propHashTable(exec), this, propertyName, slot)) return false; - JSValue* prototype = this->prototype(); - if (prototype->isObject() && asObject(prototype)->hasProperty(exec, propertyName)) + JSValuePtr prototype = this->prototype(); + if (prototype.isObject() && asObject(prototype)->hasProperty(exec, propertyName)) return false; String stringValue = valueToStringWithNullCheck(exec, value); diff --git a/WebCore/bindings/js/JSStyleSheetCustom.cpp b/WebCore/bindings/js/JSStyleSheetCustom.cpp index c9914ae..04dabf0 100644 --- a/WebCore/bindings/js/JSStyleSheetCustom.cpp +++ b/WebCore/bindings/js/JSStyleSheetCustom.cpp @@ -34,7 +34,7 @@ using namespace JSC; namespace WebCore { -JSValue* toJS(ExecState* exec, StyleSheet* styleSheet) +JSValuePtr toJS(ExecState* exec, StyleSheet* styleSheet) { if (!styleSheet) return jsNull(); diff --git a/WebCore/bindings/js/JSStyleSheetListCustom.cpp b/WebCore/bindings/js/JSStyleSheetListCustom.cpp index 2a24fe2..ea41687 100644 --- a/WebCore/bindings/js/JSStyleSheetListCustom.cpp +++ b/WebCore/bindings/js/JSStyleSheetListCustom.cpp @@ -40,7 +40,7 @@ bool JSStyleSheetList::canGetItemsForName(ExecState*, StyleSheetList* styleSheet return styleSheetList->getNamedItem(propertyName); } -JSValue* JSStyleSheetList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValuePtr JSStyleSheetList::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSStyleSheetList* thisObj = static_cast<JSStyleSheetList*>(asObject(slot.slotBase())); HTMLStyleElement* element = thisObj->impl()->getNamedItem(propertyName); diff --git a/WebCore/bindings/js/JSTextCustom.cpp b/WebCore/bindings/js/JSTextCustom.cpp index 245b4bd..8118aef 100644 --- a/WebCore/bindings/js/JSTextCustom.cpp +++ b/WebCore/bindings/js/JSTextCustom.cpp @@ -32,7 +32,7 @@ using namespace JSC; namespace WebCore { -JSValue* toJSNewlyCreated(ExecState* exec, Text* text) +JSValuePtr toJSNewlyCreated(ExecState* exec, Text* text) { if (!text) return jsNull(); diff --git a/WebCore/bindings/js/JSTreeWalkerCustom.cpp b/WebCore/bindings/js/JSTreeWalkerCustom.cpp index 9822e1a..aca0f93 100644 --- a/WebCore/bindings/js/JSTreeWalkerCustom.cpp +++ b/WebCore/bindings/js/JSTreeWalkerCustom.cpp @@ -37,7 +37,7 @@ void JSTreeWalker::mark() DOMObject::mark(); } -JSValue* JSTreeWalker::parentNode(ExecState* exec, const ArgList& args) +JSValuePtr JSTreeWalker::parentNode(ExecState* exec, const ArgList&) { Node* node = impl()->parentNode(exec); if (exec->hadException()) @@ -45,7 +45,7 @@ JSValue* JSTreeWalker::parentNode(ExecState* exec, const ArgList& args) return toJS(exec, node); } -JSValue* JSTreeWalker::firstChild(ExecState* exec, const ArgList& args) +JSValuePtr JSTreeWalker::firstChild(ExecState* exec, const ArgList&) { Node* node = impl()->firstChild(exec); if (exec->hadException()) @@ -53,7 +53,7 @@ JSValue* JSTreeWalker::firstChild(ExecState* exec, const ArgList& args) return toJS(exec, node); } -JSValue* JSTreeWalker::lastChild(ExecState* exec, const ArgList& args) +JSValuePtr JSTreeWalker::lastChild(ExecState* exec, const ArgList&) { Node* node = impl()->lastChild(exec); if (exec->hadException()) @@ -61,7 +61,7 @@ JSValue* JSTreeWalker::lastChild(ExecState* exec, const ArgList& args) return toJS(exec, node); } -JSValue* JSTreeWalker::nextSibling(ExecState* exec, const ArgList& args) +JSValuePtr JSTreeWalker::nextSibling(ExecState* exec, const ArgList&) { Node* node = impl()->nextSibling(exec); if (exec->hadException()) @@ -69,7 +69,7 @@ JSValue* JSTreeWalker::nextSibling(ExecState* exec, const ArgList& args) return toJS(exec, node); } -JSValue* JSTreeWalker::previousSibling(ExecState* exec, const ArgList& args) +JSValuePtr JSTreeWalker::previousSibling(ExecState* exec, const ArgList&) { Node* node = impl()->previousSibling(exec); if (exec->hadException()) @@ -77,7 +77,7 @@ JSValue* JSTreeWalker::previousSibling(ExecState* exec, const ArgList& args) return toJS(exec, node); } -JSValue* JSTreeWalker::previousNode(ExecState* exec, const ArgList& args) +JSValuePtr JSTreeWalker::previousNode(ExecState* exec, const ArgList&) { Node* node = impl()->previousNode(exec); if (exec->hadException()) @@ -85,7 +85,7 @@ JSValue* JSTreeWalker::previousNode(ExecState* exec, const ArgList& args) return toJS(exec, node); } -JSValue* JSTreeWalker::nextNode(ExecState* exec, const ArgList& args) +JSValuePtr JSTreeWalker::nextNode(ExecState* exec, const ArgList&) { Node* node = impl()->nextNode(exec); if (exec->hadException()) diff --git a/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp b/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp new file mode 100644 index 0000000..ba864ea --- /dev/null +++ b/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSWebKitCSSMatrixConstructor.h" + +#include "WebKitCSSMatrix.h" +#include "JSWebKitCSSMatrix.h" + +using namespace JSC; + +namespace WebCore { + +const ClassInfo JSWebKitCSSMatrixConstructor::s_info = { "WebKitCSSMatrixConstructor", 0, 0, 0 }; + +JSWebKitCSSMatrixConstructor::JSWebKitCSSMatrixConstructor(ExecState* exec, ScriptExecutionContext* context) + : DOMObject(JSWebKitCSSMatrixConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) +{ + ASSERT_UNUSED(context, context->isDocument()); + putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); +} + +static JSObject* constructWebKitCSSMatrix(ExecState* exec, JSObject*, const ArgList& args) +{ + String s; + if (args.size() >= 1) + s = args.at(exec, 0).toString(exec); + + ExceptionCode ec = 0; + RefPtr<WebKitCSSMatrix> matrix = WebKitCSSMatrix::create(s, ec); + setDOMException(exec, ec); + return CREATE_DOM_OBJECT_WRAPPER(exec, WebKitCSSMatrix, matrix.get()); +} + +ConstructType JSWebKitCSSMatrixConstructor::getConstructData(ConstructData& constructData) +{ + constructData.native.function = constructWebKitCSSMatrix; + return ConstructTypeHost; +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h b/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h new file mode 100644 index 0000000..b280241 --- /dev/null +++ b/WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSWebKitCSSMatrixConstructor_h +#define JSWebKitCSSMatrixConstructor_h + +#include "JSDOMBinding.h" +#include "JSDocument.h" + +namespace WebCore { + +class JSWebKitCSSMatrixConstructor : public DOMObject { +public: + JSWebKitCSSMatrixConstructor(JSC::ExecState*, ScriptExecutionContext*); + static const JSC::ClassInfo s_info; + +private: + virtual JSC::ConstructType getConstructData(JSC::ConstructData&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } +}; + +} + +#endif // JSWebKitCSSMatrixConstructor_h diff --git a/WebCore/bindings/js/JSDedicatedWorkerConstructor.cpp b/WebCore/bindings/js/JSWorkerConstructor.cpp index 58ea258..52147a2 100644 --- a/WebCore/bindings/js/JSDedicatedWorkerConstructor.cpp +++ b/WebCore/bindings/js/JSWorkerConstructor.cpp @@ -27,45 +27,47 @@ #if ENABLE(WORKERS) -#include "JSDedicatedWorkerConstructor.h" +#include "JSWorkerConstructor.h" -#include "DedicatedWorker.h" #include "Document.h" #include "ExceptionCode.h" #include "JSDOMWindowCustom.h" -#include "JSDedicatedWorker.h" +#include "JSWorker.h" +#include "Worker.h" using namespace JSC; namespace WebCore { -const ClassInfo JSDedicatedWorkerConstructor::s_info = { "DedicatedWorkerConstructor", 0, 0, 0 }; +const ClassInfo JSWorkerConstructor::s_info = { "WorkerConstructor", 0, 0, 0 }; -JSDedicatedWorkerConstructor::JSDedicatedWorkerConstructor(ExecState* exec) - : DOMObject(JSDedicatedWorkerConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype())) +JSWorkerConstructor::JSWorkerConstructor(ExecState* exec) + : DOMObject(JSWorkerConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) { putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); } -static JSObject* constructDedicatedWorker(ExecState* exec, JSObject* constructor, const ArgList& args) +static JSObject* constructWorker(ExecState* exec, JSObject*, const ArgList& args) { if (args.size() == 0) return throwError(exec, SyntaxError, "Not enough arguments"); - UString scriptURL = args.at(exec, 0)->toString(exec); + UString scriptURL = args.at(exec, 0).toString(exec); + if (exec->hadException()) + return 0; DOMWindow* window = asJSDOMWindow(exec->lexicalGlobalObject())->impl(); ExceptionCode ec = 0; - RefPtr<DedicatedWorker> worker = DedicatedWorker::create(scriptURL, window->document(), ec); + RefPtr<Worker> worker = Worker::create(scriptURL, window->document(), ec); setDOMException(exec, ec); return asObject(toJS(exec, worker.release())); } -ConstructType JSDedicatedWorkerConstructor::getConstructData(ConstructData& constructData) +ConstructType JSWorkerConstructor::getConstructData(ConstructData& constructData) { - constructData.native.function = constructDedicatedWorker; + constructData.native.function = constructWorker; return ConstructTypeHost; } diff --git a/WebCore/bindings/js/JSDedicatedWorkerConstructor.h b/WebCore/bindings/js/JSWorkerConstructor.h index 3eda174..d1df7eb 100644 --- a/WebCore/bindings/js/JSDedicatedWorkerConstructor.h +++ b/WebCore/bindings/js/JSWorkerConstructor.h @@ -23,8 +23,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSDedicatedWorkerConstructor_h -#define JSDedicatedWorkerConstructor_h +#ifndef JSWorkerConstructor_h +#define JSWorkerConstructor_h #if ENABLE(WORKERS) @@ -32,9 +32,9 @@ namespace WebCore { - class JSDedicatedWorkerConstructor : public DOMObject { + class JSWorkerConstructor : public DOMObject { public: - JSDedicatedWorkerConstructor(JSC::ExecState*); + JSWorkerConstructor(JSC::ExecState*); static const JSC::ClassInfo s_info; @@ -48,4 +48,4 @@ namespace WebCore { #endif // ENABLE(WORKERS) -#endif // JSDedicatedWorkerConstructor_h +#endif // JSWorkerConstructor_h diff --git a/WebCore/bindings/js/JSWorkerContextBase.cpp b/WebCore/bindings/js/JSWorkerContextBase.cpp new file mode 100644 index 0000000..24dd50f --- /dev/null +++ b/WebCore/bindings/js/JSWorkerContextBase.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" + +#if ENABLE(WORKERS) + +#include "JSWorkerContextBase.h" + +#include "Event.h" +#include "JSDOMBinding.h" +#include "JSEventListener.h" +#include "JSMessageChannelConstructor.h" +#include "JSMessageEvent.h" +#include "JSMessagePort.h" +#include "JSWorkerLocation.h" +#include "JSWorkerNavigator.h" +#include "WorkerContext.h" +#include "WorkerLocation.h" + +using namespace JSC; + +/* +@begin JSWorkerContextBaseTable +@end +*/ + +#include "JSWorkerContextBase.lut.h" + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSWorkerContextBase) + +JSWorkerContextBase::JSWorkerContextBase(PassRefPtr<JSC::Structure> structure, PassRefPtr<WorkerContext> impl) + : JSDOMGlobalObject(structure, new JSDOMGlobalObjectData, this) + , m_impl(impl) +{ +} + +JSWorkerContextBase::~JSWorkerContextBase() +{ +} + +ScriptExecutionContext* JSWorkerContextBase::scriptExecutionContext() const +{ + return m_impl.get(); +} + +static const HashTable* getJSWorkerContextBaseTable(ExecState* exec) +{ + return getHashTableForGlobalData(exec->globalData(), &JSWorkerContextBaseTable); +} + +const ClassInfo JSWorkerContextBase::s_info = { "WorkerContext", 0, 0, getJSWorkerContextBaseTable }; + +void JSWorkerContextBase::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) +{ + lookupPut<JSWorkerContextBase, Base>(exec, propertyName, value, getJSWorkerContextBaseTable(exec), this, slot); +} + +} // namespace WebCore + +#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSWorkerContextBase.h b/WebCore/bindings/js/JSWorkerContextBase.h new file mode 100644 index 0000000..d2d5bd2 --- /dev/null +++ b/WebCore/bindings/js/JSWorkerContextBase.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef JSWorkerContextBase_h +#define JSWorkerContextBase_h + +#if ENABLE(WORKERS) + +#include "JSDOMGlobalObject.h" + +namespace WebCore { + + class WorkerContext; + + class JSWorkerContextBase : public JSDOMGlobalObject { + typedef JSDOMGlobalObject Base; + public: + JSWorkerContextBase(PassRefPtr<JSC::Structure>, PassRefPtr<WorkerContext>); + virtual ~JSWorkerContextBase(); + + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValuePtr, JSC::PutPropertySlot&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + WorkerContext* impl() const { return m_impl.get(); } + virtual ScriptExecutionContext* scriptExecutionContext() const; + + private: + RefPtr<WorkerContext> m_impl; + }; + +} // namespace WebCore + +#endif // ENABLE(WORKERS) + +#endif // JSWorkerContextBase_h diff --git a/WebCore/bindings/js/JSWorkerContextCustom.cpp b/WebCore/bindings/js/JSWorkerContextCustom.cpp new file mode 100644 index 0000000..3a6dca0 --- /dev/null +++ b/WebCore/bindings/js/JSWorkerContextCustom.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WORKERS) + +#include "JSWorkerContext.h" + +#include "JSDOMBinding.h" +#include "JSEventListener.h" +#include "WorkerContext.h" + +using namespace JSC; + +namespace WebCore { + +bool JSWorkerContext::customGetOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) +{ + // Look for overrides before looking at any of our own properties. + if (JSGlobalObject::getOwnPropertySlot(exec, propertyName, slot)) + return true; + return false; +} + +void JSWorkerContext::mark() +{ + Base::mark(); + + markActiveObjectsForContext(*globalData(), scriptExecutionContext()); + + if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(impl()->onmessage())) + listener->mark(); + + typedef WorkerContext::EventListenersMap EventListenersMap; + typedef WorkerContext::ListenerVector ListenerVector; + EventListenersMap& eventListeners = impl()->eventListeners(); + for (EventListenersMap::iterator mapIter = eventListeners.begin(); mapIter != eventListeners.end(); ++mapIter) { + for (ListenerVector::iterator vecIter = mapIter->second.begin(); vecIter != mapIter->second.end(); ++vecIter) { + JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(vecIter->get()); + listener->mark(); + } + } +} + +JSValuePtr JSWorkerContext::self(ExecState*) const +{ + return JSValuePtr(this); +} + +void JSWorkerContext::setSelf(ExecState* exec, JSValuePtr value) +{ + putDirect(Identifier(exec, "self"), value); +} + +JSValuePtr JSWorkerContext::addEventListener(ExecState* exec, const ArgList& args) +{ + RefPtr<JSUnprotectedEventListener> listener = findOrCreateJSUnprotectedEventListener(exec, args.at(exec, 1)); + if (!listener) + return jsUndefined(); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); + return jsUndefined(); +} + +JSValuePtr JSWorkerContext::removeEventListener(ExecState* exec, const ArgList& args) +{ + JSUnprotectedEventListener* listener = findJSUnprotectedEventListener(exec, args.at(exec, 1)); + if (!listener) + return jsUndefined(); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); + return jsUndefined(); +} + +} // namespace WebCore + +#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSWorkerCustom.cpp b/WebCore/bindings/js/JSWorkerCustom.cpp new file mode 100644 index 0000000..2ede0da --- /dev/null +++ b/WebCore/bindings/js/JSWorkerCustom.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WORKERS) + +#include "JSWorker.h" + +#include "JSDOMGlobalObject.h" +#include "JSEventListener.h" +#include "Worker.h" + +using namespace JSC; + +namespace WebCore { + +void JSWorker::mark() +{ + DOMObject::mark(); + + if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(m_impl->onmessage())) + listener->mark(); + + if (JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(m_impl->onerror())) + listener->mark(); + + 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) { + JSUnprotectedEventListener* listener = static_cast<JSUnprotectedEventListener*>(vecIter->get()); + listener->mark(); + } + } +} + +JSValuePtr JSWorker::addEventListener(ExecState* exec, const ArgList& args) +{ + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); + if (!globalObject) + return jsUndefined(); + RefPtr<JSUnprotectedEventListener> listener = globalObject->findOrCreateJSUnprotectedEventListener(exec, args.at(exec, 1)); + if (!listener) + return jsUndefined(); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); + return jsUndefined(); +} + +JSValuePtr JSWorker::removeEventListener(ExecState* exec, const ArgList& args) +{ + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); + if (!globalObject) + return jsUndefined(); + JSUnprotectedEventListener* listener = globalObject->findJSUnprotectedEventListener(exec, args.at(exec, 1)); + if (!listener) + return jsUndefined(); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); + return jsUndefined(); +} + +} // namespace WebCore + +#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp b/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp index 31d4dd7..d7f54de 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp @@ -33,7 +33,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequestConstructor) const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, 0, 0 }; JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, ScriptExecutionContext* context) - : DOMObject(JSXMLHttpRequestConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype())) + : DOMObject(JSXMLHttpRequestConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) { ASSERT(context->isDocument()); m_document = static_cast<JSDocument*>(asObject(toJS(exec, static_cast<Document*>(context)))); diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp index 4524b16..5122ba3 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp @@ -43,7 +43,7 @@ #include "JSFile.h" #include "XMLHttpRequest.h" #include <runtime/Error.h> -#include <VM/Machine.h> +#include <interpreter/Interpreter.h> using namespace JSC; @@ -89,27 +89,22 @@ void JSXMLHttpRequest::mark() } // Custom functions -JSValue* JSXMLHttpRequest::open(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequest::open(ExecState* exec, const ArgList& args) { if (args.size() < 2) return throwError(exec, SyntaxError, "Not enough arguments"); - Frame* frame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); - if (!frame) - return jsUndefined(); - const KURL& url = frame->loader()->completeURL(args.at(exec, 1)->toString(exec)); - - ExceptionCode ec = 0; - - String method = args.at(exec, 0)->toString(exec); + const KURL& url = impl()->scriptExecutionContext()->completeURL(args.at(exec, 1).toString(exec)); + String method = args.at(exec, 0).toString(exec); bool async = true; if (args.size() >= 3) - async = args.at(exec, 2)->toBoolean(exec); + async = args.at(exec, 2).toBoolean(exec); - if (args.size() >= 4 && !args.at(exec, 3)->isUndefined()) { + ExceptionCode ec = 0; + if (args.size() >= 4 && !args.at(exec, 3).isUndefined()) { String user = valueToStringWithNullCheck(exec, args.at(exec, 3)); - if (args.size() >= 5 && !args.at(exec, 4)->isUndefined()) { + if (args.size() >= 5 && !args.at(exec, 4).isUndefined()) { String password = valueToStringWithNullCheck(exec, args.at(exec, 4)); impl()->open(method, url, async, user, password, ec); } else @@ -121,39 +116,39 @@ JSValue* JSXMLHttpRequest::open(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSXMLHttpRequest::setRequestHeader(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequest::setRequestHeader(ExecState* exec, const ArgList& args) { if (args.size() < 2) return throwError(exec, SyntaxError, "Not enough arguments"); ExceptionCode ec = 0; - impl()->setRequestHeader(args.at(exec, 0)->toString(exec), args.at(exec, 1)->toString(exec), ec); + impl()->setRequestHeader(args.at(exec, 0).toString(exec), args.at(exec, 1).toString(exec), ec); setDOMException(exec, ec); return jsUndefined(); } -JSValue* JSXMLHttpRequest::send(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequest::send(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; if (args.isEmpty()) impl()->send(ec); else { - JSValue* val = args.at(exec, 0); - if (val->isUndefinedOrNull()) + JSValuePtr val = args.at(exec, 0); + if (val.isUndefinedOrNull()) impl()->send(ec); - else if (val->isObject(&JSDocument::s_info)) + else if (val.isObject(&JSDocument::s_info)) impl()->send(toDocument(val), ec); - else if (val->isObject(&JSFile::s_info)) + else if (val.isObject(&JSFile::s_info)) impl()->send(toFile(val), ec); else - impl()->send(val->toString(exec), ec); + impl()->send(val.toString(exec), ec); } int signedLineNumber; intptr_t sourceID; UString sourceURL; - JSValue* function; - exec->machine()->retrieveLastCaller(exec, signedLineNumber, sourceID, sourceURL, function); + JSValuePtr function; + exec->interpreter()->retrieveLastCaller(exec, signedLineNumber, sourceID, sourceURL, function); impl()->setLastSendLineNumber(signedLineNumber >= 0 ? signedLineNumber : 0); impl()->setLastSendURL(sourceURL); @@ -161,27 +156,27 @@ JSValue* JSXMLHttpRequest::send(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSXMLHttpRequest::getResponseHeader(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequest::getResponseHeader(ExecState* exec, const ArgList& args) { if (args.size() < 1) return throwError(exec, SyntaxError, "Not enough arguments"); ExceptionCode ec = 0; - JSValue* header = jsStringOrNull(exec, impl()->getResponseHeader(args.at(exec, 0)->toString(exec), ec)); + JSValuePtr header = jsStringOrNull(exec, impl()->getResponseHeader(args.at(exec, 0).toString(exec), ec)); setDOMException(exec, ec); return header; } -JSValue* JSXMLHttpRequest::overrideMimeType(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequest::overrideMimeType(ExecState* exec, const ArgList& args) { if (args.size() < 1) return throwError(exec, SyntaxError, "Not enough arguments"); - impl()->overrideMimeType(args.at(exec, 0)->toString(exec)); + impl()->overrideMimeType(args.at(exec, 0).toString(exec)); return jsUndefined(); } -JSValue* JSXMLHttpRequest::addEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequest::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -189,11 +184,11 @@ JSValue* JSXMLHttpRequest::addEventListener(ExecState* exec, const ArgList& args RefPtr<JSUnprotectedEventListener> listener = globalObject->findOrCreateJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec)); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } -JSValue* JSXMLHttpRequest::removeEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequest::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -201,8 +196,13 @@ JSValue* JSXMLHttpRequest::removeEventListener(ExecState* exec, const ArgList& a JSUnprotectedEventListener* listener = globalObject->findJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } +JSValuePtr JSXMLHttpRequest::responseText(ExecState* exec) const +{ + return jsOwnedStringOrNull(exec, impl()->responseText()); +} + } // namespace WebCore diff --git a/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp index ae673d9..f456c87 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp @@ -77,7 +77,7 @@ void JSXMLHttpRequestUpload::mark() } } -JSValue* JSXMLHttpRequestUpload::addEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequestUpload::addEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -85,11 +85,11 @@ JSValue* JSXMLHttpRequestUpload::addEventListener(ExecState* exec, const ArgList RefPtr<JSUnprotectedEventListener> listener = globalObject->findOrCreateJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->addEventListener(args.at(exec, 0)->toString(exec), listener.release(), args.at(exec, 2)->toBoolean(exec)); + impl()->addEventListener(args.at(exec, 0).toString(exec), listener.release(), args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } -JSValue* JSXMLHttpRequestUpload::removeEventListener(ExecState* exec, const ArgList& args) +JSValuePtr JSXMLHttpRequestUpload::removeEventListener(ExecState* exec, const ArgList& args) { JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); if (!globalObject) @@ -97,7 +97,7 @@ JSValue* JSXMLHttpRequestUpload::removeEventListener(ExecState* exec, const ArgL JSUnprotectedEventListener* listener = globalObject->findJSUnprotectedEventListener(exec, args.at(exec, 1)); if (!listener) return jsUndefined(); - impl()->removeEventListener(args.at(exec, 0)->toString(exec), listener, args.at(exec, 2)->toBoolean(exec)); + impl()->removeEventListener(args.at(exec, 0).toString(exec), listener, args.at(exec, 2).toBoolean(exec)); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp b/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp index e27e7a5..ed456e1 100644 --- a/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp +++ b/WebCore/bindings/js/JSXSLTProcessorConstructor.cpp @@ -42,12 +42,12 @@ ASSERT_CLASS_FITS_IN_CELL(JSXSLTProcessorConstructor) const ClassInfo JSXSLTProcessorConstructor::s_info = { "XSLTProcessorConsructor", 0, 0, 0 }; JSXSLTProcessorConstructor::JSXSLTProcessorConstructor(ExecState* exec) - : DOMObject(JSXSLTProcessorConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype())) + : DOMObject(JSXSLTProcessorConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype())) { putDirect(exec->propertyNames().prototype, JSXSLTProcessorPrototype::self(exec), None); } -static JSObject* constructXSLTProcessor(ExecState* exec, JSObject*, const ArgList& args) +static JSObject* constructXSLTProcessor(ExecState* exec, JSObject*, const ArgList&) { return CREATE_DOM_OBJECT_WRAPPER(exec, XSLTProcessor, XSLTProcessor::create().get()); } diff --git a/WebCore/bindings/js/JSXSLTProcessorCustom.cpp b/WebCore/bindings/js/JSXSLTProcessorCustom.cpp index 6a5d29b..8de2e54 100644 --- a/WebCore/bindings/js/JSXSLTProcessorCustom.cpp +++ b/WebCore/bindings/js/JSXSLTProcessorCustom.cpp @@ -46,10 +46,10 @@ using namespace JSC; namespace WebCore { -JSValue* JSXSLTProcessor::importStylesheet(ExecState* exec, const ArgList& args) +JSValuePtr JSXSLTProcessor::importStylesheet(ExecState* exec, const ArgList& args) { - JSValue* nodeVal = args.at(exec, 0); - if (nodeVal->isObject(&JSNode::s_info)) { + JSValuePtr nodeVal = args.at(exec, 0); + if (nodeVal.isObject(&JSNode::s_info)) { JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); impl()->importStylesheet(node->impl()); return jsUndefined(); @@ -58,11 +58,11 @@ JSValue* JSXSLTProcessor::importStylesheet(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue* JSXSLTProcessor::transformToFragment(ExecState* exec, const ArgList& args) +JSValuePtr JSXSLTProcessor::transformToFragment(ExecState* exec, const ArgList& args) { - JSValue* nodeVal = args.at(exec, 0); - JSValue* docVal = args.at(exec, 1); - if (nodeVal->isObject(&JSNode::s_info) && docVal->isObject(&JSDocument::s_info)) { + JSValuePtr nodeVal = args.at(exec, 0); + JSValuePtr docVal = args.at(exec, 1); + if (nodeVal.isObject(&JSNode::s_info) && docVal.isObject(&JSDocument::s_info)) { WebCore::Node* node = static_cast<JSNode*>(asObject(nodeVal))->impl(); Document* doc = static_cast<Document*>(static_cast<JSDocument*>(asObject(docVal))->impl()); return toJS(exec, impl()->transformToFragment(node, doc).get()); @@ -71,10 +71,10 @@ JSValue* JSXSLTProcessor::transformToFragment(ExecState* exec, const ArgList& ar return jsUndefined(); } -JSValue* JSXSLTProcessor::transformToDocument(ExecState* exec, const ArgList& args) +JSValuePtr JSXSLTProcessor::transformToDocument(ExecState* exec, const ArgList& args) { - JSValue* nodeVal = args.at(exec, 0); - if (nodeVal->isObject(&JSNode::s_info)) { + JSValuePtr nodeVal = args.at(exec, 0); + if (nodeVal.isObject(&JSNode::s_info)) { JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); RefPtr<Document> resultDocument = impl()->transformToDocument(node->impl()); if (resultDocument) @@ -85,33 +85,33 @@ JSValue* JSXSLTProcessor::transformToDocument(ExecState* exec, const ArgList& ar return jsUndefined(); } -JSValue* JSXSLTProcessor::setParameter(ExecState* exec, const ArgList& args) +JSValuePtr JSXSLTProcessor::setParameter(ExecState* exec, const ArgList& args) { - if (args.at(exec, 1)->isUndefinedOrNull() || args.at(exec, 2)->isUndefinedOrNull()) + if (args.at(exec, 1).isUndefinedOrNull() || args.at(exec, 2).isUndefinedOrNull()) return jsUndefined(); // Throw exception? - String namespaceURI = args.at(exec, 0)->toString(exec); - String localName = args.at(exec, 1)->toString(exec); - String value = args.at(exec, 2)->toString(exec); + String namespaceURI = args.at(exec, 0).toString(exec); + String localName = args.at(exec, 1).toString(exec); + String value = args.at(exec, 2).toString(exec); impl()->setParameter(namespaceURI, localName, value); return jsUndefined(); } -JSValue* JSXSLTProcessor::getParameter(ExecState* exec, const ArgList& args) +JSValuePtr JSXSLTProcessor::getParameter(ExecState* exec, const ArgList& args) { - if (args.at(exec, 1)->isUndefinedOrNull()) + if (args.at(exec, 1).isUndefinedOrNull()) return jsUndefined(); - String namespaceURI = args.at(exec, 0)->toString(exec); - String localName = args.at(exec, 1)->toString(exec); + String namespaceURI = args.at(exec, 0).toString(exec); + String localName = args.at(exec, 1).toString(exec); String value = impl()->getParameter(namespaceURI, localName); return jsStringOrUndefined(exec, value); } -JSValue* JSXSLTProcessor::removeParameter(ExecState* exec, const ArgList& args) +JSValuePtr JSXSLTProcessor::removeParameter(ExecState* exec, const ArgList& args) { - if (args.at(exec, 1)->isUndefinedOrNull()) + if (args.at(exec, 1).isUndefinedOrNull()) return jsUndefined(); - String namespaceURI = args.at(exec, 0)->toString(exec); - String localName = args.at(exec, 1)->toString(exec); + String namespaceURI = args.at(exec, 0).toString(exec); + String localName = args.at(exec, 1).toString(exec); impl()->removeParameter(namespaceURI, localName); return jsUndefined(); } diff --git a/WebCore/bindings/js/PausedTimeouts.cpp b/WebCore/bindings/js/PausedTimeouts.cpp deleted file mode 100644 index c8a59d8..0000000 --- a/WebCore/bindings/js/PausedTimeouts.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2000 Harri Porten (porten@kde.org) - * Copyright (C) 2006 Jon Shier (jshier@iastate.edu) - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reseved. - * Copyright (C) 2006 Alexey Proskuryakov (ap@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 "PausedTimeouts.h" - -#include "ScheduledAction.h" - -namespace WebCore { - -PausedTimeouts::~PausedTimeouts() -{ - PausedTimeout* array = m_array; - if (!array) - return; - size_t count = m_length; - for (size_t i = 0; i != count; ++i) - delete array[i].action; - delete [] array; -} - -} // namespace WebCore diff --git a/WebCore/bindings/js/PausedTimeouts.h b/WebCore/bindings/js/PausedTimeouts.h deleted file mode 100644 index 3839eae..0000000 --- a/WebCore/bindings/js/PausedTimeouts.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2000 Harri Porten (porten@kde.org) - * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reseved. - * - * 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 PausedTimeouts_h -#define PausedTimeouts_h - -#include <wtf/Noncopyable.h> - -namespace WebCore { - - class ScheduledAction; - - struct PausedTimeout { - int timeoutId; - int nestingLevel; - double nextFireInterval; - double repeatInterval; - ScheduledAction* action; - }; - - class PausedTimeouts : Noncopyable { - public: - PausedTimeouts(PausedTimeout* array, size_t length) - : m_array(array) - , m_length(length) - { - } - - ~PausedTimeouts(); - - size_t numTimeouts() const { return m_length; } - PausedTimeout* takeTimeouts() { PausedTimeout* a = m_array; m_array = 0; return a; } - - private: - PausedTimeout* m_array; - size_t m_length; - }; - -} // namespace WebCore - -#endif // PausedTimeouts_h diff --git a/WebCore/bindings/js/ScheduledAction.cpp b/WebCore/bindings/js/ScheduledAction.cpp index 8d13cd2..8627474 100644 --- a/WebCore/bindings/js/ScheduledAction.cpp +++ b/WebCore/bindings/js/ScheduledAction.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2006 Jon Shier (jshier@iastate.edu) * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved. * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) + * Copyright (C) 2009 Google Inc. All rights reseved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,59 +25,110 @@ #include "ScheduledAction.h" #include "CString.h" -#include "Console.h" #include "DOMWindow.h" #include "Document.h" #include "Frame.h" #include "FrameLoader.h" +#include "JSDOMBinding.h" #include "JSDOMWindow.h" +#ifdef ANDROID_FIX // these are generated files, need to check ENABLE(WORKERS) +#if ENABLE(WORKERS) +#include "JSWorkerContext.h" +#endif +#endif #include "ScriptController.h" +#include "ScriptExecutionContext.h" +#include "ScriptSourceCode.h" +#include "ScriptValue.h" +#include "WorkerContext.h" +#include "WorkerThread.h" #include <runtime/JSLock.h> using namespace JSC; namespace WebCore { -ScheduledAction::ScheduledAction(ExecState* exec, JSValue* function, const ArgList& args) +ScheduledAction::ScheduledAction(ExecState* exec, JSValuePtr function, const ArgList& args) : m_function(function) { ArgList::const_iterator end = args.end(); - for (ArgList::const_iterator it = args.begin(); it != end; ++it) + for (ArgList::const_iterator it = args.begin(); it != end; ++it) { m_args.append((*it).jsValue(exec)); + } } -void ScheduledAction::execute(JSDOMWindowShell* windowShell) +void ScheduledAction::execute(ScriptExecutionContext* context) { - RefPtr<Frame> frame = windowShell->window()->impl()->frame(); - if (!frame) - return; + if (context->isDocument()) + execute(static_cast<Document*>(context)); +#if ENABLE(WORKERS) + else { + ASSERT(context->isWorkerContext()); + execute(static_cast<WorkerContext*>(context)); + } +#else + ASSERT(context->isDocument()); +#endif +} + +void ScheduledAction::executeFunctionInContext(JSGlobalObject* globalObject, JSValuePtr thisValue) +{ + ASSERT(m_function); + JSLock lock(false); - if (!frame->script()->isEnabled()) + CallData callData; + CallType callType = m_function.get().getCallData(callData); + if (callType == CallTypeNone) return; - frame->script()->setProcessingTimerCallback(true); + ExecState* exec = globalObject->globalExec(); - JSLock lock(false); + ArgList args; + size_t size = m_args.size(); + for (size_t i = 0; i < size; ++i) + args.append(m_args[i]); + + globalObject->startTimeoutCheck(); + call(exec, m_function, callType, callData, thisValue, args); + globalObject->stopTimeoutCheck(); + + if (exec->hadException()) + reportCurrentException(exec); +} + +#if ENABLE(WORKERS) +void ScheduledAction::execute(WorkerContext* workerContext) +{ + // In a Worker, the execution should always happen on a worker thread. + ASSERT(workerContext->thread()->threadID() == currentThread()); + + WorkerScriptController* scriptController = workerContext->script(); if (m_function) { - CallData callData; - CallType callType = m_function->getCallData(callData); - if (callType != CallTypeNone) { - JSDOMWindow* window = windowShell->window(); - ExecState* exec = window->globalExec(); - - ArgList args; - size_t size = m_args.size(); - for (size_t i = 0; i < size; ++i) - args.append(m_args[i]); - - window->startTimeoutCheck(); - call(exec, m_function, callType, callData, windowShell, args); - window->stopTimeoutCheck(); - if (exec->hadException()) - frame->domWindow()->console()->reportCurrentException(exec); - } - } else + JSWorkerContext* contextWrapper = scriptController->workerContextWrapper(); + executeFunctionInContext(contextWrapper, contextWrapper); + } else { + ScriptSourceCode code(m_code, workerContext->url()); + scriptController->evaluate(code); + } +} +#endif // ENABLE(WORKERS) + +void ScheduledAction::execute(Document* document) +{ + JSDOMWindow* window = toJSDOMWindow(document->frame()); + if (!window) + return; + + RefPtr<Frame> frame = window->impl()->frame(); + if (!frame || !frame->script()->isEnabled()) + return; + + frame->script()->setProcessingTimerCallback(true); + + if (m_function) + executeFunctionInContext(window, window->shell()); + else frame->loader()->executeScript(m_code); // Update our document's rendering following the execution of the timeout callback. diff --git a/WebCore/bindings/js/ScheduledAction.h b/WebCore/bindings/js/ScheduledAction.h index 938ac7b..a1dbbe4 100644 --- a/WebCore/bindings/js/ScheduledAction.h +++ b/WebCore/bindings/js/ScheduledAction.h @@ -21,12 +21,18 @@ #define ScheduledAction_h #include "PlatformString.h" -#include <kjs/protect.h> +#include <runtime/Protect.h> #include <wtf/Vector.h> +namespace JSC { + class JSGlobalObject; +} + namespace WebCore { - class JSDOMWindowShell; + class Document; + class ScriptExecutionContext; + class WorkerContext; /* An action (either function or string) to be executed after a specified * time interval, either once or repeatedly. Used for window.setTimeout() @@ -34,17 +40,23 @@ namespace WebCore { */ class ScheduledAction { public: - ScheduledAction(JSC::ExecState* exec, JSC::JSValue* function, const JSC::ArgList&); + ScheduledAction(JSC::ExecState* exec, JSC::JSValuePtr function, const JSC::ArgList&); ScheduledAction(const String& code) : m_code(code) { } - void execute(JSDOMWindowShell*); + void execute(ScriptExecutionContext*); private: - JSC::ProtectedPtr<JSC::JSValue> m_function; - Vector<JSC::ProtectedPtr<JSC::JSValue> > m_args; + void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValuePtr thisValue); + void execute(Document*); +#if ENABLE(WORKERS) + void execute(WorkerContext*); +#endif + + JSC::ProtectedJSValuePtr m_function; + Vector<JSC::ProtectedJSValuePtr> m_args; String m_code; }; diff --git a/WebCore/bindings/js/ScriptCachedFrameData.cpp b/WebCore/bindings/js/ScriptCachedFrameData.cpp new file mode 100644 index 0000000..955a368 --- /dev/null +++ b/WebCore/bindings/js/ScriptCachedFrameData.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2008, Google Inc. All rights reserved. + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * 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 "ScriptCachedFrameData.h" + +#include "Frame.h" +#include "GCController.h" +#include "Page.h" +#include "PageGroup.h" +#include <runtime/JSLock.h> +#include "ScriptController.h" + +using namespace JSC; + +namespace WebCore { + +ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame) +{ + JSLock lock(false); + + ScriptController* scriptController = frame->script(); + if (scriptController->haveWindowShell()) { + m_window = scriptController->windowShell()->window(); + } +} + +DOMWindow* ScriptCachedFrameData::domWindow() const { + return m_window ? m_window->impl() : 0; +} + +ScriptCachedFrameData::~ScriptCachedFrameData() +{ + clear(); +} + +void ScriptCachedFrameData::restore(Frame* frame) +{ + Page* page = frame->page(); + + JSLock lock(false); + + ScriptController* scriptController = frame->script(); + if (scriptController->haveWindowShell()) { + JSDOMWindowShell* windowShell = scriptController->windowShell(); + if (m_window) { + windowShell->setWindow(m_window.get()); + } else { + windowShell->setWindow(frame->domWindow()); + scriptController->attachDebugger(page->debugger()); + windowShell->window()->setProfileGroup(page->group().identifier()); + } + } +} + +void ScriptCachedFrameData::clear() +{ + JSLock lock(false); + + if (!m_window) { + m_window = 0; + gcController().garbageCollectSoon(); + } +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/ScriptCachedFrameData.h b/WebCore/bindings/js/ScriptCachedFrameData.h new file mode 100644 index 0000000..c661f28 --- /dev/null +++ b/WebCore/bindings/js/ScriptCachedFrameData.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2008, Google Inc. All rights reserved. + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * 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 ScriptCachedFrameData_h +#define ScriptCachedFrameData_h + +#include <runtime/Protect.h> + +namespace WebCore { + class Frame; + class JSDOMWindow; + class DOMWindow; + + class ScriptCachedFrameData { + public: + ScriptCachedFrameData(Frame*); + ~ScriptCachedFrameData(); + + void restore(Frame*); + void clear(); + DOMWindow* domWindow() const; + + private: + JSC::ProtectedPtr<JSDOMWindow> m_window; + }; + +} // namespace WebCore + +#endif // ScriptCachedFrameData_h diff --git a/WebCore/bindings/js/ScriptCallFrame.cpp b/WebCore/bindings/js/ScriptCallFrame.cpp new file mode 100644 index 0000000..29f380a --- /dev/null +++ b/WebCore/bindings/js/ScriptCallFrame.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2008, 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 "ScriptCallFrame.h" + +#include <interpreter/CallFrame.h> +#include <runtime/UString.h> + +using namespace JSC; + +namespace WebCore { + +ScriptCallFrame::ScriptCallFrame(const UString& functionName, const UString& urlString, int lineNumber, ExecState* exec, const ArgList& args, unsigned skipArgumentCount) + : m_functionName(functionName) + , m_sourceURL(urlString) + , m_lineNumber(lineNumber) +{ + size_t argumentCount = args.size(); + for (size_t i = skipArgumentCount; i < argumentCount; ++i) + m_arguments.append(ScriptValue(args.at(exec, i))); +} + +ScriptCallFrame::~ScriptCallFrame() +{ +} + +const ScriptValue &ScriptCallFrame::argumentAt(unsigned index) const +{ + ASSERT(m_arguments.size() > index); + return m_arguments[index]; +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/ScriptCallFrame.h b/WebCore/bindings/js/ScriptCallFrame.h new file mode 100644 index 0000000..64a1a08 --- /dev/null +++ b/WebCore/bindings/js/ScriptCallFrame.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2008, 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 ScriptCallFrame_h +#define ScriptCallFrame_h + +#include "KURL.h" +#include <runtime/ArgList.h> +#include "ScriptString.h" +#include "ScriptValue.h" +#include <wtf/Vector.h> + +namespace JSC { + class ExecState; + class InternalFunction; +} + +namespace WebCore { + + // FIXME: Implement retrieving line number and source URL and storing here + // for all call frames, not just the first one. + // See <https://bugs.webkit.org/show_bug.cgi?id=22556> and + // <https://bugs.webkit.org/show_bug.cgi?id=21180> + class ScriptCallFrame { + public: + ScriptCallFrame(const JSC::UString& functionName, const JSC::UString& urlString, int lineNumber, JSC::ExecState*, const JSC::ArgList&, unsigned skipArgumentCount); + ~ScriptCallFrame(); + + const ScriptString& functionName() const { return m_functionName; } + const KURL& sourceURL() const { return m_sourceURL; } + unsigned lineNumber() const { return m_lineNumber; } + + // argument retrieval methods + const ScriptValue& argumentAt(unsigned) const; + unsigned argumentCount() const { return m_arguments.size(); } + + private: + ScriptString m_functionName; + KURL m_sourceURL; + unsigned m_lineNumber; + + Vector<ScriptValue> m_arguments; + }; + +} // namespace WebCore + +#endif // ScriptCallFrame_h diff --git a/WebCore/bindings/js/ScriptCallStack.cpp b/WebCore/bindings/js/ScriptCallStack.cpp new file mode 100644 index 0000000..d984bf4 --- /dev/null +++ b/WebCore/bindings/js/ScriptCallStack.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2008, 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 "ScriptCallStack.h" + +#include <interpreter/CallFrame.h> +#include <interpreter/Interpreter.h> +#include <runtime/InternalFunction.h> +#include <runtime/JSValue.h> +#include <runtime/UString.h> +#include <runtime/JSGlobalData.h> + +using namespace JSC; + +namespace WebCore { + +ScriptCallStack::ScriptCallStack(ExecState* exec, const ArgList& args, unsigned skipArgumentCount) + : m_initialized(false) + , m_exec(exec) + , m_caller(0) +{ + int signedLineNumber; + intptr_t sourceID; + UString urlString; + JSValuePtr function; + + exec->interpreter()->retrieveLastCaller(exec, signedLineNumber, sourceID, urlString, function); + + if (function) { + m_caller = asInternalFunction(function); + unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0; + m_frames.append(ScriptCallFrame(m_caller->name(&m_exec->globalData()), urlString, lineNumber, exec, args, skipArgumentCount)); + } else { + // Caller is unknown, but we should still add the frame, because + // something called us, and gave us arguments. + m_frames.append(ScriptCallFrame(UString(), UString(), 0, exec, args, skipArgumentCount)); + } +} + +ScriptCallStack::~ScriptCallStack() +{ +} + +const ScriptCallFrame &ScriptCallStack::at(unsigned index) +{ + // First frame is pre-populated in constructor, so don't trigger + // initialization unless looking beyond the first frame. + if (index > 0) + initialize(); + ASSERT(m_frames.size() > index); + return m_frames[index]; +} + +unsigned ScriptCallStack::size() +{ + initialize(); + return m_frames.size(); +} + +void ScriptCallStack::initialize() +{ + if (!m_caller || m_initialized) + return; + + JSValuePtr func = m_exec->interpreter()->retrieveCaller(m_exec, m_caller); + while (!func.isNull()) { + InternalFunction* internalFunction = asInternalFunction(func); + ArgList emptyArgList; + m_frames.append(ScriptCallFrame(internalFunction->name(&m_exec->globalData()), UString(), 0, 0, emptyArgList, 0)); + func = m_exec->interpreter()->retrieveCaller(m_exec, internalFunction); + } + m_initialized = true; +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/ScriptCallStack.h b/WebCore/bindings/js/ScriptCallStack.h new file mode 100644 index 0000000..7634ce3 --- /dev/null +++ b/WebCore/bindings/js/ScriptCallStack.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008, 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 ScriptCallStack_h +#define ScriptCallStack_h + +#include "ScriptCallFrame.h" +#include "ScriptState.h" +#include "ScriptString.h" +#include <wtf/Noncopyable.h> + +namespace JSC { + class ExecState; + class JSValuePtr; +} + +namespace WebCore { + + class ScriptCallStack : public Noncopyable { + public: + ScriptCallStack(JSC::ExecState*, const JSC::ArgList&, unsigned skipArgumentCount = 0); + ~ScriptCallStack(); + + ScriptState* state() const { return m_exec; } + // frame retrieval methods + const ScriptCallFrame &at(unsigned); + unsigned size(); + + private: + void initialize(); + bool m_initialized; + + JSC::ExecState* m_exec; + Vector<ScriptCallFrame> m_frames; + JSC::InternalFunction* m_caller; + }; + +} // namespace WebCore + +#endif // ScriptCallStack_h diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 5346c07..efd3a70 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -36,12 +36,12 @@ #include "NP_jsobject.h" #include "Page.h" #include "PageGroup.h" -#include "PausedTimeouts.h" #include "runtime_root.h" +#include "ScriptSourceCode.h" +#include "ScriptValue.h" #include "Settings.h" -#include "StringSourceProvider.h" -#include <kjs/completion.h> +#include <runtime/Completion.h> #include <debugger/Debugger.h> #include <runtime/JSLock.h> @@ -87,10 +87,12 @@ ScriptController::~ScriptController() disconnectPlatformScriptObjects(); } -JSValue* ScriptController::evaluate(const String& sourceURL, int baseLine, const String& str) +ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) { // evaluate code. Returns the JS return value or 0 // if there was none, an error occured or the type couldn't be converted. + + const SourceCode& jsSourceCode = sourceCode.jsSourceCode(); initScriptIfNeeded(); // inlineCode is true for <a href="javascript:doSomething()"> @@ -99,6 +101,7 @@ JSValue* ScriptController::evaluate(const String& sourceURL, int baseLine, const // See smart window.open policy for where this is used. ExecState* exec = m_windowShell->window()->globalExec(); const String* savedSourceURL = m_sourceURL; + String sourceURL = jsSourceCode.provider()->url(); m_sourceURL = &sourceURL; JSLock lock(false); @@ -108,7 +111,7 @@ JSValue* ScriptController::evaluate(const String& sourceURL, int baseLine, const m_frame->keepAlive(); m_windowShell->window()->startTimeoutCheck(); - Completion comp = Interpreter::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), makeSource(str, sourceURL, baseLine), m_windowShell); + Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), jsSourceCode, m_windowShell); m_windowShell->window()->stopTimeoutCheck(); if (comp.complType() == Normal || comp.complType() == ReturnValue) { @@ -117,7 +120,7 @@ JSValue* ScriptController::evaluate(const String& sourceURL, int baseLine, const } if (comp.complType() == Throw) - m_frame->domWindow()->console()->reportException(exec, comp.value()); + reportException(exec, comp.value()); m_sourceURL = savedSourceURL; return noValue(); @@ -177,6 +180,11 @@ void ScriptController::initScript() bool ScriptController::processingUserGesture() const { + return processingUserGestureEvent() || isJavaScriptAnchorNavigation(); +} + +bool ScriptController::processingUserGestureEvent() const +{ if (!m_windowShell) return false; @@ -198,13 +206,37 @@ bool ScriptController::processingUserGesture() const type == eventNames().focusEvent || type == eventNames().blurEvent || type == eventNames().submitEvent) return true; - } else { // no event - if (m_sourceURL && m_sourceURL->isNull() && !m_processingTimerCallback) { - // This is the <a href="javascript:window.open('...')> case -> we let it through - return true; + } + + return false; +} + +// FIXME: This seems like an insufficient check to verify a click on a javascript: anchor. +bool ScriptController::isJavaScriptAnchorNavigation() const +{ + // This is the <a href="javascript:window.open('...')> case -> we let it through + if (m_sourceURL && m_sourceURL->isNull() && !m_processingTimerCallback) + return true; + + // This is the <script>window.open(...)</script> case or a timer callback -> block it + return false; +} + +bool ScriptController::anyPageIsProcessingUserGesture() const +{ + Page* page = m_frame->page(); + if (!page) + return false; + + const HashSet<Page*>& pages = page->group().pages(); + HashSet<Page*>::const_iterator end = pages.end(); + for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { + for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) { + if (frame->script()->processingUserGesture()) + return true; } - // This is the <script>window.open(...)</script> case or a timer callback -> block it } + return false; } @@ -238,6 +270,10 @@ void ScriptController::updateDocument() (*it)->updateDocument(); } +void ScriptController::updateSecurityOrigin() +{ + // Our bindings do not do anything in this case. +} Bindings::RootObject* ScriptController::bindingRootObject() { @@ -294,17 +330,17 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement // Create a JSObject bound to this element JSLock lock(false); ExecState* exec = globalObject()->globalExec(); - JSValue* jsElementValue = toJS(exec, plugin); - if (!jsElementValue || !jsElementValue->isObject()) + JSValuePtr jsElementValue = toJS(exec, plugin); + if (!jsElementValue || !jsElementValue.isObject()) return _NPN_CreateNoScriptObject(); // Wrap the JSObject in an NPObject - return _NPN_CreateScriptObject(0, jsElementValue->getObject(), bindingRootObject()); + return _NPN_CreateScriptObject(0, jsElementValue.getObject(), bindingRootObject()); } #endif #if !PLATFORM(MAC) -void ScriptController::clearPlatformScriptObjects() +void ScriptController::updatePlatformScriptObjects() { } @@ -348,29 +384,6 @@ void ScriptController::clearScriptObjects() m_windowScriptNPObject = 0; } #endif - - clearPlatformScriptObjects(); -} - -void ScriptController::pauseTimeouts(OwnPtr<PausedTimeouts>& result) -{ - if (!haveWindowShell()) { - result.clear(); - return; - } - - windowShell()->window()->pauseTimeouts(result); -} - -void ScriptController::resumeTimeouts(OwnPtr<PausedTimeouts>& pausedTimeouts) -{ - if (!haveWindowShell()) { - // Callers can assume we will always clear the passed in timeouts - pausedTimeouts.clear(); - return; - } - - windowShell()->window()->resumeTimeouts(pausedTimeouts); } } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index 047957c..28fd7e9 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -23,7 +23,8 @@ #define ScriptController_h #include "JSDOMWindowShell.h" -#include <kjs/protect.h> +#include "ScriptInstance.h" +#include <runtime/Protect.h> #include <wtf/RefPtr.h> #if PLATFORM(MAC) @@ -42,7 +43,6 @@ namespace JSC { class JSGlobalObject; namespace Bindings { - class Instance; class RootObject; } } @@ -54,6 +54,8 @@ class EventListener; class HTMLPlugInElement; class Frame; class Node; +class ScriptSourceCode; +class ScriptValue; class String; class Widget; @@ -77,7 +79,7 @@ public: return m_windowShell->window(); } - JSC::JSValue* evaluate(const String& sourceURL, int baseLine, const String& code); + ScriptValue evaluate(const ScriptSourceCode&); PassRefPtr<EventListener> createInlineEventListener(const String& functionName, const String& code, Node*); #if ENABLE(SVG) @@ -87,6 +89,7 @@ public: void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; } bool processingUserGesture() const; + bool anyPageIsProcessingUserGesture() const; bool isEnabled(); @@ -101,13 +104,18 @@ public: void clearFormerWindow(JSDOMWindow* window) { m_liveFormerWindows.remove(window); } void updateDocument(); - void pauseTimeouts(OwnPtr<PausedTimeouts>&); - void resumeTimeouts(OwnPtr<PausedTimeouts>&); + // Notifies the ScriptController that the securityOrigin of the current + // document was modified. For example, this method is called when + // document.domain is set. This method is *not* called when a new document + // is attached to a frame because updateDocument() is called instead. + void updateSecurityOrigin(); void clearScriptObjects(); void cleanupScriptObjectsForPlugin(void*); - PassRefPtr<JSC::Bindings::Instance> createScriptInstanceForWidget(Widget*); + void updatePlatformScriptObjects(); + + PassScriptInstance createScriptInstanceForWidget(Widget*); JSC::Bindings::RootObject* bindingRootObject(); PassRefPtr<JSC::Bindings::RootObject> createRootObject(void* nativeHandle); @@ -132,9 +140,11 @@ private: } void initScript(); - void clearPlatformScriptObjects(); void disconnectPlatformScriptObjects(); + bool processingUserGestureEvent() const; + bool isJavaScriptAnchorNavigation() const; + JSC::ProtectedPtr<JSDOMWindowShell> m_windowShell; HashSet<JSDOMWindow*> m_liveFormerWindows; Frame* m_frame; diff --git a/WebCore/bindings/js/ScriptControllerMac.mm b/WebCore/bindings/js/ScriptControllerMac.mm index df65352..17ad0b2 100644 --- a/WebCore/bindings/js/ScriptControllerMac.mm +++ b/WebCore/bindings/js/ScriptControllerMac.mm @@ -57,13 +57,14 @@ @interface NSObject (WebPlugin) - (id)objectForWebScript; - (NPObject *)createPluginScriptableObject; +- (PassRefPtr<JSC::Bindings::Instance>)createPluginBindingsInstance:(PassRefPtr<JSC::Bindings::RootObject>)rootObject; @end using namespace JSC::Bindings; namespace WebCore { -PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(Widget* widget) +PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widget) { NSView* widgetView = widget->platformWidget(); if (!widgetView) @@ -71,6 +72,9 @@ PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWid RefPtr<RootObject> rootObject = createRootObject(widgetView); + if ([widgetView respondsToSelector:@selector(createPluginBindingsInstance:)]) + return [widgetView createPluginBindingsInstance:rootObject.release()]; + if ([widgetView respondsToSelector:@selector(objectForWebScript)]) { id objectForWebScript = [widgetView objectForWebScript]; if (!objectForWebScript) @@ -117,7 +121,7 @@ WebScriptObject* ScriptController::windowScriptObject() return m_windowScriptObject.get(); } -void ScriptController::clearPlatformScriptObjects() +void ScriptController::updatePlatformScriptObjects() { if (m_windowScriptObject) { JSC::Bindings::RootObject* root = bindingRootObject(); @@ -134,9 +138,10 @@ void ScriptController::disconnectPlatformScriptObjects() } #if ENABLE(MAC_JAVA_BRIDGE) + static pthread_t mainThread; -static void updateRenderingForBindings(JSC::ExecState* exec, JSC::JSObject* rootObject) +static void updateRenderingForBindings(JSC::ExecState*, JSC::JSObject* rootObject) { if (pthread_self() != mainThread) return; @@ -165,6 +170,7 @@ void ScriptController::initJavaJSBindings() JSC::Bindings::JavaJSObject::initializeJNIThreading(); JSC::Bindings::Instance::setDidExecuteFunction(updateRenderingForBindings); } + #endif } diff --git a/WebCore/bindings/js/ScriptControllerQt.cpp b/WebCore/bindings/js/ScriptControllerQt.cpp index a09c7b7..8e9dfad 100644 --- a/WebCore/bindings/js/ScriptControllerQt.cpp +++ b/WebCore/bindings/js/ScriptControllerQt.cpp @@ -48,12 +48,12 @@ namespace WebCore { PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(WebCore::Widget* widget) { - if (!widget->isPluginView()) + if (widget->isPluginView()) { + PluginView* pluginView = static_cast<PluginView*>(widget); + if (pluginView->isNPAPIPlugin()) + return pluginView->bindingInstance(); return 0; - - PluginView* pluginView = static_cast<PluginView*>(widget); - if (pluginView->isNPAPIPlugin()) - return pluginView->bindingInstance(); + } QWidget* platformWidget = widget->platformWidget(); if (!platformWidget) diff --git a/WebCore/bindings/js/ScriptInstance.h b/WebCore/bindings/js/ScriptInstance.h new file mode 100644 index 0000000..3095df9 --- /dev/null +++ b/WebCore/bindings/js/ScriptInstance.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2008, 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 ScriptInstance_h +#define ScriptInstance_h + +#include <wtf/RefPtr.h> +#include "runtime.h" + +namespace WebCore { + +typedef RefPtr<JSC::Bindings::Instance> ScriptInstance; +typedef PassRefPtr<JSC::Bindings::Instance> PassScriptInstance; + +} // namespace WebCore + +#endif // ScriptInstance_h diff --git a/WebCore/bindings/js/ScriptSourceCode.h b/WebCore/bindings/js/ScriptSourceCode.h new file mode 100644 index 0000000..4a2403d --- /dev/null +++ b/WebCore/bindings/js/ScriptSourceCode.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2008, 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 ScriptSourceCode_h +#define ScriptSourceCode_h + +#include "CachedScriptSourceProvider.h" +#include "StringSourceProvider.h" +#include "KURL.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)) + { + } + + ScriptSourceCode(CachedScript* cs) + : m_code(makeSource(cs)) + { + } + + bool isEmpty() const { return m_code.length() == 0; } + + const JSC::SourceCode& jsSourceCode() const { return m_code; } + +private: + JSC::SourceCode m_code; +}; + +} // namespace WebCore + +#endif // ScriptSourceCode_h diff --git a/WebCore/bindings/js/ScriptState.h b/WebCore/bindings/js/ScriptState.h new file mode 100644 index 0000000..3cce093 --- /dev/null +++ b/WebCore/bindings/js/ScriptState.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2008, 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 ScriptState_h +#define ScriptState_h + +namespace JSC { + class ExecState; +} + +namespace WebCore { + + // The idea is to expose "state-like" methods (hadException, and any other + // methods where ExecState just dips into globalData) of JSC::ExecState as a + // separate abstraction. + // For now, the separation is purely by convention. + typedef JSC::ExecState ScriptState; + +} // namespace WebCore + +#endif // ScriptState_h diff --git a/WebCore/bindings/js/ScriptString.h b/WebCore/bindings/js/ScriptString.h new file mode 100644 index 0000000..6dab9a0 --- /dev/null +++ b/WebCore/bindings/js/ScriptString.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2008, 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 ScriptString_h +#define ScriptString_h + +#include "PlatformString.h" +#include <runtime/UString.h> + +namespace WebCore { + +class String; + +class ScriptString { +public: + ScriptString() {} + ScriptString(const char* s) : m_str(s) {} + ScriptString(const JSC::UString& s) : m_str(s) {} + + operator JSC::UString() const { return m_str; } + + bool isNull() const { return m_str.isNull(); } + size_t size() const { return m_str.size(); } + + ScriptString& operator=(const char* s) + { + m_str = s; + return *this; + } + + ScriptString& operator+=(const String& s) + { + m_str += s; + return *this; + } + + bool operator==(const ScriptString& s) const + { + return m_str == s.m_str; + } + + bool operator!=(const ScriptString& s) const + { + // Avoid exporting an extra symbol by re-using "==" operator. + return !(m_str == s.m_str); + } + +private: + JSC::UString m_str; +}; + +} // namespace WebCore + +#endif // ScriptString_h diff --git a/WebCore/bindings/js/ScriptValue.cpp b/WebCore/bindings/js/ScriptValue.cpp new file mode 100644 index 0000000..37e3f67 --- /dev/null +++ b/WebCore/bindings/js/ScriptValue.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptValue.h" + +#include "PlatformString.h" +#include <runtime/JSLock.h> +#include <runtime/Protect.h> +#include <runtime/UString.h> + +using namespace JSC; + +namespace WebCore { + +bool ScriptValue::getString(String& result) const +{ + if (!m_value) + return false; + JSLock lock(false); + UString ustring; + if (!m_value.get().getString(ustring)) + return false; + result = ustring; + return true; +} + +bool ScriptValue::isNull() const +{ + if (!m_value) + return false; + return m_value.get().isNull(); +} + +bool ScriptValue::isUndefined() const +{ + if (!m_value) + return false; + return m_value.get().isUndefined(); +} + +} // namespace WebCore diff --git a/WebCore/bindings/js/ScriptValue.h b/WebCore/bindings/js/ScriptValue.h new file mode 100644 index 0000000..855509a --- /dev/null +++ b/WebCore/bindings/js/ScriptValue.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2008, 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 ScriptValue_h +#define ScriptValue_h + +#include <runtime/Protect.h> + +namespace WebCore { + +class String; + +class ScriptValue { +public: + ScriptValue(JSC::JSValuePtr value = JSC::noValue()) : m_value(value) {} + + JSC::JSValuePtr jsValue() const { return m_value.get(); } + bool getString(String& result) const; + bool isNull() const; + bool isUndefined() const; + +private: + JSC::ProtectedJSValuePtr m_value; +}; + +} // namespace WebCore + +#endif // ScriptValue_h diff --git a/WebCore/bindings/js/StringSourceProvider.h b/WebCore/bindings/js/StringSourceProvider.h index faa848c..ab37a56 100644 --- a/WebCore/bindings/js/StringSourceProvider.h +++ b/WebCore/bindings/js/StringSourceProvider.h @@ -29,7 +29,7 @@ #ifndef StringSourceProvider_h #define StringSourceProvider_h -#include <kjs/SourceCode.h> +#include <parser/SourceCode.h> namespace WebCore { @@ -51,10 +51,11 @@ namespace WebCore { String m_source; }; - inline JSC::SourceCode makeSource(const String& source, const JSC::UString& url = JSC::UString(), int firstLine = 1) + inline JSC::SourceCode makeSource(const String& source, const String& url = String(), int firstLine = 1) { return JSC::SourceCode(StringSourceProvider::create(source, url), firstLine); } -} -#endif +} // namespace WebCore + +#endif // StringSourceProvider_h diff --git a/WebCore/bindings/js/WorkerScriptController.cpp b/WebCore/bindings/js/WorkerScriptController.cpp new file mode 100644 index 0000000..0727510 --- /dev/null +++ b/WebCore/bindings/js/WorkerScriptController.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "config.h" + +#if ENABLE(WORKERS) + +#include "WorkerScriptController.h" + +#include "JSDOMBinding.h" +#include "JSWorkerContext.h" +#include "ScriptSourceCode.h" +#include "ScriptValue.h" +#include "WorkerContext.h" +#include "WorkerMessagingProxy.h" +#include "WorkerThread.h" +#include <interpreter/Interpreter.h> +#include <runtime/Completion.h> +#include <runtime/Completion.h> +#include <runtime/JSLock.h> + +using namespace JSC; + +namespace WebCore { + +WorkerScriptController::WorkerScriptController(WorkerContext* workerContext) + : m_globalData(JSGlobalData::create()) + , m_workerContext(workerContext) + , m_executionForbidden(false) +{ +} + +WorkerScriptController::~WorkerScriptController() +{ + m_workerContextWrapper = 0; // Unprotect the global object. + + ASSERT(!m_globalData->heap.protectedObjectCount()); + ASSERT(!m_globalData->heap.isBusy()); + m_globalData->heap.destroy(); +} + +void WorkerScriptController::initScript() +{ + ASSERT(!m_workerContextWrapper); + + JSLock lock(false); + + RefPtr<Structure> prototypeStructure = JSWorkerContextPrototype::createStructure(jsNull()); + RefPtr<Structure> structure = JSWorkerContext::createStructure(new (m_globalData.get()) JSWorkerContextPrototype(prototypeStructure.release())); + m_workerContextWrapper = new (m_globalData.get()) JSWorkerContext(structure.release(), m_workerContext); +} + +ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode) +{ + { + MutexLocker lock(m_sharedDataMutex); + if (m_executionForbidden) + return noValue(); + } + + initScriptIfNeeded(); + JSLock lock(false); + + ExecState* exec = m_workerContextWrapper->globalExec(); + m_workerContextWrapper->startTimeoutCheck(); + Completion comp = JSC::evaluate(exec, exec->dynamicGlobalObject()->globalScopeChain(), sourceCode.jsSourceCode(), m_workerContextWrapper); + m_workerContextWrapper->stopTimeoutCheck(); + + m_workerContext->thread()->messagingProxy()->reportWorkerThreadActivity(m_workerContext->hasPendingActivity()); + + if (comp.complType() == Normal || comp.complType() == ReturnValue) + return comp.value(); + + if (comp.complType() == Throw) + reportException(exec, comp.value()); + return noValue(); +} + +void WorkerScriptController::forbidExecution() +{ + // This function is called from another thread. + // Mutex protection for m_executionForbidden is needed to guarantee that the value is synchronized between processors, because + // if it were not, the worker could re-enter JSC::evaluate(), but with timeout already reset. + // It is not critical for Interpreter::m_timeoutTime to be synchronized, we just rely on it reaching the worker thread's processor sooner or later. + MutexLocker lock(m_sharedDataMutex); + m_executionForbidden = true; + m_globalData->interpreter->setTimeoutTime(1); // 1 ms is the smallest timeout that can be set. +} + +} // namespace WebCore + +#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/WorkerScriptController.h b/WebCore/bindings/js/WorkerScriptController.h new file mode 100644 index 0000000..1dda5da --- /dev/null +++ b/WebCore/bindings/js/WorkerScriptController.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef WorkerScriptController_h +#define WorkerScriptController_h + +#if ENABLE(WORKERS) + +#include <runtime/Protect.h> +#include <wtf/Noncopyable.h> +#include <wtf/Threading.h> + +namespace JSC { + class JSGlobalData; +} + +namespace WebCore { + + class JSWorkerContext; + class ScriptSourceCode; + class ScriptValue; + class String; + class WorkerContext; + + class WorkerScriptController : Noncopyable { + public: + WorkerScriptController(WorkerContext*); + ~WorkerScriptController(); + + JSWorkerContext* workerContextWrapper() + { + initScriptIfNeeded(); + return m_workerContextWrapper; + } + + ScriptValue evaluate(const ScriptSourceCode&); + + void forbidExecution(); + + private: + void initScriptIfNeeded() + { + if (!m_workerContextWrapper) + initScript(); + } + void initScript(); + + RefPtr<JSC::JSGlobalData> m_globalData; + WorkerContext* m_workerContext; + JSC::ProtectedPtr<JSWorkerContext> m_workerContextWrapper; + + Mutex m_sharedDataMutex; + bool m_executionForbidden; + }; + +} // namespace WebCore + +#endif // ENABLE(WORKERS) + +#endif // WorkerScriptController_h |