Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Sync changes from mozilla-central. #21036

Merged
merged 40 commits into from Jun 12, 2018
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ea5417b
style: Make contain:paint trigger clipping independent of the overflo…
muhammedyusuf-sermet May 30, 2018
35a1a30
style: Remove invalid assertion.
emilio Jun 4, 2018
6940787
style: Make the transition-property code make more sense.
emilio Jun 1, 2018
f6f421f
style: Hide multiple -moz-window-* properties from content.
emilio Jun 1, 2018
90ef560
style: Move TransitionProperty where it belongs.
emilio Jun 1, 2018
ce5a85d
style: Use custom_properties::Name in TransitionProperty.
emilio Jun 4, 2018
1da798e
style: Introduce css(parse_condition).
emilio Jun 2, 2018
cf7b10a
style: Hide -moz- display values from content behind a pref.
emilio Jun 2, 2018
618eef7
style: Don't hide -moz-box / -moz-inline-box yet.
emilio Jun 2, 2018
0f1b793
style: Minor indentation cleanup.
emilio Jun 4, 2018
4b10b2a
style: Update smallbitvec to v2.1.1.
emilio Jun 4, 2018
2baa794
style: Sprinkle some inline in methods that are just pointer-chasing …
emilio Jun 4, 2018
710184b
style: Sprinkle some #[inline] on methods that have inline fast-paths.
emilio Jun 4, 2018
f829300
style: Don't look at the rule type from value parsing.
emilio Jun 1, 2018
8d069d1
style: Work around a bindgen bug on Android.
emilio Jun 4, 2018
8821ad7
style: Make pseudo-elements work with :host.
emilio Jun 4, 2018
2c0a19e
style: Move some parsing-only attributes to use #[parse(..)] instead …
emilio Jun 4, 2018
d461a7d
style: Make the threadsafe refcounting macros more reusable.
emilio Jun 4, 2018
63ca2a8
style: Make clearing atoms slightly more ergonomic.
emilio Jun 4, 2018
c6e43c0
style: Avoid useless allocations in custom property name serialization.
emilio Jun 5, 2018
7529788
style: Make getting a property name explicitly an indexing operation.
emilio Jun 4, 2018
915c872
style: Remove PropertyId::name.
emilio Jun 4, 2018
3816143
style: Use Atomic<bool> for the staticpref version of layout.css.font…
bzbarsky Jun 6, 2018
255fe05
style: Extend StyleComplexColor to support additive blending.
djg May 23, 2018
9c51d31
style: Inline some trivial bits.
emilio Jun 4, 2018
e052666
style: Fix a typo.
emilio Jun 5, 2018
6ca324f
style: Remove unused PropertyDeclarationBlock::set_importance.
emilio Jun 5, 2018
3c7fb2a
style: Add a before-change callback to remove_property.
emilio Jun 5, 2018
cdbc409
style: Trivially simplify a condition.
emilio Jun 5, 2018
314b14d
style: Fix nsStyleBorder::mBorderColor for GCC.
djg Jun 5, 2018
5f74a15
style: Extract {animated,computed}::Color common parts.
djg Jun 5, 2018
011cad2
style: Add a Servo API to get the serialized style of a property.
emilio Jun 7, 2018
d65b29d
style: Add CssPropFlags::SerializedByServo and use it on some simple …
emilio Jun 7, 2018
572a931
style: Add diagnostics.
emilio Jun 9, 2018
078df23
style: Update cssparser.
emilio Jun 11, 2018
e94395b
style_derive: Fix tidy lint.
emilio Jun 11, 2018
ab76003
style: Fix servo build.
emilio Jun 11, 2018
4cd16ee
style: Derive Animate for ComplexColorRatios.
emilio Jun 11, 2018
0d0b0e0
Update WPT expectations.
emilio Jun 12, 2018
2106cc4
style: Update cssparser again to avoid intermittent stack overflows o…
emilio Jun 12, 2018
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

style: Remove PropertyId::name.

It's only used for the error path in property parsing, so most of the time is
not useful.

Use the just-introduced NonCustomPropertyId::name to preserve the alias name,
which we were doing by passing the name around.

Bug: 1466645
Reviewed-by: xidorn
MozReview-Commit-ID: 46xxZKCoeBB
  • Loading branch information
emilio committed Jun 12, 2018
commit 915c8725aee035d0a602ae946795c0b1f5c7315e
@@ -1116,9 +1116,7 @@ where
let mut parser = Parser::new(&mut input);
let start_position = parser.position();
parser.parse_entirely(|parser| {
let name = id.name().into();
PropertyDeclaration::parse_into(declarations, id, name, &context, parser)
.map_err(|e| e.into())
PropertyDeclaration::parse_into(declarations, id, &context, parser)
}).map_err(|err| {
let location = err.location;
let error = ContextualParseError::UnsupportedPropertyDeclaration(
@@ -1169,7 +1167,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
}
};
input.parse_until_before(Delimiter::Bang, |input| {
PropertyDeclaration::parse_into(self.declarations, id, name, self.context, input)
PropertyDeclaration::parse_into(self.declarations, id, self.context, input)
})?;
let importance = match input.try(parse_important) {
Ok(()) => Importance::Important,
@@ -23,7 +23,7 @@ use std::fmt::{self, Write};
use std::mem::{self, ManuallyDrop};

#[cfg(feature = "servo")] use cssparser::RGBA;
use cssparser::{CowRcStr, Parser, TokenSerializationType, serialize_identifier};
use cssparser::{Parser, TokenSerializationType};
use cssparser::ParserInput;
#[cfg(feature = "servo")] use euclid::SideOffsets2D;
use context::QuirksMode;
@@ -1765,21 +1765,6 @@ impl PropertyId {
}
}

/// Returns the name of the property without CSS escaping.
pub fn name(&self) -> Cow<'static, str> {
match *self {
PropertyId::ShorthandAlias(id, _) |
PropertyId::Shorthand(id) => id.name().into(),
PropertyId::LonghandAlias(id, _) |
PropertyId::Longhand(id) => id.name().into(),
PropertyId::Custom(ref name) => {
let mut s = String::new();
write!(&mut s, "--{}", name).unwrap();
s.into()
}
}
}

