Forráskód Böngészése

Fix parsing of rgba colors in the `box-shadow` property

Michael Ragazzon 1 éve
szülő
commit
1b0fac7955

+ 2 - 2
Source/Core/PropertyParserBoxShadow.cpp

@@ -50,7 +50,7 @@ bool PropertyParserBoxShadow::ParseValue(Property& property, const String& value
 	StringList shadows_string_list;
 	{
 		auto lowercase_value = StringUtilities::ToLower(value);
-		StringUtilities::ExpandString(shadows_string_list, lowercase_value, ',');
+		StringUtilities::ExpandString(shadows_string_list, lowercase_value, ',', '(', ')');
 	}
 
 	if (shadows_string_list.empty())
@@ -64,7 +64,7 @@ bool PropertyParserBoxShadow::ParseValue(Property& property, const String& value
 	for (const String& shadow_str : shadows_string_list)
 	{
 		StringList arguments;
-		StringUtilities::ExpandString(arguments, shadow_str, ' ');
+		StringUtilities::ExpandString(arguments, shadow_str, ' ', '(', ')');
 		if (arguments.empty())
 			return false;
 

+ 1 - 0
Tests/Source/UnitTests/Properties.cpp

@@ -194,6 +194,7 @@ TEST_CASE("Property.ToString")
 	CHECK(ParsedValue("transform", "translateX(10px)") == "translateX(10px)");
 	CHECK(ParsedValue("transform", "translate(20in, 50em)") == "translate(20in, 50em)");
 
+	CHECK(ParsedValue("box-shadow", "2px 2px 0px, rgba(0, 0, 255, 255) 4px 4px 2em") == "#000000 2px 2px 0px, #0000ff 4px 4px 2em");
 	CHECK(ParsedValue("box-shadow", "2px 2px 0px, #00ff 4px 4px 2em") == "#000000 2px 2px 0px, #0000ff 4px 4px 2em");
 
 	// Due to conversion to and from premultiplied alpha, some color information is lost.