1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

Everywhere: Run clang-format

This commit is contained in:
Idan Horowitz 2022-04-01 20:58:27 +03:00 committed by Linus Groh
parent 0376c127f6
commit 086969277e
1665 changed files with 8479 additions and 8479 deletions

View file

@ -16,17 +16,17 @@
namespace Web::HTML {
bool prescan_should_abort(const ByteBuffer& input, const size_t& position)
bool prescan_should_abort(ByteBuffer const& input, size_t const& position)
{
return position >= input.size() || position >= 1024;
}
bool prescan_is_whitespace_or_slash(const u8& byte)
bool prescan_is_whitespace_or_slash(u8 const& byte)
{
return byte == '\t' || byte == '\n' || byte == '\f' || byte == '\r' || byte == ' ' || byte == '/';
}
bool prescan_skip_whitespace_and_slashes(const ByteBuffer& input, size_t& position)
bool prescan_skip_whitespace_and_slashes(ByteBuffer const& input, size_t& position)
{
while (!prescan_should_abort(input, position) && (input[position] == '\t' || input[position] == '\n' || input[position] == '\f' || input[position] == '\r' || input[position] == ' ' || input[position] == '/'))
++position;
@ -96,7 +96,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const&
return TextCodec::get_standardized_encoding(encoding);
}
RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document& document, const ByteBuffer& input, size_t& position)
RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document& document, ByteBuffer const& input, size_t& position)
{
if (!prescan_skip_whitespace_and_slashes(input, position))
return {};
@ -160,7 +160,7 @@ value:
}
// https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding
Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, const ByteBuffer& input)
Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, ByteBuffer const& input)
{
// https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding
@ -249,7 +249,7 @@ Optional<String> run_prescan_byte_stream_algorithm(DOM::Document& document, cons
}
// https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding
String run_encoding_sniffing_algorithm(DOM::Document& document, const ByteBuffer& input)
String run_encoding_sniffing_algorithm(DOM::Document& document, ByteBuffer const& input)
{
if (input.size() >= 2) {
if (input[0] == 0xFE && input[1] == 0xFF) {

View file

@ -12,12 +12,12 @@
namespace Web::HTML {
bool prescan_should_abort(const ByteBuffer& input, const size_t& position);
bool prescan_is_whitespace_or_slash(const u8& byte);
bool prescan_skip_whitespace_and_slashes(const ByteBuffer& input, size_t& position);
bool prescan_should_abort(ByteBuffer const& input, size_t const& position);
bool prescan_is_whitespace_or_slash(u8 const& byte);
bool prescan_skip_whitespace_and_slashes(ByteBuffer const& input, size_t& position);
Optional<StringView> extract_character_encoding_from_meta_element(String const&);
RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document&, const ByteBuffer& input, size_t& position);
Optional<String> run_prescan_byte_stream_algorithm(DOM::Document&, const ByteBuffer& input);
String run_encoding_sniffing_algorithm(DOM::Document&, const ByteBuffer& input);
RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document&, ByteBuffer const& input, size_t& position);
Optional<String> run_prescan_byte_stream_algorithm(DOM::Document&, ByteBuffer const& input);
String run_encoding_sniffing_algorithm(DOM::Document&, ByteBuffer const& input);
}

View file

@ -32,7 +32,7 @@
namespace Web::HTML {
static inline void log_parse_error(const SourceLocation& location = SourceLocation::current())
static inline void log_parse_error(SourceLocation const& location = SourceLocation::current())
{
dbgln("Parse error! {}", location);
}
@ -118,7 +118,7 @@ static bool is_html_integration_point(DOM::Element const& element)
return false;
}
RefPtr<DOM::Document> parse_html_document(StringView data, const AK::URL& url, const String& encoding)
RefPtr<DOM::Document> parse_html_document(StringView data, const AK::URL& url, String const& encoding)
{
auto document = DOM::Document::create(url);
auto parser = HTMLParser::create(document, data, encoding);
@ -126,7 +126,7 @@ RefPtr<DOM::Document> parse_html_document(StringView data, const AK::URL& url, c
return document;
}
HTMLParser::HTMLParser(DOM::Document& document, StringView input, const String& encoding)
HTMLParser::HTMLParser(DOM::Document& document, StringView input, String const& encoding)
: m_tokenizer(input, encoding)
, m_document(document)
{
@ -389,7 +389,7 @@ void HTMLParser::process_using_the_rules_for(InsertionMode mode, HTMLToken& toke
}
}
DOM::QuirksMode HTMLParser::which_quirks_mode(const HTMLToken& doctype_token) const
DOM::QuirksMode HTMLParser::which_quirks_mode(HTMLToken const& doctype_token) const
{
if (doctype_token.doctype_data().force_quirks)
return DOM::QuirksMode::Yes;
@ -651,7 +651,7 @@ NonnullRefPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& toke
}
// https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element
NonnullRefPtr<DOM::Element> HTMLParser::insert_foreign_element(const HTMLToken& token, const FlyString& namespace_)
NonnullRefPtr<DOM::Element> HTMLParser::insert_foreign_element(HTMLToken const& token, FlyString const& namespace_)
{
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
@ -677,7 +677,7 @@ NonnullRefPtr<DOM::Element> HTMLParser::insert_foreign_element(const HTMLToken&
return element;
}
NonnullRefPtr<DOM::Element> HTMLParser::insert_html_element(const HTMLToken& token)
NonnullRefPtr<DOM::Element> HTMLParser::insert_html_element(HTMLToken const& token)
{
return insert_foreign_element(token, Namespace::HTML);
}
@ -1011,7 +1011,7 @@ AnythingElse:
process_using_the_rules_for(m_insertion_mode, token);
}
void HTMLParser::generate_implied_end_tags(const FlyString& exception)
void HTMLParser::generate_implied_end_tags(FlyString const& exception)
{
while (current_node().local_name() != exception && current_node().local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc))
(void)m_stack_of_open_elements.pop();
@ -1335,7 +1335,7 @@ HTMLParser::AdoptionAgencyAlgorithmOutcome HTMLParser::run_the_adoption_agency_a
}
}
bool HTMLParser::is_special_tag(const FlyString& tag_name, const FlyString& namespace_)
bool HTMLParser::is_special_tag(FlyString const& tag_name, FlyString const& namespace_)
{
if (namespace_ == Namespace::HTML) {
return tag_name.is_one_of(
@ -3357,7 +3357,7 @@ void HTMLParser::reset_the_insertion_mode_appropriately()
m_insertion_mode = InsertionMode::InBody;
}
const char* HTMLParser::insertion_mode_name() const
char const* HTMLParser::insertion_mode_name() const
{
switch (m_insertion_mode) {
#define __ENUMERATE_INSERTION_MODE(mode) \
@ -3430,7 +3430,7 @@ NonnullRefPtr<HTMLParser> HTMLParser::create_for_scripting(DOM::Document& docume
return adopt_ref(*new HTMLParser(document));
}
NonnullRefPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, const ByteBuffer& input)
NonnullRefPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, ByteBuffer const& input)
{
if (document.has_encoding())
return adopt_ref(*new HTMLParser(document, input, document.encoding().value()));

View file

@ -39,7 +39,7 @@ namespace Web::HTML {
__ENUMERATE_INSERTION_MODE(AfterAfterBody) \
__ENUMERATE_INSERTION_MODE(AfterAfterFrameset)
RefPtr<DOM::Document> parse_html_document(StringView, const AK::URL&, const String& encoding);
RefPtr<DOM::Document> parse_html_document(StringView, const AK::URL&, String const& encoding);
class HTMLParser : public RefCounted<HTMLParser> {
friend class HTMLTokenizer;
@ -67,7 +67,7 @@ public:
InsertionMode insertion_mode() const { return m_insertion_mode; }
static bool is_special_tag(const FlyString& tag_name, const FlyString& namespace_);
static bool is_special_tag(FlyString const& tag_name, FlyString const& namespace_);
HTMLTokenizer& tokenizer() { return m_tokenizer; }
@ -76,12 +76,12 @@ public:
size_t script_nesting_level() const { return m_script_nesting_level; }
private:
HTMLParser(DOM::Document&, StringView input, const String& encoding);
HTMLParser(DOM::Document&, StringView input, String const& encoding);
HTMLParser(DOM::Document&);
const char* insertion_mode_name() const;
char const* insertion_mode_name() const;
DOM::QuirksMode which_quirks_mode(const HTMLToken&) const;
DOM::QuirksMode which_quirks_mode(HTMLToken const&) const;
void handle_initial(HTMLToken&);
void handle_before_html(HTMLToken&);
@ -111,7 +111,7 @@ private:
void stop_parsing() { m_stop_parsing = true; }
void generate_implied_end_tags(const FlyString& exception = {});
void generate_implied_end_tags(FlyString const& exception = {});
void generate_all_implied_end_tags_thoroughly();
NonnullRefPtr<DOM::Element> create_element_for(HTMLToken const&, FlyString const& namespace_, DOM::Node const& intended_parent);
@ -124,8 +124,8 @@ private:
DOM::Text* find_character_insertion_node();
void flush_character_insertions();
NonnullRefPtr<DOM::Element> insert_foreign_element(const HTMLToken&, const FlyString&);
NonnullRefPtr<DOM::Element> insert_html_element(const HTMLToken&);
NonnullRefPtr<DOM::Element> insert_foreign_element(HTMLToken const&, FlyString const&);
NonnullRefPtr<DOM::Element> insert_html_element(HTMLToken const&);
DOM::Element& current_node();
DOM::Element& adjusted_current_node();
DOM::Element& node_before_current_node();

View file

@ -31,7 +31,7 @@ bool ListOfActiveFormattingElements::contains(const DOM::Element& element) const
return false;
}
DOM::Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(const FlyString& tag_name)
DOM::Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marker(FlyString const& tag_name)
{
for (ssize_t i = m_entries.size() - 1; i >= 0; --i) {
auto& entry = m_entries[i];

View file

@ -34,10 +34,10 @@ public:
void remove(DOM::Element&);
const Vector<Entry>& entries() const { return m_entries; }
Vector<Entry> const& entries() const { return m_entries; }
Vector<Entry>& entries() { return m_entries; }
DOM::Element* last_element_with_tag_name_before_marker(const FlyString& tag_name);
DOM::Element* last_element_with_tag_name_before_marker(FlyString const& tag_name);
void clear_up_to_the_last_marker();

View file

@ -14,7 +14,7 @@ static Vector<FlyString> s_base_list { "applet", "caption", "html", "table", "td
StackOfOpenElements::~StackOfOpenElements() = default;
bool StackOfOpenElements::has_in_scope_impl(const FlyString& tag_name, const Vector<FlyString>& list) const
bool StackOfOpenElements::has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const& list) const
{
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
auto& node = m_elements.at(i);
@ -26,12 +26,12 @@ bool StackOfOpenElements::has_in_scope_impl(const FlyString& tag_name, const Vec
VERIFY_NOT_REACHED();
}
bool StackOfOpenElements::has_in_scope(const FlyString& tag_name) const
bool StackOfOpenElements::has_in_scope(FlyString const& tag_name) const
{
return has_in_scope_impl(tag_name, s_base_list);
}
bool StackOfOpenElements::has_in_scope_impl(const DOM::Element& target_node, const Vector<FlyString>& list) const
bool StackOfOpenElements::has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const& list) const
{
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
auto& node = m_elements.at(i);
@ -48,19 +48,19 @@ bool StackOfOpenElements::has_in_scope(const DOM::Element& target_node) const
return has_in_scope_impl(target_node, s_base_list);
}
bool StackOfOpenElements::has_in_button_scope(const FlyString& tag_name) const
bool StackOfOpenElements::has_in_button_scope(FlyString const& tag_name) const
{
auto list = s_base_list;
list.append("button");
return has_in_scope_impl(tag_name, list);
}
bool StackOfOpenElements::has_in_table_scope(const FlyString& tag_name) const
bool StackOfOpenElements::has_in_table_scope(FlyString const& tag_name) const
{
return has_in_scope_impl(tag_name, { "html", "table", "template" });
}
bool StackOfOpenElements::has_in_list_item_scope(const FlyString& tag_name) const
bool StackOfOpenElements::has_in_list_item_scope(FlyString const& tag_name) const
{
auto list = s_base_list;
list.append("ol");
@ -74,7 +74,7 @@ bool StackOfOpenElements::has_in_list_item_scope(const FlyString& tag_name) cons
// - optgroup in the HTML namespace
// - option in the HTML namespace
// NOTE: In this case it's "all element types _except_"
bool StackOfOpenElements::has_in_select_scope(const FlyString& tag_name) const
bool StackOfOpenElements::has_in_select_scope(FlyString const& tag_name) const
{
// https://html.spec.whatwg.org/multipage/parsing.html#has-an-element-in-the-specific-scope
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
@ -103,7 +103,7 @@ bool StackOfOpenElements::contains(const DOM::Element& element) const
return false;
}
bool StackOfOpenElements::contains(const FlyString& tag_name) const
bool StackOfOpenElements::contains(FlyString const& tag_name) const
{
for (auto& element_on_stack : m_elements) {
if (element_on_stack.local_name() == tag_name)
@ -112,7 +112,7 @@ bool StackOfOpenElements::contains(const FlyString& tag_name) const
return false;
}
void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(const FlyString& tag_name)
void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(FlyString const& tag_name)
{
while (m_elements.last().local_name() != tag_name)
(void)pop();
@ -132,7 +132,7 @@ DOM::Element* StackOfOpenElements::topmost_special_node_below(const DOM::Element
return found_element;
}
StackOfOpenElements::LastElementResult StackOfOpenElements::last_element_with_tag_name(const FlyString& tag_name)
StackOfOpenElements::LastElementResult StackOfOpenElements::last_element_with_tag_name(FlyString const& tag_name)
{
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
auto& element = m_elements[i];

View file

@ -36,21 +36,21 @@ public:
const DOM::Element& current_node() const { return m_elements.last(); }
DOM::Element& current_node() { return m_elements.last(); }
bool has_in_scope(const FlyString& tag_name) const;
bool has_in_button_scope(const FlyString& tag_name) const;
bool has_in_table_scope(const FlyString& tag_name) const;
bool has_in_list_item_scope(const FlyString& tag_name) const;
bool has_in_select_scope(const FlyString& tag_name) const;
bool has_in_scope(FlyString const& tag_name) const;
bool has_in_button_scope(FlyString const& tag_name) const;
bool has_in_table_scope(FlyString const& tag_name) const;
bool has_in_list_item_scope(FlyString const& tag_name) const;
bool has_in_select_scope(FlyString const& tag_name) const;
bool has_in_scope(const DOM::Element&) const;
bool contains(const DOM::Element&) const;
bool contains(const FlyString& tag_name) const;
bool contains(FlyString const& tag_name) const;
const NonnullRefPtrVector<DOM::Element>& elements() const { return m_elements; }
NonnullRefPtrVector<DOM::Element> const& elements() const { return m_elements; }
NonnullRefPtrVector<DOM::Element>& elements() { return m_elements; }
void pop_until_an_element_with_tag_name_has_been_popped(const FlyString&);
void pop_until_an_element_with_tag_name_has_been_popped(FlyString const&);
DOM::Element* topmost_special_node_below(const DOM::Element&);
@ -58,12 +58,12 @@ public:
DOM::Element* element;
ssize_t index;
};
LastElementResult last_element_with_tag_name(const FlyString&);
LastElementResult last_element_with_tag_name(FlyString const&);
DOM::Element* element_immediately_above(DOM::Element const&);
private:
bool has_in_scope_impl(const FlyString& tag_name, const Vector<FlyString>&) const;
bool has_in_scope_impl(const DOM::Element& target_node, const Vector<FlyString>&) const;
bool has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const&) const;
bool has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const&) const;
NonnullRefPtrVector<DOM::Element> m_elements;
};