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

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

Issue 2620883002: Convert Settings.in, CSSValueKeywords.in, SVGCSSValueKeywords.in to json5 (Closed)
Patch Set: Convert CSSProperties.in to json5 format Created 3 years, 11 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 in_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 13 from name_utilities import camel_case
14 14
15 15
16 class Field(object): 16 class Field(object):
17 """ 17 """
18 The generated ComputedStyle object is made up of a series of Fields. 18 The generated ComputedStyle object is made up of a series of Fields.
19 Each Field has a name, size, type, etc, and a bunch of attributes to 19 Each Field has a name, size, type, etc, and a bunch of attributes to
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 self.is_inherited_method_name = kwargs.pop('is_inherited_method_name ') 62 self.is_inherited_method_name = kwargs.pop('is_inherited_method_name ')
63 elif self.is_inherited_flag: 63 elif self.is_inherited_flag:
64 # Inherited flag-only fields 64 # Inherited flag-only fields
65 pass 65 pass
66 66
67 assert len(kwargs) == 0, 'Unexpected arguments provided to Field: ' + st r(kwargs) 67 assert len(kwargs) == 0, 'Unexpected arguments provided to Field: ' + st r(kwargs)
68 68
69 69
70 class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter): 70 class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
71 def __init__(self, in_file_path): 71 def __init__(self, json5_file_path):
72 super(ComputedStyleBaseWriter, self).__init__(in_file_path) 72 super(ComputedStyleBaseWriter, self).__init__(json5_file_path)
73 self._outputs = { 73 self._outputs = {
74 'ComputedStyleBase.h': self.generate_base_computed_style_h, 74 'ComputedStyleBase.h': self.generate_base_computed_style_h,
75 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, 75 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp,
76 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co nstants, 76 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_co nstants,
77 } 77 }
78 78
79 # A map of enum name -> list of enum values 79 # A map of enum name -> list of enum values
80 self._computed_enums = {} 80 self._computed_enums = {}
81 for property in self._properties.values(): 81 for property in self._properties.values():
82 # Only generate enums for keyword properties that use the default fi eld_storage_type. 82 # Only generate enums for keyword properties that use the default fi eld_storage_type.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl') 225 @template_expander.use_jinja('ComputedStyleBaseConstants.h.tmpl')
226 def generate_base_computed_style_constants(self): 226 def generate_base_computed_style_constants(self):
227 return { 227 return {
228 'properties': self._properties, 228 'properties': self._properties,
229 'enums': self._computed_enums, 229 'enums': self._computed_enums,
230 'fields': self._fields, 230 'fields': self._fields,
231 'expected_total_field_bytes': self._expected_total_field_bytes, 231 'expected_total_field_bytes': self._expected_total_field_bytes,
232 } 232 }
233 233
234 if __name__ == '__main__': 234 if __name__ == '__main__':
235 in_generator.Maker(ComputedStyleBaseWriter).main(sys.argv) 235 json5_generator.Maker(ComputedStyleBaseWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698