bool JSCSSStyleDeclaration::getOwnPropertyDescriptorDelegate(JSC::ExecState* exec, JSC::PropertyName propertyIdentifier, JSC::PropertyDescriptor& descriptor) { CSSPropertyInfo propertyInfo = cssPropertyIDForJSCSSPropertyName(propertyIdentifier); if (!propertyInfo.propertyID) return false; JSValue value; if (propertyInfo.hadPixelOrPosPrefix) value = cssPropertyGetterPixelOrPosPrefix(exec, this, propertyInfo.propertyID); else value = cssPropertyGetter(exec, this, propertyInfo.propertyID); descriptor.setDescriptor(value, ReadOnly | DontDelete | DontEnum); return true; }
bool ClassObjectDelegate::getOwnPropertyDescriptor(QScriptObject *object, JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::PropertyDescriptor &descriptor) { QScriptEnginePrivate *engine = scriptEngineFromExec(exec); QScript::SaveFrameHelper saveFrame(engine, exec); // for compatibility with the old back-end, normal JS properties // are queried first. if (QScriptObjectDelegate::getOwnPropertyDescriptor(object, exec, propertyName, descriptor)) return true; QScriptValue scriptObject = engine->scriptValueFromJSCValue(object); QScriptString scriptName; QScriptStringPrivate scriptName_d(engine, propertyName, QScriptStringPrivate::StackAllocated); QScriptStringPrivate::init(scriptName, &scriptName_d); uint id = 0; QScriptClass::QueryFlags qflags = m_scriptClass->queryProperty( scriptObject, scriptName, QScriptClass::HandlesReadAccess, &id); if (qflags & QScriptClass::HandlesReadAccess) { QScriptValue::PropertyFlags pflags = m_scriptClass->propertyFlags(scriptObject, scriptName, id); unsigned attribs = 0; if (pflags & QScriptValue::ReadOnly) attribs |= JSC::ReadOnly; if (pflags & QScriptValue::SkipInEnumeration) attribs |= JSC::DontEnum; if (pflags & QScriptValue::Undeletable) attribs |= JSC::DontDelete; if (pflags & QScriptValue::PropertyGetter) attribs |= JSC::Getter; if (pflags & QScriptValue::PropertySetter) attribs |= JSC::Setter; attribs |= pflags & QScriptValue::UserRange; // Rather than calling the getter, we could return an access descriptor here. QScriptValue value = m_scriptClass->property(scriptObject, scriptName, id); if (!value.isValid()) { // The class claims to have the property, but returned an invalid // value. Silently convert to undefined to avoid the invalid value // "escaping" into JS. value = QScriptValue(QScriptValue::UndefinedValue); } descriptor.setDescriptor(engine->scriptValueToJSCValue(value), attribs); return true; } return false; }