mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/CSS: Treat x resolution unit separately from dppx
Tests show that we need to preserve whether x or dppx units were used, so the simplest way is to treat them separately.
This commit is contained in:
parent
443f9e5afb
commit
338282f74d
Notes:
github-actions[bot]
2025-05-17 06:54:37 +00:00
Author: https://github.com/AtkinsSJ
Commit: 338282f74d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4783
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 14 additions and 9 deletions
|
@ -35,6 +35,7 @@ double Resolution::to_dots_per_pixel() const
|
|||
case Type::Dpcm:
|
||||
return m_value / (96.0 / 2.54); // 1cm = 96px/2.54
|
||||
case Type::Dppx:
|
||||
case Type::X:
|
||||
return m_value;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -49,19 +50,22 @@ StringView Resolution::unit_name() const
|
|||
return "dpcm"sv;
|
||||
case Type::Dppx:
|
||||
return "dppx"sv;
|
||||
case Type::X:
|
||||
return "x"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
Optional<Resolution::Type> Resolution::unit_from_name(StringView name)
|
||||
{
|
||||
if (name.equals_ignoring_ascii_case("dpi"sv)) {
|
||||
if (name.equals_ignoring_ascii_case("dpi"sv))
|
||||
return Type::Dpi;
|
||||
} else if (name.equals_ignoring_ascii_case("dpcm"sv)) {
|
||||
if (name.equals_ignoring_ascii_case("dpcm"sv))
|
||||
return Type::Dpcm;
|
||||
} else if (name.equals_ignoring_ascii_case("dppx"sv) || name.equals_ignoring_ascii_case("x"sv)) {
|
||||
if (name.equals_ignoring_ascii_case("dppx"sv))
|
||||
return Type::Dppx;
|
||||
}
|
||||
if (name.equals_ignoring_ascii_case("x"sv))
|
||||
return Type::X;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
Dpi,
|
||||
Dpcm,
|
||||
Dppx,
|
||||
X,
|
||||
};
|
||||
|
||||
static Optional<Type> unit_from_name(StringView);
|
||||
|
|
|
@ -2,8 +2,8 @@ Harness status: OK
|
|||
|
||||
Found 34 tests
|
||||
|
||||
27 Pass
|
||||
7 Fail
|
||||
30 Pass
|
||||
4 Fail
|
||||
Pass Test parsing '' with matchMedia
|
||||
Pass Test parsing ' ' with matchMedia
|
||||
Pass Test parsing 'all' with matchMedia
|
||||
|
@ -25,11 +25,11 @@ Pass Test parsing ' , ' with matchMedia
|
|||
Fail Test parsing ',,' with matchMedia
|
||||
Pass Test parsing ' , , ' with matchMedia
|
||||
Fail Test parsing ' foo,' with matchMedia
|
||||
Fail Test parsing '(min-resolution: 1x)' with matchMedia
|
||||
Pass Test parsing '(min-resolution: 1x)' with matchMedia
|
||||
Pass Test parsing '(min-resolution: calc(1x))' with matchMedia
|
||||
Fail Test parsing '(resolution: 2x)' with matchMedia
|
||||
Pass Test parsing '(resolution: 2x)' with matchMedia
|
||||
Pass Test parsing '(resolution: calc(2x))' with matchMedia
|
||||
Fail Test parsing '(max-resolution: 7x)' with matchMedia
|
||||
Pass Test parsing '(max-resolution: 7x)' with matchMedia
|
||||
Pass Test parsing '(max-resolution: calc(7x))' with matchMedia
|
||||
Pass Test parsing '(resolution: 2dppx)' with matchMedia
|
||||
Pass Test parsing '(resolution: 600dpi)' with matchMedia
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue