mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
add get_insertion_point_index_for_layout
This resolves #8107 Previously the index of the insetion point for a password input was calculated using the scrambled string based on the edit point in the raw string. That could lead to a wrong position of the caret. This commit changes this behavior to calculate the insertion point using the raw string. This is done in `HTMLInputElementHelpers::get_insertion_point_index_for_layout` and relies on a 1:1 mapping of the chars in the raw input to the scrambled chars (currently bullets) in the password input.
This commit is contained in:
parent
3fdaa6e3f3
commit
c26b80cf4f
2 changed files with 31 additions and 21 deletions
|
@ -1005,10 +1005,9 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
return Some(CharIndex(search_index(insertion_point, text.char_indices())));
|
||||
}
|
||||
if let Some(input) = this.downcast::<HTMLInputElement>() {
|
||||
let insertion_point = unsafe { input.get_insertion_point_for_layout() };
|
||||
if let Some(insertion_point) = insertion_point {
|
||||
let text = unsafe { input.get_value_for_layout() };
|
||||
return Some(CharIndex(search_index(insertion_point.index, text.char_indices())));
|
||||
let insertion_point_index = unsafe { input.get_insertion_point_index_for_layout() };
|
||||
if let Some(insertion_point_index) = insertion_point_index {
|
||||
return Some(CharIndex(insertion_point_index));
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue