summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/ComputedValues.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-02-21 16:24:12 +0100
committerAndreas Kling <kling@serenityos.org>2022-02-21 18:35:12 +0100
commitc61747fb2a4e841233a9209db8ce84f073548e34 (patch)
tree8661c6b29033710a80d3a1561d9eb1f53b71cd0f /Userland/Libraries/LibWeb/CSS/ComputedValues.h
parent2615728d6bc352d6011f98fa202a8ba821bb3755 (diff)
downloadserenity-c61747fb2a4e841233a9209db8ce84f073548e34.zip
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. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/ComputedValues.h')
-rw-r--r--Userland/Libraries/LibWeb/CSS/ComputedValues.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
index b7e73e80bb..242ec7983b 100644
--- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h
+++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
@@ -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; }