mirror of
https://github.com/servo/servo.git
synced 2025-10-02 17:49:16 +01:00
layout: Avoid negative corner radii values for border-radius (#39571)
The `border-radius` property provides the radii for the border box. For the curvature of the padding and content boxes, we then subtract the border and padding sizes. However, we weren't flooring the result by zero, which could make the background completely disappear when using `background-clip: padding-box` or `background-clip: content-box`. Testing: Adding 4 new tests, but 2 of them fail in both Servo and Firefox. Fixes: #39540 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
5442302f8b
commit
0c22f784bb
12 changed files with 264 additions and 8 deletions
|
@ -1601,20 +1601,20 @@ fn glyphs_advance_by_index(
|
|||
/// Radii for the padding edge or content edge
|
||||
fn inner_radii(mut radii: wr::BorderRadius, insets: units::LayoutSideOffsets) -> wr::BorderRadius {
|
||||
assert!(insets.left >= 0.0, "left inset must not be negative");
|
||||
radii.top_left.width -= insets.left;
|
||||
radii.bottom_left.width -= insets.left;
|
||||
radii.top_left.width = (radii.top_left.width - insets.left).max(0.0);
|
||||
radii.bottom_left.width = (radii.bottom_left.width - insets.left).max(0.0);
|
||||
|
||||
assert!(insets.right >= 0.0, "left inset must not be negative");
|
||||
radii.top_right.width -= insets.right;
|
||||
radii.bottom_right.width -= insets.right;
|
||||
radii.top_right.width = (radii.top_right.width - insets.right).max(0.0);
|
||||
radii.bottom_right.width = (radii.bottom_right.width - insets.right).max(0.0);
|
||||
|
||||
assert!(insets.top >= 0.0, "top inset must not be negative");
|
||||
radii.top_left.height -= insets.top;
|
||||
radii.top_right.height -= insets.top;
|
||||
radii.top_left.height = (radii.top_left.height - insets.top).max(0.0);
|
||||
radii.top_right.height = (radii.top_right.height - insets.top).max(0.0);
|
||||
|
||||
assert!(insets.bottom >= 0.0, "bottom inset must not be negative");
|
||||
radii.bottom_left.height -= insets.bottom;
|
||||
radii.bottom_right.height -= insets.bottom;
|
||||
radii.bottom_left.height = (radii.bottom_left.height - insets.bottom).max(0.0);
|
||||
radii.bottom_right.height = (radii.bottom_right.height - insets.bottom).max(0.0);
|
||||
radii
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue