mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Simplify ASCII whitespace check in Layout::TextNode
No functional changes.
This commit is contained in:
parent
26b5fa348c
commit
7375d8c6f9
Notes:
github-actions[bot]
2025-09-12 19:35:29 +00:00
Author: https://github.com/gmta
Commit: 7375d8c6f9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6169
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/trflynn89
1 changed files with 3 additions and 10 deletions
|
@ -324,12 +324,12 @@ void TextNode::compute_text_for_rendering()
|
||||||
|
|
||||||
auto data = apply_text_transform(dom_node().data(), computed_values().text_transform(), lang);
|
auto data = apply_text_transform(dom_node().data(), computed_values().text_transform(), lang);
|
||||||
|
|
||||||
|
// NOTE: A couple fast returns to avoid unnecessarily allocating a StringBuilder.
|
||||||
if (!collapse || data.is_empty()) {
|
if (!collapse || data.is_empty()) {
|
||||||
m_text_for_rendering = move(data);
|
m_text_for_rendering = move(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: A couple fast returns to avoid unnecessarily allocating a StringBuilder.
|
|
||||||
if (data.length_in_code_units() == 1) {
|
if (data.length_in_code_units() == 1) {
|
||||||
if (data.is_ascii_whitespace())
|
if (data.is_ascii_whitespace())
|
||||||
m_text_for_rendering = " "_utf16;
|
m_text_for_rendering = " "_utf16;
|
||||||
|
@ -338,14 +338,7 @@ void TextNode::compute_text_for_rendering()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool contains_space = false;
|
if (!any_of(data, is_ascii_space)) {
|
||||||
for (auto code_point : data) {
|
|
||||||
if (is_ascii_space(code_point)) {
|
|
||||||
contains_space = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!contains_space) {
|
|
||||||
m_text_for_rendering = move(data);
|
m_text_for_rendering = move(data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +346,7 @@ void TextNode::compute_text_for_rendering()
|
||||||
StringBuilder builder(StringBuilder::Mode::UTF16, data.length_in_code_units());
|
StringBuilder builder(StringBuilder::Mode::UTF16, data.length_in_code_units());
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
|
|
||||||
auto skip_over_whitespace = [&]() {
|
auto skip_over_whitespace = [&] {
|
||||||
while (index < data.length_in_code_units() && is_ascii_space(data.code_unit_at(index)))
|
while (index < data.length_in_code_units() && is_ascii_space(data.code_unit_at(index)))
|
||||||
++index;
|
++index;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue