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

LibWeb: Replace incorrect uses of split_view() for whitespace splitting

This commit is contained in:
Linus Groh 2022-10-01 18:29:18 +01:00 committed by Andreas Kling
parent b9220a18d1
commit b86c264975
3 changed files with 6 additions and 5 deletions

View file

@ -76,7 +76,7 @@ void DOMTokenList::associated_attribute_changed(StringView value)
if (value.is_empty()) if (value.is_empty())
return; return;
auto split_values = value.split_view(' '); auto split_values = value.split_view(Infra::ASCII_WHITESPACE);
for (auto const& split_value : split_values) for (auto const& split_value : split_values)
append_to_ordered_set(m_token_set, split_value); append_to_ordered_set(m_token_set, split_value);
} }

View file

@ -5,7 +5,6 @@
*/ */
#include <AK/AnyOf.h> #include <AK/AnyOf.h>
#include <AK/CharacterTypes.h>
#include <AK/Debug.h> #include <AK/Debug.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
@ -34,6 +33,7 @@
#include <LibWeb/HTML/HTMLSelectElement.h> #include <LibWeb/HTML/HTMLSelectElement.h>
#include <LibWeb/HTML/HTMLTextAreaElement.h> #include <LibWeb/HTML/HTMLTextAreaElement.h>
#include <LibWeb/HTML/Parser/HTMLParser.h> #include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Layout/BlockContainer.h> #include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/InlineNode.h> #include <LibWeb/Layout/InlineNode.h>
@ -328,7 +328,7 @@ CSS::CSSStyleDeclaration const* Element::inline_style() const
void Element::parse_attribute(FlyString const& name, String const& value) void Element::parse_attribute(FlyString const& name, String const& value)
{ {
if (name == HTML::AttributeNames::class_) { if (name == HTML::AttributeNames::class_) {
auto new_classes = value.split_view(is_ascii_space); auto new_classes = value.split_view(Infra::is_ascii_whitespace);
m_classes.clear(); m_classes.clear();
m_classes.ensure_capacity(new_classes.size()); m_classes.ensure_capacity(new_classes.size());
for (auto& new_class : new_classes) { for (auto& new_class : new_classes) {
@ -518,7 +518,7 @@ bool Element::is_active() const
JS::NonnullGCPtr<HTMLCollection> Element::get_elements_by_class_name(FlyString const& class_names) JS::NonnullGCPtr<HTMLCollection> Element::get_elements_by_class_name(FlyString const& class_names)
{ {
Vector<FlyString> list_of_class_names; Vector<FlyString> list_of_class_names;
for (auto& name : class_names.view().split_view(' ')) { for (auto& name : class_names.view().split_view(Infra::ASCII_WHITESPACE)) {
list_of_class_names.append(name); list_of_class_names.append(name);
} }
return HTMLCollection::create(*this, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) { return HTMLCollection::create(*this, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) {

View file

@ -12,6 +12,7 @@
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLLinkElement.h> #include <LibWeb/HTML/HTMLLinkElement.h>
#include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Loader/ResourceLoader.h> #include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Platform/ImageCodecPlugin.h> #include <LibWeb/Platform/ImageCodecPlugin.h>
@ -75,7 +76,7 @@ void HTMLLinkElement::parse_attribute(FlyString const& name, String const& value
// To determine which link types apply to a link, a, area, or form element, // To determine which link types apply to a link, a, area, or form element,
// the element's rel attribute must be split on ASCII whitespace. // the element's rel attribute must be split on ASCII whitespace.
// The resulting tokens are the keywords for the link types that apply to that element. // The resulting tokens are the keywords for the link types that apply to that element.
auto parts = lowercased_value.split_view(' '); auto parts = lowercased_value.split_view(Infra::is_ascii_whitespace);
for (auto& part : parts) { for (auto& part : parts) {
if (part == "stylesheet"sv) if (part == "stylesheet"sv)
m_relationship |= Relationship::Stylesheet; m_relationship |= Relationship::Stylesheet;