style: Change order of container shorthand

Since the initial value of container-type is an open issue [1],
I'm leaving that as-is for now.

[1] https://github.com/w3c/csswg-drafts/issues/7202

Differential Revision: https://phabricator.services.mozilla.com/D147338
This commit is contained in:
Oriol Brufau 2023-08-14 23:58:31 +02:00 committed by Martin Robinson
parent d51bd1ee46
commit 1cb9396455

View file

@ -36,7 +36,7 @@ ${helpers.two_properties_shorthand(
<%helpers:shorthand <%helpers:shorthand
engines="gecko" engines="gecko"
name="container" name="container"
sub_properties="container-type container-name" sub_properties="container-name container-type"
gecko_pref="layout.css.container-queries.enabled", gecko_pref="layout.css.container-queries.enabled",
spec="https://drafts.csswg.org/css-contain-3/#container-shorthand" spec="https://drafts.csswg.org/css-contain-3/#container-shorthand"
> >
@ -48,24 +48,24 @@ ${helpers.two_properties_shorthand(
use crate::values::specified::box_::{ContainerName, ContainerType}; use crate::values::specified::box_::{ContainerName, ContainerType};
// See https://github.com/w3c/csswg-drafts/issues/7180 for why we don't // See https://github.com/w3c/csswg-drafts/issues/7180 for why we don't
// match the spec. // match the spec.
let container_type = ContainerType::parse(context, input)?; let container_name = ContainerName::parse(context, input)?;
let container_name = if input.try_parse(|input| input.expect_delim('/')).is_ok() { let container_type = if input.try_parse(|input| input.expect_delim('/')).is_ok() {
ContainerName::parse(context, input)? ContainerType::parse(context, input)?
} else { } else {
ContainerName::none() ContainerType::NONE
}; };
Ok(expanded! { Ok(expanded! {
container_type: container_type,
container_name: container_name, container_name: container_name,
container_type: container_type,
}) })
} }
impl<'a> ToCss for LonghandsToSerialize<'a> { impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
self.container_type.to_css(dest)?;
if !self.container_name.is_none() {
dest.write_str(" / ")?;
self.container_name.to_css(dest)?; self.container_name.to_css(dest)?;
if !self.container_type.is_empty() {
dest.write_str(" / ")?;
self.container_type.to_css(dest)?;
} }
Ok(()) Ok(())
} }