mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:47:45 +00:00
LibWeb: Paint backgrounds with multiple layers :^)
This commit is contained in:
parent
cdeac132dc
commit
e8b7946732
4 changed files with 20 additions and 36 deletions
|
@ -73,8 +73,6 @@ void Box::paint_background(PaintContext& context)
|
|||
Gfx::IntRect background_rect;
|
||||
Color background_color = computed_values().background_color();
|
||||
auto* background_layers = &computed_values().background_layers();
|
||||
const Gfx::Bitmap* background_image = this->background_image() ? this->background_image()->bitmap() : nullptr;
|
||||
CSS::BackgroundRepeatData background_repeat = computed_values().background_repeat();
|
||||
|
||||
if (is_root_element()) {
|
||||
// CSS 2.1 Appendix E.2: If the element is a root element, paint the background over the entire canvas.
|
||||
|
@ -85,8 +83,6 @@ void Box::paint_background(PaintContext& context)
|
|||
if (document().html_element()->should_use_body_background_properties()) {
|
||||
background_layers = document().background_layers();
|
||||
background_color = document().background_color(context.palette());
|
||||
background_image = document().background_image();
|
||||
background_repeat = { document().background_repeat_x(), document().background_repeat_y() };
|
||||
}
|
||||
} else {
|
||||
background_rect = enclosing_int_rect(padded_rect());
|
||||
|
@ -97,13 +93,7 @@ void Box::paint_background(PaintContext& context)
|
|||
if (computed_values().border_top().width || computed_values().border_right().width || computed_values().border_bottom().width || computed_values().border_left().width)
|
||||
background_rect = enclosing_int_rect(bordered_rect());
|
||||
|
||||
auto background_data = Painting::BackgroundData {
|
||||
.color = background_color,
|
||||
.image = background_image,
|
||||
.repeat_x = background_repeat.repeat_x,
|
||||
.repeat_y = background_repeat.repeat_y
|
||||
};
|
||||
Painting::paint_background(context, background_rect, background_data, normalized_border_radius_data());
|
||||
Painting::paint_background(context, background_rect, background_color, background_layers, normalized_border_radius_data());
|
||||
}
|
||||
|
||||
void Box::paint_box_shadow(PaintContext& context)
|
||||
|
|
|
@ -49,13 +49,6 @@ void InlineNode::paint(PaintContext& context, PaintPhase phase)
|
|||
auto& painter = context.painter();
|
||||
|
||||
if (phase == PaintPhase::Background) {
|
||||
auto background_data = Painting::BackgroundData {
|
||||
.color = computed_values().background_color(),
|
||||
.image = background_image() ? background_image()->bitmap() : nullptr,
|
||||
.repeat_x = computed_values().background_repeat().repeat_x,
|
||||
.repeat_y = computed_values().background_repeat().repeat_y
|
||||
};
|
||||
|
||||
auto top_left_border_radius = computed_values().border_top_left_radius();
|
||||
auto top_right_border_radius = computed_values().border_top_right_radius();
|
||||
auto bottom_right_border_radius = computed_values().border_bottom_right_radius();
|
||||
|
@ -65,7 +58,7 @@ void InlineNode::paint(PaintContext& context, PaintPhase phase)
|
|||
// FIXME: This recalculates our (InlineNode's) absolute_rect() for every single fragment!
|
||||
auto rect = fragment.absolute_rect();
|
||||
auto border_radius_data = Painting::normalized_border_radius_data(*this, rect, top_left_border_radius, top_right_border_radius, bottom_right_border_radius, bottom_left_border_radius);
|
||||
Painting::paint_background(context, enclosing_int_rect(rect), background_data, border_radius_data);
|
||||
Painting::paint_background(context, enclosing_int_rect(rect), computed_values().background_color(), &computed_values().background_layers(), border_radius_data);
|
||||
|
||||
if (auto computed_box_shadow = computed_values().box_shadow(); computed_box_shadow.has_value()) {
|
||||
auto box_shadow_data = Painting::BoxShadowData {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue