mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Make stroke-dasharray accept context-value.
This commit is contained in:
parent
aa80859a71
commit
7827ca6bb5
8 changed files with 143 additions and 23 deletions
|
@ -4981,27 +4981,41 @@ clip-path
|
|||
|
||||
${impl_simple_copy('paint_order', 'mPaintOrder')}
|
||||
|
||||
pub fn set_stroke_dasharray<I>(&mut self, v: I)
|
||||
where I: IntoIterator<Item = longhands::stroke_dasharray::computed_value::single_value::T>,
|
||||
I::IntoIter: ExactSizeIterator
|
||||
{
|
||||
let v = v.into_iter();
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleSVG_SetDashArrayLength(&mut self.gecko, v.len() as u32);
|
||||
}
|
||||
pub fn set_stroke_dasharray(&mut self, v: longhands::stroke_dasharray::computed_value::T) {
|
||||
use gecko_bindings::structs::nsStyleSVG_STROKE_DASHARRAY_CONTEXT as CONTEXT_VALUE;
|
||||
use values::generics::svg::SVGStrokeDashArray;
|
||||
|
||||
for (mut gecko, servo) in self.gecko.mStrokeDasharray.iter_mut().zip(v) {
|
||||
match servo {
|
||||
Either::First(number) => gecko.set_value(CoordDataValue::Factor(number)),
|
||||
Either::Second(lop) => gecko.set(lop),
|
||||
match v {
|
||||
SVGStrokeDashArray::Values(v) => {
|
||||
let v = v.into_iter();
|
||||
self.gecko.mContextFlags &= !CONTEXT_VALUE;
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleSVG_SetDashArrayLength(&mut self.gecko, v.len() as u32);
|
||||
}
|
||||
for (mut gecko, servo) in self.gecko.mStrokeDasharray.iter_mut().zip(v) {
|
||||
match servo {
|
||||
Either::First(number) => gecko.set_value(CoordDataValue::Factor(number)),
|
||||
Either::Second(lop) => gecko.set(lop),
|
||||
}
|
||||
}
|
||||
}
|
||||
SVGStrokeDashArray::ContextValue => {
|
||||
self.gecko.mContextFlags |= CONTEXT_VALUE;
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleSVG_SetDashArrayLength(&mut self.gecko, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_stroke_dasharray_from(&mut self, other: &Self) {
|
||||
use gecko_bindings::structs::nsStyleSVG_STROKE_DASHARRAY_CONTEXT as CONTEXT_VALUE;
|
||||
unsafe {
|
||||
bindings::Gecko_nsStyleSVG_CopyDashArray(&mut self.gecko, &other.gecko);
|
||||
}
|
||||
self.gecko.mContextFlags =
|
||||
(self.gecko.mContextFlags & !CONTEXT_VALUE) |
|
||||
(other.gecko.mContextFlags & CONTEXT_VALUE);
|
||||
}
|
||||
|
||||
pub fn reset_stroke_dasharray(&mut self, other: &Self) {
|
||||
|
@ -5009,8 +5023,14 @@ clip-path
|
|||
}
|
||||
|
||||
pub fn clone_stroke_dasharray(&self) -> longhands::stroke_dasharray::computed_value::T {
|
||||
use gecko_bindings::structs::nsStyleSVG_STROKE_DASHARRAY_CONTEXT as CONTEXT_VALUE;
|
||||
use values::computed::LengthOrPercentage;
|
||||
use values::generics::svg::SVGStrokeDashArray;
|
||||
|
||||
if self.gecko.mContextFlags & CONTEXT_VALUE != 0 {
|
||||
debug_assert_eq!(self.gecko.mStrokeDasharray.len(), 0);
|
||||
return SVGStrokeDashArray::ContextValue;
|
||||
}
|
||||
let mut vec = vec![];
|
||||
for gecko in self.gecko.mStrokeDasharray.iter() {
|
||||
match gecko.as_value() {
|
||||
|
@ -5024,7 +5044,7 @@ clip-path
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
longhands::stroke_dasharray::computed_value::T(vec)
|
||||
SVGStrokeDashArray::Values(vec)
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue