mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:37:34 +00:00
LibWeb: Define comparison operators with CSSPixels for AvailableSize
This allows to compare CSSPixels with AvailableSize without converting it to CSSPixels, which might leak saturated (infinite) values into layout calculations.
This commit is contained in:
parent
d34007782d
commit
57c1fe97fb
1 changed files with 27 additions and 0 deletions
|
@ -57,6 +57,33 @@ private:
|
||||||
CSSPixels m_value {};
|
CSSPixels m_value {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool operator>(CSSPixels left, AvailableSize const& right)
|
||||||
|
{
|
||||||
|
if (right.is_max_content() || right.is_indefinite())
|
||||||
|
return false;
|
||||||
|
if (right.is_min_content())
|
||||||
|
return true;
|
||||||
|
return left > right.to_px_or_zero();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<(CSSPixels left, AvailableSize const& right)
|
||||||
|
{
|
||||||
|
if (right.is_max_content() || right.is_indefinite())
|
||||||
|
return true;
|
||||||
|
if (right.is_min_content())
|
||||||
|
return false;
|
||||||
|
return left < right.to_px_or_zero();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<(AvailableSize const& left, CSSPixels right)
|
||||||
|
{
|
||||||
|
if (left.is_min_content())
|
||||||
|
return true;
|
||||||
|
if (left.is_max_content() || left.is_indefinite())
|
||||||
|
return false;
|
||||||
|
return left.to_px_or_zero() < right;
|
||||||
|
}
|
||||||
|
|
||||||
class AvailableSpace {
|
class AvailableSpace {
|
||||||
public:
|
public:
|
||||||
AvailableSpace(AvailableSize w, AvailableSize h)
|
AvailableSpace(AvailableSize w, AvailableSize h)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue