Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/gfx/selection_model.cc

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/selection_model.h ('k') | ui/keyboard/keyboard_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/selection_model.h" 5 #include "ui/gfx/selection_model.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 9
10 namespace gfx { 10 namespace gfx {
11 11
12 SelectionModel::SelectionModel() 12 SelectionModel::SelectionModel()
13 : selection_(0), caret_affinity_(CURSOR_BACKWARD) {} 13 : selection_(0), caret_affinity_(CURSOR_BACKWARD) {}
14 14
15 SelectionModel::SelectionModel(size_t position, LogicalCursorDirection affinity) 15 SelectionModel::SelectionModel(size_t position, LogicalCursorDirection affinity)
16 : selection_(position), caret_affinity_(affinity) {} 16 : selection_(position), caret_affinity_(affinity) {}
17 17
18 SelectionModel::SelectionModel(ui::Range selection, 18 SelectionModel::SelectionModel(gfx::Range selection,
19 LogicalCursorDirection affinity) 19 LogicalCursorDirection affinity)
20 : selection_(selection), caret_affinity_(affinity) {} 20 : selection_(selection), caret_affinity_(affinity) {}
21 21
22 bool SelectionModel::operator==(const SelectionModel& sel) const { 22 bool SelectionModel::operator==(const SelectionModel& sel) const {
23 return selection_ == sel.selection() && 23 return selection_ == sel.selection() &&
24 caret_affinity_ == sel.caret_affinity(); 24 caret_affinity_ == sel.caret_affinity();
25 } 25 }
26 26
27 std::string SelectionModel::ToString() const { 27 std::string SelectionModel::ToString() const {
28 std::string str = "{"; 28 std::string str = "{";
29 if (selection().is_empty()) 29 if (selection().is_empty())
30 base::StringAppendF(&str, "%" PRIuS, caret_pos()); 30 base::StringAppendF(&str, "%" PRIuS, caret_pos());
31 else 31 else
32 str += selection().ToString(); 32 str += selection().ToString();
33 const bool backward = caret_affinity() == CURSOR_BACKWARD; 33 const bool backward = caret_affinity() == CURSOR_BACKWARD;
34 return str + (backward ? ",BACKWARD}" : ",FORWARD}"); 34 return str + (backward ? ",BACKWARD}" : ",FORWARD}");
35 } 35 }
36 36
37 } // namespace gfx 37 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/selection_model.h ('k') | ui/keyboard/keyboard_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698