mirror of
https://github.com/servo/servo.git
synced 2025-08-18 20:05:34 +01:00
style: Update align-self / justify-self to the spec too.
MozReview-Commit-ID: 8JKF5ucCbYm
This commit is contained in:
parent
4c773a1424
commit
8d7a3f4f3d
6 changed files with 192 additions and 133 deletions
|
@ -138,15 +138,15 @@ ${helpers.predefined_type("flex-shrink", "NonNegativeNumber",
|
|||
animation_value_type="discrete")}
|
||||
% else:
|
||||
${helpers.predefined_type(name="align-self",
|
||||
type="SelfAlignment",
|
||||
initial_value="specified::SelfAlignment::auto()",
|
||||
type="AlignSelf",
|
||||
initial_value="specified::AlignSelf(specified::SelfAlignment::auto())",
|
||||
spec="https://drafts.csswg.org/css-align/#align-self-property",
|
||||
extra_prefixes="webkit",
|
||||
animation_value_type="discrete")}
|
||||
|
||||
${helpers.predefined_type(name="justify-self",
|
||||
type="SelfAlignment",
|
||||
initial_value="specified::SelfAlignment::auto()",
|
||||
type="JustifySelf",
|
||||
initial_value="specified::JustifySelf(specified::SelfAlignment::auto())",
|
||||
spec="https://drafts.csswg.org/css-align/#justify-self-property",
|
||||
animation_value_type="discrete")}
|
||||
|
||||
|
|
|
@ -664,35 +664,43 @@
|
|||
<%helpers:shorthand name="place-self" sub_properties="align-self justify-self"
|
||||
spec="https://drafts.csswg.org/css-align/#place-self-property"
|
||||
products="gecko">
|
||||
use values::specified::align::SelfAlignment;
|
||||
use parser::Parse;
|
||||
use values::specified::align::{AlignSelf, JustifySelf, SelfAlignment, AxisDirection};
|
||||
|
||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Longhands, ParseError<'i>> {
|
||||
let align = SelfAlignment::parse(context, input)?;
|
||||
if align.has_extra_flags() {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
let justify = input.try(|input| SelfAlignment::parse(context, input)).unwrap_or(align.clone());
|
||||
if justify.has_extra_flags() {
|
||||
pub fn parse_value<'i, 't>(
|
||||
_: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let align = SelfAlignment::parse(input, AxisDirection::Block)?;
|
||||
let justify = input.try(|input| SelfAlignment::parse(input, AxisDirection::Inline));
|
||||
|
||||
let justify = match justify {
|
||||
Ok(v) => v,
|
||||
Err(err) => {
|
||||
if !align.is_valid_on_both_axes() {
|
||||
return Err(err);
|
||||
}
|
||||
align
|
||||
}
|
||||
};
|
||||
|
||||
if justify.has_extra_flags() || align.has_extra_flags() {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
||||
Ok(expanded! {
|
||||
align_self: align,
|
||||
justify_self: justify,
|
||||
align_self: AlignSelf(align),
|
||||
justify_self: JustifySelf(justify),
|
||||
})
|
||||
}
|
||||
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
if self.align_self == self.justify_self {
|
||||
self.align_self.to_css(dest)
|
||||
} else {
|
||||
self.align_self.to_css(dest)?;
|
||||
self.align_self.to_css(dest)?;
|
||||
if self.align_self.0 != self.justify_self.0 {
|
||||
dest.write_str(" ")?;
|
||||
self.justify_self.to_css(dest)
|
||||
self.justify_self.to_css(dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue