summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-09-17 20:04:35 +0100
committerAndreas Kling <kling@serenityos.org>2021-09-17 23:06:45 +0200
commitf4ea235a3388f0ae71b65aac000da55d0bb5e08b (patch)
tree65f189616a6abe925cd309d8d9213137463a6625 /Userland/Libraries/LibWeb
parent0053314dd1b3e0b66993d2486565cda39ed04cd7 (diff)
downloadserenity-f4ea235a3388f0ae71b65aac000da55d0bb5e08b.zip
LibWeb: Replace hard-coded defaults in Node::apply_style()
This now uses the values in `InitialValues`, which is not ideal, but it's better to have our defaults defined in two places, than in 3. The default for `border-colors` is `currentcolor`, so we shortcut that here and just grab the value of the `color` property. As noted, this is not perfect, but it's somewhat better.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index 2537755389..e08c28ecd9 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -321,8 +321,8 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
if (auto list_style_type = specified_style.list_style_type(); list_style_type.has_value())
computed_values.set_list_style_type(list_style_type.value());
- computed_values.set_color(specified_style.color_or_fallback(CSS::PropertyID::Color, *this, Color::Black));
- computed_values.set_background_color(specified_style.color_or_fallback(CSS::PropertyID::BackgroundColor, *this, Color::Transparent));
+ computed_values.set_color(specified_style.color_or_fallback(CSS::PropertyID::Color, *this, CSS::InitialValues::color()));
+ computed_values.set_background_color(specified_style.color_or_fallback(CSS::PropertyID::BackgroundColor, *this, CSS::InitialValues::background_color()));
computed_values.set_z_index(specified_style.z_index());
computed_values.set_opacity(specified_style.opacity());
@@ -348,7 +348,10 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
computed_values.set_box_shadow(specified_style.box_shadow());
auto do_border_style = [&](CSS::BorderData& border, CSS::PropertyID width_property, CSS::PropertyID color_property, CSS::PropertyID style_property) {
- border.color = specified_style.color_or_fallback(color_property, *this, Color::Transparent);
+ // FIXME: The default border color value is `currentcolor`, but since we can't resolve that easily,
+ // we just manually grab the value from `color`. This makes it dependent on `color` being
+ // specified first, so it's far from ideal.
+ border.color = specified_style.color_or_fallback(color_property, *this, computed_values.color());
border.line_style = specified_style.line_style(style_property).value_or(CSS::LineStyle::None);
if (border.line_style == CSS::LineStyle::None)
border.width = 0;