mirror of
https://github.com/servo/servo.git
synced 2025-08-16 02:45: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
|
@ -523,110 +523,6 @@ def set_gecko_property(ffi_name, expr):
|
|||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_svg_paint(ident, gecko_ffi_name)">
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
use crate::values::generics::svg::{SVGPaintKind, SVGPaintFallback};
|
||||
use self::structs::nsStyleSVGPaintType;
|
||||
use self::structs::nsStyleSVGFallbackType;
|
||||
|
||||
let ref mut paint = ${get_gecko_property(gecko_ffi_name)};
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleSVGPaint_Reset(paint);
|
||||
}
|
||||
match v.kind {
|
||||
SVGPaintKind::None => return,
|
||||
SVGPaintKind::ContextFill => {
|
||||
paint.mType = nsStyleSVGPaintType::eStyleSVGPaintType_ContextFill;
|
||||
}
|
||||
SVGPaintKind::ContextStroke => {
|
||||
paint.mType = nsStyleSVGPaintType::eStyleSVGPaintType_ContextStroke;
|
||||
}
|
||||
SVGPaintKind::PaintServer(url) => {
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleSVGPaint_SetURLValue(
|
||||
paint,
|
||||
&url
|
||||
)
|
||||
}
|
||||
}
|
||||
SVGPaintKind::Color(color) => {
|
||||
paint.mType = nsStyleSVGPaintType::eStyleSVGPaintType_Color;
|
||||
unsafe {
|
||||
*paint.mPaint.mColor.as_mut() = color.into();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
paint.mFallbackType = match v.fallback {
|
||||
SVGPaintFallback::Color(c) => {
|
||||
paint.mFallbackColor = c.into();
|
||||
nsStyleSVGFallbackType::eStyleSVGFallbackType_Color
|
||||
},
|
||||
SVGPaintFallback::None => {
|
||||
nsStyleSVGFallbackType::eStyleSVGFallbackType_None
|
||||
},
|
||||
SVGPaintFallback::Unset => {
|
||||
nsStyleSVGFallbackType::eStyleSVGFallbackType_NotSet
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn copy_${ident}_from(&mut self, other: &Self) {
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleSVGPaint_CopyFrom(
|
||||
&mut ${get_gecko_property(gecko_ffi_name)},
|
||||
& ${get_gecko_property(gecko_ffi_name, "other")}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn reset_${ident}(&mut self, other: &Self) {
|
||||
self.copy_${ident}_from(other)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||
use crate::values::generics::svg::{SVGPaint, SVGPaintKind, SVGPaintFallback};
|
||||
use self::structs::nsStyleSVGPaintType;
|
||||
use self::structs::nsStyleSVGFallbackType;
|
||||
let ref paint = ${get_gecko_property(gecko_ffi_name)};
|
||||
|
||||
let fallback = match paint.mFallbackType {
|
||||
nsStyleSVGFallbackType::eStyleSVGFallbackType_Color => {
|
||||
SVGPaintFallback::Color(paint.mFallbackColor.into())
|
||||
},
|
||||
nsStyleSVGFallbackType::eStyleSVGFallbackType_None => {
|
||||
SVGPaintFallback::None
|
||||
},
|
||||
nsStyleSVGFallbackType::eStyleSVGFallbackType_NotSet => {
|
||||
SVGPaintFallback::Unset
|
||||
}
|
||||
};
|
||||
|
||||
let kind = match paint.mType {
|
||||
nsStyleSVGPaintType::eStyleSVGPaintType_None => SVGPaintKind::None,
|
||||
nsStyleSVGPaintType::eStyleSVGPaintType_ContextFill => SVGPaintKind::ContextFill,
|
||||
nsStyleSVGPaintType::eStyleSVGPaintType_ContextStroke => SVGPaintKind::ContextStroke,
|
||||
nsStyleSVGPaintType::eStyleSVGPaintType_Server => {
|
||||
SVGPaintKind::PaintServer(unsafe {
|
||||
paint.mPaint.mPaintServer.as_ref().clone()
|
||||
})
|
||||
}
|
||||
nsStyleSVGPaintType::eStyleSVGPaintType_Color => {
|
||||
let col = unsafe { *paint.mPaint.mColor.as_ref() };
|
||||
SVGPaintKind::Color(col.into())
|
||||
}
|
||||
};
|
||||
SVGPaint {
|
||||
kind: kind,
|
||||
fallback: fallback,
|
||||
}
|
||||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_non_negative_length(ident, gecko_ffi_name, inherit_from=None,
|
||||
round_to_pixels=False)">
|
||||
#[allow(non_snake_case)]
|
||||
|
@ -836,7 +732,6 @@ impl Clone for ${style_struct.gecko_struct_name} {
|
|||
"MozScriptMinSize": impl_absolute_length,
|
||||
"SVGLength": impl_svg_length,
|
||||
"SVGOpacity": impl_svg_opacity,
|
||||
"SVGPaint": impl_svg_paint,
|
||||
"SVGWidth": impl_svg_length,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue