summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-01-27 15:54:38 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-04 13:52:02 +0100
commit8bd1854406a29e345c69d662836a9173987f36b7 (patch)
treefaa3e7f0a208fd7fad24734e9031b8984a4fa2b1 /Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
parent2407a03fd9caa0f1fd625f7344304f794b6946db (diff)
downloadserenity-8bd1854406a29e345c69d662836a9173987f36b7.zip
LibWeb+Base: Enable calc() for font-weight property :^)
Modified the test-page because FontDatabase looks for exact font-weight matches, so requesting weight 800 in a font that only has 700, causes it to return the default font instead. So, we ask for 700 here. The actual fix is to improve our font-matching but I am trying not to get distracted today. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/StyleComputer.cpp')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index 41325d09ea..61617cdce0 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -714,8 +714,11 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
weight = Gfx::FontWeight::Bold;
else
weight = Gfx::FontWeight::Black;
+ } else if (font_weight->is_calculated()) {
+ auto maybe_weight = font_weight->as_calculated().resolve_integer();
+ if (maybe_weight.has_value())
+ weight = maybe_weight.value();
}
- // FIXME: calc() for font-weight
bool bold = weight > Gfx::FontWeight::Regular;
@@ -777,6 +780,7 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
}
if (maybe_length.has_value()) {
// FIXME: Support font-size: calc(...)
+ // Theoretically we can do this now, but to resolve it we need a layout_node which we might not have. :^(
if (!maybe_length->is_calculated()) {
auto px = maybe_length.value().to_px(viewport_rect, font_metrics, root_font_size);
if (px != 0)