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
StylePropertyMap.set() should wrap value in a calc() if outside the a…
…llowed range https://bugs.webkit.org/show_bug.cgi?id=248547 Reviewed by Antti Koivisto. StylePropertyMap.set() should wrap value in a calc() if outside the allowed range for the given property, instead of throwing. This is the behavior expected by WPT tests and it matches what Blink is doing, though I cannot find a reference to this in the specification: - w3c/css-houdini-drafts#1081 This is covered by a lot of WPT tests. Sadly, those WPT tests still don't pass because we fail a following subtest (which I'll investigate next). For clarity, I extracted this separate check into its own test: - fast/css/css-typed-om/style-property-map-set-negative-value.html * LayoutTests/fast/css/css-typed-om/style-property-map-set-negative-value-expected.txt: Added. * LayoutTests/fast/css/css-typed-om/style-property-map-set-negative-value.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/block-size-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/column-count-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/column-rule-width-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/flex-grow-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/flex-shrink-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/font-size-adjust-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/font-size-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/font-stretch-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/height-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/inline-size-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/logical-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/orphans-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/padding-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/radius-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/shape-margin-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/tab-size-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/widows-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/width-expected.txt: * Source/WebCore/css/calc/CSSCalcExpressionNode.h: (WebCore::CSSCalcExpressionNode::shouldForceEnclosingCalcInCSSText const): (WebCore::CSSCalcExpressionNode::setShouldForceEnclosingCalcInCSSText): * Source/WebCore/css/calc/CSSCalcOperationNode.cpp: (WebCore::CSSCalcOperationNode::buildCSSText): * Source/WebCore/css/parser/CSSParserFastPaths.cpp: (WebCore::CSSParserFastPaths::isSimpleLengthPropertyID): (WebCore::parseSimpleLengthValue): (WebCore::isSimpleLengthPropertyID): Deleted. * Source/WebCore/css/parser/CSSParserFastPaths.h: * Source/WebCore/css/typedom/CSSStyleValue.h: (WebCore::CSSStyleValue::toCSSValueWithProperty const): * Source/WebCore/css/typedom/CSSUnitValue.cpp: (WebCore::isValueOutOfRangeForProperty): (WebCore::CSSUnitValue::toCSSValueWithProperty const): * Source/WebCore/css/typedom/CSSUnitValue.h: * Source/WebCore/css/typedom/StylePropertyMap.cpp: (WebCore::cssValueFromStyleValues): Canonical link: https://commits.webkit.org/257485@main
- Loading branch information
Showing
29 changed files
with
163 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Checks that calling StylePropertyMap.set() with a negative value wraps it into a calc. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS target.attributeStyleMap.set('width', new CSSUnitValue(-3.14, 'percent')) did not throw exception. | ||
PASS target.style.width is "calc(-3.14%)" | ||
PASS target.attributeStyleMap.set('perspective', new CSSUnitValue(-32, 'px')) did not throw exception. | ||
PASS target.style.perspective is "calc(-32px)" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../../../resources/js-test.js"></script> | ||
<div id="target"></div> | ||
<script> | ||
description("Checks that calling StylePropertyMap.set() with a negative value wraps it into a calc."); | ||
|
||
target = document.getElementById("target"); | ||
shouldNotThrow("target.attributeStyleMap.set('width', new CSSUnitValue(-3.14, 'percent'))"); | ||
shouldBeEqualToString("target.style.width", "calc(-3.14%)"); | ||
|
||
shouldNotThrow("target.attributeStyleMap.set('perspective', new CSSUnitValue(-32, 'px'))"); | ||
shouldBeEqualToString("target.style.perspective", "calc(-32px)"); | ||
</script> | ||
</body> | ||
</html> |
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
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
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
Oops, something went wrong.