Make ShapeSource generic

This commit is contained in:
Ravi Shankar 2017-04-17 22:34:15 +05:30
parent 24226af794
commit d56aec4109
7 changed files with 128 additions and 204 deletions

View file

@ -3564,12 +3564,12 @@ fn static_assert() {
<%def name="impl_shape_source(ident, gecko_ffi_name)">
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
use gecko_bindings::bindings::{Gecko_NewBasicShape, Gecko_DestroyShapeSource};
use gecko_bindings::structs::StyleGeometryBox;
use gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType, StyleShapeSourceType};
use gecko_bindings::structs::{StyleFillRule, StyleShapeSource};
use gecko_bindings::structs::{StyleFillRule, StyleGeometryBox, StyleShapeSource};
use gecko::conversions::basic_shape::set_corners_from_radius;
use gecko::values::GeckoStyleCoordConvertible;
use values::computed::basic_shape::*;
use values::computed::basic_shape::BasicShape;
use values::generics::basic_shape::{ShapeSource, FillRule};
let ref mut ${ident} = self.gecko.${gecko_ffi_name};
// clean up existing struct
unsafe { Gecko_DestroyShapeSource(${ident}) };
@ -3579,7 +3579,7 @@ fn static_assert() {
match v {
ShapeSource::Url(ref url) => {
unsafe {
bindings::Gecko_StyleShapeSource_SetURLValue(${ident}, url.for_ffi());
bindings::Gecko_StyleShapeSource_SetURLValue(${ident}, url.for_ffi())
}
}
ShapeSource::None => {} // don't change the type

View file

@ -248,7 +248,7 @@
use properties::style_structs;
use std::sync::Arc;
use values::computed::{Context, ToComputedValue};
use values::{computed, specified};
use values::{computed, generics, specified};
use Atom;
${caller.body()}
#[allow(unused_variables)]

View file

@ -2462,29 +2462,8 @@ ${helpers.single_keyword("-moz-orient",
}
</%helpers:longhand>
<%helpers:longhand name="shape-outside" products="gecko" animation_value_type="none" boxed="True"
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property">
use std::fmt;
use style_traits::ToCss;
use values::specified::basic_shape::{ShapeBox, ShapeSource};
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue);
pub mod computed_value {
use values::computed::basic_shape::{ShapeBox, ShapeSource};
pub type T = ShapeSource<ShapeBox>;
}
pub type SpecifiedValue = ShapeSource<ShapeBox>;
#[inline]
pub fn get_initial_value() -> computed_value::T {
Default::default()
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
ShapeSource::parse(context, input)
}
</%helpers:longhand>
${helpers.predefined_type("shape-outside", "basic_shape::ShapeWithShapeBox",
"generics::basic_shape::ShapeSource::None",
products="gecko", boxed="True",
animation_value_type="none",
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property")}

View file

@ -58,34 +58,11 @@ ${helpers.single_keyword("mask-type", "luminance alpha",
products="gecko", animation_value_type="none",
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-type")}
<%helpers:longhand name="clip-path" animation_value_type="none" products="gecko" boxed="True"
flags="CREATES_STACKING_CONTEXT"
spec="https://drafts.fxtf.org/css-masking/#propdef-clip-path">
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::basic_shape::{ShapeSource, GeometryBox};
pub mod computed_value {
use app_units::Au;
use values::computed::basic_shape::{ShapeSource, GeometryBox};
pub type T = ShapeSource<GeometryBox>;
}
pub type SpecifiedValue = ShapeSource<GeometryBox>;
#[inline]
pub fn get_initial_value() -> computed_value::T {
Default::default()
}
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
ShapeSource::parse(context, input)
}
no_viewport_percentage!(SpecifiedValue);
</%helpers:longhand>
${helpers.predefined_type("clip-path", "basic_shape::ShapeWithGeometryBox",
"generics::basic_shape::ShapeSource::None",
products="gecko", boxed="True",
animation_value_type="none", flags="CREATES_STACKING_CONTEXT",
spec="https://drafts.fxtf.org/css-masking/#propdef-clip-path")}
${helpers.single_keyword("mask-mode",
"match-source alpha luminance",