зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550432 - Do not report error for unknown property if its known moz prefixed version is specified. r=emilio
Suppose that `prop` is a property that we haven't supported yet, while its `-moz-prop` version is already supported. If an author specifies in a declaration block this property in its standard form as well as multiple verdor specific forms, as long as `-moz-prop` is specified, we shouldn't report error for unknown property `prop`. Because that's just noise. Differential Revision: https://phabricator.services.mozilla.com/D31998 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b41725bb4f
Коммит
6dd273cc7e
|
@ -15,10 +15,6 @@ let whitelist = [
|
|||
isFromDevTools: true},
|
||||
{sourceName: /devtools\/client\/debugger\/src\/components\/([A-z\/]+).css/i,
|
||||
isFromDevTools: true},
|
||||
// PDFjs rules needed for compat with other UAs.
|
||||
{sourceName: /web\/viewer\.css$/i,
|
||||
errorMessage: /Unknown property.*(appearance|user-select)/i,
|
||||
isFromDevTools: false},
|
||||
// Highlighter CSS uses a UA-only pseudo-class, see bug 985597.
|
||||
{sourceName: /highlighters\.css$/i,
|
||||
errorMessage: /Unknown pseudo-class.*moz-native-anonymous/i,
|
||||
|
|
|
@ -1301,11 +1301,9 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
|
|||
Ok(id) => id,
|
||||
Err(..) => {
|
||||
self.last_parsed_property_id = None;
|
||||
return Err(input.new_custom_error(if is_non_mozilla_vendor_identifier(&name) {
|
||||
StyleParseErrorKind::UnknownVendorProperty
|
||||
} else {
|
||||
return Err(input.new_custom_error(
|
||||
StyleParseErrorKind::UnknownProperty(name)
|
||||
}));
|
||||
));
|
||||
}
|
||||
};
|
||||
if self.context.error_reporting_enabled() {
|
||||
|
@ -1326,6 +1324,13 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
|
|||
|
||||
type SmallParseErrorVec<'i> = SmallVec<[(ParseError<'i>, &'i str, Option<PropertyId>); 2]>;
|
||||
|
||||
fn alias_of_known_property(name: &str) -> Option<PropertyId> {
|
||||
let mut prefixed = String::with_capacity(name.len() + 5);
|
||||
prefixed.push_str("-moz-");
|
||||
prefixed.push_str(name);
|
||||
PropertyId::parse_enabled_for_all_content(&prefixed).ok()
|
||||
}
|
||||
|
||||
#[cold]
|
||||
fn report_one_css_error<'i>(
|
||||
context: &ParserContext,
|
||||
|
@ -1352,10 +1357,22 @@ fn report_one_css_error<'i>(
|
|||
}
|
||||
}
|
||||
|
||||
// If the unrecognized property looks like a vendor-specific property,
|
||||
// silently ignore it instead of polluting the error output.
|
||||
if let ParseErrorKind::Custom(StyleParseErrorKind::UnknownVendorProperty) = error.kind {
|
||||
return;
|
||||
if let ParseErrorKind::Custom(StyleParseErrorKind::UnknownProperty(ref name)) = error.kind {
|
||||
if is_non_mozilla_vendor_identifier(name) {
|
||||
// If the unrecognized property looks like a vendor-specific property,
|
||||
// silently ignore it instead of polluting the error output.
|
||||
return;
|
||||
}
|
||||
if let Some(alias) = alias_of_known_property(name) {
|
||||
// This is an unknown property, but its -moz-* version is known.
|
||||
// We don't want to report error if the -moz-* version is already
|
||||
// specified.
|
||||
if let Some(block) = block {
|
||||
if all_properties_in_block(block, &alias) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref property) = property {
|
||||
|
|
|
@ -152,8 +152,6 @@ pub enum StyleParseErrorKind<'i> {
|
|||
|
||||
/// The property declaration was for an unknown property.
|
||||
UnknownProperty(CowRcStr<'i>),
|
||||
/// An unknown vendor-specific identifier was encountered.
|
||||
UnknownVendorProperty,
|
||||
/// The property declaration was for a disabled experimental property.
|
||||
ExperimentalProperty,
|
||||
/// The property declaration contained an invalid color value.
|
||||
|
|
Загрузка…
Ссылка в новой задаче