OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/touch/touch_editing_controller.h" | 5 #include "ui/base/touch/touch_editing_controller.h" |
6 | 6 |
7 namespace ui { | 7 namespace ui { |
8 | 8 |
9 namespace { | 9 namespace { |
10 TouchSelectionControllerFactory* g_shared_instance = NULL; | 10 TouchSelectionControllerFactory* g_shared_instance = NULL; |
11 } // namespace | 11 } // namespace |
12 | 12 |
13 SelectionBound::SelectionBound() | |
14 : type(ui::SelectionBound::EMPTY) { | |
15 } | |
16 | |
17 SelectionBound::~SelectionBound() { | |
18 } | |
19 | |
20 int SelectionBound::GetHeight() const { | |
21 return edge_bottom.y() - edge_top.y(); | |
22 } | |
23 | |
24 bool operator==(const SelectionBound& lhs, const SelectionBound& rhs) { | |
25 return lhs.type == rhs.type && lhs.edge_top == rhs.edge_top && | |
26 lhs.edge_bottom == rhs.edge_bottom; | |
27 } | |
28 | |
29 bool operator!=(const SelectionBound& lhs, const SelectionBound& rhs) { | |
30 return !(lhs == rhs); | |
31 } | |
32 | |
33 gfx::Rect RectBetweenSelectionBounds(const SelectionBound& b1, | |
34 const SelectionBound& b2) { | |
mohsen
2014/11/07 16:52:27
Can you rewrite this for general case (where handl
mfomitchev
2014/11/10 04:04:12
Done.
| |
35 int left = std::min(b1.edge_top.x(), b2.edge_top.x()); | |
36 int top = std::min(b1.edge_top.y(), b2.edge_top.y()); | |
37 int right = std::max(b1.edge_top.x(), b2.edge_top.x()); | |
38 int bottom = std::max(b1.edge_bottom.y(), b2.edge_bottom.y()); | |
39 | |
40 return gfx::Rect(left, top, right - left, bottom - top); | |
41 } | |
42 | |
13 TouchSelectionController* TouchSelectionController::create( | 43 TouchSelectionController* TouchSelectionController::create( |
14 TouchEditable* client_view) { | 44 TouchEditable* client_view) { |
15 if (g_shared_instance) | 45 if (g_shared_instance) |
16 return g_shared_instance->create(client_view); | 46 return g_shared_instance->create(client_view); |
17 return NULL; | 47 return NULL; |
18 } | 48 } |
19 | 49 |
20 // static | 50 // static |
21 void TouchSelectionControllerFactory::SetInstance( | 51 void TouchSelectionControllerFactory::SetInstance( |
22 TouchSelectionControllerFactory* instance) { | 52 TouchSelectionControllerFactory* instance) { |
23 g_shared_instance = instance; | 53 g_shared_instance = instance; |
24 } | 54 } |
25 | 55 |
26 } // namespace ui | 56 } // namespace ui |
OLD | NEW |