From e81d4ca1ac92972f5d66132dac177c75b5d83a2f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 16 May 2023 16:57:12 +0200 Subject: [PATCH] LibWeb: Fix off-by-one in CSS calc() "negate" operation When negating a number, we should subtract it from 0, not 1. :^) --- .../LibWeb/Layout/expected/calc-negate-length.txt | 5 +++++ Tests/LibWeb/Layout/expected/grid/borders.txt | 6 +++--- Tests/LibWeb/Layout/expected/grid/grid-gap-2.txt | 6 +++--- Tests/LibWeb/Layout/input/calc-negate-length.html | 15 +++++++++++++++ Tests/LibWeb/Layout/input/grid/borders.html | 3 +++ Tests/LibWeb/Layout/input/grid/grid-gap-2.html | 3 +++ .../CSS/StyleValues/CalculatedStyleValue.cpp | 12 ++++++------ 7 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 Tests/LibWeb/Layout/expected/calc-negate-length.txt create mode 100644 Tests/LibWeb/Layout/input/calc-negate-length.html diff --git a/Tests/LibWeb/Layout/expected/calc-negate-length.txt b/Tests/LibWeb/Layout/expected/calc-negate-length.txt new file mode 100644 index 0000000000..f1d8d52e15 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/calc-negate-length.txt @@ -0,0 +1,5 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x66 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x50 children: not-inline + BlockContainer at (8,8) content-size 100x50 children: not-inline + BlockContainer at (8,8) content-size 99x50 children: not-inline diff --git a/Tests/LibWeb/Layout/expected/grid/borders.txt b/Tests/LibWeb/Layout/expected/grid/borders.txt index 1ed18bc3ee..bf5d9ec609 100644 --- a/Tests/LibWeb/Layout/expected/grid/borders.txt +++ b/Tests/LibWeb/Layout/expected/grid/borders.txt @@ -103,14 +103,14 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline Box at (8,275.34375) content-size 784x90.9375 [GFC] children: not-inline BlockContainer <(anonymous)> at (8,275.34375) content-size 0x0 [BFC] children: inline TextNode <#text> - BlockContainer at (444.699981,285.34375) content-size 337.300018x17.46875 [BFC] children: inline + BlockContainer at (444.199981,285.34375) content-size 337.800018x17.46875 [BFC] children: inline line 0 width: 6.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 - frag 0 from TextNode start: 0, length: 1, rect: [444.699981,285.34375 6.34375x17.46875] + frag 0 from TextNode start: 0, length: 1, rect: [444.199981,285.34375 6.34375x17.46875] "1" TextNode <#text> BlockContainer <(anonymous)> at (8,275.34375) content-size 0x0 [BFC] children: inline TextNode <#text> - BlockContainer at (18,338.8125) content-size 337.299987x17.46875 [BFC] children: inline + BlockContainer at (18,338.8125) content-size 337.799987x17.46875 [BFC] children: inline line 0 width: 8.8125, height: 17.46875, bottom: 17.46875, baseline: 13.53125 frag 0 from TextNode start: 0, length: 1, rect: [18,338.8125 8.8125x17.46875] "2" diff --git a/Tests/LibWeb/Layout/expected/grid/grid-gap-2.txt b/Tests/LibWeb/Layout/expected/grid/grid-gap-2.txt index 754f200f64..02eb01f635 100644 --- a/Tests/LibWeb/Layout/expected/grid/grid-gap-2.txt +++ b/Tests/LibWeb/Layout/expected/grid/grid-gap-2.txt @@ -2,12 +2,12 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline BlockContainer at (8,8) content-size 784x50.9375 children: not-inline Box at (8,8) content-size 784x50.9375 [GFC] children: not-inline - BlockContainer at (434.699981,8) content-size 357.300018x17.46875 [BFC] children: inline + BlockContainer at (434.199981,8) content-size 357.800018x17.46875 [BFC] children: inline line 0 width: 6.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 - frag 0 from TextNode start: 0, length: 1, rect: [434.699981,8 6.34375x17.46875] + frag 0 from TextNode start: 0, length: 1, rect: [434.199981,8 6.34375x17.46875] "1" TextNode <#text> - BlockContainer at (8,41.46875) content-size 357.299987x17.46875 [BFC] children: inline + BlockContainer at (8,41.46875) content-size 357.799987x17.46875 [BFC] children: inline line 0 width: 8.8125, height: 17.46875, bottom: 17.46875, baseline: 13.53125 frag 0 from TextNode start: 0, length: 1, rect: [8,41.46875 8.8125x17.46875] "2" diff --git a/Tests/LibWeb/Layout/input/calc-negate-length.html b/Tests/LibWeb/Layout/input/calc-negate-length.html new file mode 100644 index 0000000000..2863c9499d --- /dev/null +++ b/Tests/LibWeb/Layout/input/calc-negate-length.html @@ -0,0 +1,15 @@ +
\ No newline at end of file diff --git a/Tests/LibWeb/Layout/input/grid/borders.html b/Tests/LibWeb/Layout/input/grid/borders.html index e0e433d073..5ac7445fcc 100644 --- a/Tests/LibWeb/Layout/input/grid/borders.html +++ b/Tests/LibWeb/Layout/input/grid/borders.html @@ -1,4 +1,7 @@