summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-16 13:25:06 -0700
committerGitHub <noreply@github.com>2016-06-16 13:25:06 -0700
commit19158d9f01909bf566616524f23e0acb635562f7 (patch)
treea3adf8c8713dbe6d20fe9fae055836e677b4ca47 /src/mbgl/style
parent3f024ebaf02e82e9282e303a46127f366a84904d (diff)
downloadqtlocation-mapboxgl-19158d9f01909bf566616524f23e0acb635562f7.tar.gz
[core, node] Implement setPaintProperty for color properties (#5380)
Diffstat (limited to 'src/mbgl/style')
-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 <>