def __init__(self, json5_file_paths, output_dir): super(ComputedStyleBaseWriter, self).__init__([], output_dir) self._input_files = json5_file_paths # Reads css_properties.json5, computed_style_field_aliases.json5, # runtime_enabled_features.json5 and computed_style_extra_fields.json5 self._css_properties = css_properties.CSSProperties( json5_file_paths[0:4]) # We sort the enum values based on each value's position in # the keywords as listed in css_properties.json5. This will ensure that # if there is a continuous # segment in css_properties.json5 matching the segment in this enum then # the generated enum will have the same order and continuity as # css_properties.json5 and we can get the longest continuous segment. # Thereby reduce the switch case statement to the minimum. properties = keyword_utils.sort_keyword_properties_by_canonical_order( self._css_properties.longhands, json5_file_paths[5], self.default_parameters) self._properties = properties + self._css_properties.extra_fields self._generated_enums = _create_enums(self._properties) # Organise fields into a tree structure where the root group # is ComputedStyleBase. group_parameters = dict([ (conf["name"], conf["cumulative_distribution"]) for conf in json5_generator.Json5File.load_from_files( [json5_file_paths[7]]).name_dictionaries ]) properties_ranking = [ x["name"].original for x in json5_generator.Json5File.load_from_files( [json5_file_paths[6]]).name_dictionaries ] _evaluate_rare_non_inherited_group( self._properties, properties_ranking, len(group_parameters["rare_non_inherited_properties_rule"]), group_parameters["rare_non_inherited_properties_rule"]) _evaluate_rare_inherit_group( self._properties, properties_ranking, len(group_parameters["rare_inherited_properties_rule"]), group_parameters["rare_inherited_properties_rule"]) self._root_group = _create_groups(self._properties) self._diff_functions_map = _create_diff_groups_map( json5_generator.Json5File.load_from_files([json5_file_paths[4] ]).name_dictionaries, self._root_group) self._include_paths = _get_include_paths(self._properties) self._outputs = { 'computed_style_base.h': self.generate_base_computed_style_h, 'computed_style_base.cc': self.generate_base_computed_style_cpp, 'computed_style_base_constants.h': self.generate_base_computed_style_constants, }
def __init__(self, json5_file_paths, output_dir): super(CSSValueIDMappingsWriter, self).__init__(json5_file_paths, output_dir) self._outputs = { 'css_value_id_mappings_generated.h': self.generate_css_value_mappings, } self.css_values_dictionary_file = json5_file_paths[2] css_properties = self.css_properties.longhands # We sort the enum values based on each value's position in # the keywords as listed in CSSProperties.json5. This will ensure that if there is a continuous # segment in CSSProperties.json5 matching the segment in this enum then # the generated enum will have the same order and continuity as # CSSProperties.json5 and we can get the longest continuous segment. # Thereby reduce the switch case statement to the minimum. css_properties = keyword_utils.sort_keyword_properties_by_canonical_order( css_properties, json5_file_paths[2], self.default_parameters)
def __init__(self, json5_file_paths): # Read CSSProperties.json5 super(ComputedStyleBaseWriter, self).__init__([json5_file_paths[0]]) # Ignore shorthand properties for property_ in self._properties.values(): if property_['field_template'] is not None: assert not property_['longhands'], \ "Shorthand '{}' cannot have a field_template.".format(property_['name']) css_properties = [ value for value in self._properties.values() if not value['longhands'] ] # We sort the enum values based on each value's position in # the keywords as listed in CSSProperties.json5. This will ensure that if there is a continuous # segment in CSSProperties.json5 matching the segment in this enum then # the generated enum will have the same order and continuity as # CSSProperties.json5 and we can get the longest continuous segment. # Thereby reduce the switch case statement to the minimum. css_properties = keyword_utils.sort_keyword_properties_by_canonical_order( css_properties, json5_file_paths[3], self.json5_file.parameters) for property_ in css_properties: # Set default values for extra parameters in ComputedStyleExtraFields.json5. property_['custom_copy'] = False property_['custom_compare'] = False property_['mutable'] = False # Read ComputedStyleExtraFields.json5 using the parameter specification from the CSS properties file. extra_fields = json5_generator.Json5File.load_from_files( [json5_file_paths[1]], default_parameters=self.json5_file.parameters).name_dictionaries for property_ in extra_fields: if property_['mutable']: assert property_['field_template'] == 'monotonic_flag', \ 'mutable keyword only implemented for monotonic_flag' make_style_builder.apply_property_naming_defaults(property_) all_properties = css_properties + extra_fields self._generated_enums = _create_enums(all_properties) # Organise fields into a tree structure where the root group # is ComputedStyleBase. group_parameters = dict([ (conf["name"], conf["cumulative_distribution"]) for conf in json5_generator.Json5File.load_from_files( [json5_file_paths[5]]).name_dictionaries ]) _evaluate_rare_non_inherited_group( all_properties, json5_file_paths[4], len(group_parameters["rare_non_inherited_properties_rule"]), group_parameters["rare_non_inherited_properties_rule"]) _evaluate_rare_inherit_group( all_properties, json5_file_paths[4], len(group_parameters["rare_inherited_properties_rule"]), group_parameters["rare_inherited_properties_rule"]) alias_dictionary = dict([ (alias["name"], alias) for alias in json5_generator.Json5File.load_from_files( [json5_file_paths[6]]).name_dictionaries ]) self._root_group = _create_groups(all_properties, alias_dictionary) self._diff_functions_map = _create_diff_groups_map( json5_generator.Json5File.load_from_files([json5_file_paths[2] ]).name_dictionaries, self._root_group) self._include_paths = _get_include_paths(all_properties) self._outputs = { 'ComputedStyleBase.h': self.generate_base_computed_style_h, 'ComputedStyleBase.cpp': self.generate_base_computed_style_cpp, 'ComputedStyleBaseConstants.h': self.generate_base_computed_style_constants, }