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

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

Issue 2794853002: Separate CSSValueID mappings generator from ComputedStyleBase generator. (Closed)
Patch Set: Fix build.gn 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return field_buckets 298 return field_buckets
299 299
300 300
301 class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): 301 class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
302 def __init__(self, json5_file_path): 302 def __init__(self, json5_file_path):
303 super(ComputedStyleBaseWriter, self).__init__(json5_file_path) 303 super(ComputedStyleBaseWriter, self).__init__(json5_file_path)
304 self._outputs = { 304 self._outputs = {
305 'ComputedStyleBase.h': self.generate_base_computed_style_h, 305 'ComputedStyleBase.h': self.generate_base_computed_style_h,
306 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, 306 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp,
307 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co nstants, 307 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co nstants,
308 'CSSValueIDMappingsGenerated.h': self.generate_css_value_mappings,
309 } 308 }
310 309
311 # TODO(shend): Remove this once we move NONPROPERTIES to its own JSON fi le, 310 # TODO(shend): Remove this once we move NONPROPERTIES to its own JSON fi le,
312 # since the JSON5 reader will handle missing fields and defaults. 311 # since the JSON5 reader will handle missing fields and defaults.
313 for property_ in NONPROPERTIES: 312 for property_ in NONPROPERTIES:
314 property_['name_for_methods'] = property_['name'] 313 property_['name_for_methods'] = property_['name']
315 if 'field_type_path' not in property_: 314 if 'field_type_path' not in property_:
316 property_['field_type_path'] = None 315 property_['field_type_path'] = None
317 if 'type_name' not in property_: 316 if 'type_name' not in property_:
318 property_['type_name'] = 'E' + enum_type_name(property_['name_fo r_methods']) 317 property_['type_name'] = 'E' + enum_type_name(property_['name_fo r_methods'])
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 387 }
389 388
390 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') 389 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl')
391 def generate_base_computed_style_constants(self): 390 def generate_base_computed_style_constants(self):
392 return { 391 return {
393 'properties': self._properties, 392 'properties': self._properties,
394 'enums': self._generated_enums, 393 'enums': self._generated_enums,
395 'fields': self._fields, 394 'fields': self._fields,
396 } 395 }
397 396
398 @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl')
399 def generate_css_value_mappings(self):
400 mappings = {}
401
402 for property_ in self._properties.values():
403 if property_['field_template'] == 'keyword':
404 mappings[property_['type_name']] = {
405 'default_value': enum_value_name(property_['default_value']) ,
406 'mapping': [(enum_value_name(k), enum_for_css_keyword(k)) fo r k in property_['keywords']],
407 }
408
409 return {
410 'include_paths': self._include_paths,
411 'mappings': mappings,
412 }
413
414 if __name__ == '__main__': 397 if __name__ == '__main__':
415 json5_generator.Maker(ComputedStyleBaseWriter).main() 398 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