Bug 393757 - Don't report CSS style errors for identifiers designated as vendor-specific by the CSS spec. This means we won't report errors for things like _width or for any of the -khtml-, -webkit-, -o-, -ms-, etc. properties, cutting down on error console spam a touch. r+sr+a=dbaron
Bug 393757 - Don't report CSS style errors for identifiers designated as vendor-specific by the CSS spec. This means we won't report errors for things like _width or for any of the -khtml-, -webkit-, -o-, -ms-, etc. properties, cutting down on error console spam a touch. r+sr+a=dbaron
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -786,16 +786,29 @@ CSSParserImpl::Parse(nsIUnicharInputStre
mUnsafeRulesEnabled = PR_FALSE;
aResult = mSheet;
NS_ADDREF(aResult);
return NS_OK;
}
+/**
+ * Determines whether the identifier contained in the given string is a
+ * vendor-specific identifier, as described in CSS 2.1 section 4.1.2.1.
+ */
+static PRBool
+NonMozillaVendorIdentifier(const nsAString& ident)
+{
+ return (ident.First() == PRUnichar('-') &&
+ !StringBeginsWith(ident, NS_LITERAL_STRING("-moz-"))) ||
+ ident.First() == PRUnichar('_');
+
+}
+
NS_IMETHODIMP
CSSParserImpl::ParseStyleAttribute(const nsAString& aAttributeValue,
nsIURI* aDocURL,
nsIURI* aBaseURL,
nsIPrincipal* aNodePrincipal,
nsICSSStyleRule** aResult)
{
NS_PRECONDITION(aNodePrincipal, "Must have principal here!");
@@ -1289,18 +1302,21 @@ PRBool CSSParserImpl::ParseAtRule(nsresu
}
}
if (mToken.mIdent.LowerCaseEqualsLiteral("page")) {
if (ParsePageRule(aErrorCode, aAppendFunc, aData)) {
mSection = eCSSSection_General;
return PR_TRUE;
}
}
- REPORT_UNEXPECTED_TOKEN(PEUnknownAtRule);
- OUTPUT_ERROR();
+
+ if (!NonMozillaVendorIdentifier(mToken.mIdent)) {
+ REPORT_UNEXPECTED_TOKEN(PEUnknownAtRule);
+ OUTPUT_ERROR();
+ }
// Skip over unsupported at rule, don't advance section
return SkipAtRule(aErrorCode);
}
PRBool CSSParserImpl::ParseCharsetRule(nsresult& aErrorCode, RuleAppendFunc aAppendFunc,
void* aData)
{
@@ -3293,25 +3309,28 @@ CSSParserImpl::ParseDeclaration(nsresult
REPORT_UNEXPECTED(PEDeclSkipped);
OUTPUT_ERROR();
}
// Not a declaration...
UngetToken();
return PR_FALSE;
}
- // Map property name to it's ID and then parse the property
+ // Map property name to its ID and then parse the property
nsCSSProperty propID = nsCSSProps::LookupProperty(propertyName);
if (eCSSProperty_UNKNOWN == propID) { // unknown property
- const PRUnichar *params[] = {
- propertyName.get()
- };
- REPORT_UNEXPECTED_P(PEUnknownProperty, params);
- REPORT_UNEXPECTED(PEDeclDropped);
- OUTPUT_ERROR();
+ if (!NonMozillaVendorIdentifier(propertyName)) {
+ const PRUnichar *params[] = {
+ propertyName.get()
+ };
+ REPORT_UNEXPECTED_P(PEUnknownProperty, params);
+ REPORT_UNEXPECTED(PEDeclDropped);
+ OUTPUT_ERROR();
+ }
+
return PR_FALSE;
}
if (! ParseProperty(aErrorCode, propID)) {
// XXX Much better to put stuff in the value parsers instead...
const PRUnichar *params[] = {
propertyName.get()
};
REPORT_UNEXPECTED_P(PEPropertyParsingError, params);