mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Use derive for -x-span.
This commit is contained in:
parent
156b371376
commit
b9f5388635
2 changed files with 24 additions and 17 deletions
|
@ -4,6 +4,24 @@
|
|||
|
||||
//! Various macro helpers.
|
||||
|
||||
macro_rules! trivial_to_computed_value {
|
||||
($name: ident) => {
|
||||
impl $crate::values::computed::ToComputedValue for $name {
|
||||
type ComputedValue = $name;
|
||||
|
||||
fn to_computed_value(&self, _: &$crate::values::computed::Context) -> Self {
|
||||
self.clone()
|
||||
}
|
||||
|
||||
fn from_computed_value(other: &Self) -> Self {
|
||||
other.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trivial_to_computed_value!(i32);
|
||||
|
||||
/// A macro to parse an identifier, or return an `UnexpectedIndent` error
|
||||
/// otherwise.
|
||||
///
|
||||
|
@ -76,17 +94,7 @@ macro_rules! add_impls_for_keyword_enum {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::values::computed::ToComputedValue for $name {
|
||||
type ComputedValue = $name;
|
||||
|
||||
fn to_computed_value(&self, _: &$crate::values::computed::Context) -> Self {
|
||||
self.clone()
|
||||
}
|
||||
|
||||
fn from_computed_value(other: &Self) -> Self {
|
||||
other.clone()
|
||||
}
|
||||
}
|
||||
trivial_to_computed_value!($name);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -14,15 +14,12 @@ ${helpers.single_keyword("table-layout", "auto fixed",
|
|||
spec="Internal-only (for `<col span>` pres attr)"
|
||||
animation_value_type="none"
|
||||
internal="True">
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
pub type SpecifiedValue = computed_value::T;
|
||||
pub mod computed_value {
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct T(pub i32);
|
||||
|
||||
|
@ -39,8 +36,10 @@ ${helpers.single_keyword("table-layout", "auto fixed",
|
|||
}
|
||||
|
||||
// never parse it, only set via presentation attribute
|
||||
fn parse<'i, 't>(_: &ParserContext, _: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
_: &ParserContext,
|
||||
_: &mut Parser<'i, 't>,
|
||||
) -> Result<SpecifiedValue, ParseError<'i>> {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue