mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
style: Use cbindgen for fill and stroke.
Differential Revision: https://phabricator.services.mozilla.com/D36807
This commit is contained in:
parent
83da7c1535
commit
341023690c
5 changed files with 33 additions and 129 deletions
|
@ -9,6 +9,7 @@ use cssparser::Parser;
|
|||
use style_traits::ParseError;
|
||||
|
||||
/// The fallback of an SVG paint server value.
|
||||
/// cbindgen:derive-tagged-enum-copy-constructor=true
|
||||
#[derive(
|
||||
Animate,
|
||||
Clone,
|
||||
|
@ -25,7 +26,8 @@ use style_traits::ParseError;
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
pub enum SVGPaintFallback<C> {
|
||||
#[repr(C, u8)]
|
||||
pub enum GenericSVGPaintFallback<C> {
|
||||
/// The `none` keyword.
|
||||
None,
|
||||
/// A magic value that represents no fallback specified and serializes to
|
||||
|
@ -36,10 +38,14 @@ pub enum SVGPaintFallback<C> {
|
|||
Color(C),
|
||||
}
|
||||
|
||||
pub use self::GenericSVGPaintFallback as SVGPaintFallback;
|
||||
|
||||
/// An SVG paint value
|
||||
///
|
||||
/// <https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint>
|
||||
#[animation(no_bound(UrlPaintServer))]
|
||||
///
|
||||
/// cbindgen:derive-tagged-enum-copy-constructor=true
|
||||
#[animation(no_bound(Url))]
|
||||
#[derive(
|
||||
Animate,
|
||||
Clone,
|
||||
|
@ -55,13 +61,16 @@ pub enum SVGPaintFallback<C> {
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
pub struct SVGPaint<ColorType, UrlPaintServer> {
|
||||
#[repr(C)]
|
||||
pub struct GenericSVGPaint<Color, Url> {
|
||||
/// The paint source.
|
||||
pub kind: SVGPaintKind<ColorType, UrlPaintServer>,
|
||||
pub kind: GenericSVGPaintKind<Color, Url>,
|
||||
/// The fallback color.
|
||||
pub fallback: SVGPaintFallback<ColorType>,
|
||||
pub fallback: GenericSVGPaintFallback<Color>,
|
||||
}
|
||||
|
||||
pub use self::GenericSVGPaint as SVGPaint;
|
||||
|
||||
impl<C, U> Default for SVGPaint<C, U> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
@ -71,12 +80,13 @@ impl<C, U> Default for SVGPaint<C, U> {
|
|||
}
|
||||
}
|
||||
|
||||
/// An SVG paint value without the fallback
|
||||
/// An SVG paint value without the fallback.
|
||||
///
|
||||
/// Whereas the spec only allows PaintServer
|
||||
/// to have a fallback, Gecko lets the context
|
||||
/// properties have a fallback as well.
|
||||
#[animation(no_bound(UrlPaintServer))]
|
||||
/// Whereas the spec only allows PaintServer to have a fallback, Gecko lets the
|
||||
/// context properties have a fallback as well.
|
||||
///
|
||||
/// cbindgen:derive-tagged-enum-copy-constructor=true
|
||||
#[animation(no_bound(U))]
|
||||
#[derive(
|
||||
Animate,
|
||||
Clone,
|
||||
|
@ -93,22 +103,25 @@ impl<C, U> Default for SVGPaint<C, U> {
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
pub enum SVGPaintKind<ColorType, UrlPaintServer> {
|
||||
#[repr(C, u8)]
|
||||
pub enum GenericSVGPaintKind<C, U> {
|
||||
/// `none`
|
||||
#[animation(error)]
|
||||
None,
|
||||
/// `<color>`
|
||||
Color(ColorType),
|
||||
Color(C),
|
||||
/// `url(...)`
|
||||
#[animation(error)]
|
||||
PaintServer(UrlPaintServer),
|
||||
PaintServer(U),
|
||||
/// `context-fill`
|
||||
ContextFill,
|
||||
/// `context-stroke`
|
||||
ContextStroke,
|
||||
}
|
||||
|
||||
impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlPaintServer> {
|
||||
pub use self::GenericSVGPaintKind as SVGPaintKind;
|
||||
|
||||
impl<C: Parse, U: Parse> Parse for SVGPaint<C, U> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue