static float computeLength(CSSValue* value, RenderStyle& style, RenderView* view) { CSSToLengthConversionData conversionData(&style, &style, view); if (is<CSSPrimitiveValue>(value)) { CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value); if (!primitiveValue.isLength()) return defaultLength(style, view); return primitiveValue.computeLength<float>(conversionData); } if (is<CSSCalcValue>(value)) return downcast<CSSCalcValue>(*value).computeLengthPx(conversionData); return defaultLength(style, view); }
static float computeLength(CSSValue* value, RenderStyle& style, RenderView* view) { CSSToLengthConversionData conversionData(&style, &style, view); if (is<CSSPrimitiveValue>(value)) { CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value); if (!primitiveValue.isLength()) return defaultLength(style, view); return primitiveValue.computeLength<float>(conversionData); } if (is<CSSCalcValue>(value)) { Length length(downcast<CSSCalcValue>(*value).createCalculationValue(conversionData)); return CSSPrimitiveValue::create(length, &style)->computeLength<float>(conversionData); } return defaultLength(style, view); }
float parseSizesAttribute(StringView sizesAttribute, RenderView* view, Frame* frame) { if (!view) return 0; RenderStyle& style = view->style(); for (auto& sourceSize : CSSParser(CSSStrictMode).parseSizesAttribute(sizesAttribute)) { if (match(WTFMove(sourceSize.expression), style, frame)) return computeLength(sourceSize.length.get(), style, view); } return defaultLength(style, view); }