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

Unified Diff: third_party/WebKit/Source/build/scripts/make_computed_style_base.py

Issue 2702173002: Generate mappings between CSSValueID and ComputedStyle enums. (Closed)
Patch Set: Forgot case Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/CSSValueIDMappingsGenerated.h.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/build/scripts/make_computed_style_base.py
diff --git a/third_party/WebKit/Source/build/scripts/make_computed_style_base.py b/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
index 1367b7f18538ba98157805dc5d6def55b0fc608e..b86dd26ff1b37465366b2d5fefbac463569ad2b8 100755
--- a/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
+++ b/third_party/WebKit/Source/build/scripts/make_computed_style_base.py
@@ -10,7 +10,7 @@ import json5_generator
import template_expander
import make_style_builder
-from name_utilities import camel_case, lower_first, upper_first_letter
+from name_utilities import camel_case, lower_first, upper_first_letter, enum_for_css_keyword
# Temporary hard-coded list of fields that are not CSS properties.
@@ -133,12 +133,7 @@ def _create_property_field(property_):
# From the Blink style guide: Other data members should be prefixed by "m_". [names-data-members]
field_name = 'm_' + property_name_lower
bits_needed = math.log(len(property_['keywords']), 2) # TODO: implement for non-enums
-
- # Separate the type path from the type name, if specified.
- if property_['field_type_path']:
- type_name = property_['field_type_path'].split('/')[-1]
- else:
- type_name = property_['type_name']
+ type_name = property_['type_name']
# For now, the getter name should match the field name. Later, getter names
# will start with an uppercase letter, so if they conflict with the type name,
@@ -279,8 +274,16 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
'ComputedStyleBase.h': self.generate_base_computed_style_h,
'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp,
'ComputedStyleBaseConstants.h': self.generate_base_computed_style_constants,
+ 'CSSValueIDMappingsGenerated.h': self.generate_css_value_mappings,
}
+ property_values = self._properties.values()
+
+ # Override the type name when field_type_path is specified
+ for property_ in property_values:
+ if property_['field_type_path']:
+ property_['type_name'] = property_['field_type_path'].split('/')[-1]
+
# Create all the enums used by properties
self._generated_enums = _create_enums(self._properties.values())
@@ -316,13 +319,15 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
for field in bucket:
self._fields.append(field)
+ self._include_paths = _get_include_paths(self._properties.values())
+
@template_expander.use_jinja('ComputedStyleBase.h.tmpl')
def generate_base_computed_style_h(self):
return {
'properties': self._properties,
'enums': self._generated_enums,
- 'include_paths': _get_include_paths(self._properties.values()),
+ 'include_paths': self._include_paths,
'fields': self._fields,
'expected_total_field_bytes': self._expected_total_field_bytes,
}
@@ -345,5 +350,21 @@ class ComputedStyleBaseWriter(make_style_builder.StyleBuilderWriter):
'expected_total_field_bytes': self._expected_total_field_bytes,
}
+ @template_expander.use_jinja('CSSValueIDMappingsGenerated.h.tmpl')
+ def generate_css_value_mappings(self):
+ mappings = {}
+
+ for property_ in self._properties.values():
+ if property_['field_template'] == 'keyword':
+ mappings[property_['type_name']] = {
+ 'default_value': 'k' + camel_case(property_['initial_keyword']),
+ 'mapping': [('k' + camel_case(k), enum_for_css_keyword(k)) for k in property_['keywords']],
+ }
+
+ return {
+ 'include_paths': self._include_paths,
+ 'mappings': mappings,
+ }
+
if __name__ == '__main__':
json5_generator.Maker(ComputedStyleBaseWriter).main()
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/CSSValueIDMappingsGenerated.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698