Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement radial gradients #16385

Merged
merged 9 commits into from Apr 29, 2017
@@ -528,6 +528,7 @@ pub enum DisplayItem {
WebGL(Box<WebGLDisplayItem>),
Border(Box<BorderDisplayItem>),
Gradient(Box<GradientDisplayItem>),
RadialGradient(Box<RadialGradientDisplayItem>),
Line(Box<LineDisplayItem>),
BoxShadow(Box<BoxShadowDisplayItem>),
Iframe(Box<IframeDisplayItem>),
@@ -889,6 +890,9 @@ pub struct Gradient {

/// A list of color stops.
pub stops: Vec<GradientStop>,

/// True if gradient repeats infinitly.
pub repeating: bool,
}

#[derive(Clone, Deserialize, HeapSizeOf, Serialize)]
@@ -900,6 +904,31 @@ pub struct GradientDisplayItem {
pub gradient: Gradient,
}

/// Paints a radial gradient.
#[derive(Clone, Deserialize, HeapSizeOf, Serialize)]
pub struct RadialGradient {
/// The center point of the gradient.
pub center: Point2D<Au>,

/// The radius of the gradient with an x and an y component.
pub radius: Size2D<Au>,

/// A list of color stops.
pub stops: Vec<GradientStop>,

/// True if gradient repeats infinitly.
pub repeating: bool,
}

#[derive(Clone, Deserialize, HeapSizeOf, Serialize)]
pub struct RadialGradientDisplayItem {
/// Fields common to all display item.
pub base: BaseDisplayItem,

/// Contains all gradient data.
pub gradient: RadialGradient,
}

This comment has been minimized.

@emilio

emilio Apr 16, 2017

Member

nit: stray newline.

/// A normal border, supporting CSS border styles.
#[derive(Clone, HeapSizeOf, Deserialize, Serialize)]
pub struct NormalBorder {
@@ -1124,6 +1153,7 @@ impl DisplayItem {
DisplayItem::WebGL(ref webgl_item) => &webgl_item.base,
DisplayItem::Border(ref border) => &border.base,
DisplayItem::Gradient(ref gradient) => &gradient.base,
DisplayItem::RadialGradient(ref gradient) => &gradient.base,
DisplayItem::Line(ref line) => &line.base,
DisplayItem::BoxShadow(ref box_shadow) => &box_shadow.base,
DisplayItem::Iframe(ref iframe) => &iframe.base,
@@ -1241,6 +1271,7 @@ impl fmt::Debug for DisplayItem {
DisplayItem::WebGL(_) => "WebGL".to_owned(),
DisplayItem::Border(_) => "Border".to_owned(),
DisplayItem::Gradient(_) => "Gradient".to_owned(),
DisplayItem::RadialGradient(_) => "RadialGradient".to_owned(),
DisplayItem::Line(_) => "Line".to_owned(),
DisplayItem::BoxShadow(_) => "BoxShadow".to_owned(),
DisplayItem::Iframe(_) => "Iframe".to_owned(),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.