mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Properly fail to serialize grid shorthand when not roundtripping
Other browsers also don't roundtrip properly, but they fail less severely. Differential Revision: https://phabricator.services.mozilla.com/D152794
This commit is contained in:
parent
59da4326fd
commit
f1e04f76f0
1 changed files with 39 additions and 32 deletions
|
@ -621,7 +621,6 @@
|
||||||
impl<'a> LonghandsToSerialize<'a> {
|
impl<'a> LonghandsToSerialize<'a> {
|
||||||
/// Returns true if other sub properties except template-{rows,columns} are initial.
|
/// Returns true if other sub properties except template-{rows,columns} are initial.
|
||||||
fn is_grid_template(&self) -> bool {
|
fn is_grid_template(&self) -> bool {
|
||||||
*self.grid_template_areas == GridTemplateAreas::None &&
|
|
||||||
self.grid_auto_rows.is_initial() &&
|
self.grid_auto_rows.is_initial() &&
|
||||||
self.grid_auto_columns.is_initial() &&
|
self.grid_auto_columns.is_initial() &&
|
||||||
*self.grid_auto_flow == grid_auto_flow::get_initial_value()
|
*self.grid_auto_flow == grid_auto_flow::get_initial_value()
|
||||||
|
@ -630,13 +629,19 @@
|
||||||
|
|
||||||
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 {
|
||||||
if *self.grid_template_areas != GridTemplateAreas::None ||
|
if self.is_grid_template() {
|
||||||
(!self.grid_template_rows.is_initial() &&
|
return super::grid_template::serialize_grid_template(
|
||||||
!self.grid_template_columns.is_initial()) ||
|
self.grid_template_rows,
|
||||||
self.is_grid_template() {
|
|
||||||
return super::grid_template::serialize_grid_template(self.grid_template_rows,
|
|
||||||
self.grid_template_columns,
|
self.grid_template_columns,
|
||||||
self.grid_template_areas, dest);
|
self.grid_template_areas,
|
||||||
|
dest
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if *self.grid_template_areas != GridTemplateAreas::None {
|
||||||
|
// No other syntax can set the template areas, so fail to
|
||||||
|
// serialize.
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.grid_auto_flow.contains(GridAutoFlow::COLUMN) {
|
if self.grid_auto_flow.contains(GridAutoFlow::COLUMN) {
|
||||||
|
@ -663,7 +668,10 @@
|
||||||
dest.write_str(" ")?;
|
dest.write_str(" ")?;
|
||||||
self.grid_auto_columns.to_css(dest)?;
|
self.grid_auto_columns.to_css(dest)?;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
// It should fail to serialize if other branch of the if condition's values are set.
|
// It should fail to serialize if other branch of the if condition's values are set.
|
||||||
if !self.grid_auto_columns.is_initial() ||
|
if !self.grid_auto_columns.is_initial() ||
|
||||||
!self.grid_template_rows.is_initial() {
|
!self.grid_template_rows.is_initial() {
|
||||||
|
@ -689,7 +697,6 @@
|
||||||
|
|
||||||
dest.write_str(" / ")?;
|
dest.write_str(" / ")?;
|
||||||
self.grid_template_columns.to_css(dest)?;
|
self.grid_template_columns.to_css(dest)?;
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue