diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-28 22:18:19 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-28 22:57:46 +0200 |
commit | 62cbaa74f3a60a30ce8a434295c6c565e4bdcde7 (patch) | |
tree | 4ca55e51243513ff6e8757c2fbaf6c3f3fa20067 /Libraries/LibHTML/CSS/StyleValue.h | |
parent | b8cab2a934a8846b05c4f18453339a0b99f2c26b (diff) | |
download | serenity-62cbaa74f3a60a30ce8a434295c6c565e4bdcde7.zip |
LibHTML: Respect the CSS "color" property for text
Also remove the color values from the ComputedStyle object and get them
via StyleProperties instead.
At the moment, we only handle colors that Color::from_string() parses.
Diffstat (limited to 'Libraries/LibHTML/CSS/StyleValue.h')
-rw-r--r-- | Libraries/LibHTML/CSS/StyleValue.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/Libraries/LibHTML/CSS/StyleValue.h b/Libraries/LibHTML/CSS/StyleValue.h index 516dc71f08..02dd2a1cc0 100644 --- a/Libraries/LibHTML/CSS/StyleValue.h +++ b/Libraries/LibHTML/CSS/StyleValue.h @@ -1,9 +1,10 @@ #pragma once -#include <AK/String.h> #include <AK/RefCounted.h> #include <AK/RefPtr.h> +#include <AK/String.h> #include <AK/StringView.h> +#include <LibDraw/Color.h> #include <LibHTML/CSS/Length.h> class StyleValue : public RefCounted<StyleValue> { @@ -16,6 +17,7 @@ public: Initial, String, Length, + Color, }; Type type() const { return m_type; } @@ -107,3 +109,24 @@ private: { } }; + +class ColorStyleValue : public StyleValue { +public: + static NonnullRefPtr<ColorStyleValue> create(Color color) + { + return adopt(*new ColorStyleValue(color)); + } + virtual ~ColorStyleValue() override {} + + Color color() const { return m_color; } + String to_string() const override { return String::format("COLOR: %s", m_color.to_string().characters()); } + +private: + explicit ColorStyleValue(Color color) + : StyleValue(Type::Color) + , m_color(color) + { + } + + Color m_color; +}; |