/* This file is part of the WebKit open source project. This file has been generated by generate-bindings.pl. DO NOT MODIFY! This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "config.h" #include "JSCSSStyleDeclaration.h" #include "AtomicString.h" #include "CSSRule.h" #include "CSSStyleDeclaration.h" #include "CSSValue.h" #include "JSCSSRule.h" #include "JSCSSStyleDeclarationCustom.h" #include "JSCSSValue.h" #include "KURL.h" #include #include #include #include using namespace JSC; namespace WebCore { ASSERT_CLASS_FITS_IN_CELL(JSCSSStyleDeclaration); /* Hash table */ static const HashTableValue JSCSSStyleDeclarationTableValues[5] = { { "cssText", DontDelete, (intptr_t)jsCSSStyleDeclarationCssText, (intptr_t)setJSCSSStyleDeclarationCssText }, { "length", DontDelete|ReadOnly, (intptr_t)jsCSSStyleDeclarationLength, (intptr_t)0 }, { "parentRule", DontDelete|ReadOnly, (intptr_t)jsCSSStyleDeclarationParentRule, (intptr_t)0 }, { "constructor", DontEnum|ReadOnly, (intptr_t)jsCSSStyleDeclarationConstructor, (intptr_t)0 }, { 0, 0, 0, 0 } }; static JSC_CONST_HASHTABLE HashTable JSCSSStyleDeclarationTable = #if ENABLE(PERFECT_HASH_SIZE) { 63, JSCSSStyleDeclarationTableValues, 0 }; #else { 10, 7, JSCSSStyleDeclarationTableValues, 0 }; #endif /* Hash table for constructor */ static const HashTableValue JSCSSStyleDeclarationConstructorTableValues[1] = { { 0, 0, 0, 0 } }; static JSC_CONST_HASHTABLE HashTable JSCSSStyleDeclarationConstructorTable = #if ENABLE(PERFECT_HASH_SIZE) { 0, JSCSSStyleDeclarationConstructorTableValues, 0 }; #else { 1, 0, JSCSSStyleDeclarationConstructorTableValues, 0 }; #endif class JSCSSStyleDeclarationConstructor : public DOMConstructorObject { public: JSCSSStyleDeclarationConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorObject(JSCSSStyleDeclarationConstructor::createStructure(globalObject->objectPrototype()), globalObject) { putDirect(exec->propertyNames().prototype, JSCSSStyleDeclarationPrototype::self(exec, globalObject), None); } virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual const ClassInfo* classInfo() const { return &s_info; } static const ClassInfo s_info; static PassRefPtr createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance)); } }; const ClassInfo JSCSSStyleDeclarationConstructor::s_info = { "CSSStyleDeclarationConstructor", 0, &JSCSSStyleDeclarationConstructorTable, 0 }; bool JSCSSStyleDeclarationConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { return getStaticValueSlot(exec, &JSCSSStyleDeclarationConstructorTable, this, propertyName, slot); } /* Hash table for prototype */ static const HashTableValue JSCSSStyleDeclarationPrototypeTableValues[9] = { { "getPropertyValue", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionGetPropertyValue, (intptr_t)1 }, { "getPropertyCSSValue", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionGetPropertyCSSValue, (intptr_t)1 }, { "removeProperty", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionRemoveProperty, (intptr_t)1 }, { "getPropertyPriority", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionGetPropertyPriority, (intptr_t)1 }, { "setProperty", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionSetProperty, (intptr_t)3 }, { "item", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionItem, (intptr_t)1 }, { "getPropertyShorthand", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionGetPropertyShorthand, (intptr_t)1 }, { "isPropertyImplicit", DontDelete|Function, (intptr_t)jsCSSStyleDeclarationPrototypeFunctionIsPropertyImplicit, (intptr_t)1 }, { 0, 0, 0, 0 } }; static JSC_CONST_HASHTABLE HashTable JSCSSStyleDeclarationPrototypeTable = #if ENABLE(PERFECT_HASH_SIZE) { 31, JSCSSStyleDeclarationPrototypeTableValues, 0 }; #else { 17, 15, JSCSSStyleDeclarationPrototypeTableValues, 0 }; #endif const ClassInfo JSCSSStyleDeclarationPrototype::s_info = { "CSSStyleDeclarationPrototype", 0, &JSCSSStyleDeclarationPrototypeTable, 0 }; JSObject* JSCSSStyleDeclarationPrototype::self(ExecState* exec, JSGlobalObject* globalObject) { return getDOMPrototype(exec, globalObject); } bool JSCSSStyleDeclarationPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { return getStaticFunctionSlot(exec, &JSCSSStyleDeclarationPrototypeTable, this, propertyName, slot); } const ClassInfo JSCSSStyleDeclaration::s_info = { "CSSStyleDeclaration", 0, &JSCSSStyleDeclarationTable, 0 }; JSCSSStyleDeclaration::JSCSSStyleDeclaration(PassRefPtr structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) : DOMObjectWithGlobalPointer(structure, globalObject) , m_impl(impl) { } JSCSSStyleDeclaration::~JSCSSStyleDeclaration() { forgetDOMObject(*Heap::heap(this)->globalData(), m_impl.get()); } JSObject* JSCSSStyleDeclaration::createPrototype(ExecState* exec, JSGlobalObject* globalObject) { return new (exec) JSCSSStyleDeclarationPrototype(JSCSSStyleDeclarationPrototype::createStructure(globalObject->objectPrototype())); } bool JSCSSStyleDeclaration::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { const HashEntry* entry = JSCSSStyleDeclarationTable.entry(exec, propertyName); if (entry) { slot.setCustom(this, entry->propertyGetter()); return true; } bool ok; unsigned index = propertyName.toUInt32(&ok, false); if (ok && index < static_cast(impl())->length()) { slot.setCustomIndex(this, index, indexGetter); return true; } if (canGetItemsForName(exec, static_cast(impl()), propertyName)) { slot.setCustom(this, nameGetter); return true; } return getStaticValueSlot(exec, &JSCSSStyleDeclarationTable, this, propertyName, slot); } bool JSCSSStyleDeclaration::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) { if (propertyName < static_cast(impl())->length()) { slot.setCustomIndex(this, propertyName, indexGetter); return true; } return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); } JSValue jsCSSStyleDeclarationCssText(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSCSSStyleDeclaration* castedThis = static_cast(asObject(slot.slotBase())); UNUSED_PARAM(exec); CSSStyleDeclaration* imp = static_cast(castedThis->impl()); return jsStringOrNull(exec, imp->cssText()); } JSValue jsCSSStyleDeclarationLength(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSCSSStyleDeclaration* castedThis = static_cast(asObject(slot.slotBase())); UNUSED_PARAM(exec); CSSStyleDeclaration* imp = static_cast(castedThis->impl()); return jsNumber(exec, imp->length()); } JSValue jsCSSStyleDeclarationParentRule(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSCSSStyleDeclaration* castedThis = static_cast(asObject(slot.slotBase())); UNUSED_PARAM(exec); CSSStyleDeclaration* imp = static_cast(castedThis->impl()); return toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->parentRule())); } JSValue jsCSSStyleDeclarationConstructor(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSCSSStyleDeclaration* domObject = static_cast(asObject(slot.slotBase())); return JSCSSStyleDeclaration::getConstructor(exec, domObject->globalObject()); } void JSCSSStyleDeclaration::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { if (putDelegate(exec, propertyName, value, slot)) return; lookupPut(exec, propertyName, value, &JSCSSStyleDeclarationTable, this, slot); } void setJSCSSStyleDeclarationCssText(ExecState* exec, JSObject* thisObject, JSValue value) { CSSStyleDeclaration* imp = static_cast(static_cast(thisObject)->impl()); ExceptionCode ec = 0; imp->setCssText(valueToStringWithNullCheck(exec, value), ec); setDOMException(exec, ec); } void JSCSSStyleDeclaration::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) { for (unsigned i = 0; i < static_cast(impl())->length(); ++i) propertyNames.add(Identifier::from(exec, i)); Base::getPropertyNames(exec, propertyNames); } JSValue JSCSSStyleDeclaration::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { return getDOMConstructor(exec, static_cast(globalObject)); } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyValue(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); const UString& propertyName = args.at(0).toString(exec); JSC::JSValue result = jsStringOrNull(exec, imp->getPropertyValue(propertyName)); return result; } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyCSSValue(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); const UString& propertyName = args.at(0).toString(exec); JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->getPropertyCSSValue(propertyName))); return result; } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionRemoveProperty(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); ExceptionCode ec = 0; const UString& propertyName = args.at(0).toString(exec); JSC::JSValue result = jsStringOrNull(exec, imp->removeProperty(propertyName, ec)); setDOMException(exec, ec); return result; } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyPriority(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); const UString& propertyName = args.at(0).toString(exec); JSC::JSValue result = jsStringOrNull(exec, imp->getPropertyPriority(propertyName)); return result; } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionSetProperty(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); ExceptionCode ec = 0; const UString& propertyName = args.at(0).toString(exec); const UString& value = valueToStringWithNullCheck(exec, args.at(1)); const UString& priority = args.at(2).toString(exec); imp->setProperty(propertyName, value, priority, ec); setDOMException(exec, ec); return jsUndefined(); } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionItem(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); unsigned index = args.at(0).toInt32(exec); JSC::JSValue result = jsStringOrNull(exec, imp->item(index)); return result; } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyShorthand(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); const UString& propertyName = args.at(0).toString(exec); JSC::JSValue result = jsStringOrNull(exec, imp->getPropertyShorthand(propertyName)); return result; } JSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionIsPropertyImplicit(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.isObject(&JSCSSStyleDeclaration::s_info)) return throwError(exec, TypeError); JSCSSStyleDeclaration* castedThisObj = static_cast(asObject(thisValue)); CSSStyleDeclaration* imp = static_cast(castedThisObj->impl()); const UString& propertyName = args.at(0).toString(exec); JSC::JSValue result = jsBoolean(imp->isPropertyImplicit(propertyName)); return result; } JSValue JSCSSStyleDeclaration::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSCSSStyleDeclaration* thisObj = static_cast(asObject(slot.slotBase())); return jsStringOrNull(exec, thisObj->impl()->item(slot.index())); } JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, CSSStyleDeclaration* object) { return getDOMObjectWrapper(exec, globalObject, object); } CSSStyleDeclaration* toCSSStyleDeclaration(JSC::JSValue value) { return value.isObject(&JSCSSStyleDeclaration::s_info) ? static_cast(asObject(value))->impl() : 0; } }