fn non_custom_id(&self) -> Option<NonCustomPropertyId> {
Some(match *self {
PropertyId::Custom(_) => return None,
@@ -2042,13 +2027,13 @@ impl PropertyDeclaration {
pub fn parse_into<'i, 't>(
declarations: &mut SourcePropertyDeclaration,
id: PropertyId,
name: CowRcStr<'i>,
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<(), ParseError<'i>> {
assert!(declarations.is_empty());
debug_assert!(id.allowed_in(context), "{:?}", id);

let non_custom_id = id.non_custom_id();
let start = input.state();
match id {
PropertyId::Custom(property_name) => {
@@ -2059,7 +2044,10 @@ impl PropertyDeclaration {
Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword),
Err(()) => match ::custom_properties::SpecifiedValue::parse(input) {
Ok(value) => DeclaredValueOwned::Value(value),
Err(e) => return Err(StyleParseErrorKind::new_invalid(name, e)),
Err(e) => return Err(StyleParseErrorKind::new_invalid(
format!("--{}", property_name),
e,
)),
}
};
declarations.push(PropertyDeclaration::Custom(CustomDeclaration {
@@ -2084,7 +2072,10 @@ impl PropertyDeclaration {
input.reset(&start);
let (first_token_type, css) =
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
StyleParseErrorKind::new_invalid(name, e)
StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
e,
)
})?;
Ok(PropertyDeclaration::WithVariables(VariableDeclaration {
id,
@@ -2096,7 +2087,10 @@ impl PropertyDeclaration {
}),
}))
} else {
Err(StyleParseErrorKind::new_invalid(name, err))
Err(StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
err,
))
}
})
}).map(|declaration| {
@@ -2130,7 +2124,10 @@ impl PropertyDeclaration {
input.reset(&start);
let (first_token_type, css) =
::custom_properties::parse_non_custom_with_var(input).map_err(|e| {
StyleParseErrorKind::new_invalid(name, e)
StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
e,
)
})?;
let unparsed = Arc::new(UnparsedValue {
css: css.into_owned(),
@@ -2152,7 +2149,10 @@ impl PropertyDeclaration {
}
Ok(())
} else {
Err(StyleParseErrorKind::new_invalid(name, err))
Err(StyleParseErrorKind::new_invalid(
non_custom_id.unwrap().name(),
err,
))
}
})
}
@@ -623,12 +623,12 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for KeyframeDeclarationParser<'a, 'b> {
let id = match PropertyId::parse(&name, self.context) {
Ok(id) => id,
Err(()) => return Err(input.new_custom_error(
StyleParseErrorKind::UnknownProperty(name.clone())
StyleParseErrorKind::UnknownProperty(name)
)),
};

// TODO(emilio): Shouldn't this use parse_entirely?
PropertyDeclaration::parse_into(self.declarations, id, name, self.context, input)?;
PropertyDeclaration::parse_into(self.declarations, id, self.context, input)?;

// In case there is still unparsed text in the declaration, we should
// roll back.
@@ -316,20 +316,23 @@ impl Declaration {
let mut input = ParserInput::new(&self.0);
let mut input = Parser::new(&mut input);
input.parse_entirely(|input| -> Result<(), CssParseError<()>> {
let prop = input.expect_ident_cloned().unwrap();
input.expect_colon().unwrap();
let prop = input.expect_ident_cloned().unwrap();
input.expect_colon().unwrap();

let id = PropertyId::parse(&prop, context)
.map_err(|_| input.new_custom_error(()))?;
let id = PropertyId::parse(&prop, context)
.map_err(|_| input.new_custom_error(()))?;

let mut declarations = SourcePropertyDeclaration::new();
input.parse_until_before(Delimiter::Bang, |input| {
PropertyDeclaration::parse_into(&mut declarations, id, prop, &context, input)
.map_err(|_| input.new_custom_error(()))
})?;
let _ = input.try(parse_important);
Ok(())
})
.is_ok()
let mut declarations = SourcePropertyDeclaration::new();
input.parse_until_before(Delimiter::Bang, |input| {
PropertyDeclaration::parse_into(
&mut declarations,
id,
&context,
input,
).map_err(|_| input.new_custom_error(()))
})?;
let _ = input.try(parse_important);
Ok(())
}).is_ok()
}
}
@@ -177,7 +177,11 @@ pub enum ValueParseErrorKind<'i> {

impl<'i> StyleParseErrorKind<'i> {
/// Create an InvalidValue parse error
pub fn new_invalid(name: CowRcStr<'i>, value_error: ParseError<'i>) -> ParseError<'i> {
pub fn new_invalid<S>(name: S, value_error: ParseError<'i>) -> ParseError<'i>
where
S: Into<CowRcStr<'i>>,
{
let name = name.into();
let variant = match value_error.kind {
cssparser::ParseErrorKind::Custom(StyleParseErrorKind::ValueError(e)) => {
match e {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.