summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout
diff options
context:
space:
mode:
authorMax Wipfli <mail@maxwipfli.ch>2021-06-01 21:18:08 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-03 13:31:46 +0200
commitbc8d16ad28afb7436bfde1fd0a21faf73d652230 (patch)
tree7209f27957cc40f9cc1ce27a54f4a670a69a4683 /Userland/Libraries/LibWeb/Layout
parent1c9d87c4558304cf2e955df7e4c49f9f60cd55f2 (diff)
downloadserenity-bc8d16ad28afb7436bfde1fd0a21faf73d652230.zip
Everywhere: Replace ctype.h to avoid narrowing conversions
This replaces ctype.h with CharacterType.h everywhere I could find issues with narrowing conversions. While using it will probably make sense almost everywhere in the future, the most critical places should have been addressed.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout')
-rw-r--r--Userland/Libraries/LibWeb/Layout/TextNode.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/TextNode.cpp b/Userland/Libraries/LibWeb/Layout/TextNode.cpp
index c5aaeb47d8..6f7818c55f 100644
--- a/Userland/Libraries/LibWeb/Layout/TextNode.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TextNode.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/CharacterTypes.h>
#include <AK/ScopeGuard.h>
#include <AK/StringBuilder.h>
#include <LibGfx/Painter.h>
@@ -13,7 +14,6 @@
#include <LibWeb/Layout/Label.h>
#include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Page/BrowsingContext.h>
-#include <ctype.h>
namespace Web::Layout {
@@ -30,7 +30,7 @@ TextNode::~TextNode()
static bool is_all_whitespace(const StringView& string)
{
for (size_t i = 0; i < string.length(); ++i) {
- if (!isspace(string[i]))
+ if (!is_ascii_space(string[i]))
return false;
}
return true;
@@ -116,7 +116,7 @@ void TextNode::compute_text_for_rendering(bool collapse, bool previous_is_empty_
auto it = utf8_view.begin();
auto skip_over_whitespace = [&] {
auto prev = it;
- while (it != utf8_view.end() && isspace(*it)) {
+ while (it != utf8_view.end() && is_ascii_space(*it)) {
prev = it;
++it;
}
@@ -125,7 +125,7 @@ void TextNode::compute_text_for_rendering(bool collapse, bool previous_is_empty_
if (previous_is_empty_or_ends_in_whitespace)
skip_over_whitespace();
for (; it != utf8_view.end(); ++it) {
- if (!isspace(*it)) {
+ if (!is_ascii_space(*it)) {
builder.append(utf8_view.as_string().characters_without_null_termination() + utf8_view.byte_offset_of(it), it.code_point_length_in_bytes());
} else {
builder.append(' ');
@@ -160,7 +160,7 @@ void TextNode::split_into_lines_by_rules(InlineFormattingContext& context, Layou
float chunk_width;
if (do_wrap_lines) {
- if (do_collapse && isspace(*chunk.view.begin()) && line_boxes.last().is_empty_or_ends_in_whitespace()) {
+ if (do_collapse && is_ascii_space(*chunk.view.begin()) && line_boxes.last().is_empty_or_ends_in_whitespace()) {
// This is a non-empty chunk that starts with collapsible whitespace.
// We are at either at the start of a new line, or after something that ended in whitespace,
// so we don't need to contribute our own whitespace to the line. Skip over it instead!
@@ -264,7 +264,7 @@ TextNode::ChunkIterator::ChunkIterator(StringView const& text, LayoutMode layout
, m_start_of_chunk(m_utf8_view.begin())
, m_iterator(m_utf8_view.begin())
{
- m_last_was_space = !text.is_empty() && isspace(*m_utf8_view.begin());
+ m_last_was_space = !text.is_empty() && is_ascii_space(*m_utf8_view.begin());
}
Optional<TextNode::Chunk> TextNode::ChunkIterator::next()
@@ -286,7 +286,7 @@ Optional<TextNode::Chunk> TextNode::ChunkIterator::next()
return result.release_value();
}
if (m_wrap_lines) {
- bool is_space = isspace(*m_iterator);
+ bool is_space = is_ascii_space(*m_iterator);
if (is_space != m_last_was_space) {
m_last_was_space = is_space;
if (auto result = try_commit_chunk(m_iterator, false); result.has_value())