summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/CSS/StyleValue.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-06 10:25:08 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-06 10:25:08 +0200
commit847072c2b10b17bc5eeb88037fb5173c33e70d73 (patch)
treef0cc00d4379cc62208a0cfcc4439427b236f5f16 /Libraries/LibHTML/CSS/StyleValue.h
parent83a6474d82a6ea516ab67eedabca1fe1f1dc29a3 (diff)
downloadserenity-847072c2b10b17bc5eeb88037fb5173c33e70d73.zip
LibHTML: Respect the link color set via <body link>
The default style for "a" tags now has { color: -libhtml-link; }. We implement this vendor-specific property by querying the containing document for the appropriate link color. Currently we only use the basic link color, but in the future this can be extended to remember visited links, etc.
Diffstat (limited to 'Libraries/LibHTML/CSS/StyleValue.h')
-rw-r--r--Libraries/LibHTML/CSS/StyleValue.h38
1 files changed, 36 insertions, 2 deletions
diff --git a/Libraries/LibHTML/CSS/StyleValue.h b/Libraries/LibHTML/CSS/StyleValue.h
index 240acf15cf..3a0f43e69b 100644
--- a/Libraries/LibHTML/CSS/StyleValue.h
+++ b/Libraries/LibHTML/CSS/StyleValue.h
@@ -7,6 +7,15 @@
#include <LibDraw/Color.h>
#include <LibHTML/CSS/Length.h>
+class Document;
+
+namespace CSS {
+enum class ValueID {
+ Invalid,
+ VendorSpecificLink,
+};
+}
+
class StyleValue : public RefCounted<StyleValue> {
public:
virtual ~StyleValue();
@@ -18,6 +27,7 @@ public:
String,
Length,
Color,
+ Identifier,
};
Type type() const { return m_type; }
@@ -25,10 +35,11 @@ public:
bool is_inherit() const { return type() == Type::Inherit; }
bool is_initial() const { return type() == Type::Initial; }
bool is_color() const { return type() == Type::Color; }
+ bool is_identifier() const { return type() == Type::Identifier; }
virtual String to_string() const = 0;
virtual Length to_length() const { return {}; }
- virtual Color to_color() const { return {}; }
+ virtual Color to_color(const Document&) const { return {}; }
virtual bool is_auto() const { return false; }
@@ -122,7 +133,7 @@ public:
Color color() const { return m_color; }
String to_string() const override { return m_color.to_string(); }
- Color to_color() const override { return m_color; }
+ Color to_color(const Document&) const override { return m_color; }
private:
explicit ColorStyleValue(Color color)
@@ -133,3 +144,26 @@ private:
Color m_color;
};
+
+class IdentifierStyleValue final : public StyleValue {
+public:
+ static NonnullRefPtr<IdentifierStyleValue> create(CSS::ValueID id)
+ {
+ return adopt(*new IdentifierStyleValue(id));
+ }
+ virtual ~IdentifierStyleValue() override {}
+
+ CSS::ValueID id() const { return m_id; }
+
+ virtual String to_string() const override;
+ virtual Color to_color(const Document&) const override;
+
+private:
+ explicit IdentifierStyleValue(CSS::ValueID id)
+ : StyleValue(Type::Identifier)
+ , m_id(id)
+ {
+ }
+
+ CSS::ValueID m_id { CSS::ValueID::Invalid };
+};