mirror of
https://github.com/RGBCube/serenity
synced 2025-06-29 03:22:06 +00:00
LibWeb: Add and use convinient from_raw
helper in PixelUnits
This commit is contained in:
parent
127b966219
commit
618f889486
2 changed files with 10 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue