gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / ui / gfx / selection_model.cc
blobc3a31dae10741c5da91dd6fbe72fe4803b376794
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
3 // found in the LICENSE file.
5 #include "ui/gfx/selection_model.h"
7 #include "base/format_macros.h"
8 #include "base/strings/stringprintf.h"
10 namespace gfx {
12 SelectionModel::SelectionModel()
13 : selection_(0), caret_affinity_(CURSOR_BACKWARD) {}
15 SelectionModel::SelectionModel(size_t position, LogicalCursorDirection affinity)
16 : selection_(position), caret_affinity_(affinity) {}
18 SelectionModel::SelectionModel(ui::Range selection,
19 LogicalCursorDirection affinity)
20 : selection_(selection), caret_affinity_(affinity) {}
22 bool SelectionModel::operator==(const SelectionModel& sel) const {
23 return selection_ == sel.selection() &&
24 caret_affinity_ == sel.caret_affinity();
27 std::string SelectionModel::ToString() const {
28 std::string str = "{";
29 if (selection().is_empty())
30 base::StringAppendF(&str, "%" PRIuS, caret_pos());
31 else
32 str += selection().ToString();
33 const bool backward = caret_affinity() == CURSOR_BACKWARD;
34 return str + (backward ? ",BACKWARD}" : ",FORWARD}");
37 } // namespace gfx