Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
| 5 # are met: | 5 # are met: |
| 6 # | 6 # |
| 7 # 1. Redistributions of source code must retain the above | 7 # 1. Redistributions of source code must retain the above |
| 8 # copyright notice, this list of conditions and the following | 8 # copyright notice, this list of conditions and the following |
| 9 # disclaimer. | 9 # disclaimer. |
| 10 # 2. Redistributions in binary form must reproduce the above | 10 # 2. Redistributions in binary form must reproduce the above |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 self.converted_properties = [] | 80 self.converted_properties = [] |
| 81 self.in_style_tag = False | 81 self.in_style_tag = False |
| 82 self.style_data = [] | 82 self.style_data = [] |
| 83 self.filename = filename | 83 self.filename = filename |
| 84 self.reference_support_info = reference_support_info | 84 self.reference_support_info = reference_support_info |
| 85 resources_path = self.path_from_webkit_root('LayoutTests', 'resources') | 85 resources_path = self.path_from_webkit_root('LayoutTests', 'resources') |
| 86 resources_relpath = self._filesystem.relpath(resources_path, new_path) | 86 resources_relpath = self._filesystem.relpath(resources_path, new_path) |
| 87 self.resources_relpath = resources_relpath | 87 self.resources_relpath = resources_relpath |
| 88 | 88 |
| 89 # These settings might vary between WebKit and Blink. | 89 # These settings might vary between WebKit and Blink. |
| 90 self._css_property_file = self.path_from_webkit_root('Source', 'core', ' css', 'CSSProperties.in') | 90 # Only -webkit-text-emphasis is currently needed. See: |
| 91 self.prefixed_properties = self.read_webkit_prefixed_css_property_list() | 91 # https://bugs.chromium.org/p/chromium/issues/detail?id=614955#c1 |
| 92 self.prefixed_properties = ['-webkit-text-emphasis'] | |
|
tkent
2017/01/17 03:14:53
I'm sorry, but we need more property names:
-webk
tkent
2017/01/17 03:16:50
-webkit-text-emphasis-color too :)
ktyliu
2017/01/17 03:50:25
Done :)
| |
| 92 prop_regex = r'([\s{]|^)(' + '|'.join( | 93 prop_regex = r'([\s{]|^)(' + '|'.join( |
| 93 prop.replace('-webkit-', '') for prop in self.prefixed_properties) + r')(\s+:|:)' | 94 prop.replace('-webkit-', '') for prop in self.prefixed_properties) + r')(\s+:|:)' |
| 94 self.prop_re = re.compile(prop_regex) | 95 self.prop_re = re.compile(prop_regex) |
| 95 | 96 |
| 96 def output(self): | 97 def output(self): |
| 97 return (self.converted_properties, ''.join(self.converted_data)) | 98 return (self.converted_properties, ''.join(self.converted_data)) |
| 98 | 99 |
| 99 def path_from_webkit_root(self, *comps): | 100 def path_from_webkit_root(self, *comps): |
| 100 return self._filesystem.abspath(self._filesystem.join(self._webkit_root, *comps)) | 101 return self._filesystem.abspath(self._filesystem.join(self._webkit_root, *comps)) |
| 101 | 102 |
| 102 def read_webkit_prefixed_css_property_list(self): | |
| 103 prefixed_properties = [] | |
| 104 unprefixed_properties = set() | |
| 105 | |
| 106 contents = self._filesystem.read_text_file(self._css_property_file) | |
| 107 for line in contents.splitlines(): | |
| 108 if re.match(r'^(#|//|$)', line): | |
| 109 # skip comments and preprocessor directives. | |
| 110 continue | |
| 111 prop = line.split()[0] | |
| 112 # Find properties starting with the -webkit- prefix. | |
| 113 match = re.match(r'-webkit-([\w|-]*)', prop) | |
| 114 if match: | |
| 115 prefixed_properties.append(match.group(1)) | |
| 116 else: | |
| 117 unprefixed_properties.add(prop.strip()) | |
| 118 | |
| 119 # Ignore any prefixed properties for which an unprefixed version is supp orted. | |
| 120 return [prop for prop in prefixed_properties if prop not in unprefixed_p roperties] | |
| 121 | |
| 122 def add_webkit_prefix_to_unprefixed_properties(self, text): | 103 def add_webkit_prefix_to_unprefixed_properties(self, text): |
| 123 """Searches |text| for instances of properties requiring the -webkit- pr efix and adds the prefix to them. | 104 """Searches |text| for instances of properties requiring the -webkit- pr efix and adds the prefix to them. |
| 124 | 105 |
| 125 Returns the list of converted properties and the modified text. | 106 Returns the list of converted properties and the modified text. |
| 126 """ | 107 """ |
| 127 converted_properties = set() | 108 converted_properties = set() |
| 128 text_chunks = [] | 109 text_chunks = [] |
| 129 cur_pos = 0 | 110 cur_pos = 0 |
| 130 for match in self.prop_re.finditer(text): | 111 for match in self.prop_re.finditer(text): |
| 131 text_chunks.extend([ | 112 text_chunks.extend([ |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 self.converted_data.extend(['&#', name, ';']) | 206 self.converted_data.extend(['&#', name, ';']) |
| 226 | 207 |
| 227 def handle_comment(self, data): | 208 def handle_comment(self, data): |
| 228 self.converted_data.extend(['<!--', data, '-->']) | 209 self.converted_data.extend(['<!--', data, '-->']) |
| 229 | 210 |
| 230 def handle_decl(self, decl): | 211 def handle_decl(self, decl): |
| 231 self.converted_data.extend(['<!', decl, '>']) | 212 self.converted_data.extend(['<!', decl, '>']) |
| 232 | 213 |
| 233 def handle_pi(self, data): | 214 def handle_pi(self, data): |
| 234 self.converted_data.extend(['<?', data, '>']) | 215 self.converted_data.extend(['<?', data, '>']) |
| OLD | NEW |