diff options
author | Andreas Kling <kling@serenityos.org> | 2023-05-13 06:52:06 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-13 07:38:08 +0200 |
commit | c8cf599c4412885f1b59fe75902a9df4e14d1a89 (patch) | |
tree | 3741318834135f75bac0144b92f7765b7c10c9fb /Userland | |
parent | d7ca52afaf53ddcdb9d7c1a400c4cc0c6ab12a75 (diff) | |
download | serenity-c8cf599c4412885f1b59fe75902a9df4e14d1a89.zip |
LibWeb: Make PercentageOr<T> equality comparison work for calc() values
This makes hovering around on GitHub fast again, as it no longer
believes that the grid-template-areas property keeps changing
when it didn't :^)
Also made to_string() work for calc() values as well, since I stumbled
upon that while debugging this.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/PercentageOr.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/PercentageOr.h b/Userland/Libraries/LibWeb/CSS/PercentageOr.h index ed575b28df..2e29be2096 100644 --- a/Userland/Libraries/LibWeb/CSS/PercentageOr.h +++ b/Userland/Libraries/LibWeb/CSS/PercentageOr.h @@ -114,18 +114,21 @@ public: ErrorOr<String> to_string() const { + if (is_calculated()) + return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()->to_string(); if (is_percentage()) return m_value.template get<Percentage>().to_string(); - return m_value.template get<T>().to_string(); } bool operator==(PercentageOr<T> const& other) const { - if (is_calculated()) + if (is_calculated() != other.is_calculated()) return false; if (is_percentage() != other.is_percentage()) return false; + if (is_calculated()) + return (*m_value.template get<NonnullRefPtr<CalculatedStyleValue>>() == *other.m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()); if (is_percentage()) return (m_value.template get<Percentage>() == other.m_value.template get<Percentage>()); return (m_value.template get<T>() == other.m_value.template get<T>()); |