1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 18:47:44 +00:00

LibWeb: Add and use the "snap a length as a border width" algorithm

Previously, we always rounded border-widths up when converting them to
device pixels. However, the spec asks us to follow a specific algorithm
to "snap" these values, so that the computed value is snapped.

The difference from before, is that widths of between 0 and 1 device
pixels are rounded up to 1, and and values larger than 1 are rounded
down.
This commit is contained in:
Sam Atkins 2023-07-30 16:15:38 +01:00 committed by Sam Atkins
parent 5ee1b7db7c
commit 6038e36250
3 changed files with 42 additions and 1 deletions

View file

@ -0,0 +1,5 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x204 children: not-inline
BlockContainer <div.a> at (9,9) content-size 100x100 children: not-inline
BlockContainer <div.b> at (9,111) content-size 100x100 children: not-inline

View file

@ -0,0 +1,14 @@
<style>
div {
width: 100px;
height: 100px;
}
/* Both of these border-widths should snap to 1px. */
.a {
border: 1.8px solid black;
}
.b {
border: 0.2px solid black;
}
</style><div class="a"></div><div class="b"></div>