mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Part 1: Add SVG d property in CSS
Add d property for style system. d property only supports path() for now and it has the functional notation without fill rule. https://github.com/w3c/svgwg/issues/320#issuecomment-414462645 Differential Revision: https://phabricator.services.mozilla.com/D81237
This commit is contained in:
parent
4c7ddd63b3
commit
fa6ab91acd
6 changed files with 68 additions and 4 deletions
|
@ -63,7 +63,6 @@ COUNTED_UNKNOWN_PROPERTIES = [
|
||||||
"-webkit-text-combine",
|
"-webkit-text-combine",
|
||||||
"-webkit-text-emphasis-style",
|
"-webkit-text-emphasis-style",
|
||||||
"-webkit-text-emphasis",
|
"-webkit-text-emphasis",
|
||||||
"d",
|
|
||||||
"-webkit-mask-box-image-width",
|
"-webkit-mask-box-image-width",
|
||||||
"-webkit-mask-box-image-source",
|
"-webkit-mask-box-image-source",
|
||||||
"-webkit-mask-box-image-outset",
|
"-webkit-mask-box-image-outset",
|
||||||
|
|
|
@ -246,3 +246,13 @@ ${helpers.predefined_type(
|
||||||
animation_value_type="LengthPercentage",
|
animation_value_type="LengthPercentage",
|
||||||
spec="https://svgwg.org/svg2-draft/geometry.html#R",
|
spec="https://svgwg.org/svg2-draft/geometry.html#R",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
${helpers.predefined_type(
|
||||||
|
"d",
|
||||||
|
"DProperty",
|
||||||
|
"specified::DProperty::none()",
|
||||||
|
engines="gecko",
|
||||||
|
animation_value_type="ComputedValue",
|
||||||
|
gecko_pref="layout.css.d-property.enabled",
|
||||||
|
spec="https://svgwg.org/svg2-draft/paths.html#TheDProperty",
|
||||||
|
)}
|
||||||
|
|
|
@ -82,7 +82,7 @@ pub use self::position::{
|
||||||
pub use self::ratio::Ratio;
|
pub use self::ratio::Ratio;
|
||||||
pub use self::rect::NonNegativeLengthOrNumberRect;
|
pub use self::rect::NonNegativeLengthOrNumberRect;
|
||||||
pub use self::resolution::Resolution;
|
pub use self::resolution::Resolution;
|
||||||
pub use self::svg::MozContextProperties;
|
pub use self::svg::{DProperty, MozContextProperties};
|
||||||
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
|
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
|
||||||
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
|
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
|
||||||
pub use self::text::TextUnderlinePosition;
|
pub use self::text::TextUnderlinePosition;
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::values::generics::svg as generic;
|
||||||
use crate::values::RGBA;
|
use crate::values::RGBA;
|
||||||
use crate::Zero;
|
use crate::Zero;
|
||||||
|
|
||||||
pub use crate::values::specified::{MozContextProperties, SVGPaintOrder};
|
pub use crate::values::specified::{DProperty, MozContextProperties, SVGPaintOrder};
|
||||||
|
|
||||||
/// Computed SVG Paint value
|
/// Computed SVG Paint value
|
||||||
pub type SVGPaint = generic::GenericSVGPaint<Color, ComputedUrl>;
|
pub type SVGPaint = generic::GenericSVGPaint<Color, ComputedUrl>;
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub use self::position::{PositionComponent, ZIndex};
|
||||||
pub use self::ratio::Ratio;
|
pub use self::ratio::Ratio;
|
||||||
pub use self::rect::NonNegativeLengthOrNumberRect;
|
pub use self::rect::NonNegativeLengthOrNumberRect;
|
||||||
pub use self::resolution::Resolution;
|
pub use self::resolution::Resolution;
|
||||||
pub use self::svg::MozContextProperties;
|
pub use self::svg::{DProperty, MozContextProperties};
|
||||||
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint};
|
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint};
|
||||||
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
|
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
|
||||||
pub use self::svg_path::SVGPathData;
|
pub use self::svg_path::SVGPathData;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use crate::values::specified::color::Color;
|
||||||
use crate::values::specified::url::SpecifiedUrl;
|
use crate::values::specified::url::SpecifiedUrl;
|
||||||
use crate::values::specified::AllowQuirks;
|
use crate::values::specified::AllowQuirks;
|
||||||
use crate::values::specified::LengthPercentage;
|
use crate::values::specified::LengthPercentage;
|
||||||
|
use crate::values::specified::SVGPathData;
|
||||||
use crate::values::specified::{NonNegativeLengthPercentage, Opacity};
|
use crate::values::specified::{NonNegativeLengthPercentage, Opacity};
|
||||||
use crate::values::CustomIdent;
|
use crate::values::CustomIdent;
|
||||||
use cssparser::{Parser, Token};
|
use cssparser::{Parser, Token};
|
||||||
|
@ -334,3 +335,57 @@ impl Parse for MozContextProperties {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The svg d property type.
|
||||||
|
///
|
||||||
|
/// https://svgwg.org/svg2-draft/paths.html#TheDProperty
|
||||||
|
#[derive(
|
||||||
|
Animate,
|
||||||
|
Clone,
|
||||||
|
ComputeSquaredDistance,
|
||||||
|
Debug,
|
||||||
|
Deserialize,
|
||||||
|
MallocSizeOf,
|
||||||
|
PartialEq,
|
||||||
|
Serialize,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToAnimatedZero,
|
||||||
|
ToComputedValue,
|
||||||
|
ToCss,
|
||||||
|
ToResolvedValue,
|
||||||
|
ToShmem,
|
||||||
|
)]
|
||||||
|
#[repr(C, u8)]
|
||||||
|
pub enum DProperty {
|
||||||
|
/// Path value for path(<string>) or just a <string>.
|
||||||
|
#[css(function)]
|
||||||
|
Path(SVGPathData),
|
||||||
|
/// None value.
|
||||||
|
#[animation(error)]
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DProperty {
|
||||||
|
/// return none.
|
||||||
|
#[inline]
|
||||||
|
pub fn none() -> Self {
|
||||||
|
DProperty::None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parse for DProperty {
|
||||||
|
fn parse<'i, 't>(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>,
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
// Parse none.
|
||||||
|
if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
|
||||||
|
return Ok(DProperty::none());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse possible functions.
|
||||||
|
input.expect_function_matching("path")?;
|
||||||
|
let path_data = input.parse_nested_block(|i| SVGPathData::parse(context, i))?;
|
||||||
|
Ok(DProperty::Path(path_data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue