Accept vendor prefixes for CSS names.

This commit is contained in:
Andre D
2011-08-10 15:25:20 -07:00
committed by Max Goodman
parent 335111b941
commit 42194379ba

View File

@@ -48,6 +48,8 @@ from xml.dom import DOMException
msgs = string_dict['css_validator_messages']
browser_prefixes = ['o','moz','webkit','ms','khtml','apple','xv']
custom_macros = {
'num': r'[-]?\d+|[-]?\d*\.\d+',
'percentage': r'{num}%',
@@ -79,16 +81,6 @@ custom_values = {
nonstandard_values = {
# http://www.w3.org/TR/css3-background/#border-top-right-radius
'-moz-border-radius': r'(({length}|{percentage}){w}){1,2}',
'-moz-border-radius-topleft': r'(({length}|{percentage}){w}){1,2}',
'-moz-border-radius-topright': r'(({length}|{percentage}){w}){1,2}',
'-moz-border-radius-bottomleft': r'(({length}|{percentage}){w}){1,2}',
'-moz-border-radius-bottomright': r'(({length}|{percentage}){w}){1,2}',
'-webkit-border-radius': r'(({length}|{percentage}){w}){1,2}',
'-webkit-border-top-left-radius': r'(({length}|{percentage}){w}){1,2}',
'-webkit-border-top-right-radius': r'(({length}|{percentage}){w}){1,2}',
'-webkit-border-bottom-left-radius': r'(({length}|{percentage}){w}){1,2}',
'-webkit-border-bottom-right-radius': r'(({length}|{percentage}){w}){1,2}',
'border-radius': r'(({length}|{percentage}){w}){1,2}',
'border-radius-topleft': r'(({length}|{percentage}){w}){1,2}',
'border-radius-topright': r'(({length}|{percentage}){w}){1,2}',
@@ -104,6 +96,11 @@ nonstandard_values = {
}
custom_values.update(nonstandard_values);
def _build_regex_prefix(prefixes):
return re.compile("|".join("^-"+p+"-" for p in prefixes))
prefix_regex = _build_regex_prefix(browser_prefixes)
def _expand_macros(tokdict,macrodict):
""" Expand macros in token dictionary """
def macro_value(m):
@@ -219,7 +216,12 @@ def valid_url(prop,value,report):
# value))
def strip_browser_prefix(prop):
t = prefix_regex.split(prop, maxsplit=1)
return t[len(t) - 1]
def valid_value(prop,value,report):
prop.name = strip_browser_prefix(prop.name) # Remove browser-specific prefixes eg: -moz-border-radius becomes border-radius
if not (value.valid and value.wellformed):
if (value.wellformed
and prop.name in cssproperties.cssvalues