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.
This commit is contained in:
Andreas Kling 2019-09-28 22:18:19 +02:00
commit 62cbaa74f3
Notes: sideshowbarker 2024-07-19 11:54:23 +09:00
7 changed files with 56 additions and 10 deletions

View file

@ -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;
};