mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Use a non-repeating display item for background-repeat: no-repeat
This commit is contained in:
parent
b5042eaa52
commit
c72f7894aa
1 changed files with 26 additions and 15 deletions
|
@ -426,7 +426,7 @@ impl<'a> BuilderForBoxFragment<'a> {
|
||||||
clipping_area_origin: f32,
|
clipping_area_origin: f32,
|
||||||
clipping_area_size: f32,
|
clipping_area_size: f32,
|
||||||
positioning_area_size: f32,
|
positioning_area_size: f32,
|
||||||
) -> (f32, f32) {
|
) -> (bool, f32, f32) {
|
||||||
// https://drafts.csswg.org/css-backgrounds/#background-repeat
|
// https://drafts.csswg.org/css-backgrounds/#background-repeat
|
||||||
if let Repeat::Round = repeat {
|
if let Repeat::Round = repeat {
|
||||||
*tile_size = positioning_area_size / (positioning_area_size / *tile_size).round();
|
*tile_size = positioning_area_size / (positioning_area_size / *tile_size).round();
|
||||||
|
@ -448,20 +448,20 @@ impl<'a> BuilderForBoxFragment<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match repeat {
|
match repeat {
|
||||||
Repeat::NoRepeat => (position, *tile_size),
|
Repeat::NoRepeat => (false, position, *tile_size),
|
||||||
Repeat::Repeat | Repeat::Round | Repeat::Space => {
|
Repeat::Repeat | Repeat::Round | Repeat::Space => {
|
||||||
let tile_stride = *tile_size + *tile_spacing;
|
let tile_stride = *tile_size + *tile_spacing;
|
||||||
let offset = position - clipping_area_origin;
|
let offset = position - clipping_area_origin;
|
||||||
let bounds_origin = position - tile_stride * (offset / tile_stride).ceil();
|
let bounds_origin = position - tile_stride * (offset / tile_stride).ceil();
|
||||||
let bounds_size = clipping_area_size - bounds_origin - clipping_area_origin;
|
let bounds_size = clipping_area_size - bounds_origin - clipping_area_origin;
|
||||||
(bounds_origin, bounds_size)
|
(true, bounds_origin, bounds_size)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut tile_spacing = units::LayoutSize::zero();
|
let mut tile_spacing = units::LayoutSize::zero();
|
||||||
let RepeatXY(repeat_x, repeat_y) = *get_cyclic(&b.background_repeat.0, index);
|
let RepeatXY(repeat_x, repeat_y) = *get_cyclic(&b.background_repeat.0, index);
|
||||||
let (bounds_origin_x, bounds_width) = layout_1d(
|
let (repeat_x, bounds_origin_x, bounds_width) = layout_1d(
|
||||||
&mut tile_size.width,
|
&mut tile_size.width,
|
||||||
&mut tile_spacing.width,
|
&mut tile_spacing.width,
|
||||||
repeat_x,
|
repeat_x,
|
||||||
|
@ -470,7 +470,7 @@ impl<'a> BuilderForBoxFragment<'a> {
|
||||||
clipping_area.size.width,
|
clipping_area.size.width,
|
||||||
positioning_area.size.width,
|
positioning_area.size.width,
|
||||||
);
|
);
|
||||||
let (bounds_origin_y, bounds_height) = layout_1d(
|
let (repeat_y, bounds_origin_y, bounds_height) = layout_1d(
|
||||||
&mut tile_size.height,
|
&mut tile_size.height,
|
||||||
&mut tile_spacing.height,
|
&mut tile_spacing.height,
|
||||||
repeat_y,
|
repeat_y,
|
||||||
|
@ -488,16 +488,27 @@ impl<'a> BuilderForBoxFragment<'a> {
|
||||||
let mut common = builder.common_properties(*clipping_area);
|
let mut common = builder.common_properties(*clipping_area);
|
||||||
self.with_border_edge_clip(builder, &mut common);
|
self.with_border_edge_clip(builder, &mut common);
|
||||||
|
|
||||||
builder.wr.push_repeating_image(
|
if repeat_x || repeat_y {
|
||||||
&common,
|
builder.wr.push_repeating_image(
|
||||||
bounds,
|
&common,
|
||||||
tile_size,
|
bounds,
|
||||||
tile_spacing,
|
tile_size,
|
||||||
image_rendering(self.fragment.style.clone_image_rendering()),
|
tile_spacing,
|
||||||
wr::AlphaType::PremultipliedAlpha,
|
image_rendering(self.fragment.style.clone_image_rendering()),
|
||||||
key,
|
wr::AlphaType::PremultipliedAlpha,
|
||||||
wr::ColorF::WHITE,
|
key,
|
||||||
)
|
wr::ColorF::WHITE,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
builder.wr.push_image(
|
||||||
|
&common,
|
||||||
|
bounds,
|
||||||
|
image_rendering(self.fragment.style.clone_image_rendering()),
|
||||||
|
wr::AlphaType::PremultipliedAlpha,
|
||||||
|
key,
|
||||||
|
wr::ColorF::WHITE,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_border(&mut self, builder: &mut DisplayListBuilder) {
|
fn build_border(&mut self, builder: &mut DisplayListBuilder) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue