diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index b40fb81bcb4..64a729dad5c 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2188,10 +2188,10 @@ fn static_assert() { let mut refptr = unsafe { UniqueRefPtr::from_addrefed( - Gecko_NewGridTemplateAreasValue(v.areas.len() as u32, v.strings.len() as u32, v.width)) + Gecko_NewGridTemplateAreasValue(v.0.areas.len() as u32, v.0.strings.len() as u32, v.0.width)) }; - for (servo, gecko) in v.areas.into_iter().zip(refptr.mNamedAreas.iter_mut()) { + for (servo, gecko) in v.0.areas.into_iter().zip(refptr.mNamedAreas.iter_mut()) { gecko.mName.assign_utf8(&*servo.name); gecko.mColumnStart = servo.columns.start; gecko.mColumnEnd = servo.columns.end; @@ -2199,7 +2199,7 @@ fn static_assert() { gecko.mRowEnd = servo.rows.end; } - for (servo, gecko) in v.strings.into_iter().zip(refptr.mTemplates.iter_mut()) { + for (servo, gecko) in v.0.strings.into_iter().zip(refptr.mTemplates.iter_mut()) { gecko.assign_utf8(&*servo); } @@ -2217,7 +2217,7 @@ fn static_assert() { pub fn clone_grid_template_areas(&self) -> values::computed::position::GridTemplateAreas { use std::ops::Range; use values::None_; - use values::specified::position::{NamedArea, TemplateAreas}; + use values::specified::position::{NamedArea, TemplateAreas, TemplateAreasArc}; if self.gecko.mGridTemplateAreas.mRawPtr.is_null() { return Either::Second(None_); @@ -2253,7 +2253,7 @@ fn static_assert() { (*gecko_grid_template_areas).mNColumns }; - Either::First(TemplateAreas{ areas, strings, width }) + Either::First(TemplateAreasArc(Arc::new(TemplateAreas{ areas, strings, width }))) } diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 1dc697bd201..cfc54d2d00c 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -301,5 +301,5 @@ ${helpers.predefined_type("grid-template-areas", initial_value="computed::GridTemplateAreas::none()", products="gecko", animation_value_type="discrete", - boxed=True, + gecko_pref="layout.css.grid.enabled", spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas")} diff --git a/components/style/properties/shorthand/position.mako.rs b/components/style/properties/shorthand/position.mako.rs index 340fdaddbce..53e4edbc500 100644 --- a/components/style/properties/shorthand/position.mako.rs +++ b/components/style/properties/shorthand/position.mako.rs @@ -242,18 +242,19 @@ spec="https://drafts.csswg.org/css-grid/#propdef-grid-template" products="gecko"> use parser::Parse; + use servo_arc::Arc; use values::{Either, None_}; use values::generics::grid::{LineNameList, TrackSize, TrackList, TrackListType}; use values::generics::grid::{TrackListValue, concat_serialize_idents}; use values::specified::{GridTemplateComponent, GenericGridTemplateComponent}; use values::specified::grid::parse_line_names; - use values::specified::position::TemplateAreas; + use values::specified::position::{TemplateAreas, TemplateAreasArc}; /// Parsing for `` shorthand (also used by `grid` shorthand). pub fn parse_grid_template<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<(GridTemplateComponent, GridTemplateComponent, - Either), ParseError<'i>> { + Either), ParseError<'i>> { // Other shorthand sub properties also parse `none` and `subgrid` keywords and this // shorthand should know after these keywords there is nothing to parse. Otherwise it // gets confused and rejects the sub properties that contains `none` or `subgrid`. @@ -332,7 +333,7 @@ }; Ok((GenericGridTemplateComponent::TrackList(template_rows), - template_cols, Either::First(template_areas))) + template_cols, Either::First(TemplateAreasArc(Arc::new(template_areas))))) } else { let mut template_rows = GridTemplateComponent::parse(context, input)?; if let GenericGridTemplateComponent::TrackList(ref mut list) = template_rows { @@ -365,7 +366,7 @@ pub fn serialize_grid_template( template_rows: &GridTemplateComponent, template_columns: &GridTemplateComponent, - template_areas: &Either, + template_areas: &Either, dest: &mut CssWriter, ) -> fmt::Result where @@ -378,7 +379,7 @@ }, Either::First(ref areas) => { // The length of template-area and template-rows values should be equal. - if areas.strings.len() != template_rows.track_list_len() { + if areas.0.strings.len() != template_rows.track_list_len() { return Ok(()); } @@ -423,7 +424,7 @@ } let mut names_iter = track_list.line_names.iter(); - for (((i, string), names), value) in areas.strings.iter().enumerate() + for (((i, string), names), value) in areas.0.strings.iter().enumerate() .zip(&mut names_iter) .zip(track_list.values.iter()) { if i > 0 { @@ -456,8 +457,12 @@ impl<'a> ToCss for LonghandsToSerialize<'a> { #[inline] fn to_css(&self, dest: &mut CssWriter) -> fmt::Result where W: fmt::Write { - serialize_grid_template(self.grid_template_rows, self.grid_template_columns, - self.grid_template_areas, dest) + serialize_grid_template( + self.grid_template_rows, + self.grid_template_columns, + self.grid_template_areas, + dest + ) } } diff --git a/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index e20dafed010..bd585af690d 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -11,6 +11,7 @@ use cssparser::Parser; use hash::FnvHashMap; use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; +use servo_arc::Arc; use std::fmt::{self, Write}; use std::ops::Range; use str::HTML_SPACE_CHARACTERS; @@ -624,6 +625,23 @@ impl Parse for TemplateAreas { trivial_to_computed_value!(TemplateAreas); +/// Arc type for `Arc` +#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] +pub struct TemplateAreasArc(#[ignore_malloc_size_of = "Arc"] pub Arc); + +impl Parse for TemplateAreasArc { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + let parsed = TemplateAreas::parse(context, input)?; + + Ok(TemplateAreasArc(Arc::new(parsed))) + } +} + +trivial_to_computed_value!(TemplateAreasArc); + #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] #[derive(Clone, Debug, PartialEq)] /// Not associated with any particular grid item, but can @@ -673,7 +691,7 @@ fn is_name_code_point(c: char) -> bool { /// The syntax of this property also provides a visualization of /// the structure of the grid, making the overall layout of /// the grid container easier to understand. -pub type GridTemplateAreas = Either; +pub type GridTemplateAreas = Either; impl GridTemplateAreas { #[inline]