| OLD | NEW |
| 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 from name_utilities import lower_first | 7 from name_utilities import lower_first |
| 8 | 8 |
| 9 | 9 |
| 10 class CSSProperties(in_generator.Writer): | 10 class CSSProperties(in_generator.Writer): |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 def __init__(self, file_paths): | 47 def __init__(self, file_paths): |
| 48 in_generator.Writer.__init__(self, file_paths) | 48 in_generator.Writer.__init__(self, file_paths) |
| 49 | 49 |
| 50 properties = self.in_file.name_dictionaries | 50 properties = self.in_file.name_dictionaries |
| 51 | 51 |
| 52 self._aliases = [property for property in properties if property['alias_
for']] | 52 self._aliases = [property for property in properties if property['alias_
for']] |
| 53 properties = [property for property in properties if not property['alias
_for']] | 53 properties = [property for property in properties if not property['alias
_for']] |
| 54 | 54 |
| 55 # We currently assign 0 to CSSPropertyInvalid, and 1 to CSSPropertyVaria
ble | 55 # 0: CSSPropertyInvalid |
| 56 self._first_enum_value = 2 | 56 # 1: CSSPropertyApplyAtRule |
| 57 # 2: CSSPropertyVariable |
| 58 self._first_enum_value = 3 |
| 57 | 59 |
| 58 # StylePropertyMetadata additionally assumes there are under 1024 proper
ties. | 60 # StylePropertyMetadata additionally assumes there are under 1024 proper
ties. |
| 59 assert self._first_enum_value + len(properties) < 512, 'Property aliasin
g expects there are under 512 properties.' | 61 assert self._first_enum_value + len(properties) < 512, 'Property aliasin
g expects there are under 512 properties.' |
| 60 | 62 |
| 61 for offset, property in enumerate(properties): | 63 for offset, property in enumerate(properties): |
| 62 property['property_id'] = css_name_to_enum(property['name']) | 64 property['property_id'] = css_name_to_enum(property['name']) |
| 63 property['upper_camel_name'] = camelcase_css_name(property['name']) | 65 property['upper_camel_name'] = camelcase_css_name(property['name']) |
| 64 property['lower_camel_name'] = lower_first(property['upper_camel_nam
e']) | 66 property['lower_camel_name'] = lower_first(property['upper_camel_nam
e']) |
| 65 property['enum_value'] = self._first_enum_value + offset | 67 property['enum_value'] = self._first_enum_value + offset |
| 66 property['is_internal'] = property['name'].startswith('-internal-') | 68 property['is_internal'] = property['name'].startswith('-internal-') |
| (...skipping 18 matching lines...) Expand all Loading... |
| 85 """ | 87 """ |
| 86 return ''.join(word.capitalize() for word in css_name.split('-')) | 88 return ''.join(word.capitalize() for word in css_name.split('-')) |
| 87 | 89 |
| 88 | 90 |
| 89 def css_name_to_enum(css_name): | 91 def css_name_to_enum(css_name): |
| 90 return 'CSSProperty' + camelcase_css_name(css_name) | 92 return 'CSSProperty' + camelcase_css_name(css_name) |
| 91 | 93 |
| 92 | 94 |
| 93 def css_alias_name_to_enum(css_name): | 95 def css_alias_name_to_enum(css_name): |
| 94 return 'CSSPropertyAlias' + camelcase_css_name(css_name) | 96 return 'CSSPropertyAlias' + camelcase_css_name(css_name) |
| OLD | NEW |