mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibWeb: Only allow DevicePixels operators to work with integers
Allowing floats here was causing accidental truncations. Co-authored-by: MacDue <macdue@dueutil.tech>
This commit is contained in:
parent
d3cdf151a4
commit
a3298017d6
1 changed files with 10 additions and 10 deletions
|
@ -17,33 +17,33 @@ namespace Web {
|
||||||
/// DevicePixels: A position or length on the physical display.
|
/// DevicePixels: A position or length on the physical display.
|
||||||
AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(int, DevicePixels, Arithmetic, CastToUnderlying, Comparison, Increment);
|
AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(int, DevicePixels, Arithmetic, CastToUnderlying, Comparison, Increment);
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr bool operator==(DevicePixels left, T right) { return left.value() == right; }
|
constexpr bool operator==(DevicePixels left, T right) { return left.value() == right; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr bool operator!=(DevicePixels left, T right) { return left.value() != right; }
|
constexpr bool operator!=(DevicePixels left, T right) { return left.value() != right; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr bool operator>(DevicePixels left, T right) { return left.value() > right; }
|
constexpr bool operator>(DevicePixels left, T right) { return left.value() > right; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr bool operator<(DevicePixels left, T right) { return left.value() < right; }
|
constexpr bool operator<(DevicePixels left, T right) { return left.value() < right; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr bool operator>=(DevicePixels left, T right) { return left.value() >= right; }
|
constexpr bool operator>=(DevicePixels left, T right) { return left.value() >= right; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr bool operator<=(DevicePixels left, T right) { return left.value() <= right; }
|
constexpr bool operator<=(DevicePixels left, T right) { return left.value() <= right; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr DevicePixels operator*(DevicePixels left, T right) { return left.value() * right; }
|
constexpr DevicePixels operator*(DevicePixels left, T right) { return left.value() * right; }
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr DevicePixels operator*(T left, DevicePixels right) { return right * left; }
|
constexpr DevicePixels operator*(T left, DevicePixels right) { return right * left; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr DevicePixels operator/(DevicePixels left, T right) { return left.value() / right; }
|
constexpr DevicePixels operator/(DevicePixels left, T right) { return left.value() / right; }
|
||||||
|
|
||||||
template<Arithmetic T>
|
template<Integral T>
|
||||||
constexpr DevicePixels operator%(DevicePixels left, T right) { return left.value() % right; }
|
constexpr DevicePixels operator%(DevicePixels left, T right) { return left.value() % right; }
|
||||||
|
|
||||||
/// CSSPixels: A position or length in CSS "reference pixels", independent of zoom or screen DPI.
|
/// CSSPixels: A position or length in CSS "reference pixels", independent of zoom or screen DPI.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue