mirror of
https://github.com/RGBCube/serenity
synced 2025-07-17 08:57:35 +00:00
LibWeb: Add rex
and rch
Length units
These are the same as `ex` and `ch`, but using the root element's metrics. We now have this information available, so let's use it. :^)
This commit is contained in:
parent
3c171593f8
commit
a8e0fa403a
2 changed files with 16 additions and 0 deletions
|
@ -76,8 +76,12 @@ CSSPixels Length::relative_length_to_px(CSSPixelRect const& viewport_rect, FontM
|
||||||
return m_value * root_font_metrics.font_size;
|
return m_value * root_font_metrics.font_size;
|
||||||
case Type::Ex:
|
case Type::Ex:
|
||||||
return m_value * font_metrics.x_height;
|
return m_value * font_metrics.x_height;
|
||||||
|
case Type::Rex:
|
||||||
|
return m_value * root_font_metrics.x_height;
|
||||||
case Type::Ch:
|
case Type::Ch:
|
||||||
return m_value * font_metrics.zero_advance;
|
return m_value * font_metrics.zero_advance;
|
||||||
|
case Type::Rch:
|
||||||
|
return m_value * root_font_metrics.zero_advance;
|
||||||
case Type::Lh:
|
case Type::Lh:
|
||||||
return m_value * font_metrics.line_height;
|
return m_value * font_metrics.line_height;
|
||||||
case Type::Rlh:
|
case Type::Rlh:
|
||||||
|
@ -137,8 +141,12 @@ char const* Length::unit_name() const
|
||||||
return "rem";
|
return "rem";
|
||||||
case Type::Ex:
|
case Type::Ex:
|
||||||
return "ex";
|
return "ex";
|
||||||
|
case Type::Rex:
|
||||||
|
return "rex";
|
||||||
case Type::Ch:
|
case Type::Ch:
|
||||||
return "ch";
|
return "ch";
|
||||||
|
case Type::Rch:
|
||||||
|
return "rch";
|
||||||
case Type::Lh:
|
case Type::Lh:
|
||||||
return "lh";
|
return "lh";
|
||||||
case Type::Rlh:
|
case Type::Rlh:
|
||||||
|
@ -179,8 +187,12 @@ Optional<Length::Type> Length::unit_from_name(StringView name)
|
||||||
return Length::Type::Rem;
|
return Length::Type::Rem;
|
||||||
} else if (name.equals_ignoring_ascii_case("ex"sv)) {
|
} else if (name.equals_ignoring_ascii_case("ex"sv)) {
|
||||||
return Length::Type::Ex;
|
return Length::Type::Ex;
|
||||||
|
} else if (name.equals_ignoring_ascii_case("rex"sv)) {
|
||||||
|
return Length::Type::Rex;
|
||||||
} else if (name.equals_ignoring_ascii_case("ch"sv)) {
|
} else if (name.equals_ignoring_ascii_case("ch"sv)) {
|
||||||
return Length::Type::Ch;
|
return Length::Type::Ch;
|
||||||
|
} else if (name.equals_ignoring_ascii_case("rch"sv)) {
|
||||||
|
return Length::Type::Rch;
|
||||||
} else if (name.equals_ignoring_ascii_case("lh"sv)) {
|
} else if (name.equals_ignoring_ascii_case("lh"sv)) {
|
||||||
return Length::Type::Lh;
|
return Length::Type::Lh;
|
||||||
} else if (name.equals_ignoring_ascii_case("rlh"sv)) {
|
} else if (name.equals_ignoring_ascii_case("rlh"sv)) {
|
||||||
|
|
|
@ -21,7 +21,9 @@ public:
|
||||||
Em,
|
Em,
|
||||||
Rem,
|
Rem,
|
||||||
Ex,
|
Ex,
|
||||||
|
Rex,
|
||||||
Ch,
|
Ch,
|
||||||
|
Rch,
|
||||||
Lh,
|
Lh,
|
||||||
Rlh,
|
Rlh,
|
||||||
|
|
||||||
|
@ -84,7 +86,9 @@ public:
|
||||||
return m_type == Type::Em
|
return m_type == Type::Em
|
||||||
|| m_type == Type::Rem
|
|| m_type == Type::Rem
|
||||||
|| m_type == Type::Ex
|
|| m_type == Type::Ex
|
||||||
|
|| m_type == Type::Rex
|
||||||
|| m_type == Type::Ch
|
|| m_type == Type::Ch
|
||||||
|
|| m_type == Type::Rch
|
||||||
|| m_type == Type::Lh
|
|| m_type == Type::Lh
|
||||||
|| m_type == Type::Rlh;
|
|| m_type == Type::Rlh;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue