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:
Florian Merz 2015-11-03 21:55:41 +01:00
parent 3fdaa6e3f3
commit c26b80cf4f
2 changed files with 31 additions and 21 deletions

View file

@ -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