mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
layout: Fix radius percentage resolution.
By resolving against the corresponding dimension of the border box, instead of against the width. Fixes #16764
This commit is contained in:
parent
39471cda1b
commit
c9ab75b013
2 changed files with 20 additions and 8 deletions
|
@ -564,13 +564,13 @@ fn build_border_radius(abs_bounds: &Rect<Au>,
|
|||
|
||||
handle_overlapping_radii(&abs_bounds.size, &BorderRadii {
|
||||
top_left: model::specified_border_radius(border_style.border_top_left_radius,
|
||||
abs_bounds.size.width),
|
||||
abs_bounds.size),
|
||||
top_right: model::specified_border_radius(border_style.border_top_right_radius,
|
||||
abs_bounds.size.width),
|
||||
abs_bounds.size),
|
||||
bottom_right: model::specified_border_radius(border_style.border_bottom_right_radius,
|
||||
abs_bounds.size.width),
|
||||
abs_bounds.size),
|
||||
bottom_left: model::specified_border_radius(border_style.border_bottom_left_radius,
|
||||
abs_bounds.size.width),
|
||||
abs_bounds.size),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1278,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
spread_radius: box_shadow.spread_radius,
|
||||
border_radius: model::specified_border_radius(style.get_border()
|
||||
.border_top_left_radius,
|
||||
absolute_bounds.size.width).width,
|
||||
absolute_bounds.size).width,
|
||||
clip_mode: if box_shadow.inset {
|
||||
BoxShadowClipMode::Inset
|
||||
} else {
|
||||
|
|
|
@ -478,10 +478,22 @@ pub fn specified(length: LengthOrPercentage, containing_length: Au) -> Au {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn specified_border_radius(radius: BorderRadiusSize, containing_length: Au) -> Size2D<Au> {
|
||||
/// Computes a border radius size against the containing size.
|
||||
///
|
||||
/// Note that percentages in `border-radius` are resolved against the relevant
|
||||
/// box dimension instead of only against the width per [1]:
|
||||
///
|
||||
/// > Percentages: Refer to corresponding dimension of the border box.
|
||||
///
|
||||
/// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius
|
||||
pub fn specified_border_radius(
|
||||
radius: BorderRadiusSize,
|
||||
containing_size: Size2D<Au>)
|
||||
-> Size2D<Au>
|
||||
{
|
||||
let generics::BorderRadiusSize(size) = radius;
|
||||
let w = specified(size.width, containing_length);
|
||||
let h = specified(size.height, containing_length);
|
||||
let w = specified(size.width, containing_size.width);
|
||||
let h = specified(size.height, containing_size.height);
|
||||
Size2D::new(w, h)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue