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

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

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: More fixes - things build fine at this point. Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 2 # Copyright 2016 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 math 6 import math
7 import sys 7 import sys
8 8
9 import json5_generator 9 import json5_generator
10 import template_expander 10 import template_expander
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 {'name': 'HasViewportUnits', 'field_template': 'primitive', 'default_value': 'false', 55 {'name': 'HasViewportUnits', 'field_template': 'primitive', 'default_value': 'false',
56 'type_name': 'bool', 'inherited': False, 'independent': False}, 56 'type_name': 'bool', 'inherited': False, 'independent': False},
57 {'name': 'HasRemUnits', 'field_template': 'monotonic_flag', 'default_value': 'false', 57 {'name': 'HasRemUnits', 'field_template': 'monotonic_flag', 'default_value': 'false',
58 'inherited': False, 'independent': False}, 58 'inherited': False, 'independent': False},
59 # These properties only have generated storage, and their methods are handwr itten in ComputedStyle. 59 # These properties only have generated storage, and their methods are handwr itten in ComputedStyle.
60 # TODO(shend): Remove these fields and delete the 'storage_only' template. 60 # TODO(shend): Remove these fields and delete the 'storage_only' template.
61 {'name': 'EmptyState', 'field_template': 'storage_only', 'size': 1, 'default _value': 'false', 61 {'name': 'EmptyState', 'field_template': 'storage_only', 'size': 1, 'default _value': 'false',
62 'type_name': 'bool', 'inherited': False, 'independent': False}, 62 'type_name': 'bool', 'inherited': False, 'independent': False},
63 {'name': 'StyleType', 'field_template': 'storage_only', 'size': 6, 'default_ value': '0', 63 {'name': 'StyleType', 'field_template': 'storage_only', 'size': 6, 'default_ value': '0',
64 'type_name': 'PseudoId', 'inherited': False, 'independent': False}, 64 'type_name': 'PseudoId', 'inherited': False, 'independent': False},
65 {'name': 'PseudoBits', 'field_template': 'storage_only', 'size': 8, 'default _value': 'PseudoIdNone', 65 {'name': 'PseudoBits', 'field_template': 'storage_only', 'size': 8, 'default _value': 'kPseudoIdNone',
66 'type_name': 'PseudoId', 'inherited': False, 'independent': False}, 66 'type_name': 'PseudoId', 'inherited': False, 'independent': False},
67 # True if 'underline solid' is the only text decoration on this element. 67 # True if 'underline solid' is the only text decoration on this element.
68 {'name': 'HasSimpleUnderline', 'field_template': 'storage_only', 'size': 1, 'default_value': 'false', 68 {'name': 'HasSimpleUnderline', 'field_template': 'storage_only', 'size': 1, 'default_value': 'false',
69 'type_name': 'bool', 'inherited': True, 'independent': False}, 69 'type_name': 'bool', 'inherited': True, 'independent': False},
70 # TODO(shend): vertical align is actually a CSS property, but since we don't support union fields 70 # TODO(shend): vertical align is actually a CSS property, but since we don't support union fields
71 # which can be either a keyword or Length, this is generated as a nonpropert y for now. Remove this 71 # which can be either a keyword or Length, this is generated as a nonpropert y for now. Remove this
72 # once we can support union fields and groups. 72 # once we can support union fields and groups.
73 {'name': 'VerticalAlign', 'field_template': 'storage_only', 'size': 4, 'defa ult_value': 'EVerticalAlign::kBaseline', 73 {'name': 'VerticalAlign', 'field_template': 'storage_only', 'size': 4, 'defa ult_value': 'EVerticalAlign::kBaseline',
74 'type_name': 'EVerticalAlign', 'inherited': False, 'independent': False}, 74 'type_name': 'EVerticalAlign', 'inherited': False, 'independent': False},
75 ] 75 ]
(...skipping 22 matching lines...) Expand all
98 Should be in upper camel case. 98 Should be in upper camel case.
99 property_name: Name of the property that the field is part of. 99 property_name: Name of the property that the field is part of.
100 type_name: Name of the C++ type exposed by the generated interface (e.g. EClear, int). 100 type_name: Name of the C++ type exposed by the generated interface (e.g. EClear, int).
101 field_template: Determines the interface generated for the field. Can be one of: 101 field_template: Determines the interface generated for the field. Can be one of:
102 keyword, flag, or monotonic_flag. 102 keyword, flag, or monotonic_flag.
103 size: Number of bits needed for storage. 103 size: Number of bits needed for storage.
104 default_value: Default value for this field when it is first initialized . 104 default_value: Default value for this field when it is first initialized .
105 """ 105 """
106 106
107 def __init__(self, field_role, name_for_methods, property_name, type_name, 107 def __init__(self, field_role, name_for_methods, property_name, type_name,
108 field_template, size, default_value, **kwargs): 108 field_template, size, default_value, properties, **kwargs):
109 """Creates a new field.""" 109 """Creates a new field."""
110 self.name = class_member_name(name_for_methods) 110 self.name = class_member_name(name_for_methods)
111 self.property_name = property_name 111 self.property_name = property_name
112 self.type_name = type_name 112 self.type_name = type_name
113 self.field_template = field_template 113 self.field_template = field_template
114 self.size = size 114 self.size = size
115 self.default_value = default_value 115 self.default_value = default_value
116 116
117 # Field role: one of these must be true 117 # Field role: one of these must be true
118 self.is_property = field_role == 'property' 118 self.is_property = field_role == 'property'
119 self.is_inherited_flag = field_role == 'inherited_flag' 119 self.is_inherited_flag = field_role == 'inherited_flag'
120 self.is_nonproperty = field_role == 'nonproperty' 120 self.is_nonproperty = field_role == 'nonproperty'
121 assert (self.is_property, self.is_inherited_flag, self.is_nonproperty).c ount(True) == 1, \ 121 assert (self.is_property, self.is_inherited_flag, self.is_nonproperty).c ount(True) == 1, \
122 'Field role has to be exactly one of: property, inherited_flag, nonp roperty' 122 'Field role has to be exactly one of: property, inherited_flag, nonp roperty'
123 123
124 if not self.is_inherited_flag: 124 if not self.is_inherited_flag:
125 self.is_inherited = kwargs.pop('inherited') 125 self.is_inherited = kwargs.pop('inherited')
126 self.is_independent = kwargs.pop('independent') 126 self.is_independent = kwargs.pop('independent')
127 assert self.is_inherited or not self.is_independent, 'Only inherited fields can be independent' 127 assert self.is_inherited or not self.is_independent, 'Only inherited fields can be independent'
128 128
129 self.is_inherited_method_name = method_name(join_name(name_for_metho ds, 'is inherited')) 129 self.is_inherited_method_name = method_name(join_name(name_for_metho ds, 'is inherited'))
130 130
131 # Method names 131 # Method names
132 getter_prefix = 'Get' if name_for_methods == self.type_name else '' 132 if 'getter' in properties and not self.is_inherited_flag:
133 self.getter_method_name = method_name(join_name(getter_prefix, name_for_ methods)) 133 self.getter_method_name = properties['getter']
134 self.setter_method_name = method_name(join_name('set', name_for_methods) ) 134 else:
135 self.initial_method_name = method_name(join_name('initial', name_for_met hods)) 135 getter_prefix = 'Get' if name_for_methods == self.type_name else ''
136 self.resetter_method_name = method_name(join_name('reset', name_for_meth ods)) 136 self.getter_method_name = method_name(join_name(getter_prefix, name_fo r_methods))
137 self.setter_method_name = method_name(join_name('Set', name_for_methods) )
138 self.initial_method_name = method_name(join_name('Initial', name_for_met hods))
139 self.resetter_method_name = method_name(join_name('Reset', name_for_meth ods))
137 140
138 # If the size of the field is not None, it means it is a bit field 141 # If the size of the field is not None, it means it is a bit field
139 self.is_bit_field = self.size is not None 142 self.is_bit_field = self.size is not None
140 143
141 assert len(kwargs) == 0, 'Unexpected arguments provided to Field: ' + st r(kwargs) 144 assert len(kwargs) == 0, 'Unexpected arguments provided to Field: ' + st r(kwargs)
142 145
143 146
144 def _get_include_paths(properties): 147 def _get_include_paths(properties):
145 """ 148 """
146 Get a list of paths that need to be included for ComputedStyleBase. 149 Get a list of paths that need to be included for ComputedStyleBase.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return Field( 217 return Field(
215 field_role, 218 field_role,
216 name_for_methods, 219 name_for_methods,
217 property_name=property_['name'], 220 property_name=property_['name'],
218 inherited=property_['inherited'], 221 inherited=property_['inherited'],
219 independent=property_['independent'], 222 independent=property_['independent'],
220 type_name=type_name, 223 type_name=type_name,
221 field_template=property_['field_template'], 224 field_template=property_['field_template'],
222 size=size, 225 size=size,
223 default_value=default_value, 226 default_value=default_value,
227 properties=property_,
224 ) 228 )
225 229
226 230
227 def _create_inherited_flag_field(property_): 231 def _create_inherited_flag_field(property_):
228 """ 232 """
229 Create the field used for an inheritance fast path from an independent CSS p roperty, 233 Create the field used for an inheritance fast path from an independent CSS p roperty,
230 and return the Field object. 234 and return the Field object.
231 """ 235 """
232 return Field( 236 return Field(
233 'inherited_flag', 237 'inherited_flag',
234 join_name(property_['name_for_methods'], 'is inherited'), 238 join_name(property_['name_for_methods'], 'is inherited'),
235 property_name=property_['name'], 239 property_name=property_['name'],
236 type_name='bool', 240 type_name='bool',
237 field_template='primitive', 241 field_template='primitive',
238 size=1, 242 size=1,
239 default_value='true', 243 default_value='true',
244 properties=property_,
240 ) 245 )
241 246
242 247
243 def _create_fields(field_role, properties): 248 def _create_fields(field_role, properties):
244 """ 249 """
245 Create ComputedStyle fields from properties or nonproperties and return a li st of Field objects. 250 Create ComputedStyle fields from properties or nonproperties and return a li st of Field objects.
246 """ 251 """
247 fields = [] 252 fields = []
248 for property_ in properties: 253 for property_ in properties:
249 # Only generate properties that have a field template 254 # Only generate properties that have a field template
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']], 402 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']],
398 } 403 }
399 404
400 return { 405 return {
401 'include_paths': self._include_paths, 406 'include_paths': self._include_paths,
402 'mappings': mappings, 407 'mappings': mappings,
403 } 408 }
404 409
405 if __name__ == '__main__': 410 if __name__ == '__main__':
406 json5_generator.Maker(ComputedStyleBaseWriter).main() 411 json5_generator.Maker(ComputedStyleBaseWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698