diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index b0953f9a1d9..1a6e0995fe0 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1240,26 +1240,20 @@ fn static_assert() { <% self_grid = "self.gecko.mGridTemplate%s" % kind.title() %> use gecko::values::GeckoStyleCoordConvertible; use gecko_bindings::structs::{nsTArray, nsStyleGridLine_kMaxLine}; - use nsstring::{nsCString, nsStringRepr}; + use nsstring::nsStringRepr; use std::usize; + use values::CustomIdent; use values::generics::grid::TrackListType::Auto; use values::generics::grid::{RepeatCount, TrackSize}; #[inline] - fn set_bitfield(bitfield: &mut u8, pos: u8, val: bool) { - let mask = 1 << (pos - 1); - *bitfield &= !mask; - *bitfield |= (val as u8) << (pos - 1); - } - - #[inline] - fn set_line_names(servo_names: &[String], gecko_names: &mut nsTArray) { + fn set_line_names(servo_names: &[CustomIdent], gecko_names: &mut nsTArray) { unsafe { bindings::Gecko_ResizeTArrayForStrings(gecko_names, servo_names.len() as u32); } for (servo_name, gecko_name) in servo_names.iter().zip(gecko_names.iter_mut()) { - gecko_name.assign_utf8(&nsCString::from(&*servo_name)); + gecko_name.assign(servo_name.0.as_slice()); } } @@ -1284,8 +1278,8 @@ fn static_assert() { // Set defaults ${self_grid}.mRepeatAutoIndex = -1; - set_bitfield(&mut ${self_grid}._bitfield_1, 1, false); // mIsAutoFill - set_bitfield(&mut ${self_grid}._bitfield_1, 2, false); // mIsSubgrid + ${self_grid}.set_mIsAutoFill(false); + ${self_grid}.set_mIsSubgrid(false); // FIXME: mIsSubgrid is false only for , but we don't support subgrid name lists at the moment. match v { @@ -1297,7 +1291,7 @@ fn static_assert() { let auto_repeat = track.auto_repeat.as_ref().expect("expected value"); if auto_repeat.count == RepeatCount::AutoFill { - set_bitfield(&mut ${self_grid}._bitfield_1, 1, true); + ${self_grid}.set_mIsAutoFill(true); } ${self_grid}.mRepeatAutoIndex = idx as i16; diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs index 3cb10439598..3693c670718 100644 --- a/components/style/values/generics/grid.rs +++ b/components/style/values/generics/grid.rs @@ -5,7 +5,7 @@ //! Generic types for the handling of //! [grids](https://drafts.csswg.org/css-grid/). -use cssparser::{Parser, serialize_identifier}; +use cssparser::Parser; use parser::{Parse, ParserContext}; use std::{fmt, mem, usize}; use style_traits::{ToCss, ParseError, StyleParseError}; @@ -307,15 +307,15 @@ impl ToComputedValue for TrackSize { /// Helper function for serializing identifiers with a prefix and suffix, used /// for serializing (in grid). pub fn concat_serialize_idents(prefix: &str, suffix: &str, - slice: &[String], sep: &str, dest: &mut W) -> fmt::Result + slice: &[CustomIdent], sep: &str, dest: &mut W) -> fmt::Result where W: fmt::Write { if let Some((ref first, rest)) = slice.split_first() { dest.write_str(prefix)?; - serialize_identifier(first, dest)?; + first.to_css(dest)?; for thing in rest { dest.write_str(sep)?; - serialize_identifier(thing, dest)?; + thing.to_css(dest)?; } dest.write_str(suffix)?; @@ -372,7 +372,7 @@ pub struct TrackRepeat { /// If there's no ``, then it's represented by an empty vector. /// For N `` values, there will be N+1 ``, and so this vector's /// length is always one value more than that of the ``. - pub line_names: Vec>, + pub line_names: Vec>, /// `` values. pub track_sizes: Vec>, } @@ -502,7 +502,7 @@ pub struct TrackList { /// If there's no ``, then it's represented by an empty vector. /// For N values, there will be N+1 ``, and so this vector's /// length is always one value more than that of the ``. - pub line_names: Vec>, + pub line_names: Vec>, /// `` value after computation. This field is necessary, because /// the `values` field (after computation) will only contain `` values, and /// we need something to represent this function. diff --git a/components/style/values/specified/grid.rs b/components/style/values/specified/grid.rs index d19ab3703c3..9f68196d1b1 100644 --- a/components/style/values/specified/grid.rs +++ b/components/style/values/specified/grid.rs @@ -81,16 +81,13 @@ impl Parse for TrackSize { /// Parse the grid line names into a vector of owned strings. /// /// https://drafts.csswg.org/css-grid/#typedef-line-names -pub fn parse_line_names<'i, 't>(input: &mut Parser<'i, 't>) -> Result, ParseError<'i>> { +pub fn parse_line_names<'i, 't>(input: &mut Parser<'i, 't>) -> Result, ParseError<'i>> { input.expect_square_bracket_block()?; input.parse_nested_block(|input| { let mut values = vec![]; while let Ok(ident) = input.try(|i| i.expect_ident()) { - if CustomIdent::from_ident((&*ident).into(), &["span"]).is_err() { - return Err(StyleParseError::UnspecifiedError.into()) - } - - values.push(ident.into_owned()); + let ident = CustomIdent::from_ident(ident, &["span"])?; + values.push(ident); } Ok(values)