mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Fix placeholders for password inputs
currently they show dots
This commit is contained in:
parent
9412e71460
commit
6a0ec85d43
2 changed files with 8 additions and 6 deletions
|
@ -156,7 +156,12 @@ pub trait LayoutHTMLInputElementHelpers {
|
||||||
unsafe fn get_raw_textinput_value(input: LayoutJS<HTMLInputElement>) -> DOMString {
|
unsafe fn get_raw_textinput_value(input: LayoutJS<HTMLInputElement>) -> DOMString {
|
||||||
let textinput = (*input.unsafe_get()).textinput.borrow_for_layout().get_content();
|
let textinput = (*input.unsafe_get()).textinput.borrow_for_layout().get_content();
|
||||||
if !textinput.is_empty() {
|
if !textinput.is_empty() {
|
||||||
textinput
|
if let InputType::InputPassword = (*input.unsafe_get()).input_type.get() {
|
||||||
|
// The implementation of get_insertion_point_index_for_layout expects a 1:1 mapping of chars.
|
||||||
|
DOMString::from(textinput.chars().map(|_| '●').collect::<String>())
|
||||||
|
} else {
|
||||||
|
textinput
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(*input.unsafe_get()).placeholder.borrow_for_layout().clone()
|
(*input.unsafe_get()).placeholder.borrow_for_layout().clone()
|
||||||
}
|
}
|
||||||
|
@ -180,11 +185,6 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
|
||||||
InputType::InputButton => get_raw_attr_value(self, ""),
|
InputType::InputButton => get_raw_attr_value(self, ""),
|
||||||
InputType::InputSubmit => get_raw_attr_value(self, DEFAULT_SUBMIT_VALUE),
|
InputType::InputSubmit => get_raw_attr_value(self, DEFAULT_SUBMIT_VALUE),
|
||||||
InputType::InputReset => get_raw_attr_value(self, DEFAULT_RESET_VALUE),
|
InputType::InputReset => get_raw_attr_value(self, DEFAULT_RESET_VALUE),
|
||||||
InputType::InputPassword => {
|
|
||||||
let raw = get_raw_textinput_value(self);
|
|
||||||
// The implementation of get_insertion_point_index_for_layout expects a 1:1 mapping of chars.
|
|
||||||
raw.chars().map(|_| '●').collect()
|
|
||||||
}
|
|
||||||
_ => String::from(get_raw_textinput_value(self)),
|
_ => String::from(get_raw_textinput_value(self)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
<div><input type="submit"><input type="reset"><div>
|
<div><input type="submit"><input type="reset"><div>
|
||||||
<div><input id=ch type="checkbox" checked></div>
|
<div><input id=ch type="checkbox" checked></div>
|
||||||
<div><input id=unch type="checkbox"></div>
|
<div><input id=unch type="checkbox"></div>
|
||||||
|
<div><input type="text" size="30" placeholder="this is a placeholder"></div>
|
||||||
|
<div><input type="password" size="30" placeholder="this is a password placeholder"></div>
|
||||||
<script>
|
<script>
|
||||||
document.getElementById("ch").indeterminate = true;
|
document.getElementById("ch").indeterminate = true;
|
||||||
document.getElementById("unch").indeterminate = true;
|
document.getElementById("unch").indeterminate = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue