Add support for most of the border-image properties, pass to WR.

This adds support for:
 * border-image (images, not gradients yet)
 * border-image-source
 * border-image-slice
 * border-image-repeat (stretch + repeat only for now)

Remaining work:
 * Connect border-image-outset (WR supports this).
 * border-image-width
This commit is contained in:
Glenn Watson 2017-02-17 15:42:18 +10:00
parent 854d720b21
commit ffcb319324
17 changed files with 231 additions and 107 deletions

View file

@ -891,15 +891,9 @@ pub struct GradientDisplayItem {
pub stops: Vec<GradientStop>,
}
/// Paints a border.
/// A normal border, supporting CSS border styles.
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
pub struct BorderDisplayItem {
/// Fields common to all display items.
pub base: BaseDisplayItem,
/// Border widths.
pub border_widths: SideOffsets2D<Au>,
pub struct NormalBorder {
/// Border colors.
pub color: SideOffsets2D<ColorF>,
@ -912,6 +906,50 @@ pub struct BorderDisplayItem {
pub radius: BorderRadii<Au>,
}
/// A border that is made of image segments.
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
pub struct ImageBorder {
/// The image this border uses, border-image-source.
pub image: WebRenderImageInfo,
/// How to slice the image, as per border-image-slice.
pub slice: SideOffsets2D<u32>,
/// Outsets for the border, as per border-image-outset.
pub outset: SideOffsets2D<f32>,
/// If fill is true, draw the center patch of the image.
pub fill: bool,
/// How to repeat or stretch horizontal edges (border-image-repeat).
#[ignore_heap_size_of = "WebRender traits type, and tiny"]
pub repeat_horizontal: webrender_traits::RepeatMode,
/// How to repeat or stretch vertical edges (border-image-repeat).
#[ignore_heap_size_of = "WebRender traits type, and tiny"]
pub repeat_vertical: webrender_traits::RepeatMode,
}
/// Specifies the type of border
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
pub enum BorderDetails {
Normal(NormalBorder),
Image(ImageBorder),
}
/// Paints a border.
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
pub struct BorderDisplayItem {
/// Fields common to all display items.
pub base: BaseDisplayItem,
/// Border widths.
pub border_widths: SideOffsets2D<Au>,
/// Details for specific border type
pub details: BorderDetails,
}
/// Information about the border radii.
///
/// TODO(pcwalton): Elliptical radii.