Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2439)

Unified Diff: Tools/Scripts/webkitpy/w3c/test_converter.py

Issue 1158193002: Enable test_converter.py to import CSS Writing Modes test suites (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/Scripts/webkitpy/w3c/test_converter.py
diff --git a/Tools/Scripts/webkitpy/w3c/test_converter.py b/Tools/Scripts/webkitpy/w3c/test_converter.py
index c784d49ffa9624d9ffee9a880cc9fe391bfd1898..cda33a123d0ac430dd0f6dfaafb90e9c4b343661 100755
--- a/Tools/Scripts/webkitpy/w3c/test_converter.py
+++ b/Tools/Scripts/webkitpy/w3c/test_converter.py
@@ -27,6 +27,7 @@
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+import itertools
import logging
import re
@@ -75,9 +76,21 @@ class _W3CTestConverter(HTMLParser):
self._css_property_file = self.path_from_webkit_root('Source', 'core', 'css', 'CSSProperties.in')
self.prefixed_properties = self.read_webkit_prefixed_css_property_list()
-
- self.prefixed_properties = self.read_webkit_prefixed_css_property_list()
- prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for prop in self.prefixed_properties) + ')(\s+:|:)'
+ self.prefixed_values = {
+ 'unicode-bidi': ['isolate', 'isolate-override', 'plaintext']
+ }
+ self.renamed_properties = {
+ 'text-combine-upright': '-webkit-text-combine'
+ }
+ self.renamed_values = {
+ 'text-combine-upright': {'all': 'horizontal'}
Dirk Pranke 2015/05/27 22:52:59 Is there a reason we can't just add support for th
kojii 2015/05/27 23:47:38 Replied above.
+ }
Dirk Pranke 2015/05/27 22:52:59 this section could use some comments describing sp
kojii 2015/05/27 23:47:38 I'll add and re-upload, but allow me to reply as t
+
+ prop_regex = '([\s{]|^)(' + "|".join(itertools.chain(
+ self.renamed_properties.iterkeys(),
+ self.renamed_values.iterkeys(),
+ self.prefixed_values.iterkeys(),
+ (prop.replace('-webkit-', '') for prop in self.prefixed_properties))) + ')(\s+:|:[^;]*)'
self.prop_re = re.compile(prop_regex)
def output(self):
@@ -103,8 +116,11 @@ class _W3CTestConverter(HTMLParser):
else:
unprefixed_properties.add(prop.strip())
+ # SVG writing-mode exists, but CSS writing-mode is still prefixed
+ unprefixed_properties.discard('writing-mode')
Dirk Pranke 2015/05/27 22:52:59 I don't think I understand this change; if we stil
kojii 2015/05/27 23:47:38 There are two properties, "writing-mode" and "-web
Dirk Pranke 2015/05/28 01:25:49 Will this likely cause problems if we import some
+
# Ignore any prefixed properties for which an unprefixed version is supported
- return [prop for prop in prefixed_properties if prop not in unprefixed_properties]
+ return set(prop for prop in prefixed_properties if prop not in unprefixed_properties)
Dirk Pranke 2015/05/27 22:52:59 why did this change to a set() ?
kojii 2015/05/27 23:47:38 Because line #139 uses "in" operator to check if t
Dirk Pranke 2015/05/28 01:25:49 Okay. `in` actually works with both lists and sets
def add_webkit_prefix_to_unprefixed_properties(self, text):
""" Searches |text| for instances of properties requiring the -webkit- prefix and adds the prefix to them.
@@ -115,8 +131,17 @@ class _W3CTestConverter(HTMLParser):
text_chunks = []
cur_pos = 0
for m in self.prop_re.finditer(text):
- text_chunks.extend([text[cur_pos:m.start()], m.group(1), '-webkit-', m.group(2), m.group(3)])
- converted_properties.add(m.group(2))
+ text_chunks.extend([text[cur_pos:m.start()], m.group(1)])
+ property = m.group(2)
+ oldProperty = self.renamed_properties.get(property)
+ if oldProperty:
+ text_chunks.append(oldProperty)
+ elif property in self.prefixed_properties:
+ text_chunks.extend(['-webkit-', property])
+ else:
+ text_chunks.append(property)
+ text_chunks.append(self.add_webkit_prefix_to_unprefixed_value(property, m.group(3)))
+ converted_properties.add(property)
cur_pos = m.end()
text_chunks.append(text[cur_pos:])
@@ -126,6 +151,15 @@ class _W3CTestConverter(HTMLParser):
# FIXME: Handle the JS versions of these properties and GetComputedStyle, too.
return (converted_properties, ''.join(text_chunks))
+ def add_webkit_prefix_to_unprefixed_value(self, property, text):
+ renamed_values = self.renamed_values.get(property)
+ if renamed_values:
+ text = re.sub("|".join(renamed_values.iterkeys()), lambda m: renamed_values[m.group(0)], text)
+ prefixed_values = self.prefixed_values.get(property)
+ if prefixed_values:
+ text = re.sub("|".join(prefixed_values), lambda m: '-webkit-' + m.group(0), text)
+ return text
+
def convert_reference_relpaths(self, text):
""" Searches |text| for instances of files in reference_support_info and updates the relative path to be correct for the new ref file location"""
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698