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

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

Issue 10332205: Fix logging of string16s from gfx namespace on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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') | no next file » | 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 <ostream> 7 #include "base/format_macros.h"
8 #include "base/stringprintf.h"
8 9
9 namespace gfx { 10 namespace gfx {
10 11
11 SelectionModel::SelectionModel() 12 SelectionModel::SelectionModel()
12 : selection_(0), caret_affinity_(CURSOR_BACKWARD) {} 13 : selection_(0), caret_affinity_(CURSOR_BACKWARD) {}
13 14
14 SelectionModel::SelectionModel(size_t position, LogicalCursorDirection affinity) 15 SelectionModel::SelectionModel(size_t position, LogicalCursorDirection affinity)
15 : selection_(position), caret_affinity_(affinity) {} 16 : selection_(position), caret_affinity_(affinity) {}
16 17
17 SelectionModel::SelectionModel(ui::Range selection, 18 SelectionModel::SelectionModel(ui::Range selection,
18 LogicalCursorDirection affinity) 19 LogicalCursorDirection affinity)
19 : selection_(selection), caret_affinity_(affinity) {} 20 : selection_(selection), caret_affinity_(affinity) {}
20 21
21 bool SelectionModel::operator==(const SelectionModel& sel) const { 22 bool SelectionModel::operator==(const SelectionModel& sel) const {
22 return selection_ == sel.selection() && 23 return selection_ == sel.selection() &&
23 caret_affinity_ == sel.caret_affinity(); 24 caret_affinity_ == sel.caret_affinity();
24 } 25 }
25 26
26 std::ostream& operator<<(std::ostream& out, const SelectionModel& sel) { 27 std::string SelectionModel::ToString() const {
27 out << '{'; 28 std::string str = "{";
28 if (sel.selection().is_empty()) 29 if (selection().is_empty())
29 out << sel.caret_pos(); 30 base::StringAppendF(&str, "%" PRIuS, caret_pos());
30 else 31 else
31 out << sel.selection(); 32 str += selection().ToString();
32 bool backward = sel.caret_affinity() == CURSOR_BACKWARD; 33 const bool backward = caret_affinity() == CURSOR_BACKWARD;
33 return out << (backward ? ",BACKWARD}" : ",FORWARD}"); 34 return str + (backward ? ",BACKWARD}" : ",FORWARD}");
34 } 35 }
35 36
36 } // namespace gfx 37 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/selection_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698