diff options
Diffstat (limited to 'components/script')
-rwxr-xr-x | components/script/dom/htmlinputelement.rs | 5 | ||||
-rwxr-xr-x | components/script/dom/htmltextareaelement.rs | 4 | ||||
-rw-r--r-- | components/script/textinput.rs | 7 |
3 files changed, 11 insertions, 5 deletions
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 2e26d7fe53f..cd476a47f2b 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -52,7 +52,7 @@ use std::ops::Range; use style::attr::AttrValue; use style::element_state::ElementState; use style::str::split_commas; -use textinput::{Direction, Selection, SelectionDirection, TextInput}; +use textinput::{SelectionDirection, TextInput}; use textinput::KeyReaction::{DispatchInput, Nothing, RedrawSelection, TriggerDefaultAction}; use textinput::Lines::Single; @@ -563,8 +563,7 @@ impl HTMLInputElementMethods for HTMLInputElement { self.sanitize_value(); // Step 5. if *self.textinput.borrow().single_line_content() != old_value { - self.textinput.borrow_mut() - .adjust_horizontal_to_limit(Direction::Forward, Selection::NotSelected); + self.textinput.borrow_mut().clear_selection_to_limit(); } } ValueMode::Default | diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index a2b52ce3087..b2e78e083c0 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -35,7 +35,7 @@ use std::default::Default; use std::ops::Range; use style::attr::AttrValue; use style::element_state::ElementState; -use textinput::{Direction, KeyReaction, Lines, Selection, SelectionDirection, TextInput}; +use textinput::{KeyReaction, Lines, SelectionDirection, TextInput}; #[dom_struct] pub struct HTMLTextAreaElement { @@ -257,7 +257,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement { if old_value != textinput.get_content() { // Step 4 - textinput.adjust_horizontal_to_limit(Direction::Forward, Selection::NotSelected); + textinput.clear_selection_to_limit(); } else { textinput.selection_origin = old_selection; } diff --git a/components/script/textinput.rs b/components/script/textinput.rs index b4e39eab3f8..d703ccee987 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -513,6 +513,13 @@ impl<T: ClipboardProvider> TextInput<T> { /// Remove the current selection. pub fn clear_selection(&mut self) { self.selection_origin = None; + self.selection_direction = SelectionDirection::None; + } + + /// Remove the current selection and set the edit point to the end of the content. + pub fn clear_selection_to_limit(&mut self) { + self.clear_selection(); + self.adjust_horizontal_to_limit(Direction::Forward, Selection::NotSelected); } pub fn adjust_horizontal_by_word(&mut self, direction: Direction, select: Selection) { |