Combine the two CSSBitset-generating .py files into one.

They are nearly identical, and we'll soon be adding a third one.

Change-Id: I96fe22af56fa08933c975d21b0ac1765f48a4cd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4076248
Commit-Queue: Steinar H Gunderson <sesse@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1079151}
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/make_known_exposed_properties.py b/third_party/blink/renderer/build/scripts/core/css/properties/make_known_exposed_properties.py
deleted file mode 100755
index bb7c70b..0000000
--- a/third_party/blink/renderer/build/scripts/core/css/properties/make_known_exposed_properties.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2022 The Chromium Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-from core.css import css_properties
-import json5_generator
-import template_expander
-
-
-class KnownExposedPropertiesWriter(json5_generator.Writer):
-    def __init__(self, json5_file_paths, output_dir):
-        super(KnownExposedPropertiesWriter, self).__init__([], output_dir)
-
-        self._input_files = json5_file_paths
-        properties = (
-            css_properties.CSSProperties(json5_file_paths)).properties_including_aliases
-
-        self._known_exposed_properties = [
-            p.enum_key for p in properties if p.known_exposed
-        ]
-
-        self._outputs = {
-            'known_exposed_properties.cc': self.generate_list,
-        }
-
-    @template_expander.use_jinja('core/css/properties/templates/known_exposed_properties.cc.tmpl')
-    def generate_list(self):
-        return {
-            'input_files': self._input_files,
-            'known_exposed_properties': self._known_exposed_properties,
-        }
-
-
-if __name__ == '__main__':
-    json5_generator.Maker(KnownExposedPropertiesWriter).main()
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/make_logical_group_properties.py b/third_party/blink/renderer/build/scripts/core/css/properties/make_property_bitsets.py
similarity index 65%
rename from third_party/blink/renderer/build/scripts/core/css/properties/make_logical_group_properties.py
rename to third_party/blink/renderer/build/scripts/core/css/properties/make_property_bitsets.py
index 2f57115..a1a2b4d 100755
--- a/third_party/blink/renderer/build/scripts/core/css/properties/make_logical_group_properties.py
+++ b/third_party/blink/renderer/build/scripts/core/css/properties/make_property_bitsets.py
@@ -8,9 +8,9 @@
 import template_expander
 
 
-class LogicalPropertiesWriter(json5_generator.Writer):
+class PropertyBitsetsWriter(json5_generator.Writer):
     def __init__(self, json5_file_paths, output_dir):
-        super(LogicalPropertiesWriter, self).__init__([], output_dir)
+        super(PropertyBitsetsWriter, self).__init__([], output_dir)
 
         self._input_files = json5_file_paths
         properties = (css_properties.CSSProperties(json5_file_paths)
@@ -21,18 +21,23 @@
             and p.logical_property_group['is_logical']
         ]
 
+        self._known_exposed_properties = [
+            p.enum_key for p in properties if p.known_exposed
+        ]
+
         self._outputs = {
-            'logical_group_properties.cc': self.generate_list,
+            'property_bitsets.cc': self.generate_list,
         }
 
     @template_expander.use_jinja(
-        'core/css/properties/templates/logical_group_properties.cc.tmpl')
+        'core/css/properties/templates/property_bitsets.cc.tmpl')
     def generate_list(self):
         return {
             'input_files': self._input_files,
             'logical_group_properties': self._logical_group_properties,
+            'known_exposed_properties': self._known_exposed_properties,
         }
 
 
 if __name__ == '__main__':
-    json5_generator.Maker(LogicalPropertiesWriter).main()
+    json5_generator.Maker(PropertyBitsetsWriter).main()
diff --git a/third_party/blink/renderer/build/scripts/core/css/properties/templates/logical_group_properties.cc.tmpl b/third_party/blink/renderer/build/scripts/core/css/properties/templates/property_bitsets.cc.tmpl
similarity index 72%
rename from third_party/blink/renderer/build/scripts/core/css/properties/templates/logical_group_properties.cc.tmpl
rename to third_party/blink/renderer/build/scripts/core/css/properties/templates/property_bitsets.cc.tmpl
index 5daa4a2..411ee3f 100644
--- a/third_party/blink/renderer/build/scripts/core/css/properties/templates/logical_group_properties.cc.tmpl
+++ b/third_party/blink/renderer/build/scripts/core/css/properties/templates/property_bitsets.cc.tmpl
@@ -5,7 +5,7 @@
 {% from 'templates/macros.tmpl' import source_files_for_generated_file %}
 {{source_files_for_generated_file(template_file, input_files)}}
 
-#include "third_party/blink/renderer/core/css/logical_group_properties.h"
+#include "third_party/blink/renderer/core/css/property_bitsets.h"
 
 #include "third_party/blink/renderer/core/css/properties/css_bitset.h"
 #include <array>
