From 8f0a48ef23d64ee5e512a6f6a316c2bde22637cc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 8 Sep 2022 12:41:42 +0200 Subject: [PATCH] LibWeb: Make default CSS font settings match other browsers better Let's make 16px the default font size instead of 10px. This makes our layout results match those of other engines in many more cases. Also make the h1-h6 element styles use relative (em) font sizes, also matching other browsers. --- .../Libraries/LibWeb/CSS/ComputedValues.h | 2 +- Userland/Libraries/LibWeb/CSS/Default.css | 34 ++++++++++++++++--- .../Libraries/LibWeb/CSS/StyleComputer.cpp | 6 ++-- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index 69d912ef83..ecb9c23134 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -15,7 +15,7 @@ namespace Web::CSS { class InitialValues { public: - static float font_size() { return 10; } + static float font_size() { return 16; } static int font_weight() { return 400; } static CSS::FontVariant font_variant() { return CSS::FontVariant::Normal; } static CSS::Float float_() { return CSS::Float::None; } diff --git a/Userland/Libraries/LibWeb/CSS/Default.css b/Userland/Libraries/LibWeb/CSS/Default.css index 8319932a48..30ef6d8fde 100644 --- a/Userland/Libraries/LibWeb/CSS/Default.css +++ b/Userland/Libraries/LibWeb/CSS/Default.css @@ -11,13 +11,37 @@ body { margin: 8px; } -h1, -h2 { - font-family: Pebbleton; - font-size: 14px; - font-weight: bold; +h1 { + font-size: 2em; + margin: 0.67em 0; } +h2 { + font-size: 1.5em; + margin: 0.83em 0; +} + +h3 { + font-size: 1.17em; + margin: 1em 0; +} + +h4 { + margin: 1.33em 0; +} + +h5 { + font-size: 0.83em; + margin: 1.67em 0; +} + +h6 { + font-size: 0.67em; + margin: 2.33em 0; +} + +h1, +h2, h3, h4, h5, diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 7f7a096efa..2e4931b45a 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -855,7 +855,7 @@ void StyleComputer::compute_defaulted_values(StyleProperties& style, DOM::Elemen float StyleComputer::root_element_font_size() const { - constexpr float default_root_element_font_size = 10; + constexpr float default_root_element_font_size = 16; auto const* root_element = m_document.first_child_of_type(); if (!root_element) @@ -921,7 +921,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele bool bold = weight > Gfx::FontWeight::Regular; - float font_size_in_px = 10; + float font_size_in_px = 16; if (font_size->is_identifier()) { switch (static_cast(*font_size).id()) { @@ -930,7 +930,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele case CSS::ValueID::Small: case CSS::ValueID::Medium: // FIXME: Should be based on "user's default font size" - font_size_in_px = 10; + font_size_in_px = 16; break; case CSS::ValueID::Large: case CSS::ValueID::XLarge: