1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

LibWeb: Respect font-size specified by CSS in "em" length calculations

"5em" means 5*font-size, but by forcing "em" to mean the presentation
size of the bitmap font actually used, we broke a bunch of layouts that
depended on a correct interpretation of "em".

This means that "em" units will no longer be relative to the exact
size of the bitmap font in use, but I think that's a compromise we'll
have to make, since accurate layouts are more important.

This yields a visual progression on both ACID2 and ACID3. :^)
This commit is contained in:
Andreas Kling 2022-02-21 16:24:12 +01:00
parent 2615728d6b
commit c61747fb2a
6 changed files with 32 additions and 13 deletions

View file

@ -14,6 +14,8 @@ namespace Web::CSS {
class InitialValues {
public:
static float font_size() { return 10; }
static int font_weight() { return 400; }
static CSS::Float float_() { return CSS::Float::None; }
static CSS::Clear clear() { return CSS::Clear::None; }
static CSS::Cursor cursor() { return CSS::Cursor::Auto; }
@ -146,6 +148,9 @@ public:
Vector<CSS::Transformation> transformations() const { return m_noninherited.transformations; }
float font_size() const { return m_inherited.font_size; }
int font_weight() const { return m_inherited.font_weight; }
ComputedValues clone_inherited_values() const
{
ComputedValues clone;
@ -155,6 +160,8 @@ public:
protected:
struct {
float font_size { InitialValues::font_size() };
int font_weight { InitialValues::font_weight() };
Color color { InitialValues::color() };
CSS::Cursor cursor { InitialValues::cursor() };
CSS::ImageRendering image_rendering { InitialValues::image_rendering() };
@ -217,6 +224,8 @@ class ImmutableComputedValues final : public ComputedValues {
class MutableComputedValues final : public ComputedValues {
public:
void set_font_size(float font_size) { m_inherited.font_size = font_size; }
void set_font_weight(int font_weight) { m_inherited.font_weight = font_weight; }
void set_color(const Color& color) { m_inherited.color = color; }
void set_cursor(CSS::Cursor cursor) { m_inherited.cursor = cursor; }
void set_image_rendering(CSS::ImageRendering value) { m_inherited.image_rendering = value; }