v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.CSSStyleDeclaration.NamedPropertyGetter"); // First look for API defined attributes on the style declaration object. if (info.Holder()->HasRealNamedCallbackProperty(name)) return v8::Handle<v8::Value>(); // Search the style declaration. CSSPropertyInfo* propInfo = cssPropertyInfo(name); // Do not handle non-property names. if (!propInfo) return v8::Handle<v8::Value>(); CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder()); RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID)); if (cssValue) { if (propInfo->hadPixelOrPosPrefix && cssValue->isPrimitiveValue()) { return v8::Number::New(static_cast<CSSPrimitiveValue*>( cssValue.get())->getFloatValue(CSSPrimitiveValue::CSS_PX)); } return v8StringOrNull(cssValue->cssText(), info.GetIsolate()); } String result = imp->getPropertyValueInternal(static_cast<CSSPropertyID>(propInfo->propID)); if (result.isNull()) result = ""; // convert null to empty string. return v8String(result, info.GetIsolate()); }
void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { if (!name->IsString()) return; // First look for API defined attributes on the style declaration object. if (v8CallBoolean(info.Holder()->HasRealNamedCallbackProperty(info.GetIsolate()->GetCurrentContext(), name.As<v8::String>()))) return; // Search the style declaration. CSSPropertyInfo* propInfo = cssPropertyInfo(name.As<v8::String>(), info.GetIsolate()); // Do not handle non-property names. if (!propInfo) return; CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder()); RefPtrWillBeRawPtr<CSSValue> cssValue = impl->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID)); if (cssValue) { v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate()); return; } String result = impl->getPropertyValueInternal(static_cast<CSSPropertyID>(propInfo->propID)); v8SetReturnValueString(info, result, info.GetIsolate()); }
void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { // First look for API defined attributes on the style declaration object. if (info.Holder()->HasRealNamedCallbackProperty(name)) return; // Search the style declaration. CSSPropertyInfo* propInfo = cssPropertyInfo(name); // Do not handle non-property names. if (!propInfo) return; countCssPropertyInfoUsage(info.GetIsolate(), *propInfo); CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder()); RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID)); if (cssValue) { v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate()); return; } String result = imp->getPropertyValueInternal(static_cast<CSSPropertyID>(propInfo->propID)); if (result.isNull()) result = ""; // convert null to empty string. v8SetReturnValueString(info, result, info.GetIsolate()); }
const CSSPrimitiveValue* LayoutEditor::getPropertyCSSValue( CSSPropertyID property) const { CSSStyleDeclaration* style = m_cssAgent->findEffectiveDeclaration(property, m_matchedStyles); if (!style) return nullptr; const CSSValue* cssValue = style->getPropertyCSSValueInternal(property); if (!cssValue || !cssValue->isPrimitiveValue()) return nullptr; return toCSSPrimitiveValue(cssValue); }