summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-04-28 17:18:18 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-29 16:23:50 +0200
commit0dd585ba7bedcbc87db7eaf6d586d43c5ce1fc38 (patch)
treecf2681ad5ffd637b2e90fd991d35b6fdb1d4f436 /Userland/Libraries
parent03ed37eb1417b1fbd9b1115402038a77f3f9ee12 (diff)
downloadserenity-0dd585ba7bedcbc87db7eaf6d586d43c5ce1fc38.zip
LibWeb: Add `ic` and `ric` Length units
Using the rough heuristic instead of the actual spec measurement. It's allowed by the spec, but not ideal: > In the cases where it is impossible or impractical to determine the ideographic advance measure, it must be assumed to be 1em.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Length.cpp14
-rw-r--r--Userland/Libraries/LibWeb/CSS/Length.h4
2 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp
index 5a00d70c77..7657a2e557 100644
--- a/Userland/Libraries/LibWeb/CSS/Length.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Length.cpp
@@ -89,6 +89,12 @@ CSSPixels Length::relative_length_to_px(CSSPixelRect const& viewport_rect, FontM
return m_value * font_metrics.zero_advance;
case Type::Rch:
return m_value * root_font_metrics.zero_advance;
+ case Type::Ic:
+ // FIXME: Use the "advance measure of the “水” (CJK water ideograph, U+6C34) glyph"
+ return m_value * font_metrics.font_size;
+ case Type::Ric:
+ // FIXME: Use the "advance measure of the “水” (CJK water ideograph, U+6C34) glyph"
+ return m_value * root_font_metrics.font_size;
case Type::Lh:
return m_value * font_metrics.line_height;
case Type::Rlh:
@@ -158,6 +164,10 @@ char const* Length::unit_name() const
return "ch";
case Type::Rch:
return "rch";
+ case Type::Ic:
+ return "ic";
+ case Type::Ric:
+ return "ric";
case Type::Lh:
return "lh";
case Type::Rlh:
@@ -208,6 +218,10 @@ Optional<Length::Type> Length::unit_from_name(StringView name)
return Length::Type::Ch;
} else if (name.equals_ignoring_ascii_case("rch"sv)) {
return Length::Type::Rch;
+ } else if (name.equals_ignoring_ascii_case("ic"sv)) {
+ return Length::Type::Ic;
+ } else if (name.equals_ignoring_ascii_case("ric"sv)) {
+ return Length::Type::Ric;
} else if (name.equals_ignoring_ascii_case("lh"sv)) {
return Length::Type::Lh;
} else if (name.equals_ignoring_ascii_case("rlh"sv)) {
diff --git a/Userland/Libraries/LibWeb/CSS/Length.h b/Userland/Libraries/LibWeb/CSS/Length.h
index d7551f5786..ded6735393 100644
--- a/Userland/Libraries/LibWeb/CSS/Length.h
+++ b/Userland/Libraries/LibWeb/CSS/Length.h
@@ -26,6 +26,8 @@ public:
Rcap,
Ch,
Rch,
+ Ic,
+ Ric,
Lh,
Rlh,
@@ -94,6 +96,8 @@ public:
|| m_type == Type::Rcap
|| m_type == Type::Ch
|| m_type == Type::Rch
+ || m_type == Type::Ic
+ || m_type == Type::Ric
|| m_type == Type::Lh
|| m_type == Type::Rlh;
}