| /* |
| 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 "JSCSSRule.h" |
| |
| #include "ExceptionCode.h" |
| #include "JSCSSRule.h" |
| #include "JSCSSStyleSheet.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "URL.h" |
| #include <runtime/FunctionPrototype.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsCSSRuleType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsCSSRuleCssText(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSCSSRuleCssText(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| JSC::EncodedJSValue jsCSSRuleParentStyleSheet(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsCSSRuleParentRule(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsCSSRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSCSSRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSCSSRulePrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSCSSRulePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSCSSRulePrototype* ptr = new (NotNull, JSC::allocateCell<JSCSSRulePrototype>(vm.heap)) JSCSSRulePrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSCSSRulePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructorNotConstructable<JSCSSRule> JSCSSRuleConstructor; |
| |
| /* Hash table for constructor */ |
| |
| static const HashTableValue JSCSSRuleConstructorTableValues[] = |
| { |
| { "UNKNOWN_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
| { "STYLE_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "CHARSET_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "IMPORT_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| { "MEDIA_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| { "FONT_FACE_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| { "PAGE_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| { "KEYFRAMES_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| { "KEYFRAME_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| { "SUPPORTS_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| { "WEBKIT_REGION_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(16) } }, |
| { "WEBKIT_KEYFRAMES_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| { "WEBKIT_KEYFRAME_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| }; |
| |
| static_assert(CSSRule::UNKNOWN_RULE == 0, "UNKNOWN_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::STYLE_RULE == 1, "STYLE_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::CHARSET_RULE == 2, "CHARSET_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::IMPORT_RULE == 3, "IMPORT_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::MEDIA_RULE == 4, "MEDIA_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::FONT_FACE_RULE == 5, "FONT_FACE_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::PAGE_RULE == 6, "PAGE_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::KEYFRAMES_RULE == 7, "KEYFRAMES_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::KEYFRAME_RULE == 8, "KEYFRAME_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::SUPPORTS_RULE == 12, "SUPPORTS_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::WEBKIT_REGION_RULE == 16, "WEBKIT_REGION_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::WEBKIT_KEYFRAMES_RULE == 7, "WEBKIT_KEYFRAMES_RULE in CSSRule does not match value from IDL"); |
| static_assert(CSSRule::WEBKIT_KEYFRAME_RULE == 8, "WEBKIT_KEYFRAME_RULE in CSSRule does not match value from IDL"); |
| |
| template<> JSValue JSCSSRuleConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| UNUSED_PARAM(vm); |
| return globalObject.functionPrototype(); |
| } |
| |
| template<> void JSCSSRuleConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSCSSRule::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("CSSRule"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| reifyStaticProperties(vm, JSCSSRuleConstructorTableValues, *this); |
| } |
| |
| template<> const ClassInfo JSCSSRuleConstructor::s_info = { "CSSRule", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCSSRuleConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSCSSRulePrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSRuleConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSRuleConstructor) } }, |
| { "type", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSRuleType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "cssText", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSRuleCssText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSRuleCssText) } }, |
| { "parentStyleSheet", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSRuleParentStyleSheet), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "parentRule", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSRuleParentRule), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "UNKNOWN_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
| { "STYLE_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "CHARSET_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "IMPORT_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| { "MEDIA_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| { "FONT_FACE_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| { "PAGE_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| { "KEYFRAMES_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| { "KEYFRAME_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| { "SUPPORTS_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| { "WEBKIT_REGION_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(16) } }, |
| { "WEBKIT_KEYFRAMES_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| { "WEBKIT_KEYFRAME_RULE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| }; |
| |
| const ClassInfo JSCSSRulePrototype::s_info = { "CSSRulePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCSSRulePrototype) }; |
| |
| void JSCSSRulePrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSCSSRulePrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSCSSRule::s_info = { "CSSRule", &Base::s_info, 0, CREATE_METHOD_TABLE(JSCSSRule) }; |
| |
| JSCSSRule::JSCSSRule(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CSSRule>&& impl) |
| : JSDOMWrapper<CSSRule>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSCSSRule::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSCSSRulePrototype::create(vm, globalObject, JSCSSRulePrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSCSSRule::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSCSSRule>(vm, globalObject); |
| } |
| |
| void JSCSSRule::destroy(JSC::JSCell* cell) |
| { |
| JSCSSRule* thisObject = static_cast<JSCSSRule*>(cell); |
| thisObject->JSCSSRule::~JSCSSRule(); |
| } |
| |
| EncodedJSValue jsCSSRuleType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSCSSRule*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "CSSRule", "type"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.type()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsCSSRuleCssText(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSCSSRule*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "CSSRule", "cssText"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringOrNull(state, impl.cssText()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsCSSRuleParentStyleSheet(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSCSSRule*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "CSSRule", "parentStyleSheet"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.parentStyleSheet()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsCSSRuleParentRule(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSCSSRule*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "CSSRule", "parentRule"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.parentRule()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsCSSRuleConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSCSSRulePrototype* domObject = jsDynamicCast<JSCSSRulePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSCSSRule::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSCSSRuleConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSCSSRulePrototype* domObject = jsDynamicCast<JSCSSRulePrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| bool setJSCSSRuleCssText(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue value = JSValue::decode(encodedValue); |
| UNUSED_PARAM(thisValue); |
| JSCSSRule* castedThis = jsDynamicCast<JSCSSRule*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!castedThis)) { |
| return throwSetterTypeError(*state, throwScope, "CSSRule", "cssText"); |
| } |
| auto& impl = castedThis->wrapped(); |
| ExceptionCode ec = 0; |
| auto nativeValue = valueToStringWithUndefinedOrNullCheck(state, value); |
| RETURN_IF_EXCEPTION(throwScope, false); |
| impl.setCssText(WTFMove(nativeValue), ec); |
| setDOMException(state, throwScope, ec); |
| return true; |
| } |
| |
| |
| JSValue JSCSSRule::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSCSSRuleConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| void JSCSSRule::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSCSSRule*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| thisObject->visitAdditionalChildren(visitor); |
| } |
| |
| bool JSCSSRuleOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| auto* jsCSSRule = jsCast<JSCSSRule*>(handle.slot()->asCell()); |
| void* root = WebCore::root(&jsCSSRule->wrapped()); |
| return visitor.containsOpaqueRoot(root); |
| } |
| |
| void JSCSSRuleOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsCSSRule = jsCast<JSCSSRule*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsCSSRule->wrapped(), jsCSSRule); |
| } |
| |
| CSSRule* JSCSSRule::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSCSSRule*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |