ladybird/Libraries/LibHTML/CSS/StyleValue.cpp
Andreas Kling 847072c2b1 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.
2019-10-06 10:25:08 +02:00

30 lines
592 B
C++

#include <LibHTML/CSS/StyleValue.h>
#include <LibHTML/DOM/Document.h>
StyleValue::StyleValue(Type type)
: m_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 {};
}