From 1094654adc76385d6b763f2d3d8a2f79cf612188 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 23 Mar 2022 16:55:22 +0000 Subject: [PATCH] LbWeb: Rename BoxShadowFoo => ShadowFoo The `text-shadow` property is almost identical to `box-shadow`: > Values are interpreted as for box-shadow [CSS-BACKGROUNDS-3]. > (But note that the inset keyword are not allowed.) So, let's use the same data structures and parsing code for both. :^) --- .../Libraries/LibWeb/CSS/ComputedValues.h | 10 +- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 16 +-- Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 4 +- .../CSS/ResolvedCSSStyleDeclaration.cpp | 4 +- .../Libraries/LibWeb/CSS/StyleProperties.cpp | 14 +-- .../Libraries/LibWeb/CSS/StyleProperties.h | 2 +- Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 14 +-- Userland/Libraries/LibWeb/CSS/StyleValue.h | 116 +++++++++--------- Userland/Libraries/LibWeb/Forward.h | 2 +- .../LibWeb/Painting/InlinePaintable.cpp | 4 +- .../LibWeb/Painting/PaintableBox.cpp | 4 +- .../LibWeb/Painting/ShadowPainting.cpp | 4 +- .../LibWeb/Painting/ShadowPainting.h | 8 +- 13 files changed, 101 insertions(+), 101 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index 324eba8c55..c0578e2633 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -88,13 +88,13 @@ struct FlexBasisData { bool is_definite() const { return type == CSS::FlexBasis::LengthPercentage; } }; -struct BoxShadowData { +struct ShadowData { Color color {}; CSS::Length offset_x { Length::make_px(0) }; CSS::Length offset_y { Length::make_px(0) }; CSS::Length blur_radius { Length::make_px(0) }; CSS::Length spread_distance { Length::make_px(0) }; - CSS::BoxShadowPlacement placement { CSS::BoxShadowPlacement::Outer }; + CSS::ShadowPlacement placement { CSS::ShadowPlacement::Outer }; }; struct ContentData { @@ -137,7 +137,7 @@ public: CSS::Visibility visibility() const { return m_inherited.visibility; } CSS::ImageRendering image_rendering() const { return m_inherited.image_rendering; } CSS::JustifyContent justify_content() const { return m_noninherited.justify_content; } - Vector const& box_shadow() const { return m_noninherited.box_shadow; } + Vector const& box_shadow() const { return m_noninherited.box_shadow; } CSS::BoxSizing box_sizing() const { return m_noninherited.box_sizing; } Optional const& width() const { return m_noninherited.width; } Optional const& min_width() const { return m_noninherited.min_width; } @@ -248,7 +248,7 @@ protected: CSS::Overflow overflow_x { InitialValues::overflow() }; CSS::Overflow overflow_y { InitialValues::overflow() }; float opacity { InitialValues::opacity() }; - Vector box_shadow {}; + Vector box_shadow {}; Vector transformations {}; CSS::TransformOrigin transform_origin {}; CSS::BoxSizing box_sizing { InitialValues::box_sizing() }; @@ -313,7 +313,7 @@ public: void set_align_items(CSS::AlignItems value) { m_noninherited.align_items = value; } void set_opacity(float value) { m_noninherited.opacity = value; } void set_justify_content(CSS::JustifyContent value) { m_noninherited.justify_content = value; } - void set_box_shadow(Vector&& value) { m_noninherited.box_shadow = move(value); } + void set_box_shadow(Vector&& value) { m_noninherited.box_shadow = move(value); } void set_transformations(Vector value) { m_noninherited.transformations = move(value); } void set_transform_origin(CSS::TransformOrigin value) { m_noninherited.transform_origin = value; } void set_box_sizing(CSS::BoxSizing value) { m_noninherited.box_sizing = value; } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 4fe88e415d..3f5d927d3d 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -3318,7 +3318,7 @@ RefPtr Parser::parse_border_radius_shorthand_value(Vector Parser::parse_box_shadow_value(Vector const& component_values) +RefPtr Parser::parse_shadow_value(Vector const& component_values) { // "none" if (component_values.size() == 1 && component_values.first().is(Token::Type::Ident)) { @@ -3328,11 +3328,11 @@ RefPtr Parser::parse_box_shadow_value(Vector Parser::parse_single_box_shadow_value(TokenStream& tokens) +RefPtr Parser::parse_single_shadow_value(TokenStream& tokens) { auto start_position = tokens.position(); auto error = [&]() { @@ -3345,7 +3345,7 @@ RefPtr Parser::parse_single_box_shadow_value(TokenStream offset_y; Optional blur_radius; Optional spread_distance; - Optional placement; + Optional placement; while (tokens.has_next_token()) { auto& token = tokens.peek_token(); @@ -3398,7 +3398,7 @@ RefPtr Parser::parse_single_box_shadow_value(TokenStream Parser::parse_single_box_shadow_value(TokenStream Parser::parse_content_value(Vector const& component_values) @@ -4248,7 +4248,7 @@ Result, Parser::ParsingResult> Parser::parse_css_value return parsed_value.release_nonnull(); return ParsingResult::SyntaxError; case PropertyID::BoxShadow: - if (auto parsed_value = parse_box_shadow_value(component_values)) + if (auto parsed_value = parse_shadow_value(component_values)) return parsed_value.release_nonnull(); return ParsingResult::SyntaxError; case PropertyID::Content: diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index d7e403ef9b..9bb5114a91 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -287,8 +287,6 @@ private: RefPtr parse_border_value(Vector const&); RefPtr parse_border_radius_value(Vector const&); RefPtr parse_border_radius_shorthand_value(Vector const&); - RefPtr parse_box_shadow_value(Vector const&); - RefPtr parse_single_box_shadow_value(TokenStream&); RefPtr parse_content_value(Vector const&); RefPtr parse_flex_value(Vector const&); RefPtr parse_flex_flow_value(Vector const&); @@ -296,6 +294,8 @@ private: RefPtr parse_font_family_value(Vector const&, size_t start_index = 0); RefPtr parse_list_style_value(Vector const&); RefPtr parse_overflow_value(Vector const&); + RefPtr parse_shadow_value(Vector const&); + RefPtr parse_single_shadow_value(TokenStream&); RefPtr parse_text_decoration_value(Vector const&); RefPtr parse_transform_value(Vector const&); RefPtr parse_transform_origin_value(Vector const&); diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index d22dfd120f..bd39948335 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -560,8 +560,8 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: if (box_shadow_layers.is_empty()) return {}; - auto make_box_shadow_style_value = [](BoxShadowData const& data) { - return BoxShadowStyleValue::create(data.color, data.offset_x, data.offset_y, data.blur_radius, data.spread_distance, data.placement); + auto make_box_shadow_style_value = [](ShadowData const& data) { + return ShadowStyleValue::create(data.color, data.offset_x, data.offset_y, data.blur_radius, data.spread_distance, data.placement); }; if (box_shadow_layers.size() == 1) diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 3e48827c31..411dae6698 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -914,7 +914,7 @@ Optional StyleProperties::overflow(CSS::PropertyID property_id) c } } -Vector StyleProperties::box_shadow() const +Vector StyleProperties::box_shadow() const { auto value_or_error = property(PropertyID::BoxShadow); if (!value_or_error.has_value()) @@ -922,23 +922,23 @@ Vector StyleProperties::box_shadow() const auto value = value_or_error.value(); - auto make_box_shadow_data = [](BoxShadowStyleValue const& box) { - return BoxShadowData { box.color(), box.offset_x(), box.offset_y(), box.blur_radius(), box.spread_distance(), box.placement() }; + auto make_box_shadow_data = [](ShadowStyleValue const& box) { + return ShadowData { box.color(), box.offset_x(), box.offset_y(), box.blur_radius(), box.spread_distance(), box.placement() }; }; if (value->is_value_list()) { auto& value_list = value->as_value_list(); - Vector box_shadow_data; + Vector box_shadow_data; box_shadow_data.ensure_capacity(value_list.size()); for (auto const& layer_value : value_list.values()) - box_shadow_data.append(make_box_shadow_data(layer_value.as_box_shadow())); + box_shadow_data.append(make_box_shadow_data(layer_value.as_shadow())); return box_shadow_data; } - if (value->is_box_shadow()) { - auto& box = value->as_box_shadow(); + if (value->is_shadow()) { + auto& box = value->as_shadow(); return { make_box_shadow_data(box) }; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h index a1daa29b50..0eda36532e 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h @@ -71,7 +71,7 @@ public: Optional justify_content() const; Optional overflow_x() const; Optional overflow_y() const; - Vector box_shadow() const; + Vector box_shadow() const; CSS::BoxSizing box_sizing() const; Optional pointer_events() const; Variant vertical_align() const; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 682d21dd4a..a10ffe9406 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -59,10 +59,10 @@ BorderRadiusStyleValue const& StyleValue::as_border_radius() const return static_cast(*this); } -BoxShadowStyleValue const& StyleValue::as_box_shadow() const +ShadowStyleValue const& StyleValue::as_shadow() const { - VERIFY(is_box_shadow()); - return static_cast(*this); + VERIFY(is_shadow()); + return static_cast(*this); } CalculatedStyleValue const& StyleValue::as_calculated() const @@ -295,11 +295,11 @@ String BorderRadiusStyleValue::to_string() const return String::formatted("{} / {}", m_horizontal_radius.to_string(), m_vertical_radius.to_string()); } -String BoxShadowStyleValue::to_string() const +String ShadowStyleValue::to_string() const { StringBuilder builder; builder.appendff("{} {} {} {} {}", m_color.to_string(), m_offset_x.to_string(), m_offset_y.to_string(), m_blur_radius.to_string(), m_spread_distance.to_string()); - if (m_placement == BoxShadowPlacement::Inner) + if (m_placement == ShadowPlacement::Inner) builder.append(" inset"); return builder.to_string(); } @@ -1446,13 +1446,13 @@ NonnullRefPtr LengthStyleValue::absolutized(Gfx::IntRect const& view return *this; } -NonnullRefPtr BoxShadowStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const +NonnullRefPtr ShadowStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const { auto absolutized_offset_x = absolutized_length(m_offset_x, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_offset_x); auto absolutized_offset_y = absolutized_length(m_offset_y, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_offset_y); auto absolutized_blur_radius = absolutized_length(m_blur_radius, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_blur_radius); auto absolutized_spread_distance = absolutized_length(m_spread_distance, viewport_rect, font_metrics, font_size, root_font_size).value_or(m_spread_distance); - return BoxShadowStyleValue::create(m_color, absolutized_offset_x, absolutized_offset_y, absolutized_blur_radius, absolutized_spread_distance, m_placement); + return ShadowStyleValue::create(m_color, absolutized_offset_x, absolutized_offset_y, absolutized_blur_radius, absolutized_spread_distance, m_placement); } NonnullRefPtr BorderRadiusStyleValue::absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 623964614a..0d0f4300e4 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -70,7 +70,7 @@ enum class BoxSizing { ContentBox, }; -enum class BoxShadowPlacement { +enum class ShadowPlacement { Outer, Inner, }; @@ -352,7 +352,6 @@ public: BackgroundSize, Border, BorderRadius, - BoxShadow, Calculated, Color, CombinedBorderRadius, @@ -373,6 +372,7 @@ public: Percentage, Position, Resolution, + Shadow, String, TextDecoration, Time, @@ -390,7 +390,6 @@ public: bool is_background_size() const { return type() == Type::BackgroundSize; } bool is_border() const { return type() == Type::Border; } bool is_border_radius() const { return type() == Type::BorderRadius; } - bool is_box_shadow() const { return type() == Type::BoxShadow; } bool is_calculated() const { return type() == Type::Calculated; } bool is_color() const { return type() == Type::Color; } bool is_content() const { return type() == Type::Content; } @@ -409,6 +408,7 @@ public: bool is_percentage() const { return type() == Type::Percentage; } bool is_position() const { return type() == Type::Position; } bool is_resolution() const { return type() == Type::Resolution; } + bool is_shadow() const { return type() == Type::Shadow; } bool is_string() const { return type() == Type::String; } bool is_text_decoration() const { return type() == Type::TextDecoration; } bool is_time() const { return type() == Type::Time; } @@ -425,7 +425,6 @@ public: BackgroundSizeStyleValue const& as_background_size() const; BorderRadiusStyleValue const& as_border_radius() const; BorderStyleValue const& as_border() const; - BoxShadowStyleValue const& as_box_shadow() const; CalculatedStyleValue const& as_calculated() const; ColorStyleValue const& as_color() const; ContentStyleValue const& as_content() const; @@ -444,6 +443,7 @@ public: PercentageStyleValue const& as_percentage() const; PositionStyleValue const& as_position() const; ResolutionStyleValue const& as_resolution() const; + ShadowStyleValue const& as_shadow() const; StringStyleValue const& as_string() const; TextDecorationStyleValue const& as_text_decoration() const; TimeStyleValue const& as_time() const; @@ -458,7 +458,6 @@ public: BackgroundSizeStyleValue& as_background_size() { return const_cast(const_cast(*this).as_background_size()); } BorderRadiusStyleValue& as_border_radius() { return const_cast(const_cast(*this).as_border_radius()); } BorderStyleValue& as_border() { return const_cast(const_cast(*this).as_border()); } - BoxShadowStyleValue& as_box_shadow() { return const_cast(const_cast(*this).as_box_shadow()); } CalculatedStyleValue& as_calculated() { return const_cast(const_cast(*this).as_calculated()); } ColorStyleValue& as_color() { return const_cast(const_cast(*this).as_color()); } ContentStyleValue& as_content() { return const_cast(const_cast(*this).as_content()); } @@ -477,6 +476,7 @@ public: PercentageStyleValue& as_percentage() { return const_cast(const_cast(*this).as_percentage()); } PositionStyleValue& as_position() { return const_cast(const_cast(*this).as_position()); } ResolutionStyleValue& as_resolution() { return const_cast(const_cast(*this).as_resolution()); } + ShadowStyleValue& as_shadow() { return const_cast(const_cast(*this).as_shadow()); } StringStyleValue& as_string() { return const_cast(const_cast(*this).as_string()); } TextDecorationStyleValue& as_text_decoration() { return const_cast(const_cast(*this).as_text_decoration()); } TimeStyleValue& as_time() { return const_cast(const_cast(*this).as_time()); } @@ -740,59 +740,6 @@ private: LengthPercentage m_vertical_radius; }; -class BoxShadowStyleValue final : public StyleValue { -public: - static NonnullRefPtr - create(Color const& color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, BoxShadowPlacement placement) - { - return adopt_ref(*new BoxShadowStyleValue(color, offset_x, offset_y, blur_radius, spread_distance, placement)); - } - virtual ~BoxShadowStyleValue() override = default; - - Color const& color() const { return m_color; } - Length const& offset_x() const { return m_offset_x; } - Length const& offset_y() const { return m_offset_y; } - Length const& blur_radius() const { return m_blur_radius; } - Length const& spread_distance() const { return m_spread_distance; } - BoxShadowPlacement placement() const { return m_placement; } - - virtual String to_string() const override; - - virtual bool equals(StyleValue const& other) const override - { - if (type() != other.type()) - return false; - auto& other_value = static_cast(other); - return m_color == other_value.m_color - && m_offset_x == other_value.m_offset_x - && m_offset_y == other_value.m_offset_y - && m_blur_radius == other_value.m_blur_radius - && m_spread_distance == other_value.m_spread_distance - && m_placement == other_value.m_placement; - } - -private: - explicit BoxShadowStyleValue(Color const& color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, BoxShadowPlacement placement) - : StyleValue(Type::BoxShadow) - , m_color(color) - , m_offset_x(offset_x) - , m_offset_y(offset_y) - , m_blur_radius(blur_radius) - , m_spread_distance(spread_distance) - , m_placement(placement) - { - } - - virtual NonnullRefPtr absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const override; - - Color m_color; - Length m_offset_x; - Length m_offset_y; - Length m_blur_radius; - Length m_spread_distance; - BoxShadowPlacement m_placement; -}; - class CalculatedStyleValue : public StyleValue { public: enum class ResolvedType { @@ -1510,6 +1457,59 @@ private: Resolution m_resolution; }; +class ShadowStyleValue final : public StyleValue { +public: + static NonnullRefPtr + create(Color const& color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement) + { + return adopt_ref(*new ShadowStyleValue(color, offset_x, offset_y, blur_radius, spread_distance, placement)); + } + virtual ~ShadowStyleValue() override = default; + + Color const& color() const { return m_color; } + Length const& offset_x() const { return m_offset_x; } + Length const& offset_y() const { return m_offset_y; } + Length const& blur_radius() const { return m_blur_radius; } + Length const& spread_distance() const { return m_spread_distance; } + ShadowPlacement placement() const { return m_placement; } + + virtual String to_string() const override; + + virtual bool equals(StyleValue const& other) const override + { + if (type() != other.type()) + return false; + auto& other_value = static_cast(other); + return m_color == other_value.m_color + && m_offset_x == other_value.m_offset_x + && m_offset_y == other_value.m_offset_y + && m_blur_radius == other_value.m_blur_radius + && m_spread_distance == other_value.m_spread_distance + && m_placement == other_value.m_placement; + } + +private: + explicit ShadowStyleValue(Color const& color, Length const& offset_x, Length const& offset_y, Length const& blur_radius, Length const& spread_distance, ShadowPlacement placement) + : StyleValue(Type::Shadow) + , m_color(color) + , m_offset_x(offset_x) + , m_offset_y(offset_y) + , m_blur_radius(blur_radius) + , m_spread_distance(spread_distance) + , m_placement(placement) + { + } + + virtual NonnullRefPtr absolutized(Gfx::IntRect const& viewport_rect, Gfx::FontMetrics const& font_metrics, float font_size, float root_font_size) const override; + + Color m_color; + Length m_offset_x; + Length m_offset_y; + Length m_blur_radius; + Length m_spread_distance; + ShadowPlacement m_placement; +}; + class StringStyleValue : public StyleValue { public: static NonnullRefPtr create(String const& string) diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index a065362ce7..215d28635a 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -27,7 +27,6 @@ class BackgroundSizeStyleValue; class BackgroundStyleValue; class BorderRadiusStyleValue; class BorderStyleValue; -class BoxShadowStyleValue; class CalculatedStyleValue; class ColorStyleValue; class ContentStyleValue; @@ -70,6 +69,7 @@ class Resolution; class ResolutionStyleValue; class Screen; class Selector; +class ShadowStyleValue; class StringStyleValue; class StyleComputer; class StyleProperties; diff --git a/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp b/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp index b394269bf1..0b0106c0b1 100644 --- a/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp @@ -58,7 +58,7 @@ void InlinePaintable::paint(PaintContext& context, Painting::PaintPhase phase) c Painting::paint_background(context, layout_node(), enclosing_int_rect(absolute_fragment_rect), computed_values().background_color(), &computed_values().background_layers(), border_radius_data); if (auto computed_box_shadow = computed_values().box_shadow(); !computed_box_shadow.is_empty()) { - Vector resolved_box_shadow_data; + Vector resolved_box_shadow_data; resolved_box_shadow_data.ensure_capacity(computed_box_shadow.size()); for (auto const& layer : computed_box_shadow) { resolved_box_shadow_data.empend( @@ -67,7 +67,7 @@ void InlinePaintable::paint(PaintContext& context, Painting::PaintPhase phase) c static_cast(layer.offset_y.to_px(layout_node())), static_cast(layer.blur_radius.to_px(layout_node())), static_cast(layer.spread_distance.to_px(layout_node())), - layer.placement == CSS::BoxShadowPlacement::Outer ? Painting::BoxShadowPlacement::Outer : Painting::BoxShadowPlacement::Inner); + layer.placement == CSS::ShadowPlacement::Outer ? Painting::ShadowPlacement::Outer : Painting::ShadowPlacement::Inner); } Painting::paint_box_shadow(context, enclosing_int_rect(absolute_fragment_rect), resolved_box_shadow_data); } diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 9684c1aa8f..a11a555bd3 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -203,7 +203,7 @@ void PaintableBox::paint_box_shadow(PaintContext& context) const if (box_shadow_data.is_empty()) return; - Vector resolved_box_shadow_data; + Vector resolved_box_shadow_data; resolved_box_shadow_data.ensure_capacity(box_shadow_data.size()); for (auto const& layer : box_shadow_data) { resolved_box_shadow_data.empend( @@ -212,7 +212,7 @@ void PaintableBox::paint_box_shadow(PaintContext& context) const static_cast(layer.offset_y.to_px(layout_box())), static_cast(layer.blur_radius.to_px(layout_box())), static_cast(layer.spread_distance.to_px(layout_box())), - layer.placement == CSS::BoxShadowPlacement::Outer ? BoxShadowPlacement::Outer : BoxShadowPlacement::Inner); + layer.placement == CSS::ShadowPlacement::Outer ? ShadowPlacement::Outer : ShadowPlacement::Inner); } Painting::paint_box_shadow(context, enclosing_int_rect(absolute_border_box_rect()), resolved_box_shadow_data); } diff --git a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp index f9a79d5143..1c9e0739b1 100644 --- a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp @@ -13,7 +13,7 @@ namespace Web::Painting { -void paint_box_shadow(PaintContext& context, Gfx::IntRect const& content_rect, Vector const& box_shadow_layers) +void paint_box_shadow(PaintContext& context, Gfx::IntRect const& content_rect, Vector const& box_shadow_layers) { if (box_shadow_layers.is_empty()) return; @@ -24,7 +24,7 @@ void paint_box_shadow(PaintContext& context, Gfx::IntRect const& content_rect, V for (int layer_index = box_shadow_layers.size() - 1; layer_index >= 0; layer_index--) { auto& box_shadow_data = box_shadow_layers[layer_index]; // FIXME: Paint inset shadows. - if (box_shadow_data.placement != BoxShadowPlacement::Outer) + if (box_shadow_data.placement != ShadowPlacement::Outer) continue; // FIXME: Account for rounded corners. diff --git a/Userland/Libraries/LibWeb/Painting/ShadowPainting.h b/Userland/Libraries/LibWeb/Painting/ShadowPainting.h index 9c46f56679..2e6738b75e 100644 --- a/Userland/Libraries/LibWeb/Painting/ShadowPainting.h +++ b/Userland/Libraries/LibWeb/Painting/ShadowPainting.h @@ -11,20 +11,20 @@ namespace Web::Painting { -enum class BoxShadowPlacement { +enum class ShadowPlacement { Outer, Inner, }; -struct BoxShadowData { +struct ShadowData { Gfx::Color color; int offset_x; int offset_y; int blur_radius; int spread_distance; - BoxShadowPlacement placement; + ShadowPlacement placement; }; -void paint_box_shadow(PaintContext&, Gfx::IntRect const&, Vector const&); +void paint_box_shadow(PaintContext&, Gfx::IntRect const&, Vector const&); }