diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp index 8283739455..3edf6e7b16 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.cpp +++ b/Userland/Libraries/LibWeb/CSS/Length.cpp @@ -21,6 +21,9 @@ float Length::relative_length_to_px(const Layout::Node& layout_node) const return m_value * layout_node.font().x_height(); case Type::Em: return m_value * layout_node.font_size(); + case Type::Ch: + // FIXME: Use layout_node.font().glyph_height() when writing-mode is not horizontal-tb (it has to be implemented first) + return m_value * (layout_node.font().glyph_width('0') + layout_node.font().glyph_spacing()); case Type::Rem: return m_value * layout_node.document().document_element()->layout_node()->font_size(); case Type::Vw: @@ -180,6 +183,8 @@ const char* Length::unit_name() const return "ex"; case Type::Em: return "em"; + case Type::Ch: + return "ch"; case Type::Rem: return "rem"; case Type::Auto: diff --git a/Userland/Libraries/LibWeb/CSS/Length.h b/Userland/Libraries/LibWeb/CSS/Length.h index 5e14e11818..90e1c0b283 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.h +++ b/Userland/Libraries/LibWeb/CSS/Length.h @@ -27,6 +27,7 @@ public: Pc, Ex, Em, + Ch, Rem, Vh, Vw, @@ -93,6 +94,7 @@ public: { return m_type == Type::Ex || m_type == Type::Em + || m_type == Type::Ch || m_type == Type::Rem || m_type == Type::Vh || m_type == Type::Vw diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 0f4c91d823..b4e240e89a 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -1466,6 +1466,8 @@ Optional Parser::parse_length(ParsingContext const& context, StyleCompon type = Length::Type::Em; } else if (unit_string.equals_ignoring_case("ex")) { type = Length::Type::Ex; + } else if (unit_string.equals_ignoring_case("ch")) { + type = Length::Type::Ch; } else if (unit_string.equals_ignoring_case("vw")) { type = Length::Type::Vw; } else if (unit_string.equals_ignoring_case("vh")) {