summaryrefslogtreecommitdiff
path: root/src/mbgl/style/property_parsing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/property_parsing.cpp')
-rw-r--r--src/mbgl/style/property_parsing.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/mbgl/style/property_parsing.cpp b/src/mbgl/style/property_parsing.cpp
index 2b08ba8788..2eb55dcb25 100644
--- a/src/mbgl/style/property_parsing.cpp
+++ b/src/mbgl/style/property_parsing.cpp
@@ -2,8 +2,6 @@
#include <mbgl/platform/log.hpp>
-#include <csscolorparser/csscolorparser.hpp>
-
namespace mbgl {
namespace style {
@@ -44,15 +42,13 @@ optional<Color> parseConstant(const char* name, const JSValue& value) {
return {};
}
- CSSColorParser::Color css_color = CSSColorParser::parse({ value.GetString(), value.GetStringLength() });
-
- // Premultiply the color.
- const float factor = css_color.a / 255;
+ optional<Color> result = Color::parse({ value.GetString(), value.GetStringLength() });
+ if (!result) {
+ Log::Warning(Event::ParseStyle, "value of '%s' must be a valid color", name);
+ return {};
+ }
- return Color{ (float)css_color.r * factor,
- (float)css_color.g * factor,
- (float)css_color.b * factor,
- css_color.a };
+ return result;
}
template <>