mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb/CSS: Support CalculatedOr::to_string() for integers and floats
IntegerOrCalculated and NumberOrCalculated's T types don't have a to_string() method because they're i64 and double respectively, so use String::number() for them instead. Also rearrange this method to avoid checking the variant's contents multiple times.
This commit is contained in:
parent
c77456a508
commit
a0cd6dd607
Notes:
github-actions[bot]
2025-02-28 12:51:55 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/a0cd6dd607a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3644
1 changed files with 11 additions and 4 deletions
|
@ -67,10 +67,17 @@ public:
|
|||
|
||||
String to_string() const
|
||||
{
|
||||
if (is_calculated())
|
||||
return m_value.template get<NonnullRefPtr<CalculatedStyleValue>>()->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
||||
|
||||
return m_value.template get<T>().to_string();
|
||||
return m_value.visit(
|
||||
[](T const& t) {
|
||||
if constexpr (IsArithmetic<T>) {
|
||||
return String::number(t);
|
||||
} else {
|
||||
return t.to_string();
|
||||
}
|
||||
},
|
||||
[](NonnullRefPtr<CalculatedStyleValue> const& calculated) {
|
||||
return calculated->to_string(CSSStyleValue::SerializationMode::Normal);
|
||||
});
|
||||
}
|
||||
|
||||
bool operator==(CalculatedOr<T> const& other) const
|
||||
|
|
Loading…
Add table
Reference in a new issue