Index: chrome/browser/web_dev_style/css_checker.py |
diff --git a/chrome/browser/web_dev_style/css_checker.py b/chrome/browser/web_dev_style/css_checker.py |
index 7d03a60feb8bd7b846cc94ed52edaa50beb03e2a..6b6a923ec0720eb58387cb94811bf285a4138236 100644 |
--- a/chrome/browser/web_dev_style/css_checker.py |
+++ b/chrome/browser/web_dev_style/css_checker.py |
@@ -36,6 +36,9 @@ class CSSChecker(object): |
s = _remove_mixins(s) |
return s |
+ def _extract_inline_style(s): |
+ return '\n'.join(re.findall(r'<style>([^<]*)<\/style>', s)) |
+ |
def _remove_ats(s): |
at_reg = re.compile(r""" |
@(?!\d+x\b)\w+[^'"]*?{ # @at-keyword selector junk {, not @2x |
@@ -375,13 +378,20 @@ class CSSChecker(object): |
file_filter=self.file_filter) |
files = [] |
for f in affected_files: |
- # Remove all /*comments*/, @at-keywords, and grit <if|include> tags; we're |
- # not using a real parser. TODO(dbeam): Check alpha in <if> blocks. |
- file_contents = _remove_all('\n'.join(f.NewContents())) |
- files.append((f.LocalPath(), file_contents)) |
- |
- # Only look at CSS files for now. |
- for f in filter(lambda f: f[0].endswith('.css'), files): |
+ file_contents = '\n'.join(f.NewContents()) |
+ path = f.LocalPath() |
+ # Handle CSS files and HTML files with inline styles. |
+ if path.endswith('.html'): |
+ file_contents = _extract_inline_style(file_contents) |
+ |
+ if path.endswith('.html') or path.endswith('.css'): |
+ # Remove all /*comments*/, @at-keywords, and grit <if|include> tags; |
+ # we're not using a real parser. TODO(dbeam): Check alpha in <if> |
+ # blocks. |
+ file_contents = _remove_all(file_contents) |
+ files.append((path, file_contents)) |
+ |
+ for f in files: |
file_errors = [] |
for check in added_or_modified_files_checks: |
# If the check is multiline, it receieves the whole file and gives us |