mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:07:34 +00:00
LibWeb: Make StyleValue::to_color() take a Node instead of the Document
This is in preparation for the `currentcolor` value, which needs to know what Node it's on so it can check the `color`.
This commit is contained in:
parent
8657148194
commit
86f78bff2a
6 changed files with 18 additions and 17 deletions
|
@ -105,12 +105,12 @@ LengthBox StyleProperties::length_box(CSS::PropertyID left_id, CSS::PropertyID t
|
|||
return box;
|
||||
}
|
||||
|
||||
Color StyleProperties::color_or_fallback(CSS::PropertyID id, const DOM::Document& document, Color fallback) const
|
||||
Color StyleProperties::color_or_fallback(CSS::PropertyID id, Layout::NodeWithStyle const& node, Color fallback) const
|
||||
{
|
||||
auto value = property(id);
|
||||
if (!value.has_value())
|
||||
return fallback;
|
||||
return value.value()->to_color(document);
|
||||
return value.value()->to_color(node);
|
||||
}
|
||||
|
||||
void StyleProperties::load_font(Layout::Node const& node) const
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
Length length_or_fallback(CSS::PropertyID, const Length& fallback) const;
|
||||
LengthBox length_box(CSS::PropertyID left_id, CSS::PropertyID top_id, CSS::PropertyID right_id, CSS::PropertyID bottom_id, const CSS::Length& default_value) const;
|
||||
Color color_or_fallback(CSS::PropertyID, const DOM::Document&, Color fallback) const;
|
||||
Color color_or_fallback(CSS::PropertyID, Layout::NodeWithStyle const&, Color fallback) const;
|
||||
Optional<CSS::TextAlign> text_align() const;
|
||||
CSS::Display display() const;
|
||||
Optional<CSS::Float> float_() const;
|
||||
|
|
|
@ -31,8 +31,9 @@ String IdentifierStyleValue::to_string() const
|
|||
return CSS::string_from_value_id(m_id);
|
||||
}
|
||||
|
||||
Color IdentifierStyleValue::to_color(const DOM::Document& document) const
|
||||
Color IdentifierStyleValue::to_color(Layout::NodeWithStyle const& node) const
|
||||
{
|
||||
auto& document = node.document();
|
||||
if (id() == CSS::ValueID::LibwebLink)
|
||||
return document.link_color();
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ public:
|
|||
|
||||
virtual String to_string() const = 0;
|
||||
virtual Length to_length() const { return {}; }
|
||||
virtual Color to_color(const DOM::Document&) const { return {}; }
|
||||
virtual Color to_color(Layout::NodeWithStyle const&) const { return {}; }
|
||||
|
||||
CSS::ValueID to_identifier() const;
|
||||
|
||||
|
@ -607,7 +607,7 @@ public:
|
|||
|
||||
Color color() const { return m_color; }
|
||||
String to_string() const override { return m_color.to_string(); }
|
||||
Color to_color(const DOM::Document&) const override { return m_color; }
|
||||
Color to_color(Layout::NodeWithStyle const&) const override { return m_color; }
|
||||
|
||||
virtual bool equals(const StyleValue& other) const override
|
||||
{
|
||||
|
@ -637,7 +637,7 @@ public:
|
|||
CSS::ValueID id() const { return m_id; }
|
||||
|
||||
virtual String to_string() const override;
|
||||
virtual Color to_color(const DOM::Document&) const override;
|
||||
virtual Color to_color(Layout::NodeWithStyle const& node) const override;
|
||||
|
||||
virtual bool equals(const StyleValue& other) const override
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue