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
Notes: sideshowbarker 2024-07-17 06:25:43 +09:00
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())
return;
auto split_values = value.split_view(' ');
auto split_values = value.split_view(Infra::ASCII_WHITESPACE);
for (auto const& split_value : split_values)
append_to_ordered_set(m_token_set, split_value);
}

View File

@ -5,7 +5,6 @@
*/
#include <AK/AnyOf.h>
#include <AK/CharacterTypes.h>
#include <AK/Debug.h>
#include <AK/StringBuilder.h>
#include <LibWeb/CSS/Parser/Parser.h>
@ -34,6 +33,7 @@
#include <LibWeb/HTML/HTMLSelectElement.h>
#include <LibWeb/HTML/HTMLTextAreaElement.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InitialContainingBlock.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)
{
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.ensure_capacity(new_classes.size());
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)
{
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);
}
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/DOM/Document.h>
#include <LibWeb/HTML/HTMLLinkElement.h>
#include <LibWeb/Infra/CharacterTypes.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Page.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,
// 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.
auto parts = lowercased_value.split_view(' ');
auto parts = lowercased_value.split_view(Infra::is_ascii_whitespace);
for (auto& part : parts) {
if (part == "stylesheet"sv)
m_relationship |= Relationship::Stylesheet;