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 -->
This commit is contained in:
bors-servo 2016-07-12 17:25:10 -07:00 committed by GitHub
commit 496e45b190
2 changed files with 34 additions and 2 deletions

View file

@ -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();
}