summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/CSS/StyleValue.cpp
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.cpp
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.cpp')
-rw-r--r--Libraries/LibHTML/CSS/StyleValue.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/Libraries/LibHTML/CSS/StyleValue.cpp b/Libraries/LibHTML/CSS/StyleValue.cpp
index e0d0a1764d..77ee2f9c58 100644
--- a/Libraries/LibHTML/CSS/StyleValue.cpp
+++ b/Libraries/LibHTML/CSS/StyleValue.cpp
@@ -1,4 +1,5 @@
-#include "StyleValue.h"
+#include <LibHTML/CSS/StyleValue.h>
+#include <LibHTML/DOM/Document.h>
StyleValue::StyleValue(Type type)
: m_type(type)
@@ -8,3 +9,22 @@ StyleValue::StyleValue(Type type)
StyleValue::~StyleValue()
{
}
+
+String IdentifierStyleValue::to_string() const
+{
+ switch (id()) {
+ case CSS::ValueID::Invalid:
+ return "(invalid)";
+ case CSS::ValueID::VendorSpecificLink:
+ return "-libhtml-link";
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+Color IdentifierStyleValue::to_color(const Document& document) const
+{
+ if (id() == CSS::ValueID::VendorSpecificLink)
+ return document.link_color();
+ return {};
+}