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

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

Issue 2812823004: Revert of Separate CSSValueID mappings generator from ComputedStyleBase generator. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/make_css_value_id_mappings.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 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 return field_buckets 279 return field_buckets
280 280
281 281
282 class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): 282 class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
283 def __init__(self, json5_file_path): 283 def __init__(self, json5_file_path):
284 super(ComputedStyleBaseWriter, self).__init__(json5_file_path) 284 super(ComputedStyleBaseWriter, self).__init__(json5_file_path)
285 self._outputs = { 285 self._outputs = {
286 'ComputedStyleBase.h': self.generate_base_computed_style_h, 286 'ComputedStyleBase.h': self.generate_base_computed_style_h,
287 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, 287 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp,
288 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co nstants, 288 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co nstants,
289 'CSSValueIDMappingsGenerated.h': self.generate_css_value_mappings,
289 } 290 }
290 291
291 # TODO(shend): Remove this once we move NONPROPERTIES to its own JSON fi le, 292 # TODO(shend): Remove this once we move NONPROPERTIES to its own JSON fi le,
292 # since the JSON5 reader will handle missing fields and defaults. 293 # since the JSON5 reader will handle missing fields and defaults.
293 for property_ in NONPROPERTIES: 294 for property_ in NONPROPERTIES:
294 property_['name_for_methods'] = property_['name'] 295 property_['name_for_methods'] = property_['name']
295 if 'field_type_path' not in property_: 296 if 'field_type_path' not in property_:
296 property_['field_type_path'] = None 297 property_['field_type_path'] = None
297 if 'type_name' not in property_: 298 if 'type_name' not in property_:
298 property_['type_name'] = 'E' + enum_type_name(property_['name_fo r_methods']) 299 property_['type_name'] = 'E' + enum_type_name(property_['name_fo r_methods'])
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 367 }
367 368
368 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') 369 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl')
369 def generate_base_computed_style_constants(self): 370 def generate_base_computed_style_constants(self):
370 return { 371 return {
371 'properties': self._properties, 372 'properties': self._properties,
372 'enums': self._generated_enums, 373 'enums': self._generated_enums,
373 'fields': self._fields, 374 'fields': self._fields,
374 } 375 }
375 376
377 @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl')
378 def generate_css_value_mappings(self):
379 mappings = {}
380
381 for property_ in self._properties.values():
382 if property_['field_template'] == 'keyword':
383 mappings[property_['type_name']] = {
384 'default_value': enum_value_name(property_['default_value']) ,
385 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']],
386 }
387
388 return {
389 'include_paths': self._include_paths,
390 'mappings': mappings,
391 }
392
376 if __name__ == '__main__': 393 if __name__ == '__main__':
377 json5_generator.Maker(ComputedStyleBaseWriter).main() 394 json5_generator.Maker(ComputedStyleBaseWriter).main()
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/make_css_value_id_mappings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698