Skip to content
Permalink
Browse files
Make sure computed values for 'baseline-shift' CSS property have 'px'…
… unit for lengths

https://bugs.webkit.org/show_bug.cgi?id=249318

Reviewed by Simon Fraser.

Make sure computed values for 'baseline-shift' CSS property have 'px' unit for lengths.
This is similar to what we do for other types of CSS properties. However, this SVG CSS
property would previously only compute to 'px' when applied to a SVGElement.

* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/baseline-shift-expected.txt:
* Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::svgPropertyValue):

Canonical link: https://commits.webkit.org/257928@main
  • Loading branch information
cdumez committed Dec 15, 2022
1 parent 1d99a93 commit c08063e923437d16d256cb71e2ce10faf33e04d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
@@ -11,8 +11,8 @@ PASS Can set 'baseline-shift' to a percent: -3.14%
PASS Can set 'baseline-shift' to a percent: 3.14%
PASS Can set 'baseline-shift' to a percent: calc(0% + 0%)
PASS Can set 'baseline-shift' to a length: 0px
FAIL Can set 'baseline-shift' to a length: -3.14em assert_equals: unit expected "px" but got "em"
FAIL Can set 'baseline-shift' to a length: 3.14cm assert_equals: unit expected "px" but got "cm"
PASS Can set 'baseline-shift' to a length: -3.14em
PASS Can set 'baseline-shift' to a length: 3.14cm
PASS Can set 'baseline-shift' to a length: calc(0px + 0em)
PASS Setting 'baseline-shift' to a time: 0s throws TypeError
PASS Setting 'baseline-shift' to a time: -3.14ms throws TypeError
@@ -154,8 +154,12 @@ RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID property
return CSSPrimitiveValue::createIdentifier(CSSValueSuper);
case BaselineShift::Sub:
return CSSPrimitiveValue::createIdentifier(CSSValueSub);
case BaselineShift::Length:
return svgStyle.baselineShiftValue().toCSSPrimitiveValue(m_element.get());
case BaselineShift::Length: {
auto computedValue = svgStyle.baselineShiftValue().toCSSPrimitiveValue(m_element.get());
if (computedValue->isLength() && computedValue->primitiveType() != CSSUnitType::CSS_PX)
return CSSPrimitiveValue::create(computedValue->doubleValue(CSSUnitType::CSS_PX), CSSUnitType::CSS_PX);
return computedValue;
}
}
ASSERT_NOT_REACHED();
return nullptr;

0 comments on commit c08063e

Please sign in to comment.