mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
layout: Scale images in image_set
by their specified resolution (#36374)
This PR makes it so the `resolution` factor in `image-set` also affects the image size. For instance, in the example below: ```css background-image: image-set("./small.png" 1x, "./large.png" 2x); ``` if `large.png` is used, an image which is 32x32 will be rendered as 16x16. This is specified in <https://drafts.csswg.org/css-images-4/#image-set-notation>. Testing: - `css/css-images/image-set/image-set-resolution-002.html` --------- Signed-off-by: tobinio <Tobias.frischmann1@gmail.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
3e249c9bc4
commit
4f41354349
3 changed files with 30 additions and 14 deletions
|
@ -61,8 +61,7 @@ pub use stacking_context::*;
|
|||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct WebRenderImageInfo {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub size: Size2D<u32, UnknownUnit>,
|
||||
pub key: Option<wr::ImageKey>,
|
||||
}
|
||||
|
||||
|
@ -817,8 +816,8 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
// FIXME: https://drafts.csswg.org/css-images-4/#the-image-resolution
|
||||
let dppx = 1.0;
|
||||
let intrinsic = NaturalSizes::from_width_and_height(
|
||||
image_info.width as f32 / dppx,
|
||||
image_info.height as f32 / dppx,
|
||||
image_info.size.width as f32 / dppx,
|
||||
image_info.size.height as f32 / dppx,
|
||||
);
|
||||
let Some(image_key) = image_info.key else {
|
||||
continue;
|
||||
|
@ -1007,8 +1006,8 @@ impl<'a> BuilderForBoxFragment<'a> {
|
|||
return false;
|
||||
};
|
||||
|
||||
width = image_info.width as f32;
|
||||
height = image_info.height as f32;
|
||||
width = image_info.size.width as f32;
|
||||
height = image_info.size.height as f32;
|
||||
NinePatchBorderSource::Image(key, ImageRendering::Auto)
|
||||
},
|
||||
Some(ResolvedImage::Gradient(gradient)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue