mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
LibWeb: Virtualize StyleValue equality check
And use this to simplify comparing two IdentifierStyleValues.
This commit is contained in:
parent
b04e0a7677
commit
861d22838d
1 changed files with 17 additions and 0 deletions
|
@ -202,6 +202,16 @@ public:
|
||||||
|
|
||||||
virtual bool is_auto() const { return false; }
|
virtual bool is_auto() const { return false; }
|
||||||
|
|
||||||
|
bool operator==(const StyleValue& other) const { return equals(other); }
|
||||||
|
bool operator!=(const StyleValue& other) const { return !(*this == other); }
|
||||||
|
|
||||||
|
virtual bool equals(const StyleValue& other) const
|
||||||
|
{
|
||||||
|
if (type() != other.type())
|
||||||
|
return false;
|
||||||
|
return to_string() == other.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit StyleValue(Type);
|
explicit StyleValue(Type);
|
||||||
|
|
||||||
|
@ -317,6 +327,13 @@ public:
|
||||||
virtual String to_string() const override;
|
virtual String to_string() const override;
|
||||||
virtual Color to_color(const DOM::Document&) const override;
|
virtual Color to_color(const DOM::Document&) const override;
|
||||||
|
|
||||||
|
virtual bool equals(const StyleValue& other) const override
|
||||||
|
{
|
||||||
|
if (type() != other.type())
|
||||||
|
return false;
|
||||||
|
return m_id == static_cast<const IdentifierStyleValue&>(other).m_id;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit IdentifierStyleValue(CSS::ValueID id)
|
explicit IdentifierStyleValue(CSS::ValueID id)
|
||||||
: StyleValue(Type::Identifier)
|
: StyleValue(Type::Identifier)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue