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 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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue