Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 self._webkit_root = WebKitFinder(self._filesystem).webkit_base() | 61 self._webkit_root = WebKitFinder(self._filesystem).webkit_base() |
| 62 | 62 |
| 63 self.converted_data = [] | 63 self.converted_data = [] |
| 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.new_test_harness_path = 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', 'CSSPropertyNames.in') |
| 75 self._css_property_split_string = 'alias_for=' | 75 self._css_property_split_string = 'alias_for=' |
| 76 | 76 |
| 77 self.prefixed_properties = self.read_webkit_prefixed_css_property_list() | 77 self.prefixed_properties = self.read_webkit_prefixed_css_property_list() |
| 78 | 78 |
| 79 self.test_harness_re = re.compile('/resources/testharness') | |
| 80 | |
| 81 self.prefixed_properties = self.read_webkit_prefixed_css_property_list() | 79 self.prefixed_properties = self.read_webkit_prefixed_css_property_list() |
| 82 prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for pr op in self.prefixed_properties) + ')(\s+:|:)' | 80 prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for pr op in self.prefixed_properties) + ')(\s+:|:)' |
| 83 self.prop_re = re.compile(prop_regex) | 81 self.prop_re = re.compile(prop_regex) |
| 84 | 82 |
| 85 def output(self): | 83 def output(self): |
| 86 return (self.converted_properties, ''.join(self.converted_data)) | 84 return (self.converted_properties, ''.join(self.converted_data)) |
| 87 | 85 |
| 88 def path_from_webkit_root(self, *comps): | 86 def path_from_webkit_root(self, *comps): |
| 89 return self._filesystem.abspath(self._filesystem.join(self._webkit_root, *comps)) | 87 return self._filesystem.abspath(self._filesystem.join(self._webkit_root, *comps)) |
| 90 | 88 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 | 129 |
| 132 def convert_style_data(self, data): | 130 def convert_style_data(self, data): |
| 133 converted = self.add_webkit_prefix_to_unprefixed_properties(data) | 131 converted = self.add_webkit_prefix_to_unprefixed_properties(data) |
| 134 if converted[0]: | 132 if converted[0]: |
| 135 self.converted_properties.extend(list(converted[0])) | 133 self.converted_properties.extend(list(converted[0])) |
| 136 return converted[1] | 134 return converted[1] |
| 137 | 135 |
| 138 def convert_attributes_if_needed(self, tag, attrs): | 136 def convert_attributes_if_needed(self, tag, attrs): |
| 139 converted = self.get_starttag_text() | 137 converted = self.get_starttag_text() |
| 140 if tag in ('script', 'link'): | 138 if tag in ('script', 'link'): |
| 141 attr_name = 'src' | 139 target_attr = 'src' |
| 142 if tag != 'script': | 140 if tag != 'script': |
| 143 attr_name = 'href' | 141 target_attr = 'href' |
| 144 for attr in attrs: | 142 for attr_name, attr_value in attrs: |
| 145 if attr[0] == attr_name: | 143 if attr_name == target_attr: |
| 146 new_path = re.sub(self.test_harness_re, self.new_test_harnes s_path + '/testharness', attr[1]) | 144 new_path = re.sub('/resources/testharness', |
| 147 converted = re.sub(attr[1], new_path, converted) | 145 self.resources_relpath + '/testharness', |
| 146 attr_value) | |
| 147 converted = re.sub(attr_value, new_path, converted) | |
| 148 new_path = re.sub('/common/vendor-prefix', | |
|
Dirk Pranke
2014/06/26 21:16:47
I don't recall if you answered this question, but
| |
| 149 self.resources_relpath + '/vendor-prefix', | |
| 150 attr_value) | |
| 151 converted = re.sub(attr_value, new_path, converted) | |
| 148 | 152 |
| 149 for attr in attrs: | 153 for attr_name, attr_value in attrs: |
| 150 if attr[0] == 'style': | 154 print attr_name, attr_value |
|
Dirk Pranke
2014/06/26 21:16:47
this print shouldn't be here ...
| |
| 151 new_style = self.convert_style_data(attr[1]) | 155 if attr_name == 'style': |
| 152 converted = re.sub(attr[1], new_style, converted) | 156 new_style = self.convert_style_data(attr_value) |
| 157 converted = re.sub(attr_value, new_style, converted) | |
| 158 if attr_name == 'class' and 'instructions' in attr_value: | |
|
Dirk Pranke
2014/06/26 21:16:47
can we put this logic in testharnessreport.js inst
| |
| 159 # Always hide instructions, they're for manual testers. | |
| 160 converted = re.sub(' style=".*?"', '', converted) | |
| 161 converted = re.sub('\>', ' style="display:none">', converted) | |
| 153 | 162 |
| 154 self.converted_data.append(converted) | 163 self.converted_data.append(converted) |
| 155 | 164 |
| 156 def handle_starttag(self, tag, attrs): | 165 def handle_starttag(self, tag, attrs): |
| 157 if tag == 'style': | 166 if tag == 'style': |
| 158 self.in_style_tag = True | 167 self.in_style_tag = True |
| 159 self.convert_attributes_if_needed(tag, attrs) | 168 self.convert_attributes_if_needed(tag, attrs) |
| 160 | 169 |
| 161 def handle_endtag(self, tag): | 170 def handle_endtag(self, tag): |
| 162 if tag == 'style': | 171 if tag == 'style': |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 182 | 191 |
| 183 def handle_comment(self, data): | 192 def handle_comment(self, data): |
| 184 self.converted_data.extend(['<!-- ', data, ' -->']) | 193 self.converted_data.extend(['<!-- ', data, ' -->']) |
| 185 | 194 |
| 186 def handle_decl(self, decl): | 195 def handle_decl(self, decl): |
| 187 self.converted_data.extend(['<!', decl, '>']) | 196 self.converted_data.extend(['<!', decl, '>']) |
| 188 | 197 |
| 189 def handle_pi(self, data): | 198 def handle_pi(self, data): |
| 190 self.converted_data.extend(['<?', data, '>']) | 199 self.converted_data.extend(['<?', data, '>']) |
| 191 | 200 |
| OLD | NEW |