Title: [209012] trunk/Tools
Revision
209012
Author
dba...@webkit.org
Date
2016-11-28 13:37:07 -0800 (Mon, 28 Nov 2016)

Log Message

Teach webkitpy how to read CSSProperties.json r209001
https://bugs.webkit.org/show_bug.cgi?id=165108

Reviewed by Simon Fraser.

Fix webkitpy logic so that it can read CSS property names from CSSProperties.json following r209001.

Following r209001 CSSPropertyNames.in no longer exists as it was replaced with CSSProperties.json.
We need to modify the webkitpy machinery that processed CSSPropertyNames.in to process CSSProperties.json.

* Scripts/webkitpy/w3c/test_converter.py:
(_W3CTestConverter.__init__): Make self._css_property_file and self._css_property_value_file local
variables as it is unnecessary for them to be instance variables. Call read_webkit_prefixed_css_property_list()
to read the property names from file CSSProperties.json. Call legacy_read_webkit_prefixed_css_property_list() to
read CSS keyword values from CSSValueKeywords.in.
(_W3CTestConverter.read_webkit_prefixed_css_property_list): Added.
(_W3CTestConverter):
(_W3CTestConverter.legacy_read_webkit_prefixed_css_property_list): Renamed from read_webkit_prefixed_css_property_list.
* Scripts/webkitpy/w3c/test_importer_unittest.py:
(TestImporterTest.test_harnesslinks_conversion): Substitute CSSProperties.json for CSSPropertyNames.in.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (209011 => 209012)


--- trunk/Tools/ChangeLog	2016-11-28 21:26:10 UTC (rev 209011)
+++ trunk/Tools/ChangeLog	2016-11-28 21:37:07 UTC (rev 209012)
@@ -1,3 +1,26 @@
+2016-11-28  Daniel Bates  <daba...@apple.com>
+
+        Teach webkitpy how to read CSSProperties.json r209001
+        https://bugs.webkit.org/show_bug.cgi?id=165108
+
+        Reviewed by Simon Fraser.
+
+        Fix webkitpy logic so that it can read CSS property names from CSSProperties.json following r209001.
+
+        Following r209001 CSSPropertyNames.in no longer exists as it was replaced with CSSProperties.json.
+        We need to modify the webkitpy machinery that processed CSSPropertyNames.in to process CSSProperties.json.
+
+        * Scripts/webkitpy/w3c/test_converter.py:
+        (_W3CTestConverter.__init__): Make self._css_property_file and self._css_property_value_file local
+        variables as it is unnecessary for them to be instance variables. Call read_webkit_prefixed_css_property_list()
+        to read the property names from file CSSProperties.json. Call legacy_read_webkit_prefixed_css_property_list() to
+        read CSS keyword values from CSSValueKeywords.in.
+        (_W3CTestConverter.read_webkit_prefixed_css_property_list): Added.
+        (_W3CTestConverter):
+        (_W3CTestConverter.legacy_read_webkit_prefixed_css_property_list): Renamed from read_webkit_prefixed_css_property_list.
+        * Scripts/webkitpy/w3c/test_importer_unittest.py:
+        (TestImporterTest.test_harnesslinks_conversion): Substitute CSSProperties.json for CSSPropertyNames.in.
+
 2016-11-28  Eric Carlson  <eric.carl...@apple.com>
 
         [MediaStream] Don't request user permission for a device if it has already been granted in the current browsing context

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_converter.py (209011 => 209012)


--- trunk/Tools/Scripts/webkitpy/w3c/test_converter.py	2016-11-28 21:26:10 UTC (rev 209011)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_converter.py	2016-11-28 21:37:07 UTC (rev 209012)
@@ -27,6 +27,7 @@
 # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 
+import json
 import logging
 import re
 
@@ -73,16 +74,16 @@
         self.convert_test_harness_links = convert_test_harness_links
 
         # These settings might vary between WebKit and Blink
-        self._css_property_file = self.path_from_webkit_root('Source', 'WebCore', 'css', 'CSSPropertyNames.in')
-        self._css_property_value_file = self.path_from_webkit_root('Source', 'WebCore', 'css', 'CSSValueKeywords.in')
+        css_property_file = self.path_from_webkit_root('Source', 'WebCore', 'css', 'CSSProperties.json')
+        css_property_value_file = self.path_from_webkit_root('Source', 'WebCore', 'css', 'CSSValueKeywords.in')
 
         self.test_harness_re = re.compile('/resources/testharness')
 
-        self.prefixed_properties = self.read_webkit_prefixed_css_property_list(self._css_property_file)
+        self.prefixed_properties = self.read_webkit_prefixed_css_property_list(css_property_file)
         prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for prop in self.prefixed_properties) + ')(\s+:|:)'
         self.prop_re = re.compile(prop_regex)
 
-        self.prefixed_property_values = self.read_webkit_prefixed_css_property_list(self._css_property_value_file)
+        self.prefixed_property_values = self.legacy_read_webkit_prefixed_css_property_list(css_property_value_file)
         prop_value_regex = '(:\s*|^\s*)(' + "|".join(value.replace('-webkit-', '') for value in self.prefixed_property_values) + ')(\s*;|\s*}|\s*$)'
         self.prop_value_re = re.compile(prop_value_regex)
 
@@ -94,9 +95,35 @@
 
     def read_webkit_prefixed_css_property_list(self, file_name):
         contents = self._filesystem.read_text_file(file_name)
+        if not contents:
+            return []
+        properties = json.loads(contents)['properties']
+        property_names = []
+        for property_name, property_dict in properties.iteritems():
+            property_names.append(property_name)
+            if 'codegen-properties' in property_dict:
+                codegen_options = property_dict['codegen-properties']
+                if 'aliases' in codegen_options:
+                    property_names.extend(codegen_options['aliases'])
+
         prefixed_properties = []
         unprefixed_properties = set()
+        for property_name in property_names:
+            # Find properties starting with the -webkit- prefix.
+            match = re.match('-webkit-([\w|-]*)', property_name)
+            if match:
+                prefixed_properties.append(match.group(1))
+            else:
+                unprefixed_properties.add(property_name)
 
+        # Ignore any prefixed properties for which an unprefixed version is supported
+        return [prop for prop in prefixed_properties if prop not in unprefixed_properties]
+
+    def legacy_read_webkit_prefixed_css_property_list(self, file_name):
+        contents = self._filesystem.read_text_file(file_name)
+        prefixed_properties = []
+        unprefixed_properties = set()
+
         for line in contents.splitlines():
             if re.match('^(#|//)', line) or len(line.strip()) == 0:
                 # skip comments and preprocessor directives and empty lines.

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py (209011 => 209012)


--- trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py	2016-11-28 21:26:10 UTC (rev 209011)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py	2016-11-28 21:37:07 UTC (rev 209012)
@@ -138,7 +138,7 @@
         FAKE_FILES = {
             '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/t/test.html': '<!doctype html><script src="" src=""
             '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/t/test.html': '<!doctype html><script src="" src=""
-            '/mock-checkout/Source/WebCore/css/CSSPropertyNames.in': '',
+            '/mock-checkout/Source/WebCore/css/CSSProperties.json': '',
             '/mock-checkout/Source/WebCore/css/CSSValueKeywords.in': '',
         }
         FAKE_FILES.update(FAKE_REPOSITORY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to