aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-07-12 17:25:10 -0700
committerGitHub <noreply@github.com>2016-07-12 17:25:10 -0700
commit496e45b190edc3b7f6ebb42e0a849a3d55a184d6 (patch)
tree19eac00c91f584890c5bbae8b1708797138be11c /components/script
parent3c3c32f95e7e125117b0dc5d6e7eacea3422749c (diff)
parent6c7e8129663024329e30e6905573fb76bdb96e0a (diff)
downloadservo-496e45b190edc3b7f6ebb42e0a849a3d55a184d6.tar.gz
servo-496e45b190edc3b7f6ebb42e0a849a3d55a184d6.zip
Auto merge of #12301 - ConnorGBrewster:selection_direction, r=asajeffrey
Take selection direction into account when setting selection <!-- Please describe your changes on the following line: --> r? @asajeffrey --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #12300 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12301) <!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/textinput.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index 871af9637c0..5beee247f96 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -651,8 +651,17 @@ impl<T: ClipboardProvider> TextInput<T> {
start = end;
}
- self.selection_begin = Some(self.get_text_point_for_absolute_point(start));
- self.edit_point = self.get_text_point_for_absolute_point(end);
+ match self.selection_direction {
+ SelectionDirection::None |
+ SelectionDirection::Forward => {
+ self.selection_begin = Some(self.get_text_point_for_absolute_point(start));
+ self.edit_point = self.get_text_point_for_absolute_point(end);
+ },
+ SelectionDirection::Backward => {
+ self.selection_begin = Some(self.get_text_point_for_absolute_point(end));
+ self.edit_point = self.get_text_point_for_absolute_point(start);
+ }
+ }
self.assert_ok_selection();
}