@@ -18,4 +18,10 @@
   {% endfor %}
 } };
 
+const CSSBitset kKnownExposedProperties{ {
+  {% for property in known_exposed_properties %}
+    CSSPropertyID::{{ property }},
+  {% endfor %}
+} };
+
 }  // namespace blink
diff --git a/third_party/blink/renderer/core/BUILD.gn b/third_party/blink/renderer/core/BUILD.gn
index 54981ee..6530a17 100644
--- a/third_party/blink/renderer/core/BUILD.gn
+++ b/third_party/blink/renderer/core/BUILD.gn
@@ -778,18 +778,12 @@
   ]
 }
 
-css_properties("make_core_generated_known_exposed_properties") {
-  script =
-      "../build/scripts/core/css/properties/make_known_exposed_properties.py"
-  other_inputs = [ "../build/scripts/core/css/properties/templates/known_exposed_properties.cc.tmpl" ]
-  outputs = [ "$blink_core_output_dir/known_exposed_properties.cc" ]
-}
-
-css_properties("make_core_generated_logical_group_properties") {
-  script =
-      "../build/scripts/core/css/properties/make_logical_group_properties.py"
-  other_inputs = [ "../build/scripts/core/css/properties/templates/logical_group_properties.cc.tmpl" ]
-  outputs = [ "$blink_core_output_dir/logical_group_properties.cc" ]
+css_properties("make_core_generated_property_bitsets") {
+  script = "../build/scripts/core/css/properties/make_property_bitsets.py"
+  other_inputs = [
+    "../build/scripts/core/css/properties/templates/property_bitsets.cc.tmpl",
+  ]
+  outputs = [ "$blink_core_output_dir/property_bitsets.cc" ]
 }
 
 code_generator("make_core_generated_css_value_keywords") {
@@ -1177,8 +1171,6 @@
   ":make_core_generated_html_tokenizer_names",
   ":make_core_generated_input_type_names",
   ":make_core_generated_keywords",
-  ":make_core_generated_known_exposed_properties",
-  ":make_core_generated_logical_group_properties",
   ":make_core_generated_mathml_element_type_helpers",
   ":make_core_generated_mathml_names",
   ":make_core_generated_media_feature_names",
@@ -1187,6 +1179,7 @@
   ":make_core_generated_performance_entry_names",
   ":make_core_generated_permissions_policy_helper",
   ":make_core_generated_pointer_type_names",
+  ":make_core_generated_property_bitsets",
   ":make_core_generated_script_type_names",
   ":make_core_generated_securitypolicyviolation_disposition_names",
   ":make_core_generated_shadow_element_names",
diff --git a/third_party/blink/renderer/core/css/css_property_value_set.cc b/third_party/blink/renderer/core/css/css_property_value_set.cc
index 2d9f162..822334e 100644
--- a/third_party/blink/renderer/core/css/css_property_value_set.cc
+++ b/third_party/blink/renderer/core/css/css_property_value_set.cc
@@ -25,10 +25,10 @@
 
 #include "third_party/blink/renderer/core/core_export.h"
 #include "third_party/blink/renderer/core/css/css_identifier_value.h"
-#include "third_party/blink/renderer/core/css/logical_group_properties.h"
 #include "third_party/blink/renderer/core/css/parser/css_parser.h"
 #include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
 #include "third_party/blink/renderer/core/css/properties/css_property.h"
+#include "third_party/blink/renderer/core/css/property_bitsets.h"
 #include "third_party/blink/renderer/core/css/style_property_serializer.h"
 #include "third_party/blink/renderer/core/css/style_sheet_contents.h"
 #include "third_party/blink/renderer/core/style_property_shorthand.h"
diff --git a/third_party/blink/renderer/core/css/css_style_declaration.cc b/third_party/blink/renderer/core/css/css_style_declaration.cc
index 234680d..03c02813 100644
--- a/third_party/blink/renderer/core/css/css_style_declaration.cc
+++ b/third_party/blink/renderer/core/css/css_style_declaration.cc
@@ -37,9 +37,9 @@
 #include "third_party/blink/renderer/core/css/css_property_names.h"
 #include "third_party/blink/renderer/core/css/css_style_declaration.h"
 #include "third_party/blink/renderer/core/css/css_value.h"
-#include "third_party/blink/renderer/core/css/known_exposed_properties.h"
 #include "third_party/blink/renderer/core/css/parser/css_parser.h"
 #include "third_party/blink/renderer/core/css/properties/css_property.h"
+#include "third_party/blink/renderer/core/css/property_bitsets.h"
 #include "third_party/blink/renderer/core/execution_context/execution_context.h"
 #include "third_party/blink/renderer/platform/bindings/exception_state.h"
 #include "third_party/blink/renderer/platform/bindings/script_state.h"
diff --git a/third_party/blink/renderer/core/css/known_exposed_properties.h b/third_party/blink/renderer/core/css/known_exposed_properties.h
deleted file mode 100644
index 77cb4dc..0000000
--- a/third_party/blink/renderer/core/css/known_exposed_properties.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_KNOWN_EXPOSED_PROPERTIES_H_
-#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_KNOWN_EXPOSED_PROPERTIES_H_
-
-#include <bitset>
-#include "third_party/blink/renderer/core/css/properties/css_bitset.h"
-
-namespace blink {
-
-// For properties that are not behind runtime flags (which are nearly all,
-// in practice), we can avoid resolving and looking them up to check the
-// exposure; we can just check this bitmap instead (which fits neatly into
-// two rather hot cache lines). This saves a little time in parsing.
-extern const CSSBitset kKnownExposedProperties;
-
-}  // namespace blink
-
-#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_KNOWN_EXPOSED_PROPERTIES_H_
diff --git a/third_party/blink/renderer/core/css/logical_group_properties.h b/third_party/blink/renderer/core/css/logical_group_properties.h
deleted file mode 100644
index fb983c7..0000000
--- a/third_party/blink/renderer/core/css/logical_group_properties.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_LOGICAL_GROUP_PROPERTIES_H_
-#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_LOGICAL_GROUP_PROPERTIES_H_
-
-#include <bitset>
-#include "third_party/blink/renderer/core/css/properties/css_bitset.h"
-
-namespace blink {
-
-// Properties whose presence signals that we may have to go through
-// the logic of logical properties replacing other properties, if present.
-// Equivalent to checking prop.IsInLogicalPropertyGroup() && prop.IsSurrogate(),
-// but faster.
-extern const CSSBitset kLogicalGroupProperties;
-
-}  // namespace blink
-
-#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_LOGICAL_GROUP_PROPERTIES_H_
diff --git a/third_party/blink/renderer/core/css/parser/css_property_parser.cc b/third_party/blink/renderer/core/css/parser/css_property_parser.cc
index fdfaa098..047e430 100644
--- a/third_party/blink/renderer/core/css/parser/css_property_parser.cc
+++ b/third_party/blink/renderer/core/css/parser/css_property_parser.cc
@@ -8,7 +8,6 @@
 #include "third_party/blink/renderer/core/css/css_unicode_range_value.h"
 #include "third_party/blink/renderer/core/css/css_variable_reference_value.h"
 #include "third_party/blink/renderer/core/css/hash_tools.h"
-#include "third_party/blink/renderer/core/css/known_exposed_properties.h"
 #include "third_party/blink/renderer/core/css/parser/at_rule_descriptor_parser.h"
 #include "third_party/blink/renderer/core/css/parser/css_parser_local_context.h"
 #include "third_party/blink/renderer/core/css/parser/css_parser_mode.h"
@@ -16,6 +15,7 @@
 #include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
 #include "third_party/blink/renderer/core/css/properties/css_property.h"
 #include "third_party/blink/renderer/core/css/properties/shorthand.h"
+#include "third_party/blink/renderer/core/css/property_bitsets.h"
 #include "third_party/blink/renderer/core/style_property_shorthand.h"
 #include "third_party/blink/renderer/platform/wtf/text/character_visitor.h"
 
diff --git a/third_party/blink/renderer/core/css/property_bitsets.h b/third_party/blink/renderer/core/css/property_bitsets.h
new file mode 100644
index 0000000..c00486810
--- /dev/null
+++ b/third_party/blink/renderer/core/css/property_bitsets.h
@@ -0,0 +1,27 @@
+// Copyright 2022 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_BITSETS_H_
+#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_BITSETS_H_
+
+#include <bitset>
+#include "third_party/blink/renderer/core/css/properties/css_bitset.h"
+
+namespace blink {
+
+// Properties whose presence signals that we may have to go through
+// the logic of logical properties replacing other properties, if present.
+// Equivalent to checking prop.IsInLogicalPropertyGroup() && prop.IsSurrogate(),
+// but faster.
+extern const CSSBitset kLogicalGroupProperties;
+
+// For properties that are not behind runtime flags (which are nearly all,
+// in practice), we can avoid resolving and looking them up to check the
+// exposure; we can just check this bitmap instead (which fits neatly into
+// two rather hot cache lines). This saves a little time in parsing.
+extern const CSSBitset kKnownExposedProperties;
+
+}  // namespace blink
+
+#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_PROPERTY_BITSETS_H_