mirror of
https://github.com/servo/servo.git
synced 2025-08-17 11:25:35 +01:00
[gfx/style] Implement border-radius.
This patch is a first stab at implementing border-radius. It looks fine as long as the border isn't an ellipse (that might not even parse yet), and the border-widths around a border-radius are the same. Here's a cool screenshot!  r? @pcwalton @SimonSapin
This commit is contained in:
parent
9afdce4405
commit
ffcf0bf394
5 changed files with 436 additions and 85 deletions
|
@ -474,16 +474,33 @@ pub struct GradientDisplayItem {
|
|||
/// Renders a border.
|
||||
#[deriving(Clone)]
|
||||
pub struct BorderDisplayItem {
|
||||
/// Fields common to all display items.
|
||||
pub base: BaseDisplayItem,
|
||||
|
||||
/// The border widths
|
||||
pub border: SideOffsets2D<Au>,
|
||||
/// Border widths.
|
||||
pub border_widths: SideOffsets2D<Au>,
|
||||
|
||||
/// The border colors.
|
||||
/// Border colors.
|
||||
pub color: SideOffsets2D<Color>,
|
||||
|
||||
/// The border styles.
|
||||
pub style: SideOffsets2D<border_style::T>
|
||||
/// Border styles.
|
||||
pub style: SideOffsets2D<border_style::T>,
|
||||
|
||||
/// Border radii.
|
||||
///
|
||||
/// TODO(pcwalton): Elliptical radii.
|
||||
pub radius: BorderRadii<Au>,
|
||||
}
|
||||
|
||||
/// Information about the border radii.
|
||||
///
|
||||
/// TODO(pcwalton): Elliptical radii.
|
||||
#[deriving(Clone, Default, Show)]
|
||||
pub struct BorderRadii<T> {
|
||||
pub top_left: T,
|
||||
pub top_right: T,
|
||||
pub bottom_right: T,
|
||||
pub bottom_left: T,
|
||||
}
|
||||
|
||||
/// Renders a line segment.
|
||||
|
@ -565,7 +582,8 @@ impl DisplayItem {
|
|||
|
||||
BorderDisplayItemClass(ref border) => {
|
||||
render_context.draw_border(&border.base.bounds,
|
||||
border.border,
|
||||
border.border_widths,
|
||||
&border.radius,
|
||||
border.color,
|
||||
border.style)
|
||||
}
|
||||
|
@ -658,4 +676,3 @@ impl OpaqueNodeMethods for OpaqueNode {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue