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

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

Issue 908033003: Remove dependency from ui/base to cc on non-Android platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "cc/output/viewport_selection_bound.h"
9 #include "ui/base/touch/selection_bound.h" 8 #include "ui/base/touch/selection_bound.h"
10 #include "ui/gfx/geometry/point_conversions.h" 9 #include "ui/gfx/geometry/point_conversions.h"
11 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
12 11
13 namespace ui { 12 namespace ui {
14 13
15 namespace {
16
17 SelectionBound::Type ConvertToSelectionBoundType(cc::SelectionBoundType type) {
18 switch (type) {
19 case cc::SELECTION_BOUND_LEFT:
20 return SelectionBound::LEFT;
21 case cc::SELECTION_BOUND_RIGHT:
22 return SelectionBound::RIGHT;
23 case cc::SELECTION_BOUND_CENTER:
24 return SelectionBound::CENTER;
25 case cc::SELECTION_BOUND_EMPTY:
26 return SelectionBound::EMPTY;
27 }
28 NOTREACHED() << "Unknown selection bound type";
29 return SelectionBound::EMPTY;
30 }
31
32 } // namespace
33
34 SelectionBound::SelectionBound() : type_(EMPTY), visible_(false) { 14 SelectionBound::SelectionBound() : type_(EMPTY), visible_(false) {
35 } 15 }
36 16
37 SelectionBound::SelectionBound(const cc::ViewportSelectionBound& bound) 17 SelectionBound::SelectionBound(const SelectionBound& other) = default;
38 : type_(ConvertToSelectionBoundType(bound.type)),
39 visible_(bound.visible) {
40 if (type_ != EMPTY)
41 SetEdge(bound.edge_top, bound.edge_bottom);
42 }
43 18
44 SelectionBound::~SelectionBound() { 19 SelectionBound::~SelectionBound() {
45 } 20 }
46 21
47 void SelectionBound::SetEdgeTop(const gfx::PointF& value) { 22 void SelectionBound::SetEdgeTop(const gfx::PointF& value) {
48 edge_top_ = value; 23 edge_top_ = value;
49 edge_top_rounded_ = gfx::ToRoundedPoint(value); 24 edge_top_rounded_ = gfx::ToRoundedPoint(value);
50 } 25 }
51 26
52 void SelectionBound::SetEdgeBottom(const gfx::PointF& value) { 27 void SelectionBound::SetEdgeBottom(const gfx::PointF& value) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 gfx::Point bottom_right(b1.edge_top_rounded()); 59 gfx::Point bottom_right(b1.edge_top_rounded());
85 bottom_right.SetToMax(b1.edge_bottom_rounded()); 60 bottom_right.SetToMax(b1.edge_bottom_rounded());
86 bottom_right.SetToMax(b2.edge_top_rounded()); 61 bottom_right.SetToMax(b2.edge_top_rounded());
87 bottom_right.SetToMax(b2.edge_bottom_rounded()); 62 bottom_right.SetToMax(b2.edge_bottom_rounded());
88 63
89 gfx::Vector2d diff = bottom_right - top_left; 64 gfx::Vector2d diff = bottom_right - top_left;
90 return gfx::Rect(top_left, gfx::Size(diff.x(), diff.y())); 65 return gfx::Rect(top_left, gfx::Size(diff.x(), diff.y()));
91 } 66 }
92 67
93 } // namespace ui 68 } // namespace ui
OLDNEW
« ui/base/BUILD.gn ('K') | « ui/base/touch/selection_bound.h ('k') | ui/base/ui_base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698