| OLD | NEW | 
|    1 #!/usr/bin/env python |    1 #!/usr/bin/env python | 
|    2  |    2  | 
|    3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |    3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 
|    4 # |    4 # | 
|    5 # Redistribution and use in source and binary forms, with or without |    5 # Redistribution and use in source and binary forms, with or without | 
|    6 # modification, are permitted provided that the following conditions |    6 # modification, are permitted provided that the following conditions | 
|    7 # are met: |    7 # are met: | 
|    8 # |    8 # | 
|    9 # 1. Redistributions of source code must retain the above |    9 # 1. Redistributions of source code must retain the above | 
|   10 #    copyright notice, this list of conditions and the following |   10 #    copyright notice, this list of conditions and the following | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   64         self.converted_properties = [] |   64         self.converted_properties = [] | 
|   65         self.in_style_tag = False |   65         self.in_style_tag = False | 
|   66         self.style_data = [] |   66         self.style_data = [] | 
|   67         self.filename = filename |   67         self.filename = filename | 
|   68  |   68  | 
|   69         resources_path = self.path_from_webkit_root('LayoutTests', 'resources') |   69         resources_path = self.path_from_webkit_root('LayoutTests', 'resources') | 
|   70         resources_relpath = self._filesystem.relpath(resources_path, new_path) |   70         resources_relpath = self._filesystem.relpath(resources_path, new_path) | 
|   71         self.resources_relpath = resources_relpath |   71         self.resources_relpath = resources_relpath | 
|   72  |   72  | 
|   73         # These settings might vary between WebKit and Blink |   73         # These settings might vary between WebKit and Blink | 
|   74         self._css_property_file = self.path_from_webkit_root('Source', 'core', '
     css', 'CSSPropertyNames.in') |   74         self._css_property_file = self.path_from_webkit_root('Source', 'core', '
     css', 'CSSProperties.in') | 
|   75         self._css_property_split_string = 'alias_for=' |  | 
|   76  |   75  | 
|   77         self.prefixed_properties = self.read_webkit_prefixed_css_property_list() |   76         self.prefixed_properties = self.read_webkit_prefixed_css_property_list() | 
|   78  |   77  | 
|   79         self.prefixed_properties = self.read_webkit_prefixed_css_property_list() |   78         self.prefixed_properties = self.read_webkit_prefixed_css_property_list() | 
|   80         prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for pr
     op in self.prefixed_properties) + ')(\s+:|:)' |   79         prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for pr
     op in self.prefixed_properties) + ')(\s+:|:)' | 
|   81         self.prop_re = re.compile(prop_regex) |   80         self.prop_re = re.compile(prop_regex) | 
|   82  |   81  | 
|   83     def output(self): |   82     def output(self): | 
|   84         return (self.converted_properties, ''.join(self.converted_data)) |   83         return (self.converted_properties, ''.join(self.converted_data)) | 
|   85  |   84  | 
|   86     def path_from_webkit_root(self, *comps): |   85     def path_from_webkit_root(self, *comps): | 
|   87         return self._filesystem.abspath(self._filesystem.join(self._webkit_root,
      *comps)) |   86         return self._filesystem.abspath(self._filesystem.join(self._webkit_root,
      *comps)) | 
|   88  |   87  | 
|   89     def read_webkit_prefixed_css_property_list(self): |   88     def read_webkit_prefixed_css_property_list(self): | 
|   90         prefixed_properties = [] |   89         prefixed_properties = [] | 
|   91         unprefixed_properties = set() |   90         unprefixed_properties = set() | 
|   92  |   91  | 
|   93         contents = self._filesystem.read_text_file(self._css_property_file) |   92         contents = self._filesystem.read_text_file(self._css_property_file) | 
|   94         for line in contents.splitlines(): |   93         for line in contents.splitlines(): | 
|   95             if re.match('^(#|//)', line): |   94             if re.match('^(#|//|$)', line): | 
|   96                 # skip comments and preprocessor directives |   95                 # skip comments and preprocessor directives | 
|   97                 continue |   96                 continue | 
|   98             fields = line.split(self._css_property_split_string) |   97             prop = line.split()[0] | 
|   99             for prop in fields: |   98             # Find properties starting with the -webkit- prefix. | 
|  100                 # Find properties starting with the -webkit- prefix. |   99             match = re.match('-webkit-([\w|-]*)', prop) | 
|  101                 match = re.match('-webkit-([\w|-]*)', prop) |  100             if match: | 
|  102                 if match: |  101                 prefixed_properties.append(match.group(1)) | 
|  103                     prefixed_properties.append(match.group(1)) |  102             else: | 
|  104                 else: |  103                 unprefixed_properties.add(prop.strip()) | 
|  105                     unprefixed_properties.add(prop.strip()) |  | 
|  106  |  104  | 
|  107         # Ignore any prefixed properties for which an unprefixed version is supp
     orted |  105         # Ignore any prefixed properties for which an unprefixed version is supp
     orted | 
|  108         return [prop for prop in prefixed_properties if prop not in unprefixed_p
     roperties] |  106         return [prop for prop in prefixed_properties if prop not in unprefixed_p
     roperties] | 
|  109  |  107  | 
|  110     def add_webkit_prefix_to_unprefixed_properties(self, text): |  108     def add_webkit_prefix_to_unprefixed_properties(self, text): | 
|  111         """ Searches |text| for instances of properties requiring the -webkit- p
     refix and adds the prefix to them. |  109         """ Searches |text| for instances of properties requiring the -webkit- p
     refix and adds the prefix to them. | 
|  112  |  110  | 
|  113         Returns the list of converted properties and the modified text.""" |  111         Returns the list of converted properties and the modified text.""" | 
|  114  |  112  | 
|  115         converted_properties = set() |  113         converted_properties = set() | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  190  |  188  | 
|  191     def handle_comment(self, data): |  189     def handle_comment(self, data): | 
|  192         self.converted_data.extend(['<!-- ', data, ' -->']) |  190         self.converted_data.extend(['<!-- ', data, ' -->']) | 
|  193  |  191  | 
|  194     def handle_decl(self, decl): |  192     def handle_decl(self, decl): | 
|  195         self.converted_data.extend(['<!', decl, '>']) |  193         self.converted_data.extend(['<!', decl, '>']) | 
|  196  |  194  | 
|  197     def handle_pi(self, data): |  195     def handle_pi(self, data): | 
|  198         self.converted_data.extend(['<?', data, '>']) |  196         self.converted_data.extend(['<?', data, '>']) | 
|  199  |  197  | 
| OLD | NEW |