diff options
Diffstat (limited to 'WebCore/bindings/js')
49 files changed, 1054 insertions, 1085 deletions
diff --git a/WebCore/bindings/js/JSArrayBufferViewCustom.cpp b/WebCore/bindings/js/JSArrayBufferViewCustom.cpp deleted file mode 100644 index ccbddd2..0000000 --- a/WebCore/bindings/js/JSArrayBufferViewCustom.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(3D_CANVAS) || ENABLE(BLOB) - -#include "config.h" -#include "JSArrayBufferView.h" -#include "JSInt8Array.h" -#include "JSUint8Array.h" -#include "JSInt16Array.h" -#include "JSUint16Array.h" -#include "JSInt32Array.h" -#include "JSUint32Array.h" -#include "JSFloat32Array.h" - -#include "ArrayBufferView.h" - -using namespace JSC; - -namespace WebCore { - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ArrayBufferView* object) -{ - if (!object) - return jsUndefined(); - - if (object) { - if (object->isFloatArray()) - return getDOMObjectWrapper<JSFloat32Array>(exec, globalObject, static_cast<Float32Array*>(object)); - if (object->isUnsignedByteArray()) - return getDOMObjectWrapper<JSUint8Array>(exec, globalObject, static_cast<Uint8Array*>(object)); - if (object->isByteArray()) - return getDOMObjectWrapper<JSInt8Array>(exec, globalObject, static_cast<Int8Array*>(object)); - if (object->isIntArray()) - return getDOMObjectWrapper<JSInt32Array>(exec, globalObject, static_cast<Int32Array*>(object)); - if (object->isUnsignedIntArray()) - return getDOMObjectWrapper<JSUint32Array>(exec, globalObject, static_cast<Uint32Array*>(object)); - if (object->isShortArray()) - return getDOMObjectWrapper<JSInt16Array>(exec, globalObject, static_cast<Int16Array*>(object)); - if (object->isUnsignedShortArray()) - return getDOMObjectWrapper<JSUint16Array>(exec, globalObject, static_cast<Uint16Array*>(object)); - } - return jsUndefined(); -} - -JSValue JSArrayBufferView::slice(ExecState* exec) -{ - ArrayBufferView* array = reinterpret_cast<ArrayBufferView*>(impl()); - - int start, end; - switch (exec->argumentCount()) { - case 0: - start = 0; - end = array->length(); - break; - case 1: - start = exec->argument(0).toInt32(exec); - end = array->length(); - break; - default: - start = exec->argument(0).toInt32(exec); - end = exec->argument(1).toInt32(exec); - } - return toJS(exec, globalObject(), array->slice(start, end)); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/bindings/js/JSArrayBufferViewHelper.h b/WebCore/bindings/js/JSArrayBufferViewHelper.h index ba712c6..f34f4b9 100644 --- a/WebCore/bindings/js/JSArrayBufferViewHelper.h +++ b/WebCore/bindings/js/JSArrayBufferViewHelper.h @@ -86,16 +86,33 @@ JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, T* (*conversionF // Template function used by XXXArrayConstructors. // If this returns 0, it will already have thrown a JavaScript exception. template<class C, typename T> -PassRefPtr<ArrayBufferView> constructArrayBufferView(JSC::ExecState* exec) +PassRefPtr<C> constructArrayBufferViewWithArrayBufferArgument(JSC::ExecState* exec) +{ + RefPtr<ArrayBuffer> buffer = toArrayBuffer(exec->argument(0)); + if (!buffer) + return 0; + + unsigned offset = (exec->argumentCount() > 1) ? exec->argument(1).toUInt32(exec) : 0; + if ((buffer->byteLength() - offset) % sizeof(T)) + throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size.")); + unsigned int length = (buffer->byteLength() - offset) / sizeof(T); + if (exec->argumentCount() > 2) + length = exec->argument(2).toUInt32(exec); + RefPtr<C> array = C::create(buffer, offset, length); + if (!array) + setDOMException(exec, INDEX_SIZE_ERR); + return array; +} + +template<class C, typename T> +PassRefPtr<C> constructArrayBufferView(JSC::ExecState* exec) { // There are 3 constructors: // // 1) (in int size) // 2) (in ArrayBuffer buffer, [Optional] in int offset, [Optional] in unsigned int length) // 3) (in sequence<T>) - This ends up being a JS "array-like" object - // - RefPtr<C> arrayObject; - + // // For the 0 args case, just create a zero-length view. We could // consider raising a SyntaxError for this case, but not all // JavaScript DOM bindings can distinguish between "new @@ -112,20 +129,10 @@ PassRefPtr<ArrayBufferView> constructArrayBufferView(JSC::ExecState* exec) } if (exec->argument(0).isObject()) { - RefPtr<ArrayBuffer> buffer = toArrayBuffer(exec->argument(0)); - if (buffer) { - unsigned offset = (exec->argumentCount() > 1) ? exec->argument(1).toUInt32(exec) : 0; - if ((buffer->byteLength() - offset) % sizeof(T)) - throwError(exec, createRangeError(exec, "ArrayBuffer length minus the byteOffset is not a multiple of the element size.")); - unsigned int length = (buffer->byteLength() - offset) / sizeof(T); - if (exec->argumentCount() > 2) - length = exec->argument(2).toUInt32(exec); - PassRefPtr<ArrayBufferView> array = C::create(buffer, offset, length); - if (!array) - setDOMException(exec, INDEX_SIZE_ERR); - return array; - } - + RefPtr<C> view = constructArrayBufferViewWithArrayBufferArgument<C, T>(exec); + if (view) + return view; + JSC::JSObject* array = asObject(exec->argument(0)); unsigned length = array->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec); void* tempValues; @@ -142,14 +149,14 @@ PassRefPtr<ArrayBufferView> constructArrayBufferView(JSC::ExecState* exec) values.get()[i] = static_cast<T>(v.toNumber(exec)); } - PassRefPtr<ArrayBufferView> result = C::create(values.get(), length); + RefPtr<C> result = C::create(values.get(), length); if (!result) setDOMException(exec, INDEX_SIZE_ERR); return result; } - + int length = exec->argument(0).toInt32(exec); - PassRefPtr<ArrayBufferView> result; + RefPtr<C> result; if (length >= 0) result = C::create(static_cast<unsigned>(length)); if (!result) diff --git a/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp b/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp new file mode 100644 index 0000000..8ca7f1f --- /dev/null +++ b/WebCore/bindings/js/JSAudioBufferSourceNodeCustom.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WEB_AUDIO) + +#include "AudioBufferSourceNode.h" + +#include "AudioBuffer.h" +#include "JSAudioBuffer.h" +#include "JSAudioBufferSourceNode.h" + +using namespace JSC; + +namespace WebCore { + +void JSAudioBufferSourceNode::setBuffer(ExecState*, JSValue value) +{ + AudioBufferSourceNode* imp = static_cast<AudioBufferSourceNode*>(impl()); + imp->setBuffer(toAudioBuffer(value)); +} + +} // namespace WebCore + +#endif // ENABLE(WEB_AUDIO) diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp index e46b050..7fc5740 100644 --- a/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -32,9 +32,14 @@ #include "JSAudioConstructor.cpp" #include "JSBindingState.cpp" #include "JSCDATASectionCustom.cpp" +#include "JSCSSFontFaceRuleCustom.cpp" +#include "JSCSSImportRuleCustom.cpp" +#include "JSCSSMediaRuleCustom.cpp" +#include "JSCSSPageRuleCustom.cpp" #include "JSCSSRuleCustom.cpp" #include "JSCSSRuleListCustom.cpp" #include "JSCSSStyleDeclarationCustom.cpp" +#include "JSCSSStyleRuleCustom.cpp" #include "JSCSSValueCustom.cpp" #include "JSCallbackData.cpp" #include "JSCanvasRenderingContext2DCustom.cpp" @@ -51,6 +56,9 @@ #include "JSDOMBinding.cpp" #include "JSDOMFormDataCustom.cpp" #include "JSDOMGlobalObject.cpp" +#include "JSDOMMimeTypeArrayCustom.cpp" +#include "JSDOMPluginArrayCustom.cpp" +#include "JSDOMPluginCustom.cpp" #include "JSDOMStringMapCustom.cpp" #include "JSDOMWindowBase.cpp" #include "JSDOMWindowCustom.cpp" @@ -82,10 +90,12 @@ #include "JSHTMLFrameElementCustom.cpp" #include "JSHTMLFrameSetElementCustom.cpp" #include "JSHTMLInputElementCustom.cpp" +#include "JSHTMLLinkElementCustom.cpp" #include "JSHTMLObjectElementCustom.cpp" #include "JSHTMLOptionsCollectionCustom.cpp" #include "JSHTMLOutputElementCustom.cpp" #include "JSHTMLSelectElementCustom.cpp" +#include "JSHTMLStyleElementCustom.cpp" #include "JSHistoryCustom.cpp" #include "JSImageConstructor.cpp" #include "JSImageDataCustom.cpp" @@ -98,7 +108,6 @@ #include "JSMessageChannelCustom.cpp" #include "JSMessageEventCustom.cpp" #include "JSMessagePortCustom.cpp" -#include "JSDOMMimeTypeArrayCustom.cpp" #include "JSNamedNodeMapCustom.cpp" #include "JSNavigatorCustom.cpp" #include "JSNodeCustom.cpp" @@ -107,17 +116,15 @@ #include "JSNodeIteratorCustom.cpp" #include "JSNodeListCustom.cpp" #include "JSOptionConstructor.cpp" -#include "JSDOMPluginArrayCustom.cpp" -#include "JSDOMPluginCustom.cpp" #include "JSPluginElementFunctions.cpp" #include "JSPopStateEventCustom.cpp" +#include "JSProcessingInstructionCustom.cpp" #include "JSSQLResultSetRowListCustom.cpp" #include "JSSQLTransactionCustom.cpp" #include "JSSQLTransactionSyncCustom.cpp" #include "JSSVGElementInstanceCustom.cpp" #include "JSSVGLengthCustom.cpp" #include "JSSVGPathSegCustom.cpp" -#include "JSSVGPathSegListCustom.cpp" #include "JSScriptProfileNodeCustom.cpp" #include "JSSharedWorkerCustom.cpp" #include "JSStorageCustom.cpp" @@ -127,6 +134,8 @@ #include "JSTouchCustom.cpp" #include "JSTouchListCustom.cpp" #include "JSTreeWalkerCustom.cpp" +#include "JSWebKitCSSKeyframeRuleCustom.cpp" +#include "JSWebKitCSSKeyframesRuleCustom.cpp" #include "JSWebKitCSSMatrixCustom.cpp" #include "JSWebKitPointCustom.cpp" #include "JSWebSocketCustom.cpp" diff --git a/WebCore/bindings/js/JSCSSFontFaceRuleCustom.cpp b/WebCore/bindings/js/JSCSSFontFaceRuleCustom.cpp new file mode 100644 index 0000000..a08c180 --- /dev/null +++ b/WebCore/bindings/js/JSCSSFontFaceRuleCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCSSFontFaceRule.h" + +#include "CSSFontFaceRule.h" + +using namespace JSC; + +namespace WebCore { + +void JSCSSFontFaceRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (CSSMutableStyleDeclaration* style = static_cast<CSSFontFaceRule*>(impl())->style()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style); +} + +} diff --git a/WebCore/bindings/js/JSCSSImportRuleCustom.cpp b/WebCore/bindings/js/JSCSSImportRuleCustom.cpp new file mode 100644 index 0000000..3db517d --- /dev/null +++ b/WebCore/bindings/js/JSCSSImportRuleCustom.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCSSImportRule.h" + +#include "CSSImportRule.h" + +using namespace JSC; + +namespace WebCore { + +void JSCSSImportRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (CSSStyleSheet* sheet = static_cast<CSSImportRule*>(impl())->styleSheet()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), sheet); + + if (MediaList* media = static_cast<CSSImportRule*>(impl())->media()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), media); +} + +} diff --git a/WebCore/bindings/js/JSCSSMediaRuleCustom.cpp b/WebCore/bindings/js/JSCSSMediaRuleCustom.cpp new file mode 100644 index 0000000..b5230fc --- /dev/null +++ b/WebCore/bindings/js/JSCSSMediaRuleCustom.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCSSMediaRule.h" + +#include "CSSMediaRule.h" + +using namespace JSC; + +namespace WebCore { + +void JSCSSMediaRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (MediaList* media = static_cast<CSSMediaRule*>(impl())->media()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), media); + + if (CSSRuleList* rules = static_cast<CSSMediaRule*>(impl())->cssRules()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), rules); +} + +} diff --git a/WebCore/bindings/js/JSCSSPageRuleCustom.cpp b/WebCore/bindings/js/JSCSSPageRuleCustom.cpp new file mode 100644 index 0000000..c7ac04b --- /dev/null +++ b/WebCore/bindings/js/JSCSSPageRuleCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCSSPageRule.h" + +#include "CSSPageRule.h" + +using namespace JSC; + +namespace WebCore { + +void JSCSSPageRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (CSSMutableStyleDeclaration* style = static_cast<CSSPageRule*>(impl())->style()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style); +} + +} diff --git a/WebCore/bindings/js/JSCSSRuleCustom.cpp b/WebCore/bindings/js/JSCSSRuleCustom.cpp index 20b3ab4..4d226d0 100644 --- a/WebCore/bindings/js/JSCSSRuleCustom.cpp +++ b/WebCore/bindings/js/JSCSSRuleCustom.cpp @@ -47,6 +47,17 @@ using namespace JSC; namespace WebCore { +void JSCSSRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (CSSStyleSheet* parentStyleSheet = impl()->parentStyleSheet()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), parentStyleSheet); + + if (CSSRule* parentRule = impl()->parentRule()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), parentRule); +} + JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, CSSRule* rule) { if (!rule) diff --git a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp index 458ad5b..1a448ee 100644 --- a/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp +++ b/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp @@ -47,6 +47,9 @@ void JSCSSStyleDeclaration::markChildren(MarkStack& markStack) CSSStyleDeclaration* declaration = impl(); JSGlobalData& globalData = *Heap::heap(this)->globalData(); + if (CSSRule* parentRule = declaration->parentRule()) + markDOMObjectWrapper(markStack, globalData, parentRule); + if (declaration->isMutableStyleDeclaration()) { CSSMutableStyleDeclaration* mutableDeclaration = static_cast<CSSMutableStyleDeclaration*>(declaration); CSSMutableStyleDeclaration::const_iterator end = mutableDeclaration->end(); diff --git a/WebCore/bindings/js/JSCSSStyleRuleCustom.cpp b/WebCore/bindings/js/JSCSSStyleRuleCustom.cpp new file mode 100644 index 0000000..61745ec --- /dev/null +++ b/WebCore/bindings/js/JSCSSStyleRuleCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSCSSStyleRule.h" + +#include "CSSStyleRule.h" + +using namespace JSC; + +namespace WebCore { + +void JSCSSStyleRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (CSSMutableStyleDeclaration* style = static_cast<CSSStyleRule*>(impl())->style()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style); +} + +} diff --git a/WebCore/bindings/js/JSConsoleCustom.cpp b/WebCore/bindings/js/JSConsoleCustom.cpp index 6df88f6..6a4fb17 100644 --- a/WebCore/bindings/js/JSConsoleCustom.cpp +++ b/WebCore/bindings/js/JSConsoleCustom.cpp @@ -57,23 +57,23 @@ JSValue JSConsole::profiles(ExecState* exec) const JSValue JSConsole::profile(ExecState* exec) { - OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1)); + RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1)); const String& title = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); if (exec->hadException()) return jsUndefined(); - impl()->profile(title, exec, callStack.release()); + impl()->profile(title, exec, callStack); return jsUndefined(); } JSValue JSConsole::profileEnd(ExecState* exec) { - OwnPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1)); + RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1)); const String& title = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); if (exec->hadException()) return jsUndefined(); - impl()->profileEnd(title, exec, callStack.release()); + impl()->profileEnd(title, exec, callStack); return jsUndefined(); } diff --git a/WebCore/bindings/js/JSConvolverNodeCustom.cpp b/WebCore/bindings/js/JSConvolverNodeCustom.cpp new file mode 100644 index 0000000..db7e244 --- /dev/null +++ b/WebCore/bindings/js/JSConvolverNodeCustom.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WEB_AUDIO) + +#include "ConvolverNode.h" + +#include "AudioBuffer.h" +#include "JSAudioBuffer.h" +#include "JSConvolverNode.h" + +using namespace JSC; + +namespace WebCore { + +void JSConvolverNode::setBuffer(ExecState*, JSValue value) +{ + ConvolverNode* imp = static_cast<ConvolverNode*>(impl()); + imp->setBuffer(toAudioBuffer(value)); +} + +} // namespace WebCore + +#endif // ENABLE(WEB_AUDIO) diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp index e4cff4a..0d94b44 100644 --- a/WebCore/bindings/js/JSDOMBinding.cpp +++ b/WebCore/bindings/js/JSDOMBinding.cpp @@ -35,8 +35,10 @@ #include "HTMLCanvasElement.h" #include "HTMLFrameElementBase.h" #include "HTMLImageElement.h" +#include "HTMLLinkElement.h" #include "HTMLNames.h" #include "HTMLScriptElement.h" +#include "HTMLStyleElement.h" #include "JSBinding.h" #include "JSBindingState.h" #include "JSDOMCoreException.h" @@ -50,6 +52,7 @@ #include "JSXMLHttpRequestException.h" #include "KURL.h" #include "MessagePort.h" +#include "ProcessingInstruction.h" #include "RangeException.h" #include "ScriptCachedFrameData.h" #include "ScriptController.h" @@ -231,7 +234,7 @@ void cacheDOMNodeWrapper(JSC::ExecState* exec, Document* document, Node* node, J static inline bool isObservableThroughDOM(JSNode* jsNode, DOMWrapperWorld* world) { - // Certain conditions implicitly make a JS DOM node wrapper observable + // Certain conditions implicitly make existence of a JS DOM node wrapper observable // through the DOM, even if no explicit reference to it remains. Node* node = jsNode->impl(); @@ -253,19 +256,22 @@ static inline bool isObservableThroughDOM(JSNode* jsNode, DOMWrapperWorld* world // those objects through the DOM must reflect those properties. // FIXME: It would be better if this logic could be in the node next to // the custom markChildren functions rather than here. + // Note that for some compound objects like stylesheets and CSSStyleDeclarations, + // we don't descend to check children for custom properties, and just conservatively + // keep the node wrappers protecting them alive. if (node->isElementNode()) { if (NamedNodeMap* attributes = static_cast<Element*>(node)->attributeMap()) { if (DOMObject* wrapper = world->m_wrappers.uncheckedGet(attributes)) { + // FIXME: This check seems insufficient, because NamedNodeMap items can have custom properties themselves. + // Maybe it would be OK to just keep the wrapper alive, as it is done for CSSOM objects below. if (wrapper->hasCustomProperties()) return true; } } if (node->isStyledElement()) { if (CSSMutableStyleDeclaration* style = static_cast<StyledElement*>(node)->inlineStyleDecl()) { - if (DOMObject* wrapper = world->m_wrappers.uncheckedGet(style)) { - if (wrapper->hasCustomProperties()) - return true; - } + if (world->m_wrappers.uncheckedGet(style)) + return true; } } if (static_cast<Element*>(node)->hasTagName(canvasTag)) { @@ -275,6 +281,21 @@ static inline bool isObservableThroughDOM(JSNode* jsNode, DOMWrapperWorld* world return true; } } + } else if (static_cast<Element*>(node)->hasTagName(linkTag)) { + if (StyleSheet* sheet = static_cast<HTMLLinkElement*>(node)->sheet()) { + if (world->m_wrappers.uncheckedGet(sheet)) + return true; + } + } else if (static_cast<Element*>(node)->hasTagName(styleTag)) { + if (StyleSheet* sheet = static_cast<HTMLStyleElement*>(node)->sheet()) { + if (world->m_wrappers.uncheckedGet(sheet)) + return true; + } + } + } else if (node->nodeType() == Node::PROCESSING_INSTRUCTION_NODE) { + if (StyleSheet* sheet = static_cast<ProcessingInstruction*>(node)->sheet()) { + if (world->m_wrappers.uncheckedGet(sheet)) + return true; } } } else { @@ -611,7 +632,7 @@ void setDOMException(ExecState* exec, ExceptionCode ec) break; #if ENABLE(SVG) case SVGExceptionType: - errorObject = toJS(exec, globalObject, SVGException::create(description).get(), 0 /* no context on purpose */); + errorObject = toJS(exec, globalObject, SVGException::create(description).get()); break; #endif #if ENABLE(XPATH) diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h index 64a3dad..54e9cf6 100644 --- a/WebCore/bindings/js/JSDOMBinding.h +++ b/WebCore/bindings/js/JSDOMBinding.h @@ -25,7 +25,6 @@ #include "JSDOMGlobalObject.h" #include "JSDOMWrapper.h" #include "DOMWrapperWorld.h" -#include "JSSVGContextCache.h" #include "Document.h" #include <runtime/Completion.h> #include <runtime/Lookup.h> @@ -50,10 +49,6 @@ namespace WebCore { typedef int ExceptionCode; -#if ENABLE(SVG) - class SVGElement; -#endif - // FIXME: This class should collapse into DOMObject once all DOMObjects are // updated to store a globalObject pointer. class DOMObjectWithGlobalPointer : public DOMObject { @@ -185,28 +180,6 @@ namespace WebCore { return createDOMObjectWrapper<WrapperClass>(exec, globalObject, object); } -#if ENABLE(SVG) - #define CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, className, object, context) createDOMObjectWrapper<JS##className>(exec, globalObject, static_cast<className*>(object), context) - template<class WrapperClass, class DOMClass> inline DOMObject* createDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object, SVGElement* context) - { - DOMObject* wrapper = createDOMObjectWrapper<WrapperClass, DOMClass>(exec, globalObject, object); - ASSERT(wrapper); - if (context) - JSSVGContextCache::addWrapper(wrapper, context); - return wrapper; - } - template<class WrapperClass, class DOMClass> inline JSC::JSValue getDOMObjectWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* object, SVGElement* context) - { - if (!object) - return JSC::jsNull(); - if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec, object)) { - ASSERT(JSSVGContextCache::svgContextForDOMObject(wrapper) == context); - return wrapper; - } - return createDOMObjectWrapper<WrapperClass, DOMClass>(exec, globalObject, object, context); - } -#endif - #define CREATE_DOM_NODE_WRAPPER(exec, globalObject, className, object) createDOMNodeWrapper<JS##className>(exec, globalObject, static_cast<className*>(object)) template<class WrapperClass, class DOMClass> inline JSNode* createDOMNodeWrapper(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMClass* node) { diff --git a/WebCore/bindings/js/JSDOMWindowBase.cpp b/WebCore/bindings/js/JSDOMWindowBase.cpp index e2b50d0..ad4e2f7 100644 --- a/WebCore/bindings/js/JSDOMWindowBase.cpp +++ b/WebCore/bindings/js/JSDOMWindowBase.cpp @@ -60,7 +60,7 @@ JSDOMWindowBase::JSDOMWindowBase(NonNullPassRefPtr<Structure> structure, PassRef GlobalPropertyInfo(Identifier(globalExec(), "window"), d()->shell, DontDelete | ReadOnly) }; - addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo)); + addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals)); } void JSDOMWindowBase::updateDocument() @@ -118,6 +118,26 @@ bool JSDOMWindowBase::supportsProfiling() const #endif } +bool JSDOMWindowBase::supportsRichSourceInfo() const +{ +#if !ENABLE(JAVASCRIPT_DEBUGGER) || !ENABLE(INSPECTOR) + return false; +#else + Frame* frame = impl()->frame(); + if (!frame) + return false; + + Page* page = frame->page(); + if (!page) + return false; + + bool enabled = page->inspectorController()->enabled(); + ASSERT(enabled || !debugger()); + ASSERT(enabled || !supportsProfiling()); + return enabled; +#endif +} + bool JSDOMWindowBase::shouldInterruptScript() const { ASSERT(impl()->frame()); diff --git a/WebCore/bindings/js/JSDOMWindowBase.h b/WebCore/bindings/js/JSDOMWindowBase.h index cafca73..fbef808 100644 --- a/WebCore/bindings/js/JSDOMWindowBase.h +++ b/WebCore/bindings/js/JSDOMWindowBase.h @@ -60,6 +60,7 @@ namespace WebCore { virtual JSC::ExecState* globalExec(); virtual bool supportsProfiling() const; + virtual bool supportsRichSourceInfo() const; virtual bool shouldInterruptScript() const; bool allowsAccessFrom(JSC::ExecState*) const; diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 7119ea6..95fcdc1 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -53,6 +53,7 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) #include "JSArrayBuffer.h" +#include "JSDataView.h" #include "JSInt8Array.h" #include "JSUint8Array.h" #include "JSInt32Array.h" @@ -606,6 +607,10 @@ JSValue JSDOMWindow::float32Array(ExecState* exec) const return getDOMConstructor<JSFloat32ArrayConstructor>(exec, this); } +JSValue JSDOMWindow::dataView(ExecState* exec) const +{ + return getDOMConstructor<JSDataViewConstructor>(exec, this); +} #endif JSValue JSDOMWindow::xmlHttpRequest(ExecState* exec) const diff --git a/WebCore/bindings/js/JSDataViewCustom.cpp b/WebCore/bindings/js/JSDataViewCustom.cpp new file mode 100644 index 0000000..f17e0e1 --- /dev/null +++ b/WebCore/bindings/js/JSDataViewCustom.cpp @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + +#include "JSDataView.h" + +#include "DataView.h" +#include "ExceptionCode.h" +#include "JSArrayBufferViewHelper.h" +#include <wtf/MathExtras.h> + +using namespace JSC; + +namespace WebCore { + +enum DataViewAccessType { + AccessDataViewMemberAsInt8, + AccessDataViewMemberAsUint8, + AccessDataViewMemberAsFloat32, + AccessDataViewMemberAsFloat64 +}; + +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, DataView* object) +{ + return getDOMObjectWrapper<JSDataView>(exec, globalObject, object); +} + +EncodedJSValue JSC_HOST_CALL JSDataViewConstructor::constructJSDataView(ExecState* exec) +{ + if (exec->argument(0).isNull() || !exec->argument(0).isObject()) + return throwVMTypeError(exec); + + RefPtr<DataView> view = constructArrayBufferViewWithArrayBufferArgument<DataView, char>(exec); + if (!view.get()) { + setDOMException(exec, INDEX_SIZE_ERR); + return JSValue::encode(jsUndefined()); + } + + JSDataViewConstructor* jsConstructor = static_cast<JSDataViewConstructor*>(exec->callee()); + return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), view.get()))); +} + +static JSValue getDataViewMember(ExecState* exec, DataViewAccessType type) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSDataView::s_info)) + return throwTypeError(exec); + JSDataView* castedThis = static_cast<JSDataView*>(asObject(thisValue)); + DataView* imp = static_cast<DataView*>(castedThis->impl()); + if (exec->argumentCount() < 1) + return throwError(exec, createSyntaxError(exec, "Not enough arguments")); + ExceptionCode ec = 0; + unsigned byteOffset = exec->argument(0).toUInt32(exec); + if (exec->hadException()) + return jsUndefined(); + + bool littleEndian = false; + if (exec->argumentCount() > 1 && (type == AccessDataViewMemberAsFloat32 || type == AccessDataViewMemberAsFloat64)) { + littleEndian = exec->argument(1).toBoolean(exec); + if (exec->hadException()) + return jsUndefined(); + } + + JSC::JSValue result; + switch (type) { + case AccessDataViewMemberAsInt8: + result = jsNumber(imp->getInt8(byteOffset, ec)); + break; + case AccessDataViewMemberAsUint8: + result = jsNumber(imp->getUint8(byteOffset, ec)); + break; + case AccessDataViewMemberAsFloat32: + case AccessDataViewMemberAsFloat64: { + double value = (type == AccessDataViewMemberAsFloat32) ? imp->getFloat32(byteOffset, littleEndian, ec) : imp->getFloat64(byteOffset, littleEndian, ec); + result = isnan(value) ? JSValue(nonInlineNaN()) : jsNumber(value); + break; + } default: + ASSERT_NOT_REACHED(); + break; + } + setDOMException(exec, ec); + return result; +} + +JSValue JSC_HOST_CALL JSDataView::getInt8(ExecState* exec) +{ + return getDataViewMember(exec, AccessDataViewMemberAsInt8); +} + +JSValue JSC_HOST_CALL JSDataView::getUint8(ExecState* exec) +{ + return getDataViewMember(exec, AccessDataViewMemberAsUint8); +} + +JSValue JSC_HOST_CALL JSDataView::getFloat32(ExecState* exec) +{ + return getDataViewMember(exec, AccessDataViewMemberAsFloat32); +} + +JSValue JSC_HOST_CALL JSDataView::getFloat64(ExecState* exec) +{ + return getDataViewMember(exec, AccessDataViewMemberAsFloat64); +} + +static JSValue setDataViewMember(ExecState* exec, DataViewAccessType type) +{ + JSValue thisValue = exec->hostThisValue(); + if (!thisValue.inherits(&JSDataView::s_info)) + return throwTypeError(exec); + JSDataView* castedThis = static_cast<JSDataView*>(asObject(thisValue)); + DataView* imp = static_cast<DataView*>(castedThis->impl()); + if (exec->argumentCount() < 2) + return throwError(exec, createSyntaxError(exec, "Not enough arguments")); + ExceptionCode ec = 0; + unsigned byteOffset = exec->argument(0).toUInt32(exec); + if (exec->hadException()) + return jsUndefined(); + int value = exec->argument(1).toInt32(exec); + if (exec->hadException()) + return jsUndefined(); + + switch (type) { + case AccessDataViewMemberAsInt8: + imp->setInt8(byteOffset, static_cast<char>(value), ec); + break; + case AccessDataViewMemberAsUint8: + imp->setUint8(byteOffset, static_cast<unsigned char>(value), ec); + break; + default: + ASSERT_NOT_REACHED(); + break; + } + setDOMException(exec, ec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL JSDataView::setInt8(ExecState* exec) +{ + return setDataViewMember(exec, AccessDataViewMemberAsInt8); +} + +JSValue JSC_HOST_CALL JSDataView::setUint8(ExecState* exec) +{ + return setDataViewMember(exec, AccessDataViewMemberAsUint8); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) || ENABLE(BLOB) diff --git a/WebCore/bindings/js/JSEventCustom.cpp b/WebCore/bindings/js/JSEventCustom.cpp index d671dee..fd80360 100644 --- a/WebCore/bindings/js/JSEventCustom.cpp +++ b/WebCore/bindings/js/JSEventCustom.cpp @@ -51,6 +51,7 @@ #include "JSPageTransitionEvent.h" #include "JSPopStateEvent.h" #include "JSProgressEvent.h" +#include "JSSpeechInputEvent.h" #include "JSTextEvent.h" #include "JSUIEvent.h" #include "JSWebKitAnimationEvent.h" @@ -68,6 +69,7 @@ #include "PageTransitionEvent.h" #include "PopStateEvent.h" #include "ProgressEvent.h" +#include "SpeechInputEvent.h" #include "TextEvent.h" #include "UIEvent.h" #include "WebKitAnimationEvent.h" @@ -193,6 +195,10 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event) else if (event->isAudioProcessingEvent()) wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, AudioProcessingEvent, event); #endif +#if ENABLE(INPUT_SPEECH) + else if (event->isSpeechInputEvent()) + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SpeechInputEvent, event); +#endif else wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, Event, event); diff --git a/WebCore/bindings/js/JSFloat32ArrayCustom.cpp b/WebCore/bindings/js/JSFloat32ArrayCustom.cpp index 671ee68..880d68c 100644 --- a/WebCore/bindings/js/JSFloat32ArrayCustom.cpp +++ b/WebCore/bindings/js/JSFloat32ArrayCustom.cpp @@ -27,10 +27,10 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) -#include "JSArrayBufferViewHelper.h" #include "JSFloat32Array.h" #include "Float32Array.h" +#include "JSArrayBufferViewHelper.h" using namespace JSC; @@ -54,7 +54,7 @@ JSC::JSValue JSFloat32Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSFloat32ArrayConstructor::constructJSFloat32Array(ExecState* exec) { JSFloat32ArrayConstructor* jsConstructor = static_cast<JSFloat32ArrayConstructor*>(exec->callee()); - RefPtr<Float32Array> array = static_cast<Float32Array*>(constructArrayBufferView<Float32Array, float>(exec).get()); + RefPtr<Float32Array> array = constructArrayBufferView<Float32Array, float>(exec); if (!array.get()) // Exception has already been thrown. return JSValue::encode(JSValue()); diff --git a/WebCore/bindings/js/JSHTMLLinkElementCustom.cpp b/WebCore/bindings/js/JSHTMLLinkElementCustom.cpp new file mode 100644 index 0000000..8cc8d5f --- /dev/null +++ b/WebCore/bindings/js/JSHTMLLinkElementCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSHTMLLinkElement.h" + +#include "HTMLLinkElement.h" + +using namespace JSC; + +namespace WebCore { + +void JSHTMLLinkElement::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (StyleSheet* sheet = static_cast<HTMLLinkElement*>(impl())->sheet()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), sheet); +} + +} diff --git a/WebCore/bindings/js/JSHTMLStyleElementCustom.cpp b/WebCore/bindings/js/JSHTMLStyleElementCustom.cpp new file mode 100644 index 0000000..9b0d1a7 --- /dev/null +++ b/WebCore/bindings/js/JSHTMLStyleElementCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSHTMLStyleElement.h" + +#include "HTMLStyleElement.h" + +using namespace JSC; + +namespace WebCore { + +void JSHTMLStyleElement::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (StyleSheet* sheet = static_cast<HTMLStyleElement*>(impl())->sheet()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), sheet); +} + +} diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp index 9cf4604..de72dea 100644 --- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp +++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp @@ -95,7 +95,6 @@ ScriptObject InjectedScriptHost::createInjectedScript(const String& source, Scri args.append(toJS(scriptState, globalObject, this)); args.append(globalThisValue); args.append(jsNumber(id)); - args.append(jsString(scriptState, String("JSC"))); JSValue result = JSC::call(scriptState, functionValue, callType, callData, globalThisValue, args); if (result.isObject()) return ScriptObject(scriptState, result.getObject()); @@ -137,6 +136,15 @@ JSValue JSInjectedScriptHost::nodeForId(ExecState* exec) return toJS(exec, node); } +JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec) +{ + if (exec->argumentCount() < 1) + return jsUndefined(); + + UString result = exec->argument(0).toThisObject(exec)->className(); + return jsString(exec, result); +} + JSValue JSInjectedScriptHost::pushNodePathToFrontend(ExecState* exec) { if (exec->argumentCount() < 3) diff --git a/WebCore/bindings/js/JSInt16ArrayCustom.cpp b/WebCore/bindings/js/JSInt16ArrayCustom.cpp index 797568c..e08da8a 100644 --- a/WebCore/bindings/js/JSInt16ArrayCustom.cpp +++ b/WebCore/bindings/js/JSInt16ArrayCustom.cpp @@ -27,10 +27,10 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) -#include "JSArrayBufferViewHelper.h" #include "JSInt16Array.h" #include "Int16Array.h" +#include "JSArrayBufferViewHelper.h" using namespace JSC; @@ -54,7 +54,7 @@ JSC::JSValue JSInt16Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSInt16ArrayConstructor::constructJSInt16Array(ExecState* exec) { JSInt16ArrayConstructor* jsConstructor = static_cast<JSInt16ArrayConstructor*>(exec->callee()); - RefPtr<Int16Array> array = static_cast<Int16Array*>(constructArrayBufferView<Int16Array, short>(exec).get()); + RefPtr<Int16Array> array = constructArrayBufferView<Int16Array, short>(exec); if (!array.get()) // Exception has already been thrown. return JSValue::encode(JSValue()); diff --git a/WebCore/bindings/js/JSInt32ArrayCustom.cpp b/WebCore/bindings/js/JSInt32ArrayCustom.cpp index 53e6ec6..5aa64bb 100644 --- a/WebCore/bindings/js/JSInt32ArrayCustom.cpp +++ b/WebCore/bindings/js/JSInt32ArrayCustom.cpp @@ -27,10 +27,10 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) -#include "JSArrayBufferViewHelper.h" #include "JSInt32Array.h" #include "Int32Array.h" +#include "JSArrayBufferViewHelper.h" using namespace JSC; @@ -54,7 +54,7 @@ JSC::JSValue JSInt32Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSInt32ArrayConstructor::constructJSInt32Array(ExecState* exec) { JSInt32ArrayConstructor* jsConstructor = static_cast<JSInt32ArrayConstructor*>(exec->callee()); - RefPtr<Int32Array> array = static_cast<Int32Array*>(constructArrayBufferView<Int32Array, int>(exec).get()); + RefPtr<Int32Array> array = constructArrayBufferView<Int32Array, int>(exec); if (!array.get()) // Exception has already been thrown. return JSValue::encode(JSValue()); diff --git a/WebCore/bindings/js/JSInt8ArrayCustom.cpp b/WebCore/bindings/js/JSInt8ArrayCustom.cpp index 7556d6a..b63de54 100644 --- a/WebCore/bindings/js/JSInt8ArrayCustom.cpp +++ b/WebCore/bindings/js/JSInt8ArrayCustom.cpp @@ -27,10 +27,10 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) -#include "JSArrayBufferViewHelper.h" #include "JSInt8Array.h" #include "Int8Array.h" +#include "JSArrayBufferViewHelper.h" #include <runtime/Error.h> using namespace JSC; @@ -55,7 +55,7 @@ JSC::JSValue JSInt8Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSInt8ArrayConstructor::constructJSInt8Array(ExecState* exec) { JSInt8ArrayConstructor* jsConstructor = static_cast<JSInt8ArrayConstructor*>(exec->callee()); - RefPtr<Int8Array> array = static_cast<Int8Array*>(constructArrayBufferView<Int8Array, signed char>(exec).get()); + RefPtr<Int8Array> array = constructArrayBufferView<Int8Array, signed char>(exec); if (!array.get()) // Exception has already been thrown. return JSValue::encode(JSValue()); diff --git a/WebCore/bindings/js/JSJavaScriptAudioNodeCustom.cpp b/WebCore/bindings/js/JSJavaScriptAudioNodeCustom.cpp new file mode 100644 index 0000000..9acabf3 --- /dev/null +++ b/WebCore/bindings/js/JSJavaScriptAudioNodeCustom.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(WEB_AUDIO) + +#include "JavaScriptAudioNode.h" + +#include "JSJavaScriptAudioNode.h" + +using namespace JSC; + +namespace WebCore { + +void JSJavaScriptAudioNode::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + static_cast<JavaScriptAudioNode*>(impl())->markJSEventListeners(markStack); +} + +} // namespace WebCore + +#endif // ENABLE(WEB_AUDIO) diff --git a/WebCore/bindings/js/JSProcessingInstructionCustom.cpp b/WebCore/bindings/js/JSProcessingInstructionCustom.cpp new file mode 100644 index 0000000..868e319 --- /dev/null +++ b/WebCore/bindings/js/JSProcessingInstructionCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSProcessingInstruction.h" + +#include "ProcessingInstruction.h" + +using namespace JSC; + +namespace WebCore { + +void JSProcessingInstruction::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (StyleSheet* sheet = static_cast<ProcessingInstruction*>(impl())->sheet()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), sheet); +} + +} diff --git a/WebCore/bindings/js/JSSVGContextCache.h b/WebCore/bindings/js/JSSVGContextCache.h deleted file mode 100644 index 75ed324..0000000 --- a/WebCore/bindings/js/JSSVGContextCache.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef JSSVGContextCache_h -#define JSSVGContextCache_h - -#if ENABLE(SVG) -#include "SVGElement.h" -#include <wtf/StdLibExtras.h> - -namespace WebCore { - -class DOMObject; - -class JSSVGContextCache : public Noncopyable { -public: - typedef HashMap<DOMObject*, SVGElement*> WrapperMap; - - static WrapperMap& wrapperMap() - { - DEFINE_STATIC_LOCAL(WrapperMap, s_wrapperMap, ()); - return s_wrapperMap; - } - - static void addWrapper(DOMObject* wrapper, SVGElement* context) - { - ASSERT(wrapper); - ASSERT(context); - - pair<WrapperMap::iterator, bool> result = wrapperMap().add(wrapper, context); - if (result.second) { - WrapperMap::iterator& it = result.first; - ASSERT_UNUSED(it, it->second == context); - } - } - - static void forgetWrapper(DOMObject* wrapper) - { - ASSERT(wrapper); - - WrapperMap& map = wrapperMap(); - WrapperMap::iterator it = map.find(wrapper); - if (it == map.end()) - return; - - map.remove(it); - } - - static void propagateSVGDOMChange(DOMObject* wrapper, const QualifiedName& attributeName) - { - WrapperMap& map = wrapperMap(); - WrapperMap::iterator it = map.find(wrapper); - if (it == map.end()) - return; - - SVGElement* context = it->second; - ASSERT(context); - - context->svgAttributeChanged(attributeName); - } - - static SVGElement* svgContextForDOMObject(DOMObject* wrapper) - { - ASSERT(wrapper); - - WrapperMap& map = wrapperMap(); - WrapperMap::iterator it = map.find(wrapper); - if (it == map.end()) - return 0; - - SVGElement* context = it->second; - ASSERT(context); - return context; - } - -}; - -} - -#endif -#endif diff --git a/WebCore/bindings/js/JSSVGLengthCustom.cpp b/WebCore/bindings/js/JSSVGLengthCustom.cpp index 9a9138c..5b668c4 100644 --- a/WebCore/bindings/js/JSSVGLengthCustom.cpp +++ b/WebCore/bindings/js/JSSVGLengthCustom.cpp @@ -45,6 +45,11 @@ JSValue JSSVGLength::value(ExecState* exec) const void JSSVGLength::setValue(ExecState* exec, JSValue value) { + if (impl()->role() == AnimValRole) { + setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR); + return; + } + if (!value.isUndefinedOrNull() && !value.isNumber() && !value.isBoolean()) { throwVMTypeError(exec); return; @@ -64,6 +69,11 @@ void JSSVGLength::setValue(ExecState* exec, JSValue value) JSValue JSSVGLength::convertToSpecifiedUnits(ExecState* exec) { + if (impl()->role() == AnimValRole) { + setDOMException(exec, NO_MODIFICATION_ALLOWED_ERR); + return jsUndefined(); + } + SVGLength& podImp = impl()->propertyReference(); // Mimic the behaviour of RequiresAllArguments=Raise. diff --git a/WebCore/bindings/js/JSSVGPODListCustom.h b/WebCore/bindings/js/JSSVGPODListCustom.h deleted file mode 100644 index c2af93f..0000000 --- a/WebCore/bindings/js/JSSVGPODListCustom.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) Research In Motion Limited 2010. All rights reserved. - * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> - * 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 Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef JSSVGPODListCustom_h -#define JSSVGPODListCustom_h - -#include "JSSVGContextCache.h" -#include "JSSVGPODTypeWrapper.h" -#include "SVGList.h" - -namespace WebCore { - -namespace JSSVGPODListCustom { - -// Helper structure only containing public typedefs, as C++ does not allow templatized typedefs -template<typename PODType> -struct JSSVGPODListTraits { - typedef SVGPODListItem<PODType> PODListItem; - typedef SVGList<RefPtr<PODListItem> > PODList; - typedef PODType (*ConversionCallback)(JSC::JSValue); -}; - -template<typename JSPODListType, typename PODType> -static JSC::JSValue finishGetter(JSC::ExecState* exec, ExceptionCode& ec, JSPODListType* wrapper, - PassRefPtr<typename JSSVGPODListTraits<PODType>::PODListItem> item) -{ - if (ec) { - setDOMException(exec, ec); - return JSC::jsUndefined(); - } - - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(wrapper); - return toJS(exec, wrapper->globalObject(), - JSSVGPODTypeWrapperCreatorForList<PODType>::create(item.get(), listImp->associatedAttributeName()).get(), context); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue finishSetter(JSC::ExecState* exec, ExceptionCode& ec, JSPODListType* wrapper, - PassRefPtr<typename JSSVGPODListTraits<PODType>::PODListItem> item) -{ - if (ec) { - setDOMException(exec, ec); - return JSC::jsUndefined(); - } - - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - - const QualifiedName& attributeName = listImp->associatedAttributeName(); - JSSVGContextCache::propagateSVGDOMChange(wrapper, attributeName); - - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(wrapper); - return toJS(exec, wrapper->globalObject(), - JSSVGPODTypeWrapperCreatorForList<PODType>::create(item.get(), attributeName).get(), context); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue finishSetterReadOnlyResult(JSC::ExecState* exec, ExceptionCode& ec, JSPODListType* wrapper, - PassRefPtr<typename JSSVGPODListTraits<PODType>::PODListItem> item) -{ - if (ec) { - setDOMException(exec, ec); - return JSC::jsUndefined(); - } - - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - JSSVGContextCache::propagateSVGDOMChange(wrapper, listImp->associatedAttributeName()); - return toJS(exec, wrapper->globalObject(), - JSSVGStaticPODTypeWrapper<PODType>::create(*item).get(), 0 /* no context on purpose */); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue clear(JSPODListType* wrapper, JSC::ExecState* exec, - typename JSSVGPODListTraits<PODType>::ConversionCallback) -{ - ExceptionCode ec = 0; - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - listImp->clear(ec); - - if (ec) - setDOMException(exec, ec); - else - JSSVGContextCache::propagateSVGDOMChange(wrapper, listImp->associatedAttributeName()); - - return JSC::jsUndefined(); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue initialize(JSPODListType* wrapper, JSC::ExecState* exec, - typename JSSVGPODListTraits<PODType>::ConversionCallback conversion) -{ - ExceptionCode ec = 0; - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - return finishSetter<JSPODListType, PODType>(exec, ec, wrapper, - listImp->initialize(JSSVGPODListTraits<PODType>::PODListItem::copy(conversion(exec->argument(0))), ec)); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue getItem(JSPODListType* wrapper, JSC::ExecState* exec, - typename JSSVGPODListTraits<PODType>::ConversionCallback) -{ - bool indexOk = false; - unsigned index = finiteInt32Value(exec->argument(0), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return JSC::jsUndefined(); - } - - ExceptionCode ec = 0; - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - return finishGetter<JSPODListType, PODType>(exec, ec, wrapper, - listImp->getItem(index, ec)); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue insertItemBefore(JSPODListType* wrapper, JSC::ExecState* exec, - typename JSSVGPODListTraits<PODType>::ConversionCallback conversion) -{ - bool indexOk = false; - unsigned index = finiteInt32Value(exec->argument(1), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return JSC::jsUndefined(); - } - - ExceptionCode ec = 0; - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - return finishSetter<JSPODListType, PODType>(exec, ec, wrapper, - listImp->insertItemBefore(JSSVGPODListTraits<PODType>::PODListItem::copy(conversion(exec->argument(0))), index, ec)); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue replaceItem(JSPODListType* wrapper, JSC::ExecState* exec, - typename JSSVGPODListTraits<PODType>::ConversionCallback conversion) -{ - bool indexOk = false; - unsigned index = finiteInt32Value(exec->argument(1), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return JSC::jsUndefined(); - } - - ExceptionCode ec = 0; - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - return finishSetter<JSPODListType, PODType>(exec, ec, wrapper, - listImp->replaceItem(JSSVGPODListTraits<PODType>::PODListItem::copy(conversion(exec->argument(0))), index, ec)); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue removeItem(JSPODListType* wrapper, JSC::ExecState* exec, - typename JSSVGPODListTraits<PODType>::ConversionCallback) -{ - bool indexOk = false; - unsigned index = finiteInt32Value(exec->argument(0), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return JSC::jsUndefined(); - } - - ExceptionCode ec = 0; - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - return finishSetterReadOnlyResult<JSPODListType, PODType>(exec, ec, wrapper, - listImp->removeItem(index, ec)); -} - -template<typename JSPODListType, typename PODType> -static JSC::JSValue appendItem(JSPODListType* wrapper, JSC::ExecState* exec, - typename JSSVGPODListTraits<PODType>::ConversionCallback conversion) -{ - ExceptionCode ec = 0; - typename JSSVGPODListTraits<PODType>::PODList* listImp = wrapper->impl(); - return finishSetter<JSPODListType, PODType>(exec, ec, wrapper, - listImp->appendItem(JSSVGPODListTraits<PODType>::PODListItem::copy(conversion(exec->argument(0))), ec)); -} - -} - -} - -#endif diff --git a/WebCore/bindings/js/JSSVGPODTypeWrapper.h b/WebCore/bindings/js/JSSVGPODTypeWrapper.h deleted file mode 100644 index 2329365..0000000 --- a/WebCore/bindings/js/JSSVGPODTypeWrapper.h +++ /dev/null @@ -1,410 +0,0 @@ -/* - * Copyright (C) 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> - * 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 JSSVGPODTypeWrapper_h -#define JSSVGPODTypeWrapper_h - -#if ENABLE(SVG) -#include "JSSVGContextCache.h" -#include "SVGElement.h" -#include <wtf/StdLibExtras.h> - -namespace WebCore { - -class DOMObject; - -template<typename PODType> -class JSSVGPODTypeWrapper : public RefCounted<JSSVGPODTypeWrapper<PODType> > { -public: - virtual ~JSSVGPODTypeWrapper() { } - - virtual operator PODType() = 0; - virtual void commitChange(PODType, DOMObject*) = 0; -}; - -// 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 -// 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 (i.e. '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 -// 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 -// 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, ...). -// Those custom wrappers are called JSSVGPODTypeWrapper and are capable of updating the POD types -// by taking function pointers to the getter & setter functions of the "creator object", the object -// which exposed a SVG POD type. For example, the JSSVGPODTypeWrapper object wrapping a SVGMatrix -// object takes (SVGTransform*, &SVGTransform::matrix, &SVGTransform::setMatrix). A JS call like -// "someElement.transform.matrix.a = 50.0' causes the JSSVGMatrix object to call SVGTransform::setMatrix, -// method, which in turn notifies 'someElement' that the 'SVGNames::transformAttr' has changed. -// That's a short sketch of our SVG DOM implementation. - -// Represents a JS wrapper object for SVGAnimated* classes, exposing SVG POD types that contain writable properties -// (Two cases: SVGAnimatedLength exposing SVGLength, SVGAnimatedRect exposing SVGRect) - -#if COMPILER(MSVC) -// GetterMethod and SetterMethod are each 12 bytes. We have to pack to a size -// greater than or equal to that to avoid an alignment warning (C4121). 16 is -// the next-largest size allowed for packing, so we use that. -#pragma pack(push, 16) -#endif -template<typename PODType, typename PODTypeCreator> -class JSSVGDynamicPODTypeWrapper : public JSSVGPODTypeWrapper<PODType> { -public: - typedef PODType (PODTypeCreator::*GetterMethod)() const; - typedef void (PODTypeCreator::*SetterMethod)(const PODType&); - - static PassRefPtr<JSSVGDynamicPODTypeWrapper> create(PassRefPtr<PODTypeCreator> creator, GetterMethod getter, SetterMethod setter) - { - return adoptRef(new JSSVGDynamicPODTypeWrapper(creator, getter, setter)); - } - - virtual operator PODType() - { - return (m_creator.get()->*m_getter)(); - } - - virtual void commitChange(PODType type, DOMObject* wrapper) - { - (m_creator.get()->*m_setter)(type); - JSSVGContextCache::propagateSVGDOMChange(wrapper, m_creator->associatedAttributeName()); - } - -private: - JSSVGDynamicPODTypeWrapper(PassRefPtr<PODTypeCreator> creator, GetterMethod getter, SetterMethod setter) - : m_creator(creator) - , m_getter(getter) - , m_setter(setter) - { - ASSERT(m_creator); - ASSERT(m_getter); - ASSERT(m_setter); - } - - virtual ~JSSVGDynamicPODTypeWrapper(); - - // Update callbacks - RefPtr<PODTypeCreator> m_creator; - GetterMethod m_getter; - SetterMethod m_setter; -}; -#if COMPILER(MSVC) -#pragma pack(pop) -#endif - -// Represents a JS wrapper object for SVG POD types (not for SVGAnimated* classes). Any modification to the SVG POD -// types don't cause any updates unlike JSSVGDynamicPODTypeWrapper. This class is used for return values (ie. getBBox()) -// and for properties where SVG specification explicitly states, that the contents of the POD type are immutable. - -template<typename PODType> -class JSSVGStaticPODTypeWrapper : public JSSVGPODTypeWrapper<PODType> { -public: - static PassRefPtr<JSSVGStaticPODTypeWrapper> create(PODType type) - { - return adoptRef(new JSSVGStaticPODTypeWrapper(type)); - } - - virtual operator PODType() - { - return m_podType; - } - - virtual void commitChange(PODType type, DOMObject*) - { - m_podType = type; - } - -protected: - JSSVGStaticPODTypeWrapper(PODType type) - : m_podType(type) - { - } - - PODType m_podType; -}; - -template<typename PODType, typename ParentTypeArg> -class JSSVGStaticPODTypeWrapperWithPODTypeParent : public JSSVGStaticPODTypeWrapper<PODType> { -public: - typedef JSSVGPODTypeWrapper<ParentTypeArg> ParentType; - - static PassRefPtr<JSSVGStaticPODTypeWrapperWithPODTypeParent> create(PODType type, PassRefPtr<ParentType> parent) - { - return adoptRef(new JSSVGStaticPODTypeWrapperWithPODTypeParent(type, parent)); - } - - virtual void commitChange(PODType type, DOMObject* wrapper) - { - JSSVGStaticPODTypeWrapper<PODType>::commitChange(type, wrapper); - m_parentType->commitChange(ParentTypeArg(type), wrapper); - } - -private: - JSSVGStaticPODTypeWrapperWithPODTypeParent(PODType type, PassRefPtr<ParentType> parent) - : JSSVGStaticPODTypeWrapper<PODType>(type) - , m_parentType(parent) - { - } - - RefPtr<ParentType> m_parentType; -}; - -#if COMPILER(MSVC) -// GetterMethod and SetterMethod are each 12 bytes. We have to pack to a size -// greater than or equal to that to avoid an alignment warning (C4121). 16 is -// the next-largest size allowed for packing, so we use that. -#pragma pack(push, 16) -#endif -template<typename PODType, typename ParentType> -class JSSVGStaticPODTypeWrapperWithParent : public JSSVGPODTypeWrapper<PODType> { -public: - typedef PODType (ParentType::*GetterMethod)() const; - typedef void (ParentType::*SetterMethod)(const PODType&); - - static PassRefPtr<JSSVGStaticPODTypeWrapperWithParent> create(PassRefPtr<ParentType> parent, GetterMethod getter, SetterMethod setter) - { - return adoptRef(new JSSVGStaticPODTypeWrapperWithParent(parent, getter, setter)); - } - - virtual operator PODType() - { - return (m_parent.get()->*m_getter)(); - } - - virtual void commitChange(PODType type, DOMObject*) - { - (m_parent.get()->*m_setter)(type); - } - -private: - JSSVGStaticPODTypeWrapperWithParent(PassRefPtr<ParentType> parent, GetterMethod getter, SetterMethod setter) - : m_parent(parent) - , m_getter(getter) - , m_setter(setter) - { - ASSERT(m_parent); - ASSERT(m_getter); - ASSERT(m_setter); - } - - // Update callbacks - RefPtr<ParentType> m_parent; - GetterMethod m_getter; - SetterMethod m_setter; -}; - -template<typename PODType> -class SVGPODListItem; - -// Just like JSSVGDynamicPODTypeWrapper, but only used for SVGList* objects wrapping around POD values. - -template<typename PODType> -class JSSVGPODTypeWrapperCreatorForList : public JSSVGPODTypeWrapper<PODType> { -public: - typedef SVGPODListItem<PODType> PODListItemPtrType; - - typedef PODType (SVGPODListItem<PODType>::*GetterMethod)() const; - typedef void (SVGPODListItem<PODType>::*SetterMethod)(const PODType&); - - static PassRefPtr<JSSVGPODTypeWrapperCreatorForList> create(PassRefPtr<PODListItemPtrType> creator, const QualifiedName& attributeName) - { - return adoptRef(new JSSVGPODTypeWrapperCreatorForList(creator, attributeName)); - } - - virtual operator PODType() - { - return (m_creator.get()->*m_getter)(); - } - - virtual void commitChange(PODType type, DOMObject* wrapper) - { - if (!m_setter) - return; - - (m_creator.get()->*m_setter)(type); - JSSVGContextCache::propagateSVGDOMChange(wrapper, m_associatedAttributeName); - } - -private: - JSSVGPODTypeWrapperCreatorForList(PassRefPtr<PODListItemPtrType> creator, const QualifiedName& attributeName) - : m_creator(creator) - , m_getter(&PODListItemPtrType::value) - , m_setter(&PODListItemPtrType::setValue) - , m_associatedAttributeName(attributeName) - { - ASSERT(m_creator); - ASSERT(m_getter); - ASSERT(m_setter); - } - - // Update callbacks - RefPtr<PODListItemPtrType> m_creator; - GetterMethod m_getter; - SetterMethod m_setter; - const QualifiedName& m_associatedAttributeName; -}; - -// Caching facilities -template<typename PODType, typename PODTypeCreator> -struct PODTypeWrapperCacheInfo { - typedef PODType (PODTypeCreator::*GetterMethod)() const; - typedef void (PODTypeCreator::*SetterMethod)(const PODType&); - - // Empty value - PODTypeWrapperCacheInfo() - : creator(0) - , getter(0) - , setter(0) - { - } - - // Deleted value - PODTypeWrapperCacheInfo(WTF::HashTableDeletedValueType) - : creator(reinterpret_cast<PODTypeCreator*>(-1)) - , getter(0) - , setter(0) - { - } - bool isHashTableDeletedValue() const - { - return creator == reinterpret_cast<PODTypeCreator*>(-1); - } - - PODTypeWrapperCacheInfo(PODTypeCreator* _creator, GetterMethod _getter, SetterMethod _setter) - : creator(_creator) - , getter(_getter) - , setter(_setter) - { - ASSERT(creator); - ASSERT(getter); - } - - bool operator==(const PODTypeWrapperCacheInfo& other) const - { - return creator == other.creator && getter == other.getter && setter == other.setter; - } - - PODTypeCreator* creator; - GetterMethod getter; - SetterMethod setter; -}; -#if COMPILER(MSVC) -#pragma pack(pop) -#endif - -template<typename PODType, typename PODTypeCreator> -struct PODTypeWrapperCacheInfoHash { - typedef PODTypeWrapperCacheInfo<PODType, PODTypeCreator> CacheInfo; - - static unsigned hash(const CacheInfo& info) - { - return WTF::StringHasher::createBlobHash<sizeof(CacheInfo)>(&info); - } - - static bool equal(const CacheInfo& a, const CacheInfo& b) - { - return a == b; - } - - static const bool safeToCompareToEmptyOrDeleted = true; -}; - -template<typename PODType, typename PODTypeCreator> -struct PODTypeWrapperCacheInfoTraits : WTF::GenericHashTraits<PODTypeWrapperCacheInfo<PODType, PODTypeCreator> > { - typedef PODTypeWrapperCacheInfo<PODType, PODTypeCreator> CacheInfo; - - static const bool emptyValueIsZero = true; - static const bool needsDestruction = false; - - static const CacheInfo& emptyValue() - { - DEFINE_STATIC_LOCAL(CacheInfo, key, ()); - return key; - } - - static void constructDeletedValue(CacheInfo& slot) - { - new (&slot) CacheInfo(WTF::HashTableDeletedValue); - } - - static bool isDeletedValue(const CacheInfo& value) - { - return value.isHashTableDeletedValue(); - } -}; - -// Used for dynamic read-write attributes -template<typename PODType, typename PODTypeCreator> -class JSSVGDynamicPODTypeWrapperCache { -public: - typedef PODType (PODTypeCreator::*GetterMethod)() const; - typedef void (PODTypeCreator::*SetterMethod)(const PODType&); - - typedef PODTypeWrapperCacheInfo<PODType, PODTypeCreator> CacheInfo; - typedef PODTypeWrapperCacheInfoHash<PODType, PODTypeCreator> CacheInfoHash; - typedef PODTypeWrapperCacheInfoTraits<PODType, PODTypeCreator> CacheInfoTraits; - - typedef JSSVGPODTypeWrapper<PODType> WrapperBase; - typedef JSSVGDynamicPODTypeWrapper<PODType, PODTypeCreator> Wrapper; - typedef HashMap<CacheInfo, Wrapper*, CacheInfoHash, CacheInfoTraits> WrapperMap; - - static WrapperMap& wrapperMap() - { - DEFINE_STATIC_LOCAL(WrapperMap, s_wrapperMap, ()); - return s_wrapperMap; - } - - static PassRefPtr<WrapperBase> lookupOrCreateWrapper(PODTypeCreator* creator, GetterMethod getter, SetterMethod setter) - { - CacheInfo info(creator, getter, setter); - pair<typename WrapperMap::iterator, bool> result = wrapperMap().add(info, 0); - if (!result.second) // pre-existing entry - return result.first->second; - - RefPtr<Wrapper> wrapper = Wrapper::create(creator, getter, setter); - result.first->second = wrapper.get(); - return wrapper.release(); - } - - static void forgetWrapper(PODTypeCreator* creator, GetterMethod getter, SetterMethod setter) - { - CacheInfo info(creator, getter, setter); - wrapperMap().remove(info); - } -}; - -template<typename PODType, typename PODTypeCreator> -JSSVGDynamicPODTypeWrapper<PODType, PODTypeCreator>::~JSSVGDynamicPODTypeWrapper() -{ - JSSVGDynamicPODTypeWrapperCache<PODType, PODTypeCreator>::forgetWrapper(m_creator.get(), m_getter, m_setter); -} - -} // namespace WebCore - -#endif // ENABLE(SVG) -#endif // JSSVGPODTypeWrapper_h diff --git a/WebCore/bindings/js/JSSVGPathSegCustom.cpp b/WebCore/bindings/js/JSSVGPathSegCustom.cpp index eac2c4b..f0aa86b 100644 --- a/WebCore/bindings/js/JSSVGPathSegCustom.cpp +++ b/WebCore/bindings/js/JSSVGPathSegCustom.cpp @@ -58,58 +58,56 @@ using namespace JSC; namespace WebCore { -JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, SVGPathSeg* object, SVGElement* context) +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, SVGPathSeg* object) { if (!object) return jsNull(); - if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec, object)) { - ASSERT(JSSVGContextCache::svgContextForDOMObject(wrapper) == context); + if (DOMObject* wrapper = getCachedDOMObjectWrapper(exec, object)) return wrapper; - } switch (object->pathSegType()) { case SVGPathSeg::PATHSEG_CLOSEPATH: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegClosePath, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegClosePath, object); case SVGPathSeg::PATHSEG_MOVETO_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoAbs, object); case SVGPathSeg::PATHSEG_MOVETO_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegMovetoRel, object); case SVGPathSeg::PATHSEG_LINETO_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoAbs, object); case SVGPathSeg::PATHSEG_LINETO_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoRel, object); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicAbs, object); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicRel, object); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticAbs, object); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticRel, object); case SVGPathSeg::PATHSEG_ARC_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcAbs, object); case SVGPathSeg::PATHSEG_ARC_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegArcRel, object); case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalAbs, object); case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoHorizontalRel, object); case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalAbs, object); case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegLinetoVerticalRel, object); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothAbs, object); case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoCubicSmoothRel, object); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothAbs, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothAbs, object); case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothRel, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSegCurvetoQuadraticSmoothRel, object); case SVGPathSeg::PATHSEG_UNKNOWN: default: - return CREATE_SVG_OBJECT_WRAPPER(exec, globalObject, SVGPathSeg, object, context); + return CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, SVGPathSeg, object); } } diff --git a/WebCore/bindings/js/JSSVGPathSegListCustom.cpp b/WebCore/bindings/js/JSSVGPathSegListCustom.cpp deleted file mode 100644 index 9767c1a..0000000 --- a/WebCore/bindings/js/JSSVGPathSegListCustom.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "JSSVGPathSegList.h" - -#include "Document.h" -#include "Frame.h" -#include "JSSVGContextCache.h" -#include "JSSVGPathSeg.h" -#include "SVGDocumentExtensions.h" -#include "SVGElement.h" -#include "SVGPathSegList.h" - -#include <wtf/Assertions.h> - -using namespace JSC; - -namespace WebCore { - -JSValue JSSVGPathSegList::clear(ExecState* exec) -{ - ExceptionCode ec = 0; - - SVGPathSegList* list = impl(); - list->clear(ec); - - setDOMException(exec, ec); - - JSSVGContextCache::propagateSVGDOMChange(this, list->associatedAttributeName()); - return jsUndefined(); -} - -JSValue JSSVGPathSegList::initialize(ExecState* exec) -{ - ExceptionCode ec = 0; - SVGPathSeg* newItem = toSVGPathSeg(exec->argument(0)); - - SVGPathSegList* list = impl(); - - SVGPathSeg* obj = WTF::getPtr(list->initialize(newItem, ec)); - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(this); - - JSValue result = toJS(exec, globalObject(), obj, context); - setDOMException(exec, ec); - - JSSVGContextCache::propagateSVGDOMChange(this, list->associatedAttributeName()); - return result; -} - -JSValue JSSVGPathSegList::getItem(ExecState* exec) -{ - ExceptionCode ec = 0; - - bool indexOk; - unsigned index = finiteInt32Value(exec->argument(0), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); - } - - SVGPathSegList* list = impl(); - SVGPathSeg* obj = WTF::getPtr(list->getItem(index, ec)); - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(this); - - JSValue result = toJS(exec, globalObject(), obj, context); - setDOMException(exec, ec); - return result; -} - -JSValue JSSVGPathSegList::insertItemBefore(ExecState* exec) -{ - ExceptionCode ec = 0; - SVGPathSeg* newItem = toSVGPathSeg(exec->argument(0)); - - bool indexOk; - unsigned index = finiteInt32Value(exec->argument(1), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); - } - - SVGPathSegList* list = impl(); - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(this); - - JSValue result = toJS(exec, globalObject(), WTF::getPtr(list->insertItemBefore(newItem, index, ec)), context); - setDOMException(exec, ec); - - JSSVGContextCache::propagateSVGDOMChange(this, list->associatedAttributeName()); - return result; -} - -JSValue JSSVGPathSegList::replaceItem(ExecState* exec) -{ - ExceptionCode ec = 0; - SVGPathSeg* newItem = toSVGPathSeg(exec->argument(0)); - - bool indexOk; - unsigned index = finiteInt32Value(exec->argument(1), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); - } - - SVGPathSegList* list = impl(); - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(this); - - JSValue result = toJS(exec, globalObject(), WTF::getPtr(list->replaceItem(newItem, index, ec)), context); - setDOMException(exec, ec); - - JSSVGContextCache::propagateSVGDOMChange(this, list->associatedAttributeName()); - return result; -} - -JSValue JSSVGPathSegList::removeItem(ExecState* exec) -{ - ExceptionCode ec = 0; - - bool indexOk; - unsigned index = finiteInt32Value(exec->argument(0), exec, indexOk); - if (!indexOk) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return jsUndefined(); - } - - SVGPathSegList* list = impl(); - - RefPtr<SVGPathSeg> obj(list->removeItem(index, ec)); - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(this); - - JSValue result = toJS(exec, globalObject(), obj.get(), context); - setDOMException(exec, ec); - - JSSVGContextCache::propagateSVGDOMChange(this, list->associatedAttributeName()); - return result; -} - -JSValue JSSVGPathSegList::appendItem(ExecState* exec) -{ - ExceptionCode ec = 0; - SVGPathSeg* newItem = toSVGPathSeg(exec->argument(0)); - - SVGPathSegList* list = impl(); - SVGElement* context = JSSVGContextCache::svgContextForDOMObject(this); - - JSValue result = toJS(exec, globalObject(), WTF::getPtr(list->appendItem(newItem, ec)), context); - setDOMException(exec, ec); - - JSSVGContextCache::propagateSVGDOMChange(this, list->associatedAttributeName()); - return result; -} - -} - -#endif // ENABLE(SVG) diff --git a/WebCore/bindings/js/JSUint16ArrayCustom.cpp b/WebCore/bindings/js/JSUint16ArrayCustom.cpp index 9f12fa7..6a024ee 100644 --- a/WebCore/bindings/js/JSUint16ArrayCustom.cpp +++ b/WebCore/bindings/js/JSUint16ArrayCustom.cpp @@ -27,9 +27,9 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) -#include "JSArrayBufferViewHelper.h" #include "JSUint16Array.h" +#include "JSArrayBufferViewHelper.h" #include "Uint16Array.h" using namespace JSC; @@ -54,7 +54,7 @@ JSC::JSValue JSUint16Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSUint16ArrayConstructor::constructJSUint16Array(ExecState* exec) { JSUint16ArrayConstructor* jsConstructor = static_cast<JSUint16ArrayConstructor*>(exec->callee()); - RefPtr<Uint16Array> array = static_cast<Uint16Array*>(constructArrayBufferView<Uint16Array, unsigned short>(exec).get()); + RefPtr<Uint16Array> array = constructArrayBufferView<Uint16Array, unsigned short>(exec); if (!array.get()) // Exception has already been thrown. return JSValue::encode(JSValue()); diff --git a/WebCore/bindings/js/JSUint32ArrayCustom.cpp b/WebCore/bindings/js/JSUint32ArrayCustom.cpp index c757786..34eb8de 100644 --- a/WebCore/bindings/js/JSUint32ArrayCustom.cpp +++ b/WebCore/bindings/js/JSUint32ArrayCustom.cpp @@ -27,9 +27,9 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) -#include "JSArrayBufferViewHelper.h" #include "JSUint32Array.h" +#include "JSArrayBufferViewHelper.h" #include "Uint32Array.h" using namespace JSC; @@ -54,7 +54,7 @@ JSC::JSValue JSUint32Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSUint32ArrayConstructor::constructJSUint32Array(ExecState* exec) { JSUint32ArrayConstructor* jsConstructor = static_cast<JSUint32ArrayConstructor*>(exec->callee()); - RefPtr<Uint32Array> array = static_cast<Uint32Array*>(constructArrayBufferView<Uint32Array, unsigned int>(exec).get()); + RefPtr<Uint32Array> array = constructArrayBufferView<Uint32Array, unsigned int>(exec); if (!array.get()) // Exception has already been thrown. return JSValue::encode(JSValue()); diff --git a/WebCore/bindings/js/JSUint8ArrayCustom.cpp b/WebCore/bindings/js/JSUint8ArrayCustom.cpp index adf60a9..a9ed73f 100644 --- a/WebCore/bindings/js/JSUint8ArrayCustom.cpp +++ b/WebCore/bindings/js/JSUint8ArrayCustom.cpp @@ -27,9 +27,9 @@ #if ENABLE(3D_CANVAS) || ENABLE(BLOB) -#include "JSArrayBufferViewHelper.h" #include "JSUint8Array.h" +#include "JSArrayBufferViewHelper.h" #include "Uint8Array.h" using namespace JSC; @@ -54,7 +54,7 @@ JSC::JSValue JSUint8Array::set(JSC::ExecState* exec) EncodedJSValue JSC_HOST_CALL JSUint8ArrayConstructor::constructJSUint8Array(ExecState* exec) { JSUint8ArrayConstructor* jsConstructor = static_cast<JSUint8ArrayConstructor*>(exec->callee()); - RefPtr<Uint8Array> array = static_cast<Uint8Array*>(constructArrayBufferView<Uint8Array, unsigned char>(exec).get()); + RefPtr<Uint8Array> array = constructArrayBufferView<Uint8Array, unsigned char>(exec); if (!array.get()) // Exception has already been thrown. return JSValue::encode(JSValue()); diff --git a/WebCore/bindings/js/JSWebKitCSSKeyframeRuleCustom.cpp b/WebCore/bindings/js/JSWebKitCSSKeyframeRuleCustom.cpp new file mode 100644 index 0000000..0eaebf1 --- /dev/null +++ b/WebCore/bindings/js/JSWebKitCSSKeyframeRuleCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSWebKitCSSKeyframeRule.h" + +#include "WebKitCSSKeyframeRule.h" + +using namespace JSC; + +namespace WebCore { + +void JSWebKitCSSKeyframeRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (CSSMutableStyleDeclaration* style = static_cast<WebKitCSSKeyframeRule*>(impl())->style()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), style); +} + +} diff --git a/WebCore/bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp b/WebCore/bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp new file mode 100644 index 0000000..b590b6a --- /dev/null +++ b/WebCore/bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSWebKitCSSKeyframesRule.h" + +#include "WebKitCSSKeyframesRule.h" + +using namespace JSC; + +namespace WebCore { + +void JSWebKitCSSKeyframesRule::markChildren(MarkStack& markStack) +{ + Base::markChildren(markStack); + + if (CSSRuleList* rules = static_cast<WebKitCSSKeyframesRule*>(impl())->cssRules()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), rules); +} + +} diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp index 58d324d..7cf8207 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp @@ -29,6 +29,7 @@ #include "config.h" #include "JSXMLHttpRequest.h" +#include "ArrayBuffer.h" #include "Blob.h" #include "DOMFormData.h" #include "DOMWindow.h" @@ -38,6 +39,7 @@ #include "FrameLoader.h" #include "HTMLDocument.h" #include "InspectorInstrumentation.h" +#include "JSArrayBuffer.h" #include "JSBlob.h" #include "JSDOMFormData.h" #include "JSDOMWindowCustom.h" @@ -59,6 +61,19 @@ void JSXMLHttpRequest::markChildren(MarkStack& markStack) if (XMLHttpRequestUpload* upload = m_impl->optionalUpload()) markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), upload); + if (Document* responseDocument = m_impl->optionalResponseXML()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), responseDocument); + +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + if (ArrayBuffer* responseArrayBuffer = m_impl->optionalResponseArrayBuffer()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), responseArrayBuffer); +#endif + +#if ENABLE(XHR_RESPONSE_BLOB) + if (Blob* responseBlob = m_impl->optionalResponseBlob()) + markDOMObjectWrapper(markStack, *Heap::heap(this)->globalData(), responseBlob); +#endif + m_impl->markJSEventListeners(markStack); } @@ -77,7 +92,7 @@ JSValue JSXMLHttpRequest::open(ExecState* exec) if (exec->argumentCount() >= 4 && !exec->argument(3).isUndefined()) { String user = valueToStringWithNullCheck(exec, exec->argument(3)); - + if (exec->argumentCount() >= 5 && !exec->argument(4).isUndefined()) { String password = valueToStringWithNullCheck(exec, exec->argument(4)); impl()->open(method, url, async, user, password, ec); @@ -109,6 +124,10 @@ JSValue JSXMLHttpRequest::send(ExecState* exec) impl()->send(toBlob(val), ec); else if (val.inherits(&JSDOMFormData::s_info)) impl()->send(toDOMFormData(val), ec); +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + else if (val.inherits(&JSArrayBuffer::s_info)) + impl()->send(toArrayBuffer(val), ec); +#endif else impl()->send(ustringToString(val.toString(exec)), ec); } @@ -136,6 +155,56 @@ JSValue JSXMLHttpRequest::responseText(ExecState* exec) const return jsOwnedStringOrNull(exec, text); } +JSValue JSXMLHttpRequest::response(ExecState* exec) const +{ + switch (impl()->responseTypeCode()) { + case XMLHttpRequest::ResponseTypeDefault: + case XMLHttpRequest::ResponseTypeText: + return responseText(exec); + + case XMLHttpRequest::ResponseTypeDocument: + { + ExceptionCode ec = 0; + Document* document = impl()->responseXML(ec); + if (ec) { + setDOMException(exec, ec); + return jsUndefined(); + } + return toJS(exec, globalObject(), document); + } + + case XMLHttpRequest::ResponseTypeBlob: +#if ENABLE(XHR_RESPONSE_BLOB) + { + ExceptionCode ec = 0; + Blob* blob = impl()->responseBlob(ec); + if (ec) { + setDOMException(exec, ec); + return jsUndefined(); + } + return toJS(exec, globalObject(), blob); + } +#else + return jsUndefined(); +#endif + +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + case XMLHttpRequest::ResponseTypeArrayBuffer: + { + ExceptionCode ec = 0; + ArrayBuffer* arrayBuffer = impl()->responseArrayBuffer(ec); + if (ec) { + setDOMException(exec, ec); + return jsUndefined(); + } + return toJS(exec, globalObject(), arrayBuffer); + } +#endif + } + + return jsUndefined(); +} + EncodedJSValue JSC_HOST_CALL JSXMLHttpRequestConstructor::constructJSXMLHttpRequest(ExecState* exec) { JSXMLHttpRequestConstructor* jsConstructor = static_cast<JSXMLHttpRequestConstructor*>(exec->callee()); diff --git a/WebCore/bindings/js/OptionsObject.h b/WebCore/bindings/js/OptionsObject.h new file mode 100644 index 0000000..34910c0 --- /dev/null +++ b/WebCore/bindings/js/OptionsObject.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef OptionsObject_h +#define OptionsObject_h + +// FIXME: Implement. + +#endif // OptionsObject_h diff --git a/WebCore/bindings/js/ScriptCallStackFactory.cpp b/WebCore/bindings/js/ScriptCallStackFactory.cpp index 25fabdd..9a64ffc 100644 --- a/WebCore/bindings/js/ScriptCallStackFactory.cpp +++ b/WebCore/bindings/js/ScriptCallStackFactory.cpp @@ -48,7 +48,7 @@ using namespace JSC; namespace WebCore { -PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) +PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) { Vector<ScriptCallFrame> frames; CallFrame* callFrame = exec; @@ -75,16 +75,16 @@ PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t m break; callFrame = callFrame->callerFrame(); } - return new ScriptCallStack(frames); + return ScriptCallStack::create(frames); } -PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount) +PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState* exec, unsigned skipArgumentCount) { Vector<ScriptValue> arguments; size_t argumentCount = exec->argumentCount(); for (size_t i = skipArgumentCount; i < argumentCount; ++i) arguments.append(ScriptValue(exec->argument(i))); - return new ScriptArguments(exec, arguments); + return ScriptArguments::create(exec, arguments); } bool ScriptCallStack::stackTrace(int, const RefPtr<InspectorArray>&) diff --git a/WebCore/bindings/js/ScriptCallStackFactory.h b/WebCore/bindings/js/ScriptCallStackFactory.h index 744d88d..9fbfc78 100644 --- a/WebCore/bindings/js/ScriptCallStackFactory.h +++ b/WebCore/bindings/js/ScriptCallStackFactory.h @@ -31,7 +31,7 @@ #ifndef ScriptCallStackFactory_h #define ScriptCallStackFactory_h -#include <wtf/PassOwnPtr.h> +#include <wtf/Forward.h> namespace JSC { class ExecState; @@ -42,8 +42,8 @@ namespace WebCore { class ScriptArguments; class ScriptCallStack; -PassOwnPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize); -PassOwnPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); +PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState*, size_t maxStackSize); +PassRefPtr<ScriptArguments> createScriptArguments(JSC::ExecState*, unsigned skipArgumentCount); } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptHeapSnapshot.h b/WebCore/bindings/js/ScriptHeapSnapshot.h index c81c782..4c3d915 100644 --- a/WebCore/bindings/js/ScriptHeapSnapshot.h +++ b/WebCore/bindings/js/ScriptHeapSnapshot.h @@ -38,15 +38,22 @@ namespace WebCore { class ScriptHeapSnapshot : public RefCounted<ScriptHeapSnapshot> { public: - virtual ~ScriptHeapSnapshot() {} + class OutputStream { + public: + virtual ~OutputStream() { } + virtual void Write(const String& chunk) = 0; + virtual void Close() = 0; + }; + + virtual ~ScriptHeapSnapshot() { } String title() const { return ""; } unsigned int uid() const { return 0; } - PassRefPtr<InspectorObject> buildInspectorObjectForHead() const { return InspectorObject::create(); } + void writeJSON(OutputStream*) { } private: - ScriptHeapSnapshot() {} + ScriptHeapSnapshot() { } }; } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptProfile.cpp b/WebCore/bindings/js/ScriptProfile.cpp index 8731ec2..84451fb 100644 --- a/WebCore/bindings/js/ScriptProfile.cpp +++ b/WebCore/bindings/js/ScriptProfile.cpp @@ -66,6 +66,7 @@ ScriptProfileNode* ScriptProfile::head() const return m_profile->head(); } +#if ENABLE(INSPECTOR) static PassRefPtr<InspectorObject> buildInspectorObjectFor(const JSC::ProfileNode* node) { RefPtr<InspectorObject> result = InspectorObject::create(); @@ -94,6 +95,7 @@ PassRefPtr<InspectorObject> ScriptProfile::buildInspectorObjectForHead() const { return buildInspectorObjectFor(m_profile->head()); } +#endif } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptProfile.h b/WebCore/bindings/js/ScriptProfile.h index b39d2c9..0b38edc 100644 --- a/WebCore/bindings/js/ScriptProfile.h +++ b/WebCore/bindings/js/ScriptProfile.h @@ -51,7 +51,9 @@ public: unsigned int uid() const; ScriptProfileNode* head() const; +#if ENABLE(INSPECTOR) PassRefPtr<InspectorObject> buildInspectorObjectForHead() const; +#endif private: ScriptProfile(PassRefPtr<JSC::Profile> profile); diff --git a/WebCore/bindings/js/ScriptValue.cpp b/WebCore/bindings/js/ScriptValue.cpp index a58e0c7..a2a72b6 100644 --- a/WebCore/bindings/js/ScriptValue.cpp +++ b/WebCore/bindings/js/ScriptValue.cpp @@ -84,6 +84,12 @@ bool ScriptValue::isObject() const return m_value.get().isObject(); } +bool ScriptValue::isFunction() const +{ + CallData callData; + return getCallData(m_value, callData) != CallTypeNone; +} + PassRefPtr<SerializedScriptValue> ScriptValue::serialize(ScriptState* scriptState) { return SerializedScriptValue::create(scriptState, jsValue()); diff --git a/WebCore/bindings/js/ScriptValue.h b/WebCore/bindings/js/ScriptValue.h index b170fcf..5746c3f 100644 --- a/WebCore/bindings/js/ScriptValue.h +++ b/WebCore/bindings/js/ScriptValue.h @@ -55,8 +55,11 @@ public: bool isNull() const; bool isUndefined() const; bool isObject() const; + bool isFunction() const; bool hasNoValue() const { return m_value == JSC::JSValue(); } + bool operator==(const ScriptValue& other) const { return m_value == other.m_value; } + PassRefPtr<SerializedScriptValue> serialize(ScriptState*); static ScriptValue deserialize(ScriptState*, SerializedScriptValue*); |