Skip to content

Commit

Permalink
Cleanup some old code
Browse files Browse the repository at this point in the history
  • Loading branch information
wafflespeanut committed Jun 19, 2017
1 parent 3a4bd24 commit c145dd7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
20 changes: 7 additions & 13 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -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<nsStringRepr>) {
fn set_line_names(servo_names: &[CustomIdent], gecko_names: &mut nsTArray<nsStringRepr>) {
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());
}
}

Expand All @@ -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 <none>, but we don't support subgrid name lists at the moment.

match v {
Expand All @@ -1297,7 +1291,7 @@ fn static_assert() {
let auto_repeat = track.auto_repeat.as_ref().expect("expected <auto-track-repeat> 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;
Expand Down
12 changes: 6 additions & 6 deletions components/style/values/generics/grid.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -307,15 +307,15 @@ impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
/// Helper function for serializing identifiers with a prefix and suffix, used
/// for serializing <line-names> (in grid).
pub fn concat_serialize_idents<W>(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)?;
Expand Down Expand Up @@ -372,7 +372,7 @@ pub struct TrackRepeat<L> {
/// If there's no `<line-names>`, then it's represented by an empty vector.
/// For N `<track-size>` values, there will be N+1 `<line-names>`, and so this vector's
/// length is always one value more than that of the `<track-size>`.
pub line_names: Vec<Vec<String>>,
pub line_names: Vec<Vec<CustomIdent>>,
/// `<track-size>` values.
pub track_sizes: Vec<TrackSize<L>>,
}
Expand Down Expand Up @@ -502,7 +502,7 @@ pub struct TrackList<T> {
/// If there's no `<line-names>`, then it's represented by an empty vector.
/// For N values, there will be N+1 `<line-names>`, and so this vector's
/// length is always one value more than that of the `<track-size>`.
pub line_names: Vec<Vec<String>>,
pub line_names: Vec<Vec<CustomIdent>>,
/// `<auto-repeat>` value after computation. This field is necessary, because
/// the `values` field (after computation) will only contain `<track-size>` values, and
/// we need something to represent this function.
Expand Down
9 changes: 3 additions & 6 deletions components/style/values/specified/grid.rs
Expand Up @@ -81,16 +81,13 @@ impl Parse for TrackSize<LengthOrPercentage> {
/// 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<Vec<String>, ParseError<'i>> {
pub fn parse_line_names<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Vec<CustomIdent>, 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)
Expand Down

0 comments on commit c145dd7

Please sign in to comment.