mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:22:07 +00:00
LibWeb: Replace incorrect uses of AK::is_ascii_space()
This commit is contained in:
parent
87ac38c78b
commit
fb21271334
4 changed files with 10 additions and 12 deletions
|
@ -5,11 +5,11 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/CharacterTypes.h>
|
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibWeb/DOM/DOMTokenList.h>
|
#include <LibWeb/DOM/DOMTokenList.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
|
#include <LibWeb/Infra/CharacterTypes.h>
|
||||||
#include <LibWeb/WebIDL/DOMException.h>
|
#include <LibWeb/WebIDL/DOMException.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -234,7 +234,7 @@ WebIDL::ExceptionOr<void> DOMTokenList::validate_token(StringView token) const
|
||||||
{
|
{
|
||||||
if (token.is_empty())
|
if (token.is_empty())
|
||||||
return WebIDL::SyntaxError::create(realm(), "Non-empty DOM tokens are not allowed");
|
return WebIDL::SyntaxError::create(realm(), "Non-empty DOM tokens are not allowed");
|
||||||
if (any_of(token, is_ascii_space))
|
if (any_of(token, Infra::is_ascii_whitespace))
|
||||||
return WebIDL::InvalidCharacterError::create(realm(), "DOM tokens containing ASCII whitespace are not allowed");
|
return WebIDL::InvalidCharacterError::create(realm(), "DOM tokens containing ASCII whitespace are not allowed");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <LibWeb/HTML/ImageData.h>
|
#include <LibWeb/HTML/ImageData.h>
|
||||||
#include <LibWeb/HTML/Path2D.h>
|
#include <LibWeb/HTML/Path2D.h>
|
||||||
#include <LibWeb/HTML/TextMetrics.h>
|
#include <LibWeb/HTML/TextMetrics.h>
|
||||||
|
#include <LibWeb/Infra/CharacterTypes.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <LibWeb/Platform/FontPlugin.h>
|
#include <LibWeb/Platform/FontPlugin.h>
|
||||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
@ -393,11 +394,9 @@ CanvasRenderingContext2D::PreparedText CanvasRenderingContext2D::prepare_text(St
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Replace all ASCII whitespace in text with U+0020 SPACE characters.
|
// 2. Replace all ASCII whitespace in text with U+0020 SPACE characters.
|
||||||
// NOTE: This also replaces vertical tabs with space even though WHATWG
|
|
||||||
// doesn't consider it as whitespace.
|
|
||||||
StringBuilder builder { text.length() };
|
StringBuilder builder { text.length() };
|
||||||
for (auto c : text) {
|
for (auto c : text) {
|
||||||
builder.append(is_ascii_space(c) ? ' ' : c);
|
builder.append(Infra::is_ascii_whitespace(c) ? ' ' : c);
|
||||||
}
|
}
|
||||||
String replaced_text = builder.build();
|
String replaced_text = builder.build();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <LibWeb/DOM/Attr.h>
|
#include <LibWeb/DOM/Attr.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLEncodingDetection.h>
|
#include <LibWeb/HTML/Parser/HTMLEncodingDetection.h>
|
||||||
|
#include <LibWeb/Infra/CharacterTypes.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
@ -50,8 +51,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const&
|
||||||
lexer.ignore(charset_index.value() + 7);
|
lexer.ignore(charset_index.value() + 7);
|
||||||
|
|
||||||
lexer.ignore_while([](char c) {
|
lexer.ignore_while([](char c) {
|
||||||
// FIXME: Not the exact same ASCII whitespace. The spec does not include vertical tab (\v).
|
return Infra::is_ascii_whitespace(c);
|
||||||
return is_ascii_space(c);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lexer.peek() != '=')
|
if (lexer.peek() != '=')
|
||||||
|
@ -64,8 +64,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const&
|
||||||
lexer.ignore();
|
lexer.ignore();
|
||||||
|
|
||||||
lexer.ignore_while([](char c) {
|
lexer.ignore_while([](char c) {
|
||||||
// FIXME: Not the exact same ASCII whitespace. The spec does not include vertical tab (\v).
|
return Infra::is_ascii_whitespace(c);
|
||||||
return is_ascii_space(c);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lexer.is_eof())
|
if (lexer.is_eof())
|
||||||
|
@ -90,8 +89,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(String const&
|
||||||
}
|
}
|
||||||
|
|
||||||
auto encoding = lexer.consume_until([](char c) {
|
auto encoding = lexer.consume_until([](char c) {
|
||||||
// FIXME: Not the exact same ASCII whitespace. The spec does not include vertical tab (\v).
|
return Infra::is_ascii_whitespace(c) || c == ';';
|
||||||
return is_ascii_space(c) || c == ';';
|
|
||||||
});
|
});
|
||||||
return TextCodec::get_standardized_encoding(encoding);
|
return TextCodec::get_standardized_encoding(encoding);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||||
#include <LibWeb/HTML/Parser/HTMLToken.h>
|
#include <LibWeb/HTML/Parser/HTMLToken.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
|
#include <LibWeb/Infra/CharacterTypes.h>
|
||||||
#include <LibWeb/Namespace.h>
|
#include <LibWeb/Namespace.h>
|
||||||
#include <LibWeb/SVG/TagNames.h>
|
#include <LibWeb/SVG/TagNames.h>
|
||||||
|
|
||||||
|
@ -3668,7 +3669,7 @@ RefPtr<CSS::StyleValue> parse_dimension_value(StringView string)
|
||||||
auto position = input.begin();
|
auto position = input.begin();
|
||||||
|
|
||||||
// 3. Skip ASCII whitespace within input given position.
|
// 3. Skip ASCII whitespace within input given position.
|
||||||
while (position != input.end() && is_ascii_space(*position))
|
while (position != input.end() && Infra::is_ascii_whitespace(*position))
|
||||||
++position;
|
++position;
|
||||||
|
|
||||||
// 4. If position is past the end of input or the code point at position within input is not an ASCII digit,
|
// 4. If position is past the end of input or the code point at position within input is not an ASCII digit,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue