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

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

Issue 2620233002: Add 'priority' key to CSSProperties.in (Closed)
Patch Set: There goes most of my patch ;) 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
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 in_generator
7 import name_utilities 7 import name_utilities
8 8
9 9
10 class CSSProperties(in_generator.Writer): 10 class CSSProperties(in_generator.Writer):
(...skipping 13 matching lines...) Expand all
24 'setter': None, 24 'setter': None,
25 'initial': None, 25 'initial': None,
26 'type_name': None, 26 'type_name': None,
27 'converter': None, 27 'converter': None,
28 'custom_all': False, 28 'custom_all': False,
29 'custom_initial': False, 29 'custom_initial': False,
30 'custom_inherit': False, 30 'custom_inherit': False,
31 'custom_value': False, 31 'custom_value': False,
32 'builder_skip': False, 32 'builder_skip': False,
33 'direction_aware': False, 33 'direction_aware': False,
34 'priority': 2,
34 'api_class': None, 35 'api_class': None,
35 # Generated ComputedStyle annotations. 36 # Generated ComputedStyle annotations.
36 'field_storage_type': None, 37 'field_storage_type': None,
37 # Typed OM annotations. 38 # Typed OM annotations.
38 'typedom_types': [], 39 'typedom_types': [],
39 'keywords': [], 40 'keywords': [],
40 'initial_keyword': None, 41 'initial_keyword': None,
41 'keyword_only': False, 42 'keyword_only': False,
42 'supports_percentage': False, 43 'supports_percentage': False,
43 'repeated': False, 44 'repeated': False,
(...skipping 11 matching lines...) Expand all
55 'custom_value': (True, False), 56 'custom_value': (True, False),
56 'builder_skip': (True, False), 57 'builder_skip': (True, False),
57 'direction_aware': (True, False), 58 'direction_aware': (True, False),
58 'keyword_only': (True, False), 59 'keyword_only': (True, False),
59 } 60 }
60 61
61 def __init__(self, file_paths): 62 def __init__(self, file_paths):
62 in_generator.Writer.__init__(self, file_paths) 63 in_generator.Writer.__init__(self, file_paths)
63 64
64 properties = self.in_file.name_dictionaries 65 properties = self.in_file.name_dictionaries
66
67 # Sort properties by priority, then alphabetically.
68 properties.sort(key=lambda p: (int(p['priority']), name_utilities.strip_ webkit_prefix(p['name'])))
alancutter (OOO until 2018) 2017/01/11 03:24:20 This sorting key has collisions between different
sashab 2017/01/11 03:57:44 Done. Added check for sorting key collisions.
69
65 self._aliases = [property for property in properties if property['alias_ for']] 70 self._aliases = [property for property in properties if property['alias_ for']]
66 properties = [property for property in properties if not property['alias _for']] 71 properties = [property for property in properties if not property['alias _for']]
67 72
68 # 0: CSSPropertyInvalid 73 # 0: CSSPropertyInvalid
69 # 1: CSSPropertyApplyAtRule 74 # 1: CSSPropertyApplyAtRule
70 # 2: CSSPropertyVariable 75 # 2: CSSPropertyVariable
71 self._first_enum_value = 3 76 self._first_enum_value = 3
72 77
73 # StylePropertyMetadata additionally assumes there are under 1024 proper ties. 78 # StylePropertyMetadata additionally assumes there are under 1024 proper ties.
74 assert self._first_enum_value + len(properties) < 512, 'Property aliasin g expects there are under 512 properties.' 79 assert self._first_enum_value + len(properties) < 512, 'Property aliasin g expects there are under 512 properties.'
75 80
76 for offset, property in enumerate(properties): 81 for offset, property in enumerate(properties):
77 property['property_id'] = name_utilities.enum_for_css_property(prope rty['name']) 82 property['property_id'] = name_utilities.enum_for_css_property(prope rty['name'])
78 property['upper_camel_name'] = name_utilities.camel_case(property['n ame']) 83 property['upper_camel_name'] = name_utilities.camel_case(property['n ame'])
79 property['lower_camel_name'] = name_utilities.lower_first(property[' upper_camel_name']) 84 property['lower_camel_name'] = name_utilities.lower_first(property[' upper_camel_name'])
80 property['enum_value'] = self._first_enum_value + offset 85 property['enum_value'] = self._first_enum_value + offset
81 property['is_internal'] = property['name'].startswith('-internal-') 86 property['is_internal'] = property['name'].startswith('-internal-')
82 87
83 self._properties_including_aliases = properties 88 self._properties_including_aliases = properties
84 self._properties = {property['property_id']: property for property in pr operties} 89 self._properties = {property['property_id']: property for property in pr operties}
85 90
86 # The generated code will only work with at most one alias per property 91 # The generated code will only work with at most one alias per property
87 assert len({property['alias_for'] for property in self._aliases}) == len (self._aliases) 92 assert len({property['alias_for'] for property in self._aliases}) == len (self._aliases)
88 93
89 for property in self._aliases: 94 for property in self._aliases:
90 property['property_id'] = name_utilities.enum_for_css_property_alias (property['name']) 95 property['property_id'] = name_utilities.enum_for_css_property_alias (property['name'])
91 aliased_property = self._properties[name_utilities.enum_for_css_prop erty(property['alias_for'])] 96 aliased_property = self._properties[name_utilities.enum_for_css_prop erty(property['alias_for'])]
92 property['enum_value'] = aliased_property['enum_value'] + 512 97 property['enum_value'] = aliased_property['enum_value'] + 512
93 self._properties_including_aliases += self._aliases 98 self._properties_including_aliases += self._aliases
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698