mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-04-05 04:06:08 +00:00
LibWeb: Add and use convinient from_raw helper in PixelUnits
This commit is contained in:
committed by
Alexander Kalenik
parent
127b966219
commit
618f889486
@@ -83,16 +83,12 @@ int CSSPixels::operator<=>(CSSPixels const& other) const
|
||||
|
||||
CSSPixels CSSPixels::operator+() const
|
||||
{
|
||||
CSSPixels result;
|
||||
result.set_raw_value(+raw_value());
|
||||
return result;
|
||||
return from_raw(+raw_value());
|
||||
}
|
||||
|
||||
CSSPixels CSSPixels::operator-() const
|
||||
{
|
||||
CSSPixels result;
|
||||
result.set_raw_value(-raw_value());
|
||||
return result;
|
||||
return from_raw(-raw_value());
|
||||
}
|
||||
|
||||
static inline int saturated_addition(int a, int b)
|
||||
@@ -156,9 +152,7 @@ CSSPixels& CSSPixels::operator/=(CSSPixels const& other)
|
||||
|
||||
CSSPixels CSSPixels::abs() const
|
||||
{
|
||||
CSSPixels result;
|
||||
result.set_raw_value(::abs(m_value));
|
||||
return result;
|
||||
return from_raw(::abs(m_value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,13 @@ public:
|
||||
CSSPixels(float value);
|
||||
CSSPixels(double value);
|
||||
|
||||
static CSSPixels from_raw(int value)
|
||||
{
|
||||
CSSPixels res;
|
||||
res.set_raw_value(value);
|
||||
return res;
|
||||
}
|
||||
|
||||
float to_float() const;
|
||||
double to_double() const;
|
||||
int to_int() const;
|
||||
|
||||
Reference in New Issue
Block a user