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

Side by Side Diff: third_party/WebKit/Source/build/scripts/css_properties.py

Issue 2620883002: Convert Settings.in, CSSValueKeywords.in, SVGCSSValueKeywords.in to json5 (Closed)
Patch Set: Convert CSSProperties.in to json5 format Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/json5_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import in_generator 6 import json5_generator
7 import name_utilities 7 import name_utilities
8 8
9 9
10 class CSSProperties(in_generator.Writer): 10 class CSSProperties(json5_generator.Writer):
11 defaults = { 11 def __init__(self, file_paths):
12 'alias_for': None, 12 json5_generator.Writer.__init__(self, file_paths)
13 'descriptor_only': None,
14 'runtime_flag': None,
15 'longhands': '',
16 'interpolable': False,
17 'inherited': False,
18 'independent': False,
19 'font': False,
20 'svg': False,
21 'name_for_methods': None,
22 'use_handlers_for': None,
23 'getter': None,
24 'setter': None,
25 'initial': None,
26 'type_name': None,
27 'converter': None,
28 'custom_all': False,
29 'custom_initial': False,
30 'custom_inherit': False,
31 'custom_value': False,
32 'builder_skip': False,
33 'direction_aware': False,
34 'priority': 'Low',
35 'api_class': None,
36 # Generated ComputedStyle annotations.
37 'field_storage_type': None,
38 # Typed OM annotations.
39 'typedom_types': [],
40 'keywords': [],
41 'initial_keyword': None,
42 'keyword_only': False,
43 'supports_percentage': False,
44 'repeated': False,
45 }
46 13
47 valid_values = { 14 properties = self.json5_file.name_dictionaries
48 'interpolable': (True, False),
49 'inherited': (True, False),
50 'independent': (True, False),
51 'font': (True, False),
52 'svg': (True, False),
53 'custom_all': (True, False),
54 'custom_initial': (True, False),
55 'custom_inherit': (True, False),
56 'custom_value': (True, False),
57 'builder_skip': (True, False),
58 'direction_aware': (True, False),
59 'priority': ('Animation', 'High', 'Low'),
60 'keyword_only': (True, False),
61 }
62
63 def __init__(self, file_paths):
64 in_generator.Writer.__init__(self, file_paths)
65
66 properties = self.in_file.name_dictionaries
67 15
68 # Sort properties by priority, then alphabetically. 16 # Sort properties by priority, then alphabetically.
69 for property in properties: 17 for property in properties:
70 # This order must match the order in CSSPropertyPriority.h. 18 # This order must match the order in CSSPropertyPriority.h.
71 priority_numbers = {'Animation': 0, 'High': 1, 'Low': 2} 19 priority_numbers = {'Animation': 0, 'High': 1, 'Low': 2}
72 priority = priority_numbers[property['priority']] 20 priority = priority_numbers[property['priority']]
73 name_without_leading_dash = property['name'] 21 name_without_leading_dash = property['name']
74 if property['name'].startswith('-'): 22 if property['name'].startswith('-'):
75 name_without_leading_dash = property['name'][1:] 23 name_without_leading_dash = property['name'][1:]
76 property['sorting_key'] = (priority, name_without_leading_dash) 24 property['sorting_key'] = (priority, name_without_leading_dash)
(...skipping 27 matching lines...) Expand all
104 self._properties = {property['property_id']: property for property in pr operties} 52 self._properties = {property['property_id']: property for property in pr operties}
105 53
106 # The generated code will only work with at most one alias per property 54 # The generated code will only work with at most one alias per property
107 assert len({property['alias_for'] for property in self._aliases}) == len (self._aliases) 55 assert len({property['alias_for'] for property in self._aliases}) == len (self._aliases)
108 56
109 for property in self._aliases: 57 for property in self._aliases:
110 property['property_id'] = name_utilities.enum_for_css_property_alias (property['name']) 58 property['property_id'] = name_utilities.enum_for_css_property_alias (property['name'])
111 aliased_property = self._properties[name_utilities.enum_for_css_prop erty(property['alias_for'])] 59 aliased_property = self._properties[name_utilities.enum_for_css_prop erty(property['alias_for'])]
112 property['enum_value'] = aliased_property['enum_value'] + 512 60 property['enum_value'] = aliased_property['enum_value'] + 512
113 self._properties_including_aliases += self._aliases 61 self._properties_including_aliases += self._aliases
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/json5_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698