aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2025-04-11 09:35:21 -0700
committerGitHub <noreply@github.com>2025-04-11 16:35:21 +0000
commit601517e3aa83ff8f1c100dbaf91277cde20b7570 (patch)
treeee6227874e44d66b02a582cabecd7b2065a00a90 /components/layout_2020
parent0aa08042d54947e9d9f01457b293081a835a70ba (diff)
downloadservo-601517e3aa83ff8f1c100dbaf91277cde20b7570.tar.gz
servo-601517e3aa83ff8f1c100dbaf91277cde20b7570.zip
Cleanup after #36461 (#36472)
This avoids some minor code duplication. Testing: not needed (no behavior change) Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020')
-rw-r--r--components/layout_2020/display_list/mod.rs8
-rw-r--r--components/layout_2020/dom_traversal.rs12
2 files changed, 7 insertions, 13 deletions
diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs
index a872ac9ef17..fa313b306f4 100644
--- a/components/layout_2020/display_list/mod.rs
+++ b/components/layout_2020/display_list/mod.rs
@@ -1233,11 +1233,9 @@ fn glyphs_advance_by_index(
let mut point = baseline_origin;
let mut index = index;
for run in glyph_runs {
- let total_advance = run.advance_for_byte_range(
- &ServoRange::new(fonts::ByteIndex(0), index.min(run.len())),
- justification_adjustment,
- );
- index = index - index.min(run.len());
+ let range = ServoRange::new(fonts::ByteIndex(0), index.min(run.len()));
+ index = index - range.length();
+ let total_advance = run.advance_for_byte_range(&range, justification_adjustment);
point.x += total_advance;
}
point
diff --git a/components/layout_2020/dom_traversal.rs b/components/layout_2020/dom_traversal.rs
index 966cf83443a..42101e3edbc 100644
--- a/components/layout_2020/dom_traversal.rs
+++ b/components/layout_2020/dom_traversal.rs
@@ -211,12 +211,8 @@ fn traverse_children_of<'dom, Node>(
if is_text_input_element || is_textarea_element {
let info = NodeAndStyleInfo::new(parent_element, parent_element.style(context));
-
- if parent_element
- .to_threadsafe()
- .node_text_content()
- .is_empty()
- {
+ let node_text_content = parent_element.to_threadsafe().node_text_content();
+ if node_text_content.is_empty() {
// The addition of zero-width space here forces the text input to have an inline formatting
// context that might otherwise be trimmed if there's no text. This is important to ensure
// that the input element is at least as tall as the line gap of the caret:
@@ -225,9 +221,9 @@ fn traverse_children_of<'dom, Node>(
// This is also used to ensure that the caret will still be rendered when the input is empty.
// TODO: Is there a less hacky way to do this?
handler.handle_text(&info, "\u{200B}".into());
+ } else {
+ handler.handle_text(&info, node_text_content);
}
-
- handler.handle_text(&info, parent_element.to_threadsafe().node_text_content());
}
if !is_text_input_element && !is_textarea_element {