mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
parent
ac576910d2
commit
a7a5babb3a
5 changed files with 44 additions and 56 deletions
|
@ -34,7 +34,7 @@ use std::default::Default;
|
|||
use std::ops::Range;
|
||||
use style::attr::AttrValue;
|
||||
use style::element_state::ElementState;
|
||||
use textinput::{KeyReaction, Lines, SelectionDirection, TextInput};
|
||||
use textinput::{Direction, KeyReaction, Lines, Selection, SelectionDirection, TextInput};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLTextAreaElement {
|
||||
|
@ -232,10 +232,25 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
|
||||
fn SetValue(&self, value: DOMString) {
|
||||
// TODO move the cursor to the end of the field
|
||||
self.textinput.borrow_mut().set_content(value);
|
||||
let mut textinput = self.textinput.borrow_mut();
|
||||
|
||||
// Step 1
|
||||
let old_value = textinput.get_content();
|
||||
let old_selection = textinput.selection_begin;
|
||||
|
||||
// Step 2
|
||||
textinput.set_content(value);
|
||||
|
||||
// Step 3
|
||||
self.value_changed.set(true);
|
||||
|
||||
if old_value != textinput.get_content() {
|
||||
// Step 4
|
||||
textinput.adjust_horizontal_to_limit(Direction::Forward, Selection::NotSelected);
|
||||
} else {
|
||||
textinput.selection_begin = old_selection;
|
||||
}
|
||||
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue