Commit Graph

2 Commits

Author SHA1 Message Date
Sam Atkins
a3298017d6 LibWeb: Only allow DevicePixels operators to work with integers
Allowing floats here was causing accidental truncations.

Co-authored-by: MacDue <macdue@dueutil.tech>
2022-12-14 16:47:57 +00:00
Sam Atkins
bd272e638c LibWeb: Introduce CSSPixels and DevicePixels classes
These are an attempt to separate the internal "pixel" used by CSS from
the actual "pixel" that exists on the display. Because of things like
2x display scaling, the ratio between these can vary, so having
distinct types will help prevent errors when converting from one unit
to the other.

`CSSPixels` refers to the `px` unit used on the web, which depending on
the device may or may not map to 1 pixel on the physical display. It's
a wrapper around `float`, and will be used by LibWeb for size and
position values up until we go to paint them to the screen.

`DevicePixels` on the other hand is a 1-to-1 pixel on the physical
display. It's a wrapper around `int`.
2022-12-08 12:46:03 +00:00