Auto merge of #15735 - servo:cssparserup, r=emilio

Update cssparser to 0.11

<!-- Please describe your changes on the following line: -->

<s>Depends on https://github.com/servo/rust-cssparser/pull/122.</s>

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15735)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-02-26 02:19:32 -08:00 committed by GitHub
commit 94e563e4d9
42 changed files with 143 additions and 175 deletions

View file

@ -33,7 +33,6 @@ def main():
rust = render(template, product=product, data=properties, __file__=template)
if output == "style-crate":
write(os.environ["OUT_DIR"], "properties.rs", rust)
write(os.environ["OUT_DIR"], "static_ids.txt", static_ids(properties))
if product == "gecko":
template = os.path.join(BASE, "gecko.mako.rs")
rust = render(template, data=properties)
@ -72,19 +71,6 @@ def write(directory, filename, content):
open(os.path.join(directory, filename), "wb").write(content)
def static_id_generator(properties):
for kind, props in [("Longhand", properties.longhands),
("Shorthand", properties.shorthands)]:
for p in props:
yield "%s\tStaticId::%s(%sId::%s)" % (p.name, kind, kind, p.camel_case)
for alias in p.alias:
yield "%s\tStaticId::%s(%sId::%s)" % (alias, kind, kind, p.camel_case)
def static_ids(properties):
return '\n'.join(static_id_generator(properties))
def write_html(properties):
properties = dict(
(p.name, {

View file

@ -69,7 +69,7 @@ impl TransitionProperty {
/// Parse a transition-property value.
pub fn parse(input: &mut Parser) -> Result<Self, ()> {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"all" => Ok(TransitionProperty::All),
% for prop in data.longhands:
% if prop.animatable:

View file

@ -68,7 +68,7 @@
/// Parse a display value.
pub fn parse(_context: &ParserContext, input: &mut Parser)
-> Result<SpecifiedValue, ()> {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
% for value in values:
"${value}" => {
Ok(computed_value::T::${to_rust_ident(value)})
@ -299,7 +299,7 @@ ${helpers.single_keyword("-moz-top-layer", "none top",
input.try(|i| specified::LengthOrPercentage::parse(context, i))
.map(SpecifiedValue::LengthOrPercentage)
.or_else(|_| {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
% for keyword in vertical_align_keywords:
"${keyword}" => Ok(SpecifiedValue::${to_rust_ident(keyword)}),
% endfor
@ -588,7 +588,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
impl Parse for SpecifiedValue {
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
if let Ok(function_name) = input.try(|input| input.expect_function()) {
return match_ignore_ascii_case! { function_name,
return match_ignore_ascii_case! { &function_name,
"cubic-bezier" => {
let (mut p1x, mut p1y, mut p2x, mut p2y) = (0.0, 0.0, 0.0, 0.0);
try!(input.parse_nested_block(|input| {
@ -618,7 +618,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
if input.try(|input| input.expect_comma()).is_ok() {
start_end = try!(match_ignore_ascii_case! {
try!(input.expect_ident()),
&try!(input.expect_ident()),
"start" => Ok(StartEnd::Start),
"end" => Ok(StartEnd::End),
_ => Err(())
@ -1319,7 +1319,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
Err(_) => break,
};
match_ignore_ascii_case! {
name,
&name,
"matrix" => {
try!(input.parse_nested_block(|input| {
let values = try!(input.parse_comma_separated(|input| {

View file

@ -140,7 +140,7 @@
content.push(ContentItem::String(value.into_owned()))
}
Ok(Token::Function(name)) => {
content.push(try!(match_ignore_ascii_case! { name,
content.push(try!(match_ignore_ascii_case! { &name,
"counter" => input.parse_nested_block(|input| {
let name = try!(input.expect_ident()).into_owned();
let style = input.try(|input| {
@ -163,7 +163,7 @@
}));
}
Ok(Token::Ident(ident)) => {
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"open-quote" => content.push(ContentItem::OpenQuote),
"close-quote" => content.push(ContentItem::CloseQuote),
"no-open-quote" => content.push(ContentItem::NoOpenQuote),

View file

@ -339,7 +339,7 @@ ${helpers.predefined_type("clip",
% endif
if let Ok(function_name) = input.try(|input| input.expect_function()) {
filters.push(try!(input.parse_nested_block(|input| {
match_ignore_ascii_case! { function_name,
match_ignore_ascii_case! { &function_name,
"blur" => specified::Length::parse_non_negative(input).map(SpecifiedFilter::Blur),
"brightness" => parse_factor(input).map(SpecifiedFilter::Brightness),
"contrast" => parse_factor(input).map(SpecifiedFilter::Contrast),
@ -445,7 +445,7 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<Origi
if let Err(_) = input.try(|input| {
let token = try!(input.expect_ident());
match_ignore_ascii_case! {
token,
&token,
"left" => {
if horizontal.is_none() {
horizontal = Some(LengthOrPercentage::Percentage(Percentage(0.0)))

View file

@ -63,7 +63,7 @@
}
_ => {}
}
match_ignore_ascii_case! { input,
match_ignore_ascii_case! { &input,
"serif" => return FontFamily::Generic(atom!("serif")),
"sans-serif" => return FontFamily::Generic(atom!("sans-serif")),
"cursive" => return FontFamily::Generic(atom!("cursive")),
@ -85,7 +85,7 @@
// string (as lowercase) in the static atoms table. We don't have an
// API to do that yet though, so we do the simple thing for now.
let mut css_wide_keyword = false;
match_ignore_ascii_case! { first_ident,
match_ignore_ascii_case! { &first_ident,
"serif" => return Ok(FontFamily::Generic(atom!("serif"))),
"sans-serif" => return Ok(FontFamily::Generic(atom!("sans-serif"))),
"cursive" => return Ok(FontFamily::Generic(atom!("cursive"))),
@ -254,7 +254,7 @@ ${helpers.single_keyword("font-variant-caps",
/// normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
input.try(|input| {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"normal" => Ok(SpecifiedValue::Normal),
"bold" => Ok(SpecifiedValue::Bold),
"bolder" => Ok(SpecifiedValue::Bolder),
@ -557,7 +557,7 @@ ${helpers.single_keyword("font-variant-caps",
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
let mut result = SpecifiedValue { weight: false, style: false };
match_ignore_ascii_case! {try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"none" => Ok(result),
"weight" => {
result.weight = true;

View file

@ -22,12 +22,12 @@ ${helpers.single_keyword("text-anchor",
// Section 11 - Painting: Filling, Stroking and Marker Symbols
${helpers.single_keyword("color-interpolation",
"auto sRGB linearRGB",
"auto srgb linearrgb",
products="gecko",
animatable=False,
spec="https://www.w3.org/TR/SVG11/painting.html#ColorInterpolationProperty")}
${helpers.single_keyword("color-interpolation-filters", "auto sRGB linearRGB",
${helpers.single_keyword("color-interpolation-filters", "auto srgb linearrgb",
products="gecko",
gecko_constant_prefix="NS_STYLE_COLOR_INTERPOLATION",
animatable=False,
@ -52,7 +52,7 @@ ${helpers.single_keyword("fill-rule", "nonzero evenodd",
spec="https://www.w3.org/TR/SVG11/painting.html#FillRuleProperty")}
${helpers.single_keyword("shape-rendering",
"auto optimizeSpeed crispEdges geometricPrecision",
"auto optimizespeed crispedges geometricprecision",
products="gecko",
animatable=False,
spec="https://www.w3.org/TR/SVG11/painting.html#ShapeRenderingProperty")}
@ -196,7 +196,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
loop {
let result = input.try(|i| {
match_ignore_ascii_case! { i.expect_ident()?,
match_ignore_ascii_case! { &i.expect_ident()?,
"fill" => Ok(FILL),
"stroke" => Ok(STROKE),
"markers" => Ok(MARKERS),

View file

@ -60,7 +60,7 @@
impl Parse for Side {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Side, ()> {
if let Ok(ident) = input.try(|input| input.expect_ident()) {
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"clip" => Ok(Side::Clip),
"ellipsis" => Ok(Side::Ellipsis),
_ => Err(())
@ -179,7 +179,7 @@ ${helpers.single_keyword("unicode-bidi",
while input.try(|input| {
if let Ok(ident) = input.expect_ident() {
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"underline" => if result.contains(UNDERLINE) { return Err(()) }
else { empty = false; result.insert(UNDERLINE) },
"overline" => if result.contains(OVERLINE) { return Err(()) }

View file

@ -455,7 +455,7 @@ impl Parse for CSSWideKeyword {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
let ident = input.expect_ident()?;
input.expect_exhausted()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"initial" => Ok(CSSWideKeyword::InitialKeyword),
"inherit" => Ok(CSSWideKeyword::InheritKeyword),
"unset" => Ok(CSSWideKeyword::UnsetKeyword),
@ -731,24 +731,33 @@ impl ToCss for PropertyId {
}
}
// FIXME(https://github.com/rust-lang/rust/issues/33156): remove this enum and use PropertyId
// when stable Rust allows destructors in statics.
enum StaticId {
Longhand(LonghandId),
Shorthand(ShorthandId),
}
include!(concat!(env!("OUT_DIR"), "/static_ids.rs"));
impl PropertyId {
/// Returns a given property from the string `s`.
///
/// Returns Err(()) for unknown non-custom properties
pub fn parse(s: Cow<str>) -> Result<Self, ()> {
if let Ok(name) = ::custom_properties::parse_name(&s) {
pub fn parse(property_name: Cow<str>) -> Result<Self, ()> {
if let Ok(name) = ::custom_properties::parse_name(&property_name) {
return Ok(PropertyId::Custom(::custom_properties::Name::from(name)))
}
let lower_case = ::str::cow_into_ascii_lowercase(s);
match STATIC_IDS.get(&*lower_case) {
// FIXME(https://github.com/rust-lang/rust/issues/33156): remove this enum and use PropertyId
// when stable Rust allows destructors in statics.
enum StaticId {
Longhand(LonghandId),
Shorthand(ShorthandId),
}
ascii_case_insensitive_phf_map! {
StaticIds: Map<StaticId> = {
% for (kind, properties) in [("Longhand", data.longhands), ("Shorthand", data.shorthands)]:
% for property in properties:
% for name in [property.name] + property.alias:
"${name}" => "StaticId::${kind}(${kind}Id::${property.camel_case})",
% endfor
% endfor
% endfor
}
}
match StaticIds::get(&property_name) {
Some(&StaticId::Longhand(id)) => Ok(PropertyId::Longhand(id)),
Some(&StaticId::Shorthand(id)) => Ok(PropertyId::Shorthand(id)),
None => Err(()),