mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
This avoids some minor code duplication. Testing: not needed (no behavior change) Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
0aa08042d5
commit
601517e3aa
2 changed files with 7 additions and 13 deletions
|
@ -1233,11 +1233,9 @@ fn glyphs_advance_by_index(
|
||||||
let mut point = baseline_origin;
|
let mut point = baseline_origin;
|
||||||
let mut index = index;
|
let mut index = index;
|
||||||
for run in glyph_runs {
|
for run in glyph_runs {
|
||||||
let total_advance = run.advance_for_byte_range(
|
let range = ServoRange::new(fonts::ByteIndex(0), index.min(run.len()));
|
||||||
&ServoRange::new(fonts::ByteIndex(0), index.min(run.len())),
|
index = index - range.length();
|
||||||
justification_adjustment,
|
let total_advance = run.advance_for_byte_range(&range, justification_adjustment);
|
||||||
);
|
|
||||||
index = index - index.min(run.len());
|
|
||||||
point.x += total_advance;
|
point.x += total_advance;
|
||||||
}
|
}
|
||||||
point
|
point
|
||||||
|
|
|
@ -211,12 +211,8 @@ fn traverse_children_of<'dom, Node>(
|
||||||
|
|
||||||
if is_text_input_element || is_textarea_element {
|
if is_text_input_element || is_textarea_element {
|
||||||
let info = NodeAndStyleInfo::new(parent_element, parent_element.style(context));
|
let info = NodeAndStyleInfo::new(parent_element, parent_element.style(context));
|
||||||
|
let node_text_content = parent_element.to_threadsafe().node_text_content();
|
||||||
if parent_element
|
if node_text_content.is_empty() {
|
||||||
.to_threadsafe()
|
|
||||||
.node_text_content()
|
|
||||||
.is_empty()
|
|
||||||
{
|
|
||||||
// The addition of zero-width space here forces the text input to have an inline formatting
|
// 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
|
// 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:
|
// 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.
|
// 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?
|
// TODO: Is there a less hacky way to do this?
|
||||||
handler.handle_text(&info, "\u{200B}".into());
|
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 {
|
if !is_text_input_element && !is_textarea_element {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue