mirror of
https://github.com/RGBCube/serenity
synced 2025-06-29 22:32:08 +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 CSSPixels::operator+() const
|
||||||
{
|
{
|
||||||
CSSPixels result;
|
return from_raw(+raw_value());
|
||||||
result.set_raw_value(+raw_value());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPixels CSSPixels::operator-() const
|
CSSPixels CSSPixels::operator-() const
|
||||||
{
|
{
|
||||||
CSSPixels result;
|
return from_raw(-raw_value());
|
||||||
result.set_raw_value(-raw_value());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int saturated_addition(int a, int b)
|
static inline int saturated_addition(int a, int b)
|
||||||
|
@ -156,9 +152,7 @@ CSSPixels& CSSPixels::operator/=(CSSPixels const& other)
|
||||||
|
|
||||||
CSSPixels CSSPixels::abs() const
|
CSSPixels CSSPixels::abs() const
|
||||||
{
|
{
|
||||||
CSSPixels result;
|
return from_raw(::abs(m_value));
|
||||||
result.set_raw_value(::abs(m_value));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,13 @@ public:
|
||||||
CSSPixels(float value);
|
CSSPixels(float value);
|
||||||
CSSPixels(double value);
|
CSSPixels(double value);
|
||||||
|
|
||||||
|
static CSSPixels from_raw(int value)
|
||||||
|
{
|
||||||
|
CSSPixels res;
|
||||||
|
res.set_raw_value(value);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
float to_float() const;
|
float to_float() const;
|
||||||
double to_double() const;
|
double to_double() const;
|
||||||
int to_int() const;
|
int to_int() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue