mirror of
https://github.com/servo/servo.git
synced 2025-07-03 13:33:39 +01:00
Derive ToCss for all vector longhands that cannot be empty
We don't need to check for emptiness and write `none` for them.
This commit is contained in:
parent
31036d6510
commit
247bcbbbd6
1 changed files with 24 additions and 10 deletions
|
@ -83,8 +83,10 @@
|
||||||
need_animatable=need_animatable, **kwargs)">
|
need_animatable=need_animatable, **kwargs)">
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
% if allow_empty:
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, Separator, ToCss};
|
use style_traits::{CssWriter, Separator, ToCss};
|
||||||
|
% endif
|
||||||
|
|
||||||
pub mod single_value {
|
pub mod single_value {
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
@ -122,6 +124,14 @@
|
||||||
% if need_animatable or animation_value_type == "ComputedValue":
|
% if need_animatable or animation_value_type == "ComputedValue":
|
||||||
#[derive(Animate, ComputeSquaredDistance)]
|
#[derive(Animate, ComputeSquaredDistance)]
|
||||||
% endif
|
% endif
|
||||||
|
% if not allow_empty:
|
||||||
|
% if separator == "Comma":
|
||||||
|
#[css(comma, iterable)]
|
||||||
|
% else:
|
||||||
|
#[css(iterable)]
|
||||||
|
% endif
|
||||||
|
#[derive(ToCss)]
|
||||||
|
% endif
|
||||||
pub struct T(
|
pub struct T(
|
||||||
% if allow_empty and allow_empty != "NotInitial":
|
% if allow_empty and allow_empty != "NotInitial":
|
||||||
pub Vec<single_value::T>,
|
pub Vec<single_value::T>,
|
||||||
|
@ -154,6 +164,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
% if allow_empty:
|
||||||
impl ToCss for computed_value::T {
|
impl ToCss for computed_value::T {
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||||
where
|
where
|
||||||
|
@ -163,11 +174,7 @@
|
||||||
if let Some(val) = iter.next() {
|
if let Some(val) = iter.next() {
|
||||||
val.to_css(dest)?;
|
val.to_css(dest)?;
|
||||||
} else {
|
} else {
|
||||||
% if allow_empty:
|
return dest.write_str("none");
|
||||||
dest.write_str("none")?;
|
|
||||||
% else:
|
|
||||||
warn!("Found empty value for property ${name}");
|
|
||||||
% endif
|
|
||||||
}
|
}
|
||||||
for i in iter {
|
for i in iter {
|
||||||
dest.write_str(::style_traits::${separator}::separator())?;
|
dest.write_str(::style_traits::${separator}::separator())?;
|
||||||
|
@ -176,11 +183,21 @@
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
/// The specified value of ${name}.
|
/// The specified value of ${name}.
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||||
|
% if not allow_empty:
|
||||||
|
% if separator == "Comma":
|
||||||
|
#[css(comma, iterable)]
|
||||||
|
% else:
|
||||||
|
#[css(iterable)]
|
||||||
|
% endif
|
||||||
|
#[derive(ToCss)]
|
||||||
|
% endif
|
||||||
pub struct SpecifiedValue(pub Vec<single_value::SpecifiedValue>);
|
pub struct SpecifiedValue(pub Vec<single_value::SpecifiedValue>);
|
||||||
|
|
||||||
|
% if allow_empty:
|
||||||
impl ToCss for SpecifiedValue {
|
impl ToCss for SpecifiedValue {
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||||
where
|
where
|
||||||
|
@ -190,11 +207,7 @@
|
||||||
if let Some(val) = iter.next() {
|
if let Some(val) = iter.next() {
|
||||||
val.to_css(dest)?;
|
val.to_css(dest)?;
|
||||||
} else {
|
} else {
|
||||||
% if allow_empty:
|
return dest.write_str("none");
|
||||||
dest.write_str("none")?;
|
|
||||||
% else:
|
|
||||||
warn!("Found empty value for property ${name}");
|
|
||||||
% endif
|
|
||||||
}
|
}
|
||||||
for i in iter {
|
for i in iter {
|
||||||
dest.write_str(::style_traits::${separator}::separator())?;
|
dest.write_str(::style_traits::${separator}::separator())?;
|
||||||
|
@ -203,6 +216,7 @@
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
pub fn get_initial_value() -> computed_value::T {
|
||||||
% if allow_empty and allow_empty != "NotInitial":
|
% if allow_empty and allow_empty != "NotInitial":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue