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

Side by Side Diff: ui/base/touch/touch_editing_controller.cc

Issue 759433002: Reland: Move TouchSelectionController from content to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Excluded ui/touch_selection from Windows GN build Created 6 years 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
OLDNEW
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) {
35 int all_x[] ={
36 b1.edge_top.x(), b2.edge_top.x(), b1.edge_bottom.x(), b2.edge_bottom.x()
37 };
38 int all_y[] = {
39 b1.edge_top.y(), b2.edge_top.y(), b1.edge_bottom.y(), b2.edge_bottom.y()
40 };
41 const int num_elements = arraysize(all_x);
42 COMPILE_ASSERT(arraysize(all_y) == num_elements, array_size_mismatch);
43
44 int left = *std::min_element(all_x, all_x + num_elements);
45 int top = *std::min_element(all_y, all_y + num_elements);
46 int right = *std::max_element(all_x, all_x + num_elements);
47 int bottom = *std::max_element(all_y, all_y + num_elements);
48
49 return gfx::Rect(left, top, right - left, bottom - top);
50 }
51
52 TouchSelectionController* TouchSelectionController::create( 13 TouchSelectionController* TouchSelectionController::create(
53 TouchEditable* client_view) { 14 TouchEditable* client_view) {
54 if (g_shared_instance) 15 if (g_shared_instance)
55 return g_shared_instance->create(client_view); 16 return g_shared_instance->create(client_view);
56 return NULL; 17 return NULL;
57 } 18 }
58 19
59 // static 20 // static
60 void TouchSelectionControllerFactory::SetInstance( 21 void TouchSelectionControllerFactory::SetInstance(
61 TouchSelectionControllerFactory* instance) { 22 TouchSelectionControllerFactory* instance) {
62 g_shared_instance = instance; 23 g_shared_instance = instance;
63 } 24 }
64 25
65 } // namespace ui 26 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/touch/touch_editing_controller.h ('k') | ui/base/touch/touch_editing_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698