Changeset 285235 in webkit
- Timestamp:
- Nov 3, 2021 3:18:37 PM (9 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-radius-valid-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-radius-valid.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/StyleProperties.cpp (modified) (3 diffs)
-
Source/WebCore/css/StyleProperties.h (modified) (1 diff)
-
Source/WebCore/css/parser/CSSPropertyParser.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r285214 r285235 1 2021-11-03 Joonghun Park <jh718.park@samsung.com> 2 3 border-radius inline style should serialize with valid syntax 4 https://bugs.webkit.org/show_bug.cgi?id=183994 5 6 This patch have border-radius property serializes in canonical order 7 as specified in https://drafts.csswg.org/css-backgrounds/#border-radius. 8 9 Reviewed by Darin Adler. 10 11 * web-platform-tests/css/css-backgrounds/parsing/border-radius-valid-expected.txt: Add more test case results. 12 * web-platform-tests/css/css-backgrounds/parsing/border-radius-valid.html: Add more test cases. 13 1 14 2021-11-03 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-radius-valid-expected.txt
r267650 r285235 1 1 2 2 PASS e.style['border-radius'] = "1px" should set the property value 3 PASS e.style['border-radius'] = "1px 5%" should set the property value 4 PASS e.style['border-radius'] = "1px 2% 3px" should set the property value 3 5 PASS e.style['border-radius'] = "1px 2% 3px 4%" should set the property value 4 FAIL e.style['border-radius'] = "5em / 1px 2% 3px 4%" should set the property value assert_equals: serialization should be canonical expected "5em / 1px 2% 3px 4%" but got "5em 1px 5em 2% 5em 3px 5em 4%" 5 FAIL e.style['border-radius'] = "1px 2% 3px 4% / 5em" should set the property value assert_equals: serialization should be canonical expected "1px 2% 3px 4% / 5em" but got "1px 5em 2% 5em 3px 5em 4% 5em" 6 FAIL e.style['border-radius'] = "1px 1px 1px 2% / 1px 2% 1px 2%" should set the property value assert_equals: serialization should be canonical expected "1px 1px 1px 2% / 1px 2%" but got "1px 1px 2% 1px 2%" 7 FAIL e.style['border-radius'] = "1px 1px 1px 1px / 1px 1px 2% 1px" should set the property value assert_equals: serialization should be canonical expected "1px / 1px 1px 2%" but got "1px 1px 1px 2%" 6 PASS e.style['border-radius'] = "1px / 2px" should set the property value 7 PASS e.style['border-radius'] = "5em / 1px 2% 3px 4%" should set the property value 8 PASS e.style['border-radius'] = "1px 2% / 3px 4px" should set the property value 9 PASS e.style['border-radius'] = "1px 2px 3em / 1px 2px 3%" should set the property value 10 PASS e.style['border-radius'] = "1px 2% / 2px 3em 4px 5em" should set the property value 11 PASS e.style['border-radius'] = "1px 2% 3px 4% / 5em" should set the property value 12 PASS e.style['border-radius'] = "1px 1px 1px 2% / 1px 2% 1px 2%" should set the property value 13 PASS e.style['border-radius'] = "1px 1px 1px 1px / 1px 1px 2% 1px" should set the property value 8 14 PASS e.style['border-radius'] = "1px 1px 2% 2%" should set the property value 9 15 PASS e.style['border-radius'] = "1px 2% 1px 1px" should set the property value 10 FAIL e.style['border-radius'] = "1px 2% 2% 2% / 1px 2% 3px 2%" should set the property value assert_equals: serialization should be canonical expected "1px 2% 2% / 1px 2% 3px" but got "1px 2% 2% 3px" 16 PASS e.style['border-radius'] = "1px 2% 2% 2% / 1px 2% 3px 2%" should set the property value 11 17 PASS e.style['border-top-left-radius'] = "10px" should set the property value 12 18 PASS e.style['border-top-right-radius'] = "20%" should set the property value -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-radius-valid.html
r255239 r285235 13 13 <script> 14 14 test_valid_value("border-radius", "1px"); 15 test_valid_value("border-radius", "1px 5%"); 16 test_valid_value("border-radius", "1px 2% 3px"); 15 17 test_valid_value("border-radius", "1px 2% 3px 4%"); 18 test_valid_value("border-radius", "1px / 2px"); 16 19 test_valid_value("border-radius", "5em / 1px 2% 3px 4%"); 20 test_valid_value("border-radius", "1px 2% / 3px 4px"); 21 test_valid_value("border-radius", "1px 2px 3em / 1px 2px 3%"); 22 test_valid_value("border-radius", "1px 2% / 2px 3em 4px 5em"); 17 23 test_valid_value("border-radius", "1px 2% 3px 4% / 5em"); 18 24 -
trunk/Source/WebCore/ChangeLog
r285234 r285235 1 2021-11-03 Joonghun Park <jh718.park@samsung.com> 2 3 border-radius inline style should serialize with valid syntax 4 https://bugs.webkit.org/show_bug.cgi?id=183994 5 6 This patch have border-radius property serializes in canonical order 7 as specified in https://drafts.csswg.org/css-backgrounds/#border-radius. 8 9 Reviewed by Darin Adler. 10 11 * css/StyleProperties.cpp: 12 (WebCore::StyleProperties::getPropertyValue const): 13 (WebCore::StyleProperties::borderRadiusValue const): 14 * css/StyleProperties.h: 15 * css/parser/CSSPropertyParser.cpp: 16 1 17 2021-11-03 David Kilzer <ddkilzer@apple.com> 2 18 -
trunk/Source/WebCore/css/StyleProperties.cpp
r285015 r285235 36 36 #include "Color.h" 37 37 #include "Document.h" 38 #include "Pair.h" 38 39 #include "PropertySetCSSStyleDeclaration.h" 39 40 #include "StylePropertyShorthand.h" … … 320 321 return String(); 321 322 case CSSPropertyBorderRadius: 322 return get4Values(borderRadiusShorthand());323 return borderRadiusValue(borderRadiusShorthand()); 323 324 case CSSPropertyGap: 324 325 return get2Values(gapShorthand()); … … 362 363 return value->cssText(); 363 364 return String(); 365 } 366 367 String StyleProperties::borderRadiusValue(const StylePropertyShorthand& shorthand) const 368 { 369 auto serialize = [](const CSSValue* topLeft, const CSSValue* topRight, const CSSValue* bottomRight, const CSSValue* bottomLeft) -> String { 370 bool showBottomLeft = !(*topRight == *bottomLeft); 371 bool showBottomRight = !(*topLeft == *bottomRight) || showBottomLeft; 372 bool showTopRight = !(*topLeft == *topRight) || showBottomRight; 373 374 return makeString(topLeft->cssText(), showTopRight ? " " : "", showTopRight ? topRight->cssText() : "", showBottomRight ? " " : "", showBottomRight ? bottomRight->cssText() : "", showBottomLeft ? " " : "", showBottomLeft ? bottomLeft->cssText() : ""); 375 }; 376 377 int topLeftValueIndex = findPropertyIndex(shorthand.properties()[0]); 378 int topRightValueIndex = findPropertyIndex(shorthand.properties()[1]); 379 int bottomRightValueIndex = findPropertyIndex(shorthand.properties()[2]); 380 int bottomLeftValueIndex = findPropertyIndex(shorthand.properties()[3]); 381 382 if (topLeftValueIndex == -1 || topRightValueIndex == -1 || bottomRightValueIndex == -1 || bottomLeftValueIndex == -1) 383 return String(); 384 385 PropertyReference topLeft = propertyAt(topLeftValueIndex); 386 PropertyReference topRight = propertyAt(topRightValueIndex); 387 PropertyReference bottomRight = propertyAt(bottomRightValueIndex); 388 PropertyReference bottomLeft = propertyAt(bottomLeftValueIndex); 389 390 auto* topLeftValue = topLeft.value(); 391 auto* topRightValue = topRight.value(); 392 auto* bottomRightValue = bottomRight.value(); 393 auto* bottomLeftValue = bottomLeft.value(); 394 395 // All 4 properties must be specified. 396 if (!topLeftValue || !topRightValue || !bottomRightValue || !bottomLeftValue) 397 return String(); 398 399 // Important flags must be the same 400 if (topLeft.isImportant() != topRight.isImportant() || topRight.isImportant() != bottomRight.isImportant() || bottomRight.isImportant() != bottomLeft.isImportant()) 401 return String(); 402 403 if (topLeftValue->isInheritedValue() && topRightValue->isInheritedValue() && bottomRightValue->isInheritedValue() && bottomLeftValue->isInheritedValue()) 404 return getValueName(CSSValueInherit); 405 406 if (topLeftValue->isInitialValue() || topRightValue->isInitialValue() || bottomRightValue->isInitialValue() || bottomLeftValue->isInitialValue()) { 407 if (topLeftValue->isInitialValue() && topRightValue->isInitialValue() && bottomRightValue->isInitialValue() && bottomLeftValue->isInitialValue() && !topLeft.isImplicit()) { 408 // All components are "initial" and "topLeft" is not implicit. 409 return getValueName(CSSValueInitial); 410 } 411 return String(); 412 } 413 414 auto& topLeftPair = *downcast<CSSPrimitiveValue>(*topLeftValue).pairValue(); 415 auto& topRightPair = *downcast<CSSPrimitiveValue>(*topRightValue).pairValue(); 416 auto& bottomRightPair = *downcast<CSSPrimitiveValue>(*bottomRightValue).pairValue(); 417 auto& bottomLeftPair = *downcast<CSSPrimitiveValue>(*bottomLeftValue).pairValue(); 418 419 auto first = serialize(topLeftPair.first(), topRightPair.first(), bottomRightPair.first(), bottomLeftPair.first()); 420 auto second = serialize(topLeftPair.second(), topRightPair.second(), bottomRightPair.second(), bottomLeftPair.second()); 421 if (first == second) 422 return first; 423 424 return makeString(first, " / ", second); 364 425 } 365 426 -
trunk/Source/WebCore/css/StyleProperties.h
r285015 r285235 171 171 String get2Values(const StylePropertyShorthand&) const; 172 172 String get4Values(const StylePropertyShorthand&) const; 173 String borderRadiusValue(const StylePropertyShorthand&) const; 173 174 String borderSpacingValue(const StylePropertyShorthand&) const; 174 175 String fontValue() const; -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r285045 r285235 64 64 #include "FontFace.h" 65 65 #include "HashTools.h" 66 // FIXME-NEWPARSER: CSSPrimitiveValue is a large class that holds many unrelated objects, 67 // switching behavior on the type of the object it is holding. 68 // Since CSSValue is already a class hierarchy, this adds an unnecessary second level to the hierarchy that complicates code. 69 // So we need to remove the various behaviors from CSSPrimitiveValue and split them into separate subclasses of CSSValue. 66 70 // FIXME-NEWPARSER: Replace Pair and Rect with actual CSSValue subclasses (CSSValuePair and CSSQuadValue). 67 71 #include "Pair.h"
Note: See TracChangeset
for help on using the changeset viewer.