Index: ui/gfx/selection_model.cc |
diff --git a/ui/gfx/selection_model.cc b/ui/gfx/selection_model.cc |
index 3dec8be443e086c31235ba65b734778f18271f36..d453c61d17d33118c348c0a1ab382ba2106c6499 100644 |
--- a/ui/gfx/selection_model.cc |
+++ b/ui/gfx/selection_model.cc |
@@ -4,47 +4,34 @@ |
#include "ui/gfx/selection_model.h" |
-namespace gfx { |
- |
-SelectionModel::SelectionModel() { |
- Init(0, 0, 0, LEADING); |
-} |
+#include <ostream> |
-SelectionModel::SelectionModel(size_t pos) { |
- Init(pos, pos, pos, LEADING); |
-} |
+namespace gfx { |
-SelectionModel::SelectionModel(size_t end, |
- size_t pos, |
- CaretPlacement placement) { |
- Init(end, end, pos, placement); |
-} |
+SelectionModel::SelectionModel() |
+ : selection_(0), caret_affinity_(CURSOR_BACKWARD) {} |
-SelectionModel::SelectionModel(size_t start, |
- size_t end, |
- size_t pos, |
- CaretPlacement placement) { |
- Init(start, end, pos, placement); |
-} |
+SelectionModel::SelectionModel(size_t position, LogicalCursorDirection affinity) |
+ : selection_(position), caret_affinity_(affinity) {} |
-SelectionModel::~SelectionModel() { |
-} |
+SelectionModel::SelectionModel(ui::Range selection, |
+ LogicalCursorDirection affinity) |
+ : selection_(selection), caret_affinity_(affinity) {} |
-bool SelectionModel::Equals(const SelectionModel& sel) const { |
- return selection_start_ == sel.selection_start() && |
- selection_end_ == sel.selection_end() && |
- caret_pos_ == sel.caret_pos() && |
- caret_placement_ == sel.caret_placement(); |
+bool SelectionModel::operator==(const SelectionModel& sel) const { |
+ return selection_ == sel.selection() && |
+ caret_affinity_ == sel.caret_affinity(); |
} |
-void SelectionModel::Init(size_t start, |
- size_t end, |
- size_t pos, |
- CaretPlacement placement) { |
- selection_start_ = start; |
- selection_end_ = end; |
- caret_pos_ = pos; |
- caret_placement_ = placement; |
+std::ostream& operator<<(std::ostream& out, const SelectionModel& sel) { |
+ out << '{'; |
+ if (sel.selection().is_empty()) |
+ out << sel.caret_pos(); |
+ else |
+ out << sel.selection(); |
+ const char* affinity_string = |
+ sel.caret_affinity() == CURSOR_FORWARD ? "FORWARD" : "BACKWARD"; |
+ return out << affinity_string << '}'; |
} |
} // namespace gfx |