[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!

![](https://www.dropbox.com/s/gdtmgjrlnf82gzz/Screenshot%202014-11-12%2018.03.29.png?dl=0)

r? @pcwalton @SimonSapin
This commit is contained in:
Clark Gaebel 2014-11-12 18:06:50 -08:00
parent 9afdce4405
commit ffcf0bf394
5 changed files with 436 additions and 85 deletions

View file

@ -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 {
}
}
}