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

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

Issue 2742263002: Add 'storage_only' template to make_computed_style_base.py. (Closed)
Patch Set: Created 3 years, 9 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
11 import make_style_builder 11 import make_style_builder
12 12
13 from name_utilities import camel_case, lower_first, upper_first_letter, enum_for _css_keyword 13 from name_utilities import camel_case, lower_first, upper_first_letter, enum_for _css_keyword
14 14
15 15
16 # Temporary hard-coded list of fields that are not CSS properties. 16 # Temporary hard-coded list of fields that are not CSS properties.
17 # Ideally these would be specified in a .json5 file. 17 # Ideally these would be specified in a .json5 file.
18 NONPROPERTY_FIELDS = [ 18 NONPROPERTY_FIELDS = [
19 # Style can not be shared. 19 # Style can not be shared.
20 {'name': 'unique', 'field': {'template': 'monotonic_flag'}}, 20 {'name': 'unique', 'field': {'template': 'monotonic_flag'}},
21 # Whether this style is affected by these pseudo-classes. 21 # Whether this style is affected by these pseudo-classes.
22 {'name': 'affectedByFocus', 'field': {'template': 'monotonic_flag'}}, 22 {'name': 'affectedByFocus', 'field': {'template': 'monotonic_flag'}},
23 {'name': 'affectedByHover', 'field': {'template': 'monotonic_flag'}}, 23 {'name': 'affectedByHover', 'field': {'template': 'monotonic_flag'}},
24 {'name': 'affectedByActive', 'field': {'template': 'monotonic_flag'}}, 24 {'name': 'affectedByActive', 'field': {'template': 'monotonic_flag'}},
25 {'name': 'affectedByDrag', 'field': {'template': 'monotonic_flag'}}, 25 {'name': 'affectedByDrag', 'field': {'template': 'monotonic_flag'}},
26 # A non-inherited property references a variable or @apply is used 26 # A non-inherited property references a variable or @apply is used
27 {'name': 'hasVariableReferenceFromNonInheritedProperty', 'field': {'template ': 'monotonic_flag'}}, 27 {'name': 'hasVariableReferenceFromNonInheritedProperty', 'field': {'template ': 'monotonic_flag'}},
28 # Explicitly inherits a non-inherited property 28 # Explicitly inherits a non-inherited property
29 {'name': 'hasExplicitlyInheritedProperties', 'field': {'template': 'monotoni c_flag'}}, 29 {'name': 'hasExplicitlyInheritedProperties', 'field': {'template': 'monotoni c_flag'}},
30 {'name': 'emptyState', 'field': {'template': 'storage_only', 'size': 1}},
sashab 2017/03/13 07:57:11 # These properties only have generated storage, an
shend 2017/03/14 22:20:06 Done.
30 ] 31 ]
31 32
32 33
33 class Field(object): 34 class Field(object):
34 """ 35 """
35 The generated ComputedStyle object is made up of a series of Fields. 36 The generated ComputedStyle object is made up of a series of Fields.
36 Each Field has a name, size, type, etc, and a bunch of attributes to 37 Each Field has a name, size, type, etc, and a bunch of attributes to
37 determine which methods it will be used in. 38 determine which methods it will be used in.
38 39
39 A Field also has enough information to use any storage type in C++, such as 40 A Field also has enough information to use any storage type in C++, such as
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 setter_method_name='set' + field_name_suffix_upper, 198 setter_method_name='set' + field_name_suffix_upper,
198 initial_method_name='initial' + field_name_suffix_upper, 199 initial_method_name='initial' + field_name_suffix_upper,
199 resetter_method_name='reset' + field_name_suffix_upper, 200 resetter_method_name='reset' + field_name_suffix_upper,
200 ) 201 )
201 202
202 203
203 def _create_nonproperty_field(property_): 204 def _create_nonproperty_field(property_):
204 """ 205 """
205 Create a nonproperty field from its name and return the Field object. 206 Create a nonproperty field from its name and return the Field object.
206 """ 207 """
207 # TODO(shend): Make this work for nonflags 208 # TODO(shend): Make this work for other templates (need to compute size corr ectly)
208 assert property_['field']['template'] in ('flag', 'monotonic_flag'), \ 209 assert property_['field']['template'] in ('flag', 'monotonic_flag', 'storage _only'), \
209 "Nonproperties with arbitrary templates are not yet supported" 210 "Nonproperties with arbitrary templates are not yet supported"
210 member_name = 'm_' + property_['name'] 211 member_name = 'm_' + property_['name']
211 field_name_upper = upper_first_letter(property_['name']) 212 field_name_upper = upper_first_letter(property_['name'])
212 213
213 return Field( 214 return Field(
214 'nonproperty', 215 'nonproperty',
215 name=member_name, 216 name=member_name,
216 property_name=property_['name'], 217 property_name=property_['name'],
217 type_name='bool', 218 type_name='bool',
218 template=property_['field']['template'], 219 template=property_['field']['template'],
219 size=1, 220 size=property_['field'].get('size', 1),
sashab 2017/03/13 07:57:11 Can you document somewhere (like at the top of the
shend 2017/03/14 22:20:06 Done.
220 default_value='false', 221 default_value='false',
221 getter_method_name=property_['name'], 222 getter_method_name=property_['name'],
222 setter_method_name='set' + field_name_upper, 223 setter_method_name='set' + field_name_upper,
223 initial_method_name='initial' + field_name_upper, 224 initial_method_name='initial' + field_name_upper,
224 resetter_method_name='reset' + field_name_upper, 225 resetter_method_name='reset' + field_name_upper,
225 ) 226 )
226 227
227 228
228 def _create_fields(properties): 229 def _create_fields(properties):
229 """ 230 """
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 'mapping': [('k' + camel_case(k), enum_for_css_keyword(k)) f or k in property_['keywords']], 380 'mapping': [('k' + camel_case(k), enum_for_css_keyword(k)) f or k in property_['keywords']],
380 } 381 }
381 382
382 return { 383 return {
383 'include_paths': self._include_paths, 384 'include_paths': self._include_paths,
384 'mappings': mappings, 385 'mappings': mappings,
385 } 386 }
386 387
387 if __name__ == '__main__': 388 if __name__ == '__main__':
388 json5_generator.Maker(ComputedStyleBaseWriter).main() 389 json5_generator.Maker(ComputedStyleBaseWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698