From 22de7321b3f8376d5eb4aa4c2827dbf460ed249a Mon Sep 17 00:00:00 2001 From: Kent Tamura Date: Thu, 5 Oct 2017 13:16:38 +0000 Subject: [PATCH] make_element_factory.py generates snake_case files. Bug: 770603 Change-Id: Idd9f6ea0c9d2d6ace0af99bd894d7aec7f99e42b Reviewed-on: https://chromium-review.googlesource.com/701816 Reviewed-by: Hitoshi Yoshida Commit-Queue: Kent Tamura Cr-Commit-Position: refs/heads/master@{#506712} --- .../Source/build/scripts/make_element_factory.py | 12 +++++------- third_party/WebKit/Source/build/scripts/scripts.gni | 4 ++-- ...ementFactory.cpp.tmpl => element_factory.cc.tmpl} | 2 +- ...{ElementFactory.h.tmpl => element_factory.h.tmpl} | 7 ++----- third_party/WebKit/Source/core/BUILD.gn | 8 ++++---- third_party/WebKit/Source/core/dom/Document.cpp | 4 ++-- .../WebKit/Source/core/editing/EditingUtilities.cpp | 2 +- .../WebKit/Source/core/html/custom/CustomElement.cpp | 2 +- .../Source/core/html/parser/HTMLConstructionSite.cpp | 2 +- .../WebKit/Source/core/html/track/vtt/VTTElement.cpp | 2 +- 10 files changed, 20 insertions(+), 25 deletions(-) rename third_party/WebKit/Source/build/scripts/templates/{ElementFactory.cpp.tmpl => element_factory.cc.tmpl} (98%) rename third_party/WebKit/Source/build/scripts/templates/{ElementFactory.h.tmpl => element_factory.h.tmpl} (78%) diff --git a/third_party/WebKit/Source/build/scripts/make_element_factory.py b/third_party/WebKit/Source/build/scripts/make_element_factory.py index c792667a263e1..d7b1cd4c302e0 100755 --- a/third_party/WebKit/Source/build/scripts/make_element_factory.py +++ b/third_party/WebKit/Source/build/scripts/make_element_factory.py @@ -57,12 +57,10 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter): def __init__(self, json5_file_paths): super(MakeElementFactoryWriter, self).__init__(json5_file_paths) - # FIXME: When we start using these element factories, we'll want to - # remove the "new" prefix and also have our base class generate - # *Names.h and *Names.cpp. + basename = self.namespace.lower() + '_element_factory' self._outputs.update({ - (self.namespace + 'ElementFactory.h'): self.generate_factory_header, - (self.namespace + 'ElementFactory.cpp'): self.generate_factory_implementation, + (basename + '.h'): self.generate_factory_header, + (basename + '.cc'): self.generate_factory_implementation, }) fallback_interface = self.tags_json5_file.metadata['fallbackInterfaceName'].strip('"') @@ -90,11 +88,11 @@ def __init__(self, json5_file_paths): 'input_files': self._input_files, }) - @template_expander.use_jinja('templates/ElementFactory.h.tmpl', filters=filters) + @template_expander.use_jinja('templates/element_factory.h.tmpl', filters=filters) def generate_factory_header(self): return self._template_context - @template_expander.use_jinja('templates/ElementFactory.cpp.tmpl', filters=filters) + @template_expander.use_jinja('templates/element_factory.cc.tmpl', filters=filters) def generate_factory_implementation(self): return self._template_context diff --git a/third_party/WebKit/Source/build/scripts/scripts.gni b/third_party/WebKit/Source/build/scripts/scripts.gni index 5ef52edf0f27e..0293915abeddf 100644 --- a/third_party/WebKit/Source/build/scripts/scripts.gni +++ b/third_party/WebKit/Source/build/scripts/scripts.gni @@ -47,8 +47,8 @@ make_qualified_names_files = make_element_factory_files = make_qualified_names_files + [ "$_scripts_dir/make_element_factory.py", - "$_scripts_dir/templates/ElementFactory.cpp.tmpl", - "$_scripts_dir/templates/ElementFactory.h.tmpl", + "$_scripts_dir/templates/element_factory.cc.tmpl", + "$_scripts_dir/templates/element_factory.h.tmpl", ] make_element_type_helpers_files = diff --git a/third_party/WebKit/Source/build/scripts/templates/ElementFactory.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/element_factory.cc.tmpl similarity index 98% rename from third_party/WebKit/Source/build/scripts/templates/ElementFactory.cpp.tmpl rename to third_party/WebKit/Source/build/scripts/templates/element_factory.cc.tmpl index 304657480be00..ebeac55723521 100644 --- a/third_party/WebKit/Source/build/scripts/templates/ElementFactory.cpp.tmpl +++ b/third_party/WebKit/Source/build/scripts/templates/element_factory.cc.tmpl @@ -3,7 +3,7 @@ {{source_files_for_generated_file(template_file, input_files)}} -#include "{{namespace}}ElementFactory.h" +#include "core/{{namespace|lower}}_element_factory.h" #include "core/{{namespace|lower}}_names.h" {% for header in tags|groupby('interface_header') %} diff --git a/third_party/WebKit/Source/build/scripts/templates/ElementFactory.h.tmpl b/third_party/WebKit/Source/build/scripts/templates/element_factory.h.tmpl similarity index 78% rename from third_party/WebKit/Source/build/scripts/templates/ElementFactory.h.tmpl rename to third_party/WebKit/Source/build/scripts/templates/element_factory.h.tmpl index 102dd1eb9612e..eceae0e60d8de 100644 --- a/third_party/WebKit/Source/build/scripts/templates/ElementFactory.h.tmpl +++ b/third_party/WebKit/Source/build/scripts/templates/element_factory.h.tmpl @@ -3,17 +3,14 @@ {{source_files_for_generated_file(template_file, input_files)}} -#ifndef {{namespace}}ElementFactory_h -#define {{namespace}}ElementFactory_h +#ifndef BLINK_CORE_{{namespace|upper}}_ELEMENT_FACTORY_H_ +#define BLINK_CORE_{{namespace|upper}}_ELEMENT_FACTORY_H_ #include "core/dom/Document.h" -#include "platform/heap/Handle.h" #include "platform/wtf/Forward.h" -#include "platform/wtf/RefPtr.h" namespace blink { -class Document; class {{namespace}}Element; {% if namespace == 'HTML' %} class HTMLFormElement; diff --git a/third_party/WebKit/Source/core/BUILD.gn b/third_party/WebKit/Source/core/BUILD.gn index 4cfc28fe346a0..dc63b59ee1499 100644 --- a/third_party/WebKit/Source/core/BUILD.gn +++ b/third_party/WebKit/Source/core/BUILD.gn @@ -849,8 +849,8 @@ process_json5_files("make_core_generated_html_element_factory") { ] other_inputs = make_element_factory_files outputs = [ - "$blink_core_output_dir/HTMLElementFactory.cpp", - "$blink_core_output_dir/HTMLElementFactory.h", + "$blink_core_output_dir/html_element_factory.cc", + "$blink_core_output_dir/html_element_factory.h", "$blink_core_output_dir/html_names.cc", "$blink_core_output_dir/html_names.h", ] @@ -876,8 +876,8 @@ process_json5_files("make_core_generated_svg_names") { ] other_inputs = make_element_factory_files outputs = [ - "$blink_core_output_dir/SVGElementFactory.cpp", - "$blink_core_output_dir/SVGElementFactory.h", + "$blink_core_output_dir/svg_element_factory.cc", + "$blink_core_output_dir/svg_element_factory.h", "$blink_core_output_dir/svg_names.cc", "$blink_core_output_dir/svg_names.h", ] diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index 1f5e2c5113a81..a2bf0ece61c08 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp @@ -40,9 +40,7 @@ #include "bindings/core/v8/WindowProxy.h" #include "bindings/core/v8/html_script_element_or_svg_script_element.h" #include "bindings/core/v8/string_or_dictionary.h" -#include "core/HTMLElementFactory.h" #include "core/HTMLElementTypeHelpers.h" -#include "core/SVGElementFactory.h" #include "core/animation/DocumentAnimations.h" #include "core/animation/DocumentTimeline.h" #include "core/animation/PendingAnimations.h" @@ -169,6 +167,7 @@ #include "core/html/parser/HTMLParserIdioms.h" #include "core/html/parser/NestingLevelIncrementer.h" #include "core/html/parser/TextResourceDecoder.h" +#include "core/html_element_factory.h" #include "core/html_names.h" #include "core/input/EventHandler.h" #include "core/input/TouchList.h" @@ -211,6 +210,7 @@ #include "core/svg/SVGScriptElement.h" #include "core/svg/SVGTitleElement.h" #include "core/svg/SVGUseElement.h" +#include "core/svg_element_factory.h" #include "core/svg_names.h" #include "core/timing/DOMWindowPerformance.h" #include "core/timing/Performance.h" diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp index 3c9a8ed60db94..2cb0961f02f45 100644 --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp @@ -25,7 +25,6 @@ #include "core/editing/EditingUtilities.h" -#include "core/HTMLElementFactory.h" #include "core/InputTypeNames.h" #include "core/clipboard/DataObject.h" #include "core/dom/Document.h" @@ -61,6 +60,7 @@ #include "core/html/HTMLSpanElement.h" #include "core/html/HTMLTableCellElement.h" #include "core/html/HTMLUListElement.h" +#include "core/html_element_factory.h" #include "core/html_names.h" #include "core/layout/LayoutObject.h" #include "core/layout/LayoutTableCell.h" diff --git a/third_party/WebKit/Source/core/html/custom/CustomElement.cpp b/third_party/WebKit/Source/core/html/custom/CustomElement.cpp index e534de2a07882..2facca8cf118b 100644 --- a/third_party/WebKit/Source/core/html/custom/CustomElement.cpp +++ b/third_party/WebKit/Source/core/html/custom/CustomElement.cpp @@ -4,7 +4,6 @@ #include "core/html/custom/CustomElement.h" -#include "core/HTMLElementFactory.h" #include "core/HTMLElementTypeHelpers.h" #include "core/dom/Document.h" #include "core/dom/QualifiedName.h" @@ -17,6 +16,7 @@ #include "core/html/custom/CustomElementRegistry.h" #include "core/html/custom/V0CustomElement.h" #include "core/html/custom/V0CustomElementRegistrationContext.h" +#include "core/html_element_factory.h" #include "platform/wtf/text/AtomicStringHash.h" namespace blink { diff --git a/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp b/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp index c6202df193be7..9e26a31328763 100644 --- a/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp +++ b/third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp @@ -27,7 +27,6 @@ #include "core/html/parser/HTMLConstructionSite.h" #include -#include "core/HTMLElementFactory.h" #include "core/dom/Comment.h" #include "core/dom/DocumentFragment.h" #include "core/dom/DocumentType.h" @@ -55,6 +54,7 @@ #include "core/html/parser/HTMLParserReentryPermit.h" #include "core/html/parser/HTMLStackItem.h" #include "core/html/parser/HTMLToken.h" +#include "core/html_element_factory.h" #include "core/html_names.h" #include "core/loader/FrameLoader.h" #include "core/svg/SVGScriptElement.h" diff --git a/third_party/WebKit/Source/core/html/track/vtt/VTTElement.cpp b/third_party/WebKit/Source/core/html/track/vtt/VTTElement.cpp index f6b30503eeaeb..8b9437ae083dd 100644 --- a/third_party/WebKit/Source/core/html/track/vtt/VTTElement.cpp +++ b/third_party/WebKit/Source/core/html/track/vtt/VTTElement.cpp @@ -25,8 +25,8 @@ #include "core/html/track/vtt/VTTElement.h" -#include "core/HTMLElementFactory.h" #include "core/css/StyleChangeReason.h" +#include "core/html_element_factory.h" namespace blink {