mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
LibWeb: Replace incorrect uses of String::trim_whitespace()
This commit is contained in:
parent
fb21271334
commit
b9220a18d1
4 changed files with 10 additions and 5 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <LibWeb/HTML/EventNames.h>
|
#include <LibWeb/HTML/EventNames.h>
|
||||||
#include <LibWeb/HTML/HTMLFormElement.h>
|
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||||
|
#include <LibWeb/Infra/CharacterTypes.h>
|
||||||
#include <LibWeb/Layout/BlockContainer.h>
|
#include <LibWeb/Layout/BlockContainer.h>
|
||||||
#include <LibWeb/Layout/ButtonBox.h>
|
#include <LibWeb/Layout/ButtonBox.h>
|
||||||
#include <LibWeb/Layout/CheckBox.h>
|
#include <LibWeb/Layout/CheckBox.h>
|
||||||
|
@ -300,7 +301,7 @@ String HTMLInputElement::value_sanitization_algorithm(String value) const
|
||||||
if (!(c == '\r' || c == '\n'))
|
if (!(c == '\r' || c == '\n'))
|
||||||
builder.append(c);
|
builder.append(c);
|
||||||
}
|
}
|
||||||
return builder.to_string().trim_whitespace();
|
return builder.string_view().trim(Infra::ASCII_WHITESPACE);
|
||||||
}
|
}
|
||||||
} else if (type_state() == HTMLInputElement::TypeAttributeState::Number) {
|
} else if (type_state() == HTMLInputElement::TypeAttributeState::Number) {
|
||||||
// If the value of the element is not a valid floating-point number, then set it to the empty string instead.
|
// If the value of the element is not a valid floating-point number, then set it to the empty string instead.
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <LibWeb/HTML/HTMLOptionElement.h>
|
#include <LibWeb/HTML/HTMLOptionElement.h>
|
||||||
#include <LibWeb/HTML/HTMLScriptElement.h>
|
#include <LibWeb/HTML/HTMLScriptElement.h>
|
||||||
#include <LibWeb/HTML/HTMLSelectElement.h>
|
#include <LibWeb/HTML/HTMLSelectElement.h>
|
||||||
|
#include <LibWeb/Infra/CharacterTypes.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
@ -97,7 +98,7 @@ static String strip_and_collapse_whitespace(StringView string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...and then remove any leading and trailing ASCII whitespace from that string.
|
// ...and then remove any leading and trailing ASCII whitespace from that string.
|
||||||
return builder.to_string().trim_whitespace();
|
return builder.to_string().trim(Infra::ASCII_WHITESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void concatenate_descendants_text_content(DOM::Node const* node, StringBuilder& builder)
|
static void concatenate_descendants_text_content(DOM::Node const* node, StringBuilder& builder)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <LibWeb/HTML/EventNames.h>
|
#include <LibWeb/HTML/EventNames.h>
|
||||||
#include <LibWeb/HTML/HTMLScriptElement.h>
|
#include <LibWeb/HTML/HTMLScriptElement.h>
|
||||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||||
|
#include <LibWeb/Infra/CharacterTypes.h>
|
||||||
#include <LibWeb/Loader/ResourceLoader.h>
|
#include <LibWeb/Loader/ResourceLoader.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
@ -168,7 +169,7 @@ void HTMLScriptElement::prepare_script()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the script's type as follows:
|
// Determine the script's type as follows:
|
||||||
if (is_javascript_mime_type_essence_match(script_block_type.trim_whitespace())) {
|
if (is_javascript_mime_type_essence_match(script_block_type.trim(Infra::ASCII_WHITESPACE))) {
|
||||||
// - If the script block's type string with leading and trailing ASCII whitespace stripped is a JavaScript MIME type essence match, the script's type is "classic".
|
// - If the script block's type string with leading and trailing ASCII whitespace stripped is a JavaScript MIME type essence match, the script's type is "classic".
|
||||||
m_script_type = ScriptType::Classic;
|
m_script_type = ScriptType::Classic;
|
||||||
} else if (script_block_type.equals_ignoring_case("module"sv)) {
|
} else if (script_block_type.equals_ignoring_case("module"sv)) {
|
||||||
|
@ -222,8 +223,8 @@ void HTMLScriptElement::prepare_script()
|
||||||
auto event = attribute(HTML::AttributeNames::event);
|
auto event = attribute(HTML::AttributeNames::event);
|
||||||
|
|
||||||
// 3. Strip leading and trailing ASCII whitespace from event and for.
|
// 3. Strip leading and trailing ASCII whitespace from event and for.
|
||||||
for_ = for_.trim_whitespace();
|
for_ = for_.trim(Infra::ASCII_WHITESPACE);
|
||||||
event = event.trim_whitespace();
|
event = event.trim(Infra::ASCII_WHITESPACE);
|
||||||
|
|
||||||
// 4. If for is not an ASCII case-insensitive match for the string "window", then return. The script is not executed.
|
// 4. If for is not an ASCII case-insensitive match for the string "window", then return. The script is not executed.
|
||||||
if (!for_.equals_ignoring_case("window"sv)) {
|
if (!for_.equals_ignoring_case("window"sv)) {
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
namespace Web::Infra {
|
namespace Web::Infra {
|
||||||
|
|
||||||
|
constexpr auto ASCII_WHITESPACE = "\t\n\f\r "sv;
|
||||||
|
|
||||||
// https://infra.spec.whatwg.org/#ascii-whitespace
|
// https://infra.spec.whatwg.org/#ascii-whitespace
|
||||||
constexpr bool is_ascii_whitespace(u32 code_point)
|
constexpr bool is_ascii_whitespace(u32 code_point)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue