Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add support for CSSNumericValue.toSum()
https://bugs.webkit.org/show_bug.cgi?id=246673 Reviewed by Geoffrey Garen. Add support for CSSNumericValue.toSum(): - https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-tosum * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTransformComponent-toMatrix-relative-units-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/numeric-objects/toSum.tentative-expected.txt: Rebaseline WPT tests now that more checks are passing. * Source/WebCore/css/CSSUnits.cpp: (WebCore::unitCategory): Match the categories more closely with the specification. It is particularly important to split the different types of lengths. "em" for example is a font-relative length. We used to have it with the absolute lengths and would thus incorrectly convert it to "px" which is the canonical unit for absolute lengths. (WebCore::canonicalUnitTypeForCategory): (WebCore::operator<<): * Source/WebCore/css/CSSUnits.h: * Source/WebCore/css/typedom/CSSNumericValue.cpp: (WebCore::createCSSUnitValueFromAddend): Properly implement: - https://drafts.css-houdini.org/css-typed-om/#create-a-cssunitvalue-from-a-sum-value-item and factor to its own function for reuse. In particular, we were supposed to fail if the unit exponent is not 1. (WebCore::CSSNumericValue::to): Factor out some code to createCSSUnitValueFromAddend(). (WebCore::CSSNumericValue::toSum): Implement as per: - - https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-tosum * Source/WebCore/css/typedom/CSSUnitValue.cpp: (WebCore::CSSUnitValue::toSumValue const): * Source/WebCore/css/typedom/numeric/CSSNumericType.cpp: (WebCore::CSSNumericType::create): Canonical link: https://commits.webkit.org/255679@main
- Loading branch information
Showing
7 changed files
with
134 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
|
||
FAIL Converting a CSSNumericValue to a sum with invalid units throws SyntaxError assert_throws_dom: function "() => CSS.px(1).toSum('px', 'lemon')" did not throw | ||
PASS Converting a CSSNumericValue to a sum with invalid units throws SyntaxError | ||
PASS Converting a CSSNumericValue with an invalid sum value to a sum throws TypeError | ||
FAIL Converting a CSSNumericValue with compound units to a sum throws TypeError assert_throws_js: function "() => new CSSMathProduct(CSS.px(1), CSS.px(1)).to('px')" did not throw | ||
FAIL Converting a CSSNumericValue to a sum with an incompatible unit throws TypeError assert_throws_js: function "() => CSS.px(1).toSum('number')" did not throw | ||
FAIL Converting a CSSNumericValue to a sum with units that are not addable throws TypeError assert_throws_js: function "() => CSS.px(1).toSum('px', 's')" did not throw | ||
FAIL Converting a CSSNumericValue with leftover units to a sum throws TypeError assert_throws_js: function "() => new CSSMathSum(CSS.px(1), CSS.em(1)).toSum('px')" did not throw | ||
FAIL Converting CSSNumericValue to a sum with its own unit returns itself assert_equals: expected "px" but got "number" | ||
FAIL Converting CSSNumericValue to a sum with no arguments returns all the units in sorted order assert_equals: expected 4 but got 1 | ||
FAIL Converting CSSNumericValue to a sum with a relative unit converts correctly assert_approx_equals: expected 20 +/- 0.000001 but got 1 | ||
FAIL Converting CSSNumericValue to a sum containing extra units returns zero for those units assert_equals: expected 3 but got 1 | ||
FAIL CSSNumericValue.toSum converts greedily assert_equals: expected 2 but got 1 | ||
PASS Converting a CSSNumericValue with compound units to a sum throws TypeError | ||
PASS Converting a CSSNumericValue to a sum with an incompatible unit throws TypeError | ||
PASS Converting a CSSNumericValue to a sum with units that are not addable throws TypeError | ||
PASS Converting a CSSNumericValue with leftover units to a sum throws TypeError | ||
PASS Converting CSSNumericValue to a sum with its own unit returns itself | ||
PASS Converting CSSNumericValue to a sum with no arguments returns all the units in sorted order | ||
PASS Converting CSSNumericValue to a sum with a relative unit converts correctly | ||
PASS Converting CSSNumericValue to a sum containing extra units returns zero for those units | ||
PASS CSSNumericValue.toSum converts greedily | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters