From e050f21f36103b2395d655ec5f881d0caff1a4ef Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Tue, 11 Aug 2020 00:07:16 +0200 Subject: [PATCH] LibWeb: Mark compilation-unit-only functions as static This enables a nice warning in case a function becomes dead code. Also, in the case of {Event,Node}WrapperFactory.cpp, the corresponding header was forgotten. This would cause an issue later when we enable -Wmissing-declarations. Is my clang-format misconfigured? Why is the diff for NodeWrapperFactory.cpp so large? --- .../LibWeb/Bindings/EventWrapperFactory.cpp | 1 + .../LibWeb/Bindings/NodeWrapperFactory.cpp | 30 +++++++++---------- Libraries/LibWeb/CSS/SelectorEngine.cpp | 4 +-- .../CodeGenerators/WrapperGenerator.cpp | 3 +- Libraries/LibWeb/Loader/Resource.cpp | 4 +-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp b/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp index 88f4d900fb..46d99f4fd5 100644 --- a/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp @@ -25,6 +25,7 @@ */ #include +#include #include namespace Web { diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index 4826e02d92..499c36177e 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -31,33 +31,33 @@ #include #include #include +#include #include #include -#include #include #include +#include #include -#include #include +#include #include #include -#include +#include #include #include -#include #include #include #include +#include #include #include -#include #include #include #include #include +#include #include #include -#include #include #include #include @@ -65,8 +65,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -83,8 +83,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -97,38 +97,39 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include -#include #include #include +#include #include -#include #include +#include #include #include -#include #include #include #include #include #include +#include #include #include -#include #include #include #include #include +#include #include #include -#include #include #include #include @@ -136,8 +137,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -167,7 +168,6 @@ #include #include #include -#include namespace Web::Bindings { diff --git a/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Libraries/LibWeb/CSS/SelectorEngine.cpp index d640c5bc54..942fccf0cd 100644 --- a/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -42,7 +42,7 @@ static bool matches_hover_pseudo_class(const DOM::Element& element) return element.is_ancestor_of(*hovered_node); } -bool matches(const CSS::Selector::SimpleSelector& component, const DOM::Element& element) +static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::Element& element) { switch (component.pseudo_class) { case CSS::Selector::SimpleSelector::PseudoClass::None: @@ -114,7 +114,7 @@ bool matches(const CSS::Selector::SimpleSelector& component, const DOM::Element& } } -bool matches(const CSS::Selector& selector, int component_list_index, const DOM::Element& element) +static bool matches(const CSS::Selector& selector, int component_list_index, const DOM::Element& element) { auto& component_list = selector.complex_selectors()[component_list_index]; for (auto& component : component_list.compound_selector) { diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 5670104a8c..8472ab3dd7 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -116,7 +116,7 @@ struct Interface { String fully_qualified_name; }; -OwnPtr parse_interface(const StringView& input) +static OwnPtr parse_interface(const StringView& input) { auto interface = make(); @@ -339,7 +339,6 @@ int main(int argc, char** argv) interface->fully_qualified_name = interface->name; } - #if 0 dbg() << "Attributes:"; for (auto& attribute : interface->attributes) { diff --git a/Libraries/LibWeb/Loader/Resource.cpp b/Libraries/LibWeb/Loader/Resource.cpp index 418b8d170a..696229dc76 100644 --- a/Libraries/LibWeb/Loader/Resource.cpp +++ b/Libraries/LibWeb/Loader/Resource.cpp @@ -60,7 +60,7 @@ void Resource::for_each_client(Function callback) } } -String encoding_from_content_type(const String& content_type) +static String encoding_from_content_type(const String& content_type) { auto offset = content_type.index_of("charset="); if (offset.has_value()) { @@ -75,7 +75,7 @@ String encoding_from_content_type(const String& content_type) return "utf-8"; } -String mime_type_from_content_type(const String& content_type) +static String mime_type_from_content_type(const String& content_type) { auto offset = content_type.index_of(";"); if (offset.has_value())