diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/build/scripts')
63 files changed, 294 insertions, 235 deletions
diff --git a/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py b/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py index a989def3854..9c44e535b22 100644 --- a/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py +++ b/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter.py @@ -60,6 +60,7 @@ SPECIAL_TOKENS = [ 'FE', 'V0', 'V8', + 'v8', ] _SPECIAL_TOKENS_WITH_NUMBERS = [token for token in SPECIAL_TOKENS if re.search(r'[0-9]', token)] @@ -226,3 +227,10 @@ class NameStyleConverter(object): i.e. kUpperCamelCase """ return 'k' + self.to_upper_camel_case() + + def to_header_guard(self): + """Represents this name as a header guard style in Chromium C++ style. + + i.e. THIRD_PARTY_BLINK_RENDERER_MODULES_MODULES_EXPORT_H_ + """ + return re.sub(r'[-/.]', '_', self.to_macro_case()) + '_' diff --git a/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter_test.py b/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter_test.py index d3d5944b674..09daf14a4d1 100644 --- a/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter_test.py +++ b/chromium/third_party/blink/renderer/build/scripts/blinkbuild/name_style_converter_test.py @@ -191,3 +191,10 @@ class NameStyleConverterTest(unittest.TestCase): 'upper_camel_case': 'SVGScriptElement', 'macro_case': 'SVG_SCRIPT_ELEMENT', }) + + def test_to_header_guard(self): + converter = NameStyleConverter('third_party/blink/renderer/bindings/modules/v8/v8_path_2d.h') + self.assertEqual(converter.to_header_guard(), 'THIRD_PARTY_BLINK_RENDERER_BINDINGS_MODULES_V8_V8_PATH_2D_H_') + +if __name__ == '__main__': + unittest.main() diff --git a/chromium/third_party/blink/renderer/build/scripts/make_css_primitive_value_unit_trie.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_primitive_value_unit_trie.py index b6c0cfb6164..316284c0cbf 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_css_primitive_value_unit_trie.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_primitive_value_unit_trie.py @@ -3,7 +3,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import os import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) import json5_generator import trie_builder @@ -20,7 +22,7 @@ class UnitTrieWriter(json5_generator.Writer): 'css_primitive_value_unit_trie.cc': self.generate_implementation } - @template_expander.use_jinja('templates/css_primitive_value_unit_trie.cc.tmpl') + @template_expander.use_jinja('core/css/templates/css_primitive_value_unit_trie.cc.tmpl') def generate_implementation(self): return { 'input_files': self._input_files, diff --git a/chromium/third_party/blink/renderer/build/scripts/make_css_property_names.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_property_names.py index 4a9c81cff33..5cb3e205fff 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_css_property_names.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_property_names.py @@ -1,5 +1,9 @@ #!/usr/bin/env python +import os +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) + from core.css import css_properties import gperf import json5_generator @@ -25,7 +29,7 @@ class CSSPropertyNamesWriter(json5_generator.Writer): return " static_cast<CSSPropertyID>(%(enum_value)s), " \ "// %(property_id)s" % property_ - @template_expander.use_jinja('templates/css_property_names.h.tmpl') + @template_expander.use_jinja('core/css/templates/css_property_names.h.tmpl') def generate_header(self): return { 'alias_offset': self._css_properties.alias_offset, @@ -45,7 +49,7 @@ class CSSPropertyNamesWriter(json5_generator.Writer): max(map(len, self._css_properties.properties_by_id)), } - @gperf.use_jinja_gperf_template('templates/css_property_names.cc.tmpl', + @gperf.use_jinja_gperf_template('core/css/templates/css_property_names.cc.tmpl', ['-Q', 'CSSPropStringPool']) def generate_implementation(self): enum_value_to_name = {} diff --git a/chromium/third_party/blink/renderer/build/scripts/make_css_tokenizer_codepoints.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_tokenizer_codepoints.py index 54d4a374606..c48d23ae703 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_css_tokenizer_codepoints.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_tokenizer_codepoints.py @@ -4,9 +4,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import in_generator -import sys import os +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) + +import in_generator module_basename = os.path.basename(__file__) module_pyname = os.path.splitext(module_basename)[0] + '.py' diff --git a/chromium/third_party/blink/renderer/build/scripts/make_css_value_id_mappings.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_value_id_mappings.py index 907821095d1..b0cdb892012 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_css_value_id_mappings.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_value_id_mappings.py @@ -3,6 +3,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import os +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) + from blinkbuild.name_style_converter import NameStyleConverter import json5_generator import template_expander @@ -115,7 +119,7 @@ class CSSValueIDMappingsWriter(make_style_builder.StyleBuilderWriter): css_properties = keyword_utils.sort_keyword_properties_by_canonical_order( css_properties, json5_file_paths[2], self.default_parameters) - @template_expander.use_jinja('templates/css_value_id_mappings_generated.h.tmpl') + @template_expander.use_jinja('core/css/templates/css_value_id_mappings_generated.h.tmpl') def generate_css_value_mappings(self): mappings = {} include_paths = set() diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_value_keywords.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_value_keywords.py index c9ea5d05b8f..7c08560cfcf 100755 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_value_keywords.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_css_value_keywords.py @@ -14,11 +14,13 @@ import gperf class CSSValueKeywordsWriter(json5_generator.Writer): + _FILE_BASENAME = 'css_value_keywords' + def __init__(self, file_paths, output_dir): json5_generator.Writer.__init__(self, file_paths, output_dir) self._outputs = { - "css_value_keywords.h": self.generate_header, - "css_value_keywords.cc": self.generate_implementation + (self._FILE_BASENAME + '.h'): self.generate_header, + (self._FILE_BASENAME + '.cc'): self.generate_implementation, } self._value_keywords = self.json5_file.name_dictionaries @@ -43,6 +45,7 @@ class CSSValueKeywordsWriter(json5_generator.Writer): 'value_keywords_count': self._keyword_count, 'max_value_keyword_length': max(len(keyword['name'].original) for keyword in self._value_keywords), + 'header_guard': self.make_header_guard(self._relative_output_dir + self._FILE_BASENAME + '.h') } def _value_keywords_with_mode(self, mode): diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_feature_names.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_feature_names.py index 273aaba6a3c..5f1ad9cbf88 100755 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_feature_names.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_feature_names.py @@ -14,9 +14,12 @@ import media_feature_symbol class MakeMediaFeatureNamesWriter(make_names.MakeNamesWriter): - pass -MakeMediaFeatureNamesWriter.filters['symbol'] = media_feature_symbol.getMediaFeatureSymbolWithSuffix('MediaFeature') + def __init__(self, json5_file_path, output_dir): + super(MakeMediaFeatureNamesWriter, self).__init__(json5_file_path, output_dir) + MakeMediaFeatureNamesWriter.filters['symbol'] = ( + media_feature_symbol.getMediaFeatureSymbolWithSuffix('MediaFeature')) + if __name__ == "__main__": json5_generator.Maker(MakeMediaFeatureNamesWriter).main() diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_features.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_features.py index 487e6b3f732..fcf89d7d4f2 100755 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_features.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_media_features.py @@ -21,7 +21,8 @@ class MakeMediaFeaturesWriter(json5_generator.Writer): } filters = { 'symbol': media_feature_symbol.getMediaFeatureSymbolWithSuffix(''), - 'to_function_name': lambda symbol: NameStyleConverter(symbol).to_function_name(), + # symbol[1:] removes the leading 'k' produced by the above function. + 'to_function_name': lambda symbol: NameStyleConverter(symbol[1:]).to_function_name(), } def __init__(self, json5_file_path, output_dir): @@ -33,6 +34,7 @@ class MakeMediaFeaturesWriter(json5_generator.Writer): self._template_context = { 'entries': self.json5_file.name_dictionaries, 'input_files': self._input_files, + 'header_guard': self.make_header_guard(self._relative_output_dir + 'media_festures.h') } @template_expander.use_jinja('core/css/templates/media_features.h.tmpl', filters=filters) diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py b/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py index 11e80e2c5c9..060d2f32a5a 100755 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/make_style_shorthands.py @@ -40,15 +40,17 @@ import template_expander class StylePropertyShorthandWriter(json5_generator.Writer): class_name = 'StylePropertyShorthand' + _FILE_BASENAME = 'style_property_shorthand' def __init__(self, json5_file_paths, output_dir): super(StylePropertyShorthandWriter, self).__init__([], output_dir) self._input_files = json5_file_paths self._outputs = { - 'style_property_shorthand.cc': + (self._FILE_BASENAME + '.cc'): self.generate_style_property_shorthand_cpp, - 'style_property_shorthand.h': - self.generate_style_property_shorthand_h} + (self._FILE_BASENAME + '.h'): + self.generate_style_property_shorthand_h + } json5_properties = css_properties.CSSProperties(json5_file_paths) self._shorthands = json5_properties.shorthands @@ -83,6 +85,7 @@ class StylePropertyShorthandWriter(json5_generator.Writer): return { 'input_files': self._input_files, 'properties': self._shorthands, + 'header_guard': self.make_header_guard(self._relative_output_dir + self._FILE_BASENAME + '.h') } if __name__ == '__main__': diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/parser/templates/at_rule_descriptors.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/parser/templates/at_rule_descriptors.h.tmpl index 0e41a3e1031..900fa592198 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/parser/templates/at_rule_descriptors.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/parser/templates/at_rule_descriptors.h.tmpl @@ -5,7 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PARSER_AT_RULE_DESCRIPTORS_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PARSER_AT_RULE_DESCRIPTORS_H_ -#include "third_party/blink/renderer/core/css_property_names.h" +#include "third_party/blink/renderer/core/css/css_property_names.h" #include "third_party/blink/renderer/platform/wtf/text/string_view.h" #include <string.h> diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl index 1947b2ffc35..becfce1a85b 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property.h.tmpl @@ -9,7 +9,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_H_ -#include "third_party/blink/renderer/core/css_property_names.h" +#include "third_party/blink/renderer/core/css/css_property_names.h" #include "third_party/blink/renderer/core/css/css_value.h" #include "third_party/blink/renderer/core/css/properties/css_unresolved_property.h" #include "third_party/blink/renderer/platform/heap/heap_allocator.h" diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.cc.tmpl index 3647ca60c02..838dccaf48d 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.cc.tmpl @@ -13,9 +13,9 @@ {% endfor %} namespace blink { -namespace CSSLonghand { +namespace css_longhand { {{style_builder_functions(property, false)}} -} // namespace CSSLonghand +} // namespace css_longhand } // namespace blink diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.h.tmpl index 91a0efed320..94e9ee344bb 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_property_subclass.h.tmpl @@ -14,14 +14,14 @@ {% endfor %} namespace blink { -namespace CSS{{property.namespace_group}} { +namespace css_{{property.namespace_group.lower()}} { {% if property.is_property %} // Implements the '{{property.name}}' CSS property {% else %} // Implements the '{{property.name}}' CSS descriptor {% endif %} -// See src/third_party/WebKit/Source/core/css/properties/README.md +// See src/third_party/blink/renderer/core/css/properties/README.md {% if property.alias_for != None%} class {{property_classname}} final : public CSSUnresolvedProperty { public: @@ -130,7 +130,7 @@ class {{property_classname}} final : public {{property.namespace_group}} { {% endif %} }; -} // namespace CSS{{property.namespace_group}} +} // namespace css_{{property.namespace_group.lower()}} } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTIES_{{property.namespace_group.upper()}}_{{property_filename|upper}}_H_ diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.cc.tmpl index 78721960a97..56c9eb7c292 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.cc.tmpl @@ -23,10 +23,10 @@ namespace { static constexpr Variable property_csspropertyvariable; {% for _, property_id, classname, namespace_group, _ in property_classes_by_property_id %} -static constexpr CSS{{namespace_group}}::{{classname}} property_{{property_id.lower()}}; +static constexpr css_{{namespace_group.lower()}}::{{classname}} property_{{property_id.lower()}}; {% endfor %} {% for _, property_id, classname, namespace_group, _ in alias_classes_by_property_id %} -static constexpr CSS{{namespace_group}}::{{classname}} property_{{property_id.lower()}}; +static constexpr css_{{namespace_group.lower()}}::{{classname}} property_{{property_id.lower()}}; {% endfor %} } // namespace diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.h.tmpl index 440453d6c10..ea360d624a9 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/css_unresolved_property.h.tmpl @@ -9,7 +9,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_UNRESOLVED_PROPERTY_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_UNRESOLVED_PROPERTY_H_ -#include "third_party/blink/renderer/core/css_property_names.h" +#include "third_party/blink/renderer/core/css/css_property_names.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink { diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl index e10f98b0b49..5ff29d8618a 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/properties/templates/style_builder_functions.tmpl @@ -161,7 +161,7 @@ ToLonghand(resolved_property).{{apply_call}}; const NinePieceImage& current_image = state.Style()->{{getter}}(); {# Check for equality in case we can bail out before creating a new NinePieceImage. #} {% if modifier_type == 'Outset' %} - if (StyleBuildingUtils::BorderImageLengthMatchesAllSides(current_image.Outset(), + if (style_building_utils::BorderImageLengthMatchesAllSides(current_image.Outset(), BorderImageLength(Length(0, kFixed)))) return; {% elif modifier_type == 'Repeat' %} @@ -172,20 +172,20 @@ ToLonghand(resolved_property).{{apply_call}}; // Masks have a different initial value for slices. Preserve the value of 0 // for backwards compatibility. if (current_image.Fill() == true && - StyleBuildingUtils::LengthMatchesAllSides(current_image.ImageSlices(), Length(0, kFixed))) + style_building_utils::LengthMatchesAllSides(current_image.ImageSlices(), Length(0, kFixed))) return; {% elif modifier_type == 'Slice' and not is_mask_box %} if (current_image.Fill() == false && - StyleBuildingUtils::LengthMatchesAllSides(current_image.ImageSlices(), Length(100, kPercent))) + style_building_utils::LengthMatchesAllSides(current_image.ImageSlices(), Length(100, kPercent))) return; {% elif modifier_type == 'Width' and is_mask_box %} // Masks have a different initial value for widths. Preserve the value of // 'auto' for backwards compatibility. - if (StyleBuildingUtils::BorderImageLengthMatchesAllSides(current_image.BorderSlices(), + if (style_building_utils::BorderImageLengthMatchesAllSides(current_image.BorderSlices(), BorderImageLength(Length(kAuto)))) return; {% elif modifier_type == 'Width' and not is_mask_box %} - if (StyleBuildingUtils::BorderImageLengthMatchesAllSides(current_image.BorderSlices(), + if (style_building_utils::BorderImageLengthMatchesAllSides(current_image.BorderSlices(), BorderImageLength(1.0))) return; {% endif %} @@ -407,8 +407,8 @@ ToLonghand(resolved_property).{{apply_call}}; const CSSValueList& list = ToCSSValueList(value); - for (size_t i = 0; i < list.length(); ++i) { - const CSSValuePair& pair = ToCSSValuePair(list.Item(i)); + for (const CSSValue* item : list) { + const CSSValuePair& pair = ToCSSValuePair(*item); AtomicString identifier(ToCSSCustomIdentValue(pair.First()).Value()); int counter_value = ToCSSPrimitiveValue(pair.Second()).GetIntValue(); CounterDirectives& directives = diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/css_primitive_value_unit_trie.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_primitive_value_unit_trie.cc.tmpl index 84c3a5b6bfb..84c3a5b6bfb 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/css_primitive_value_unit_trie.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_primitive_value_unit_trie.cc.tmpl diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/css_property_names.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_property_names.cc.tmpl index 54c9f645a8c..25e3e6bab05 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/css_property_names.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_property_names.cc.tmpl @@ -3,7 +3,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "third_party/blink/renderer/core/{{file_basename}}.h" +#include "third_party/blink/renderer/core/css/{{file_basename}}.h" #include <string.h> #include "third_party/blink/renderer/core/css/hash_tools.h" @@ -25,7 +25,6 @@ struct Property; %omit-struct-type %language=C++ %readonly-tables -%global-table %compare-strncmp %define class-name {{class_name}}Hash %define lookup-function-name findPropertyImpl diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/css_property_names.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_property_names.h.tmpl index b20372d39c1..3b8186fa027 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/css_property_names.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_property_names.h.tmpl @@ -1,8 +1,8 @@ {% from 'templates/macros.tmpl' import license %} {{license()}} -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_NAMES_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_NAMES_H_ +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_NAMES_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_NAMES_H_ #include <stddef.h> #include "third_party/blink/renderer/core/core_export.h" @@ -62,4 +62,4 @@ CSSPropertyID CORE_EXPORT cssPropertyID(const WTF::String&); } // namespace blink -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_NAMES_H_ +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PROPERTY_NAMES_H_ diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/css_value_id_mappings_generated.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_id_mappings_generated.h.tmpl index 8e371e71baa..66d484f7f3c 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/css_value_id_mappings_generated.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_id_mappings_generated.h.tmpl @@ -3,12 +3,12 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ #include "base/logging.h" -#include "third_party/blink/renderer/core/computed_style_base_constants.h" #include "third_party/blink/renderer/core/css_value_keywords.h" +#include "third_party/blink/renderer/core/style/computed_style_base_constants.h" {% for path in include_paths %} #include "{{path}}" {% endfor %} @@ -100,4 +100,4 @@ inline CSSValueID platformEnumToCSSValueIDGenerated({{enum_name}} v) { } // namespace blink -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_VALUE_ID_MAPPINGS_GENERATED_H_ diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_keywords.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_keywords.h.tmpl index ae17728ee96..e91f3222d47 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_keywords.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/css_value_keywords.h.tmpl @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BLINK_CORE_CSS_VALUE_KEYWORDS_H_ -#define BLINK_CORE_CSS_VALUE_KEYWORDS_H_ +#ifndef {{header_guard}} +#define {{header_guard}} -#include "third_party/blink/renderer/core/css/parser/css_parser_mode.h" #include <string.h> +#include "third_party/blink/renderer/core/css/parser/css_parser_mode.h" + namespace blink { enum CSSValueID { @@ -23,6 +24,6 @@ const size_t maxCSSValueKeywordLength = {{max_value_keyword_length}}; const char* getValueName(CSSValueID); bool isValueAllowedInMode(unsigned short id, CSSParserMode mode); -} // namespace blink +} // namespace blink -#endif // BLINK_CORE_CSS_VALUE_KEYWORDS_H_ +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/cssom_types.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/cssom_types.cc.tmpl index f479b87b811..4b7dc54bb91 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/cssom_types.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/cssom_types.cc.tmpl @@ -93,7 +93,8 @@ bool CSSOMTypes::IsPropertySupported(CSSPropertyID id) { bool CSSOMTypes::PropertyCanTake(CSSPropertyID id, const AtomicString& custom_property_name, const PropertyRegistration* registration, - const CSSStyleValue& value) { + const CSSStyleValue& value, + const CSSSyntaxComponent*& match) { DCHECK_EQ(id == CSSPropertyVariable, !custom_property_name.IsNull()); if (id == CSSPropertyVariable && registration) { @@ -101,7 +102,8 @@ bool CSSOMTypes::PropertyCanTake(CSSPropertyID id, return ToCSSUnsupportedStyleValue(value).GetCustomPropertyName() == custom_property_name; } - return registration->Syntax().CanTake(value); + match = registration->Syntax().Match(value); + return match != nullptr; } if (value.GetType() == CSSStyleValue::kKeywordType) { diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/media_features.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/media_features.h.tmpl index 4f7fe5d43f3..4b8de52e195 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/media_features.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/media_features.h.tmpl @@ -1,10 +1,10 @@ {% from "templates/macros.tmpl" import license, source_files_for_generated_file %} -{{ license() }} +{{license()}} {{source_files_for_generated_file(template_file, input_files)}} -#ifndef BLINK_CORE_CSS_MEDIA_FEATURES_H_ -#define BLINK_CORE_CSS_MEDIA_FEATURES_H_ +#ifndef {{header_guard}} +#define {{header_guard}} #define CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(macro) \ {% for entry in entries %} @@ -14,4 +14,4 @@ {% endif %} {% endfor %} -#endif // BLINK_CORE_CSS_MEDIA_FEATURES_H_ +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl index 20ae092e477..49cc3b86342 100644 --- a/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/css/templates/style_property_shorthand.h.tmpl @@ -22,10 +22,10 @@ {% from 'templates/macros.tmpl' import source_files_for_generated_file %} {{source_files_for_generated_file(template_file, input_files)}} -#ifndef BLINK_CORE_STYLE_PROPERTY_SHORTHAND_H_ -#define BLINK_CORE_STYLE_PROPERTY_SHORTHAND_H_ +#ifndef {{header_guard}} +#define {{header_guard}} -#include "css_property_names.h" +#include "third_party/blink/renderer/core/css/css_property_names.h" #include "third_party/blink/renderer/core/css/properties/css_property.h" #include "third_party/blink/renderer/platform/wtf/vector.h" @@ -74,6 +74,6 @@ void getMatchingShorthandsForLonghand( unsigned indexOfShorthandForLonghand(CSSPropertyID, const Vector<StylePropertyShorthand, 4>&); -} // namespace blink +} // namespace blink -#endif // BLINK_CORE_STYLE_PROPERTY_SHORTHAND_H_ +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/make_computed_style_base.py b/chromium/third_party/blink/renderer/build/scripts/core/style/make_computed_style_base.py index a15ae5e8794..21dbfa4cae8 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_computed_style_base.py +++ b/chromium/third_party/blink/renderer/build/scripts/core/style/make_computed_style_base.py @@ -3,6 +3,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import os +import sys +sys.path.append(os.path.join(os.path.dirname(__file__), '../..')) + import math import json5_generator @@ -556,7 +560,7 @@ class ComputedStyleBaseWriter(json5_generator.Writer): } @template_expander.use_jinja( - 'templates/computed_style_base.h.tmpl', tests={'in': lambda a, b: a in b}) + 'core/style/templates/computed_style_base.h.tmpl', tests={'in': lambda a, b: a in b}) def generate_base_computed_style_h(self): return { 'input_files': self._input_files, @@ -568,7 +572,7 @@ class ComputedStyleBaseWriter(json5_generator.Writer): } @template_expander.use_jinja( - 'templates/computed_style_base.cc.tmpl', + 'core/style/templates/computed_style_base.cc.tmpl', tests={'in': lambda a, b: a in b}) def generate_base_computed_style_cpp(self): return { @@ -580,7 +584,7 @@ class ComputedStyleBaseWriter(json5_generator.Writer): 'diff_functions_map': self._diff_functions_map, } - @template_expander.use_jinja('templates/computed_style_base_constants.h.tmpl') + @template_expander.use_jinja('core/style/templates/computed_style_base_constants.h.tmpl') def generate_base_computed_style_constants(self): return { 'input_files': self._input_files, diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/computed_style_base.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/style/templates/computed_style_base.cc.tmpl index b640e745205..5697ad5a947 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/computed_style_base.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/style/templates/computed_style_base.cc.tmpl @@ -5,8 +5,8 @@ {{source_files_for_generated_file(template_file, input_files)}} -#include "third_party/blink/renderer/core/computed_style_base.h" #include "third_party/blink/renderer/core/style/computed_style.h" +#include "third_party/blink/renderer/core/style/computed_style_base.h" #include "third_party/blink/renderer/platform/wtf/size_assertions.h" namespace blink { diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/computed_style_base.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/style/templates/computed_style_base.h.tmpl index fdcf46c9442..eeaaa0586e5 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/computed_style_base.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/style/templates/computed_style_base.h.tmpl @@ -5,8 +5,8 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_COMPUTED_STYLE_BASE_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_COMPUTED_STYLE_BASE_H_ +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_H_ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/layout/layout_theme.h" @@ -185,4 +185,4 @@ class ComputedStyleBase { } // namespace blink -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_COMPUTED_STYLE_BASE_H_ +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_H_ diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/computed_style_base_constants.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/core/style/templates/computed_style_base_constants.h.tmpl index ef98612f9f5..aee3668af2f 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/computed_style_base_constants.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/core/style/templates/computed_style_base_constants.h.tmpl @@ -3,8 +3,8 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_COMPUTED_STYLE_BASE_CONSTANTS_H_ -#define THIRD_PARTY_BLINK_RENDERER_CORE_COMPUTED_STYLE_BASE_CONSTANTS_H_ +#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_CONSTANTS_H_ +#define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_CONSTANTS_H_ namespace blink { @@ -36,4 +36,4 @@ inline {{enum.type_name}}& operator{{op}}=({{enum.type_name}}& a, {{enum.type_na {% endfor %} } // namespace blink -#endif // THIRD_PARTY_BLINK_RENDERER_CORE_COMPUTED_STYLE_BASE_CONSTANTS_H_ +#endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_COMPUTED_STYLE_BASE_CONSTANTS_H_ diff --git a/chromium/third_party/blink/renderer/build/scripts/gperf.py b/chromium/third_party/blink/renderer/build/scripts/gperf.py index 057796677c4..df7b713a8a2 100644 --- a/chromium/third_party/blink/renderer/build/scripts/gperf.py +++ b/chromium/third_party/blink/renderer/build/scripts/gperf.py @@ -38,7 +38,7 @@ def generate_gperf(gperf_path, gperf_input, gperf_args): # so replace gperf's /*FALLTHROUGH*/ comment with the statement. # https://savannah.gnu.org/bugs/index.php?53029 gperf_output = gperf_output.replace('/*FALLTHROUGH*/', ' FALLTHROUGH;') - script = 'third_party/WebKit/Source/build/scripts/gperf.py' + script = 'third_party/blink/renderer/build/scripts/gperf.py' return '// Generated by %s\n' % script + gperf_output except OSError: raise subprocess.CalledProcessError( diff --git a/chromium/third_party/blink/renderer/build/scripts/json5_generator.py b/chromium/third_party/blink/renderer/build/scripts/json5_generator.py index 2a4ed7db2a5..2b8cd7520e4 100644 --- a/chromium/third_party/blink/renderer/build/scripts/json5_generator.py +++ b/chromium/third_party/blink/renderer/build/scripts/json5_generator.py @@ -252,7 +252,7 @@ class Writer(object): return NameStyleConverter(name).to_snake_case() def make_header_guard(self, path): - return re.sub(r'[-/.]', '_', path).upper() + '_' + return NameStyleConverter(path).to_header_guard() class Maker(object): diff --git a/chromium/third_party/blink/renderer/build/scripts/make_element_lookup_trie.py b/chromium/third_party/blink/renderer/build/scripts/make_element_lookup_trie.py index d0fce32f3c1..f370fd553de 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_element_lookup_trie.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_element_lookup_trie.py @@ -29,6 +29,7 @@ import sys +from blinkbuild.name_style_converter import NameStyleConverter import json5_generator import trie_builder import template_expander @@ -53,6 +54,9 @@ class ElementLookupTrieWriter(json5_generator.Writer): 'namespacePrefix': '', 'namespaceURI': '', } + filters = { + 'symbol': lambda symbol: 'k' + NameStyleConverter(symbol).to_upper_camel_case() + } def __init__(self, json5_file_paths, output_dir): super(ElementLookupTrieWriter, self).__init__(json5_file_paths, output_dir) @@ -73,7 +77,7 @@ class ElementLookupTrieWriter(json5_generator.Writer): 'namespace': self._namespace, } - @template_expander.use_jinja('templates/element_lookup_trie.cc.tmpl') + @template_expander.use_jinja('templates/element_lookup_trie.cc.tmpl', filters=filters) def generate_implementation(self): return { 'input_files': self._input_files, diff --git a/chromium/third_party/blink/renderer/build/scripts/make_element_type_helpers.py b/chromium/third_party/blink/renderer/build/scripts/make_element_type_helpers.py index 0c8561e0d5f..210e5c26fd8 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_element_type_helpers.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_element_type_helpers.py @@ -8,12 +8,11 @@ from collections import defaultdict import hasher import json5_generator -import name_utilities import template_expander def _symbol(tag): - return name_utilities.cpp_name(tag).replace('-', '_') + return 'k' + tag['name'].to_upper_camel_case() class MakeElementTypeHelpersWriter(json5_generator.Writer): @@ -60,6 +59,7 @@ class MakeElementTypeHelpersWriter(json5_generator.Writer): '{0}/{0}_element.h'.format(self.namespace.lower()) self._template_context = { 'base_element_header': base_element_header, + 'cpp_namespace': self.namespace.lower() + '_names', 'input_files': self._input_files, 'namespace': self.namespace, 'tags': self.json5_file.name_dictionaries, diff --git a/chromium/third_party/blink/renderer/build/scripts/make_event_factory.py b/chromium/third_party/blink/renderer/build/scripts/make_event_factory.py index d509a3e8d42..a941cc0a793 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_event_factory.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_event_factory.py @@ -91,6 +91,7 @@ def measure_name(name): class EventFactoryWriter(json5_generator.Writer): default_parameters = { 'ImplementedAs': {}, + 'interfaceHeaderDir': {}, 'RuntimeEnabled': {}, } default_metadata = { @@ -100,7 +101,7 @@ class EventFactoryWriter(json5_generator.Writer): } filters = { 'cpp_name': name_utilities.cpp_name, - 'script_name': name_utilities.script_name, + 'name': lambda entry: entry['name'].original, 'create_event_whitelist': create_event_whitelist, 'create_event_measure_whitelist': create_event_measure_whitelist, 'measure_name': measure_name, @@ -109,7 +110,7 @@ class EventFactoryWriter(json5_generator.Writer): def __init__(self, json5_file_path, output_dir): super(EventFactoryWriter, self).__init__(json5_file_path, output_dir) self.namespace = self.json5_file.metadata['namespace'].strip('"') - assert self.namespace == 'Event', 'namespace field should be "Event".' + assert self.namespace == 'event_interface_names', 'namespace field should be "event_interface_names".' self.suffix = self.json5_file.metadata['suffix'].strip('"') snake_suffix = (self.suffix.lower() + '_') if self.suffix else '' self._outputs = { @@ -121,14 +122,10 @@ class EventFactoryWriter(json5_generator.Writer): exit(1) def _headers_header_include_path(self, entry): - path = os.path.dirname(entry['name'].original) + path = entry['interfaceHeaderDir'] if len(path): path += '/' - if entry['ImplementedAs']: - path += self.get_file_basename(entry['ImplementedAs']) - else: - path += self.get_file_basename(os.path.basename(entry['name'].original)) - return path + '.h' + return path + self.get_file_basename(name_utilities.cpp_name(entry)) + '.h' def _headers_header_includes(self, entries): includes = dict() diff --git a/chromium/third_party/blink/renderer/build/scripts/make_instrumenting_probes.py b/chromium/third_party/blink/renderer/build/scripts/make_instrumenting_probes.py index 64d6e7d533a..514a0dcfc1f 100644 --- a/chromium/third_party/blink/renderer/build/scripts/make_instrumenting_probes.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_instrumenting_probes.py @@ -60,7 +60,8 @@ def agent_name_to_class(config, agent_name): def agent_name_to_include(config, agent_name): include_path = agent_config(config, agent_name, "include_path") or config["settings"]["include_path"] agent_class = agent_name_to_class(config, agent_name) - return os.path.join(include_path, NameStyleConverter(agent_class).to_snake_case() + ".h") + include_file = os.path.join(include_path, NameStyleConverter(agent_class).to_snake_case() + ".h") + return include_file.replace("dev_tools", "devtools") def initialize_jinja_env(config, cache_dir): @@ -106,7 +107,7 @@ def load_model_from_idl(source): class File(object): def __init__(self, name, source): self.name = NameStyleConverter(name).to_snake_case() - self.header_name = self.name + "_inl" + self.header_name = self.name + "_inl.h" self.forward_declarations = [] self.declarations = [] for line in map(str.strip, source.split("\n")): @@ -263,15 +264,18 @@ def main(): template_context["template_file"] = "/probe_sink.h.tmpl" sink_h_template = jinja_env.get_template(template_context["template_file"]) - sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "_sink.h", "w") + sink_h_file_name = to_singular(base_name) + "_sink.h" + sink_h_file = open(output_dirpath + "/" + sink_h_file_name, "w") + template_context["header_guard"] = NameStyleConverter(output_path_in_gen_dir + "/" + sink_h_file_name).to_header_guard() sink_h_file.write(sink_h_template.render(template_context)) sink_h_file.close() for f in files: template_context["file"] = f template_context["template_file"] = "/instrumenting_probes_inl.h.tmpl" + template_context["header_guard"] = NameStyleConverter(output_path_in_gen_dir + "/" + f.header_name).to_header_guard() h_template = jinja_env.get_template(template_context["template_file"]) - h_file = open(output_dirpath + "/" + f.header_name + ".h", "w") + h_file = open(output_dirpath + "/" + f.header_name, "w") h_file.write(h_template.render(template_context)) h_file.close() diff --git a/chromium/third_party/blink/renderer/build/scripts/make_internal_runtime_flags.py b/chromium/third_party/blink/renderer/build/scripts/make_internal_runtime_flags.py index d8e2fa99bfc..b0fd5dd2b3e 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_internal_runtime_flags.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_internal_runtime_flags.py @@ -62,6 +62,7 @@ class InternalRuntimeFlagsWriter(make_runtime_features.RuntimeFeatureWriter): 'feature_sets': self._feature_sets(), 'input_files': self._input_files, 'standard_features': self._standard_features, + 'header_guard': self._header_guard, } diff --git a/chromium/third_party/blink/renderer/build/scripts/make_internal_settings.py b/chromium/third_party/blink/renderer/build/scripts/make_internal_settings.py index 8827eea5e63..8d12f653635 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_internal_settings.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_internal_settings.py @@ -40,6 +40,7 @@ class MakeInternalSettingsWriter(json5_generator.Writer): 'to_passing_type': to_passing_type, 'to_idl_type': to_idl_type, } + _FILE_BASENAME = 'internal_settings_generated' def __init__(self, json5_file_path, output_dir): super(MakeInternalSettingsWriter, self).__init__(json5_file_path, output_dir) @@ -47,14 +48,15 @@ class MakeInternalSettingsWriter(json5_generator.Writer): self.json5_file.name_dictionaries.sort(key=lambda entry: entry['name'].original) self._outputs = { - 'internal_settings_generated.h': self.generate_header, - 'internal_settings_generated.cc': self.generate_implementation, - 'internal_settings_generated.idl': self.generate_idl, + (self._FILE_BASENAME + '.h'): self.generate_header, + (self._FILE_BASENAME + '.cc'): self.generate_implementation, + (self._FILE_BASENAME + '.idl'): self.generate_idl, } self._template_context = { 'input_files': self._input_files, 'primary_header_name': 'internal_settings_generated.h', 'settings': self.json5_file.name_dictionaries, + 'header_guard': self.make_header_guard(self._relative_output_dir + self._FILE_BASENAME + '.h') } @template_expander.use_jinja('templates/internal_settings_generated.h.tmpl', filters=filters) diff --git a/chromium/third_party/blink/renderer/build/scripts/make_names.py b/chromium/third_party/blink/renderer/build/scripts/make_names.py index 99f8a8f2586..dba17c66a1d 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_names.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_names.py @@ -35,19 +35,19 @@ import json5_generator import template_expander import name_utilities + def _symbol(entry): if entry['Symbol'] is not None: return entry['Symbol'] - # FIXME: Remove this special case for the ugly x-webkit-foo attributes. - if entry['name'].original.startswith('-webkit-'): - return entry['name'].original.replace('-', '_')[1:] - return name_utilities.cpp_name(entry).replace('-', '_').replace(' ', '_') + return 'k' + entry['name'].to_upper_camel_case() class MakeNamesWriter(json5_generator.Writer): default_parameters = { 'Conditional': {}, # FIXME: Add support for Conditional. 'ImplementedAs': {}, + # This is not used in make_names,py, but used in make_event_factory.py. + 'interfaceHeaderDir': {}, 'RuntimeEnabled': {}, # What should we do for runtime-enabled features? 'Symbol': {}, } @@ -59,7 +59,6 @@ class MakeNamesWriter(json5_generator.Writer): filters = { 'cpp_name': name_utilities.cpp_name, 'hash': hasher.hash, - 'script_name': name_utilities.script_name, 'symbol': _symbol, } @@ -70,7 +69,13 @@ class MakeNamesWriter(json5_generator.Writer): suffix = self.json5_file.metadata['suffix'].strip('"') export = self.json5_file.metadata['export'].strip('"') - assert namespace, 'A namespace is required.' + if not namespace: + raise ValueError('A namespace is required.') + # https://google.github.io/styleguide/cppguide.html#Namespace_Names + if namespace.lower() != namespace: + raise ValueError('The namespace field should be lower-cased. ' + + '"%s" is specified in %s.' % + (namespace, json5_file_path)) basename, _ = os.path.splitext(os.path.basename(json5_file_path[0])) self._outputs = { diff --git a/chromium/third_party/blink/renderer/build/scripts/make_origin_trials.py b/chromium/third_party/blink/renderer/build/scripts/make_origin_trials.py index 5a72aa3169c..465636c03f6 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_origin_trials.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_origin_trials.py @@ -89,6 +89,7 @@ class OriginTrialsWriter(make_runtime_features.RuntimeFeatureWriter): 'origin_trial_features': self._origin_trial_features, 'implied_origin_trial_features': self._implied_mappings, 'input_files': self._input_files, + 'header_guard': self._header_guard, } diff --git a/chromium/third_party/blink/renderer/build/scripts/make_qualified_names.py b/chromium/third_party/blink/renderer/build/scripts/make_qualified_names.py index 9957831019f..1b3bdaa039b 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_qualified_names.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_qualified_names.py @@ -40,7 +40,7 @@ from json5_generator import Json5File def _symbol(entry): - return entry['name'].original.replace('-', '_') + return 'k' + entry['name'].to_upper_camel_case() class MakeQualifiedNamesWriter(json5_generator.Writer): @@ -85,10 +85,10 @@ class MakeQualifiedNamesWriter(json5_generator.Writer): self.attrs_json5_file.merge_from(self.aria_reader.attributes_list()) self.namespace = self._metadata('namespace') + cpp_namespace = self.namespace.lower() + '_names' + namespace_prefix = self._metadata('namespacePrefix') or 'k' - namespace_prefix = self._metadata('namespacePrefix') or self.namespace.lower() namespace_uri = self._metadata('namespaceURI') - use_namespace_for_attrs = self.attrs_json5_file.metadata['attrsNullNamespace'] is None self._outputs = { @@ -98,6 +98,7 @@ class MakeQualifiedNamesWriter(json5_generator.Writer): qualified_header = self._relative_output_dir + self.namespace.lower() + '_names.h' self._template_context = { 'attrs': self.attrs_json5_file.name_dictionaries, + 'cpp_namespace': cpp_namespace, 'export': self._metadata('export'), 'header_guard': self.make_header_guard(qualified_header), 'input_files': self._input_files, diff --git a/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py b/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py index f9efefe7a5c..a17e488f0b4 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_runtime_features.py @@ -59,6 +59,7 @@ class RuntimeFeatureWriter(json5_generator.Writer): feature['enabled_condition'] = enabled_condition self._standard_features = [feature for feature in self._features if not feature['custom']] self._origin_trial_features = [feature for feature in self._features if feature['origin_trial_feature_name']] + self._header_guard = self.make_header_guard(self._relative_output_dir + self.file_basename + '.h') @staticmethod def _data_member_name(str_or_converter): @@ -77,6 +78,7 @@ class RuntimeFeatureWriter(json5_generator.Writer): 'input_files': self._input_files, 'standard_features': self._standard_features, 'origin_trial_controlled_features': self._origin_trial_features, + 'header_guard': self._header_guard, } @template_expander.use_jinja('templates/' + file_basename + '.h.tmpl') @@ -95,13 +97,14 @@ class RuntimeFeatureTestHelpersWriter(json5_generator.Writer): def __init__(self, json5_file_path, output_dir): super(RuntimeFeatureTestHelpersWriter, self).__init__(json5_file_path, output_dir) self._outputs = {('testing/' + self.file_basename + '.h'): self.generate_header} - self._features = self.json5_file.name_dictionaries + self._header_guard = self.make_header_guard(self._relative_output_dir + self.file_basename + '.h') def _template_inputs(self): return { 'features': self._features, 'input_files': self._input_files, + 'header_guard': self._header_guard, } @template_expander.use_jinja('templates/' + file_basename + '.h.tmpl') diff --git a/chromium/third_party/blink/renderer/build/scripts/make_settings.py b/chromium/third_party/blink/renderer/build/scripts/make_settings.py index 4f2752ad33f..b463bee6e48 100755 --- a/chromium/third_party/blink/renderer/build/scripts/make_settings.py +++ b/chromium/third_party/blink/renderer/build/scripts/make_settings.py @@ -73,6 +73,7 @@ class MakeSettingsWriter(json5_generator.Writer): self._template_context = { 'input_files': self._input_files, 'settings': self.json5_file.name_dictionaries, + 'header_guard': self.make_header_guard(self._relative_output_dir + 'settings_macros.h') } @template_expander.use_jinja('templates/settings_macros.h.tmpl', filters=filters) diff --git a/chromium/third_party/blink/renderer/build/scripts/media_feature_symbol.py b/chromium/third_party/blink/renderer/build/scripts/media_feature_symbol.py index f9d51e96a7a..10d8a10f354 100644 --- a/chromium/third_party/blink/renderer/build/scripts/media_feature_symbol.py +++ b/chromium/third_party/blink/renderer/build/scripts/media_feature_symbol.py @@ -3,23 +3,14 @@ # found in the LICENSE file. +from blinkbuild.name_style_converter import NameStyleConverter + + def mediaFeatureSymbol(entry, suffix): name = entry['name'].original if name.startswith('-webkit-'): name = name[8:] - - foundDash = False - newName = "" - for chr in name: - if chr == '-': - foundDash = True - continue - if foundDash: - chr = chr.upper() - foundDash = False - newName = newName + chr - newName = newName + suffix - return newName + return 'k' + NameStyleConverter(name).to_upper_camel_case() + suffix def getMediaFeatureSymbolWithSuffix(suffix): diff --git a/chromium/third_party/blink/renderer/build/scripts/name_utilities.py b/chromium/third_party/blink/renderer/build/scripts/name_utilities.py index d6afcc029e7..2ef88dad080 100644 --- a/chromium/third_party/blink/renderer/build/scripts/name_utilities.py +++ b/chromium/third_party/blink/renderer/build/scripts/name_utilities.py @@ -26,15 +26,9 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import os.path - from blinkbuild.name_style_converter import NameStyleConverter -def script_name(entry): - return os.path.basename(entry['name'].original) - - def cpp_bool(value): if value is True: return 'true' @@ -46,7 +40,7 @@ def cpp_bool(value): def cpp_name(entry): - return entry['ImplementedAs'] or script_name(entry) + return entry['ImplementedAs'] or entry['name'].original def enum_for_css_keyword(keyword): diff --git a/chromium/third_party/blink/renderer/build/scripts/rule_bison.py b/chromium/third_party/blink/renderer/build/scripts/rule_bison.py index 7f17e0f22d5..9e88f1c3915 100755 --- a/chromium/third_party/blink/renderer/build/scripts/rule_bison.py +++ b/chromium/third_party/blink/renderer/build/scripts/rule_bison.py @@ -42,6 +42,8 @@ import os.path import subprocess import sys +from blinkbuild.name_style_converter import NameStyleConverter + assert len(sys.argv) == 4 or len(sys.argv) == 5 inputFile = sys.argv[1] @@ -105,9 +107,12 @@ os.unlink(outputHTmp) # Rewrite the generated header with #include guards. outputH = os.path.join(outputDir, inputRoot + '.h') +outputHInGen = outputH.replace('gen/', '') +headerGuard = NameStyleConverter(outputHInGen).to_header_guard() + outputHFile = open(outputH, 'w') -print >>outputHFile, '#ifndef %sH' % inputRoot -print >>outputHFile, '#define %sH' % inputRoot +print >>outputHFile, '#ifndef %s' % headerGuard +print >>outputHFile, '#define %s' % headerGuard print >>outputHFile, outputHContents -print >>outputHFile, '#endif' +print >>outputHFile, '#endif // %s' % headerGuard outputHFile.close() diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl index 96d8303736e..96ede7f9df0 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_factory.cc.tmpl @@ -31,10 +31,10 @@ static {{namespace}}Element* {{namespace}}{{tag|symbol}}Constructor( const CreateElementFlags flags) { {% if tag.runtimeEnabled %} if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) - return {{fallback_interface}}::Create({{namespace}}Names::{{tag|symbol}}Tag, document); + return {{fallback_interface}}::Create({{cpp_namespace}}::{{tag|symbol}}Tag, document); {% endif %} return {{tag.interface}}::Create( - {%- if tag.multipleTagNames %}{{namespace}}Names::{{tag|symbol}}Tag, {% endif -%} + {%- if tag.multipleTagNames %}{{cpp_namespace}}::{{tag|symbol}}Tag, {% endif -%} document {%- if tag.constructorNeedsCreateElementFlags %}, flags{% endif -%} ); @@ -53,7 +53,7 @@ static void create{{namespace}}FunctionMap() { // compile in MSVC. If tags list is empty, add check to skip this. static const Create{{namespace}}FunctionMapData data[] = { {% for tag in tags|sort if not tag.noConstructor %} - { {{namespace}}Names::{{tag|symbol}}Tag, {{namespace}}{{tag|symbol}}Constructor }, + { {{cpp_namespace}}::{{tag|symbol}}Tag, {{namespace}}{{tag|symbol}}Constructor }, {% endfor %} }; for (size_t i = 0; i < arraysize(data); i++) diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_lookup_trie.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_lookup_trie.cc.tmpl index 8c5096044e0..2eab64f679e 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_lookup_trie.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_lookup_trie.cc.tmpl @@ -11,12 +11,12 @@ namespace blink { -using namespace {{namespace}}Names; +using namespace {{namespace|lower}}_names; const AtomicString& lookup{{namespace}}Tag(const UChar* data, unsigned length) { DCHECK(data); DCHECK(length); - {% macro trie_return_statement(tag) %}{{tag}}Tag.LocalName(){% endmacro %} + {% macro trie_return_statement(tag) %}{{tag|symbol}}Tag.LocalName(){% endmacro %} {{ trie_length_switch(length_tries, trie_return_statement, false) | indent(4) }} return g_null_atom; } diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl index d0f65a3f7ba..7b4a4578b6a 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/element_type_helpers.h.tmpl @@ -23,7 +23,7 @@ inline bool Is{{tag.interface}}(const {{namespace}}Element& element) { if (!RuntimeEnabledFeatures::{{tag.runtimeEnabled}}Enabled()) return false; {% endif %} - return element.HasTagName({{namespace}}Names::{{tag|symbol}}Tag); + return element.HasTagName({{cpp_namespace}}::{{tag|symbol}}Tag); } inline bool Is{{tag.interface}}(const {{namespace}}Element* element) { return element && Is{{tag.interface}}(*element); diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/event_factory.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/event_factory.cc.tmpl index 1fe511bb71c..498baf402ef 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/event_factory.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/event_factory.cc.tmpl @@ -18,14 +18,14 @@ namespace blink { Event* Event{{suffix}}Factory::Create(ExecutionContext* executionContext, const String& type) { - {% for event in events if event|script_name|create_event_whitelist or event|script_name|create_event_measure_whitelist %} - {% if event|script_name|create_event_whitelist or event|script_name|create_event_measure_whitelist %} - if (DeprecatedEqualIgnoringCase(type, "{{event|script_name}}"){% if event.RuntimeEnabled %} && RuntimeEnabledFeatures::{{event.RuntimeEnabled}}(){% endif %}) { + {% for event in events if event|name|create_event_whitelist or event|name|create_event_measure_whitelist %} + {% if event|name|create_event_whitelist or event|name|create_event_measure_whitelist %} + if (DeprecatedEqualIgnoringCase(type, "{{event|name}}"){% if event.RuntimeEnabled %} && RuntimeEnabledFeatures::{{event.RuntimeEnabled}}(){% endif %}) { {% else %} - if (type == "{{event|script_name}}"{% if event.RuntimeEnabled %} && RuntimeEnabledFeatures::{{event.RuntimeEnabled}}(){% endif %}) { + if (type == "{{event|name}}"{% if event.RuntimeEnabled %} && RuntimeEnabledFeatures::{{event.RuntimeEnabled}}(){% endif %}) { {% endif %} - {% if not event|script_name|create_event_whitelist %} - UseCounter::Count(executionContext, WebFeature::k{{event|script_name|measure_name}}); + {% if not event|name|create_event_whitelist %} + UseCounter::Count(executionContext, WebFeature::k{{event|name|measure_name}}); {% endif %} return {{event|cpp_name}}::Create(); } diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_inl.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_inl.h.tmpl index 92f0d113554..86d48b872e9 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_inl.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/instrumenting_probes_inl.h.tmpl @@ -5,8 +5,8 @@ {% from 'macros.tmpl' import source_files_for_generated_file %} {{source_files_for_generated_file(template_file, input_files)}} -#ifndef {{file.header_name.upper()}}_H -#define {{file.header_name.upper()}}_H +#ifndef {{header_guard}} +#define {{header_guard}} #include "third_party/blink/renderer/platform/heap/heap_allocator.h" #include "third_party/blink/renderer/bindings/core/v8/script_source_code.h" @@ -80,4 +80,4 @@ inline void {{probe.name}}({{params_list(probe)}}) { } // namespace probe } // namespace blink -#endif // !defined({{file.header_name.upper()}}_H) +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/internal_runtime_flags.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/internal_runtime_flags.h.tmpl index 8f4a96e3fb5..bcc131bfc92 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/internal_runtime_flags.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/internal_runtime_flags.h.tmpl @@ -3,8 +3,8 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef InternalRuntimeFlags_h -#define InternalRuntimeFlags_h +#ifndef {{header_guard}} +#define {{header_guard}} #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" @@ -18,9 +18,11 @@ class InternalRuntimeFlags : public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: static InternalRuntimeFlags* create() { - return new InternalRuntimeFlags; + return MakeGarbageCollected<InternalRuntimeFlags>(); } + InternalRuntimeFlags() {} + // These are reset between layout tests from Internals::resetToConsistentState // using RuntimeEnabledFeatures::Backup. {% for feature in standard_features if feature.settable_from_internals %} @@ -38,11 +40,8 @@ class InternalRuntimeFlags : public ScriptWrappable { {% endif %} } {% endfor %} - - private: - InternalRuntimeFlags() {} }; -} // namespace blink +} // namespace blink -#endif // InternalRuntimeFlags_h +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl index 50a86395612..7933bd1896f 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/internal_settings_generated.h.tmpl @@ -3,13 +3,13 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef InternalSettingsGenerated_h -#define InternalSettingsGenerated_h +#ifndef {{header_guard}} +#define {{header_guard}} +#include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/wtf/ref_counted.h" -#include "base/memory/scoped_refptr.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink { @@ -37,6 +37,6 @@ class InternalSettingsGenerated : public ScriptWrappable { {% endfor %} }; -} // namespace blink +} // namespace blink -#endif // InternalSettingsGenerated_h +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/make_names.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/make_names.cc.tmpl index 8be40d6920a..9d0a3104de7 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/make_names.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/make_names.cc.tmpl @@ -8,18 +8,18 @@ #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" namespace blink { -namespace {{namespace}}Names { +namespace {{namespace}} { -void* {{suffix}}NamesStorage[{{namespace}}{{suffix}}NamesCount * ((sizeof(AtomicString) + sizeof(void *) - 1) / sizeof(void *))]; +void* {{suffix|lower}}names_storage[k{{suffix}}NamesCount * ((sizeof(AtomicString) + sizeof(void *) - 1) / sizeof(void *))]; {% for entry in entries|sort(attribute='name', case_sensitive=True) %} -const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage)[{{loop.index0}}]; +const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix|lower}}names_storage)[{{loop.index0}}]; {% endfor %} -void init{{suffix}}() { - static bool isLoaded = false; - if (isLoaded) return; - isLoaded = true; +void Init{{suffix}}() { + static bool is_loaded = false; + if (is_loaded) return; + is_loaded = true; struct NameEntry { const char* name; @@ -33,12 +33,12 @@ void init{{suffix}}() { {% endfor %} }; - for (size_t i = 0; i < arraysize(kNames); i++) { - StringImpl* stringImpl = StringImpl::CreateStatic(kNames[i].name, kNames[i].length, kNames[i].hash); - void* address = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage) + i; - new (address) AtomicString(stringImpl); + for (size_t i = 0; i < arraysize(kNames); ++i) { + StringImpl* impl = StringImpl::CreateStatic(kNames[i].name, kNames[i].length, kNames[i].hash); + void* address = reinterpret_cast<AtomicString*>(&{{suffix|lower}}names_storage) + i; + new (address) AtomicString(impl); } } -} // {{namespace}}Names -} // namespace blink +} // namespace {{namespace}} +} // namespace blink diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/make_names.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/make_names.h.tmpl index 621c966d6ee..6b624979d16 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/make_names.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/make_names.h.tmpl @@ -17,17 +17,17 @@ {% endif %} namespace blink { -namespace {{namespace}}Names { +namespace {{namespace}} { {% for entry in entries|sort %} {{symbol_export}}extern const WTF::AtomicString& {{entry|symbol}}; {% endfor %} -const unsigned {{namespace}}{{suffix}}NamesCount = {{entries|length}}; +constexpr unsigned k{{suffix}}NamesCount = {{entries|length}}; -{{symbol_export}}void init{{suffix}}(); +{{symbol_export}}void Init{{suffix}}(); -} // {{namespace}}Names +} // namespace {{namespace}} } // namespace blink #endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.cc.tmpl index 7bf6eeb8d7c..eacbbd47517 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.cc.tmpl @@ -11,61 +11,59 @@ #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" namespace blink { -namespace {{namespace}}Names { - -using namespace blink; +namespace {{cpp_namespace}} { DEFINE_GLOBAL(AtomicString, {{namespace_prefix}}NamespaceURI); {% if tags %} // Tags -void* {{suffix}}TagStorage[{{namespace}}TagsCount * ((sizeof({{namespace}}QualifiedName) + sizeof(void *) - 1) / sizeof(void *))]; +void* tag_storage[kTagsCount * ((sizeof({{namespace}}QualifiedName) + sizeof(void *) - 1) / sizeof(void *))]; {% for tag in tags|sort(attribute='name', case_sensitive=True) %} -const {{namespace}}QualifiedName& {{tag|symbol}}Tag = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage)[{{loop.index0}}]; +const {{namespace}}QualifiedName& {{tag|symbol}}Tag = reinterpret_cast<{{namespace}}QualifiedName*>(&tag_storage)[{{loop.index0}}]; {% endfor %} -std::unique_ptr<const {{namespace}}QualifiedName*[]> get{{namespace}}Tags() { - auto tags = std::make_unique<const {{namespace}}QualifiedName*[]>({{namespace}}TagsCount); - for (size_t i = 0; i < {{namespace}}TagsCount; i++) - tags[i] = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage) + i; +std::unique_ptr<const {{namespace}}QualifiedName*[]> GetTags() { + auto tags = std::make_unique<const {{namespace}}QualifiedName*[]>(kTagsCount); + for (size_t i = 0; i < kTagsCount; ++i) + tags[i] = reinterpret_cast<{{namespace}}QualifiedName*>(&tag_storage) + i; return tags; } {% endif %} // Attributes -void* {{suffix}}AttrStorage[{{namespace}}AttrsCount * ((sizeof(QualifiedName) + sizeof(void *) - 1) / sizeof(void *))]; +void* attr_storage[kAttrsCount * ((sizeof(QualifiedName) + sizeof(void *) - 1) / sizeof(void *))]; {% for attr in attrs|sort(attribute='name', case_sensitive=True) %} -const QualifiedName& {{attr|symbol}}Attr = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage)[{{loop.index0}}]; +const QualifiedName& {{attr|symbol}}Attr = reinterpret_cast<QualifiedName*>(&attr_storage)[{{loop.index0}}]; {% endfor %} {% if namespace != 'HTML' %} -std::unique_ptr<const QualifiedName*[]> get{{namespace}}Attrs() { - auto attrs = std::make_unique<const QualifiedName*[]>({{namespace}}AttrsCount); - for (size_t i = 0; i < {{namespace}}AttrsCount; i++) - attrs[i] = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage) + i; +std::unique_ptr<const QualifiedName*[]> GetAttrs() { + auto attrs = std::make_unique<const QualifiedName*[]>(kAttrsCount); + for (size_t i = 0; i < kAttrsCount; ++i) + attrs[i] = reinterpret_cast<QualifiedName*>(&attr_storage) + i; return attrs; } {% endif %} -void init() { +void Init() { struct NameEntry { const char* name; unsigned hash; unsigned char length; - unsigned char isTag; - unsigned char isAttr; + unsigned char is_tag; + unsigned char is_attr; }; + // Namespace // Use placement new to initialize the globals. - AtomicString {{namespace_prefix}}NS("{{namespace_uri}}"); + AtomicString ns_uri("{{namespace_uri}}"); + new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString(ns_uri); - // Namespace - new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString({{namespace_prefix}}NS); {% set tagnames = tags|map(attribute='name')|list() %} {% set attrnames = attrs|map(attribute='name')|list() %} static const NameEntry kNames[] = { @@ -78,31 +76,31 @@ void init() { size_t tag_i = 0; {% endif %} size_t attr_i = 0; - for (size_t i = 0; i < arraysize(kNames); i++) { - StringImpl* stringImpl = StringImpl::CreateStatic(kNames[i].name, kNames[i].length, kNames[i].hash); + for (size_t i = 0; i < arraysize(kNames); ++i) { + StringImpl* impl = StringImpl::CreateStatic(kNames[i].name, kNames[i].length, kNames[i].hash); {% if tags %} - if (kNames[i].isTag) { - void* address = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage) + tag_i; - QualifiedName::CreateStatic(address, stringImpl, {{namespace_prefix}}NS); - tag_i++; + if (kNames[i].is_tag) { + void* address = reinterpret_cast<{{namespace}}QualifiedName*>(&tag_storage) + tag_i; + QualifiedName::CreateStatic(address, impl, ns_uri); + ++tag_i; } - if (!kNames[i].isAttr) + if (!kNames[i].is_attr) continue; {% endif %} - void* address = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage) + attr_i; + void* address = reinterpret_cast<QualifiedName*>(&attr_storage) + attr_i; {% if use_namespace_for_attrs %} - QualifiedName::CreateStatic(address, stringImpl, {{namespace_prefix}}NS); + QualifiedName::CreateStatic(address, impl, ns_uri); {% else %} - QualifiedName::CreateStatic(address, stringImpl); + QualifiedName::CreateStatic(address, impl); {% endif %} - attr_i++; + ++attr_i; } {% if tags %} - DCHECK_EQ(tag_i, {{namespace}}TagsCount); + DCHECK_EQ(tag_i, kTagsCount); {% endif %} - DCHECK_EQ(attr_i, {{namespace}}AttrsCount); + DCHECK_EQ(attr_i, kAttrsCount); } -} // namespace {{namespace}}Names +} // namespace {{cpp_namespace}} } // namespace blink diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl index b4c5c86d63a..cb05c6c4315 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/make_qualified_names.h.tmpl @@ -6,17 +6,18 @@ #ifndef {{header_guard}} #define {{header_guard}} +#include <memory> + {% if export == 'CORE_EXPORT' %} #include "third_party/blink/renderer/core/core_export.h" {% endif %} #include "third_party/blink/renderer/core/dom/qualified_name.h" -#include <memory> namespace blink { class {{namespace}}QualifiedName : public QualifiedName { }; -namespace {{namespace}}Names { +namespace {{cpp_namespace}} { {% set symbol_export = '%s ' % export if export else '' %} // Namespace @@ -33,18 +34,18 @@ namespace {{namespace}}Names { {% endfor %} {% if tags %} -const unsigned {{namespace}}TagsCount = {{tags|count}}; -{{symbol_export}}std::unique_ptr<const {{namespace}}QualifiedName*[]> get{{namespace}}Tags(); +constexpr unsigned kTagsCount = {{tags|count}}; +{{symbol_export}}std::unique_ptr<const {{namespace}}QualifiedName*[]> GetTags(); {% endif %} -const unsigned {{namespace}}AttrsCount = {{attrs|count}}; +constexpr unsigned kAttrsCount = {{attrs|count}}; {% if namespace != 'HTML' %} -std::unique_ptr<const QualifiedName*[]> get{{namespace}}Attrs(); +std::unique_ptr<const QualifiedName*[]> GetAttrs(); {% endif %} -void init(); +void Init(); -} // namespace {{namespace}}Names +} // namespace {{cpp_namespace}} } // namespace blink #endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.cc.tmpl index 7c2e355dd9b..7aa623dd1a7 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.cc.tmpl @@ -12,14 +12,14 @@ namespace blink { {% for feature in features %} {% if feature.origin_trial_feature_name %} -const char OriginTrials::k{{feature.name}}TrialName[] = "{{feature.origin_trial_feature_name}}"; +const char origin_trials::k{{feature.name}}TrialName[] = "{{feature.origin_trial_feature_name}}"; {% endif %} {% endfor %} {% for feature in features %} {% if feature.origin_trial_feature_name %} -bool OriginTrials::{{feature.name}}Enabled(const ExecutionContext* executionContext) { +bool origin_trials::{{feature.name}}Enabled(const ExecutionContext* executionContext) { if (RuntimeEnabledFeatures::{{feature.name}}EnabledByRuntimeFlag()) return true; {% if feature.origin_trial_os %} @@ -30,6 +30,11 @@ bool OriginTrials::{{feature.name}}Enabled(const ExecutionContext* executionCont {%- endfor %} {% endif %} +{%- for depends_on in feature.depends_on %} + if (!RuntimeEnabledFeatures::{{depends_on}}Enabled()) + return false; +{%- endfor %} + const OriginTrialContext* context = OriginTrialContext::From(executionContext); if (!context) return false; if (context->IsTrialEnabled(k{{feature.name}}TrialName)) @@ -52,7 +57,7 @@ bool OriginTrials::{{feature.name}}Enabled(const ExecutionContext* executionCont {% endif %} {% endfor %} -Vector<AtomicString> OriginTrials::GetImpliedTrials(const String& trial_name) { +Vector<AtomicString> origin_trials::GetImpliedTrials(const String& trial_name) { {% for implied_by_name, implied_list in implied_origin_trial_features.items() %} if (trial_name == k{{implied_by_name}}TrialName) { Vector<AtomicString> implied_trials = { diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.h.tmpl index ed530591361..7f4ff3ba4de 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/origin_trials.h.tmpl @@ -3,21 +3,26 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef BLINK_CORE_ORIGIN_TRIALS_ORIGIN_TRIALS_H_ -#define BLINK_CORE_ORIGIN_TRIALS_ORIGIN_TRIALS_H_ +#ifndef {{header_guard}} +#define {{header_guard}} #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h" +#define ASSERT_ORIGIN_TRIAL(feature) \ +static_assert(std::is_same<decltype(::blink::origin_trials::feature##Enabled(\ + nullptr)), bool>(), \ + #feature " must be part of an origin trial"); + namespace blink { class ExecutionContext; // A namespace with dynamic tests for experimental features which can be // enabled by the origin trials framework via origin trial tokens. -namespace OriginTrials { +namespace origin_trials { {% for feature in features %} {% if feature.origin_trial_feature_name %} @@ -33,8 +38,8 @@ CORE_EXPORT bool {{feature.name}}Enabled(const ExecutionContext*); CORE_EXPORT Vector<AtomicString> GetImpliedTrials(const String& trial_name); -} // namespace OriginTrials +} // namespace origin_trials -} // namespace blink +} // namespace blink -#endif // BLINK_CORE_ORIGIN_TRIALS_ORIGIN_TRIALS_H_ +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl index 09d869fad19..e3cff077041 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/probe_sink.h.tmpl @@ -6,12 +6,11 @@ {{source_files_for_generated_file(template_file, input_files)}} {% set sink_class = (name | to_singular) + "Sink" %} -{% set sink_class_header = (header | to_singular) + "_sink" %} {% set export_header = config["settings"]["export_header"] %} {% set export_symbol = config["settings"]["export_symbol"] %} -#ifndef {{sink_class_header.upper()}}_H -#define {{sink_class_header.upper()}}_H +#ifndef {{header_guard}} +#define {{header_guard}} #include <atomic> @@ -75,4 +74,4 @@ class {{export_symbol}} {{sink_class}} : public GarbageCollectedFinalized<{{sink } // namespace blink -#endif // !defined({{sink_class_header.upper()}}_H) +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features.h.tmpl index 77be3bb3cda..b74af567130 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features.h.tmpl @@ -3,14 +3,13 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef RuntimeEnabledFeatures_h -#define RuntimeEnabledFeatures_h +#ifndef {{header_guard}} +#define {{header_guard}} #include <string> #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/wtf/allocator.h" -#include "third_party/blink/renderer/platform/wtf/forward.h" namespace blink { @@ -56,7 +55,7 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures { // to test whether the feature is unconditionally enabled (for example, by // starting the browser with the appropriate command-line flag). However, // that is almost always the incorrect check. Most renderer code should - // be calling OriginTrials::<feature>Enabled() instead, to test if the + // be calling origin_trials::<feature>Enabled() instead, to test if the // feature is enabled in a given context. {% for feature in features %} @@ -77,6 +76,6 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures { {% endfor %} }; -} // namespace blink +} // namespace blink -#endif // RuntimeEnabledFeatures_h +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features_test_helpers.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features_test_helpers.h.tmpl index a26579b3b3b..ba7399c844f 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features_test_helpers.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/runtime_enabled_features_test_helpers.h.tmpl @@ -3,8 +3,8 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef BLINK_PLATFORM_TESTING_RUNTIME_ENABLED_FEATURES_TEST_HELPERS_H_ -#define BLINK_PLATFORM_TESTING_RUNTIME_ENABLED_FEATURES_TEST_HELPERS_H_ +#ifndef {{header_guard}} +#define {{header_guard}} #include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/wtf/assertions.h" @@ -39,6 +39,6 @@ typedef ScopedRuntimeEnabledFeatureForTest< RuntimeEnabledFeatures::Set{{feature.name}}Enabled> Scoped{{feature.name}}ForTest; {% endfor %} -} // namespace blink +} // namespace blink -#endif // BLINK_PLATFORM_TESTING_RUNTIME_ENABLED_FEATURES_TEST_HELPERS_H_ +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/settings_macros.h.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/settings_macros.h.tmpl index 33c2220baa9..0ed1f533f06 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/settings_macros.h.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/settings_macros.h.tmpl @@ -3,8 +3,8 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef SettingsMacros_h -#define SettingsMacros_h +#ifndef {{header_guard}} +#define {{header_guard}} #define SETTINGS_GETTERS_AND_SETTERS \ {% for setting in settings %} @@ -67,4 +67,4 @@ void Settings::SetFromStrings(const String& name, const String& value) { \ } // End of SETTINGS_SETTER_BODIES. -#endif // SettingsMacros_h +#endif // {{header_guard}} diff --git a/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl b/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl index 657c373b880..6e234f3937a 100644 --- a/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl +++ b/chromium/third_party/blink/renderer/build/scripts/templates/web_origin_trials.cc.tmpl @@ -16,8 +16,8 @@ bool WebOriginTrials::isTrialEnabled(const WebDocument* web_document, const WebS if (!web_document) return false; {% for feature in features %} {% if feature.origin_trial_feature_name %} - if (trial == OriginTrials::k{{feature.name}}TrialName) - return OriginTrials::{{feature.name}}Enabled(*web_document); + if (trial == origin_trials::k{{feature.name}}TrialName) + return origin_trials::{{feature.name}}Enabled(*web_document); {% endif %} {% endfor %} return false; |