mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +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
Notes:
sideshowbarker
2024-07-17 03:13:05 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/a3298017d6 Pull-request: https://github.com/SerenityOS/serenity/pull/16448 Reviewed-by: https://github.com/awesomekling ✅
1 changed files with 10 additions and 10 deletions
|
@ -17,33 +17,33 @@ namespace Web {
|
|||
/// DevicePixels: A position or length on the physical display.
|
||||
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; }
|
||||
|
||||
template<Arithmetic T>
|
||||
template<Integral T>
|
||||
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; }
|
||||
|
||||
template<Arithmetic T>
|
||||
template<Integral T>
|
||||
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; }
|
||||
|
||||
template<Arithmetic T>
|
||||
template<Integral T>
|
||||
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; }
|
||||
template<Arithmetic T>
|
||||
template<Integral T>
|
||||
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; }
|
||||
|
||||
template<Arithmetic T>
|
||||
template<Integral T>
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue