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

Side by Side Diff: ash/wm/workspace/magnetism_matcher.cc

Issue 1540753002: Switch to standard integer types in ash/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: arraysize Created 5 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
« no previous file with comments | « ash/wm/workspace/magnetism_matcher.h ('k') | ash/wm/workspace/multi_window_resize_controller.h » ('j') | 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 "ash/wm/workspace/magnetism_matcher.h" 5 #include "ash/wm/workspace/magnetism_matcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 namespace ash { 10 namespace ash {
11 namespace { 11 namespace {
12 12
13 // Returns true if |a| is close enough to |b| that the two edges snap. 13 // Returns true if |a| is close enough to |b| that the two edges snap.
14 bool IsCloseEnough(int a, int b) { 14 bool IsCloseEnough(int a, int b) {
15 return abs(a - b) <= MagnetismMatcher::kMagneticDistance; 15 return abs(a - b) <= MagnetismMatcher::kMagneticDistance;
16 } 16 }
17 17
18 // Returns true if the specified SecondaryMagnetismEdge can be matched with a 18 // Returns true if the specified SecondaryMagnetismEdge can be matched with a
19 // primary edge of |primary|. |edges| is a bitmask of the allowed 19 // primary edge of |primary|. |edges| is a bitmask of the allowed
20 // MagnetismEdges. 20 // MagnetismEdges.
21 bool CanMatchSecondaryEdge(MagnetismEdge primary, 21 bool CanMatchSecondaryEdge(MagnetismEdge primary,
22 SecondaryMagnetismEdge secondary, 22 SecondaryMagnetismEdge secondary,
23 uint32 edges) { 23 uint32_t edges) {
24 // Convert |secondary| to a MagnetismEdge so we can compare it to |edges|. 24 // Convert |secondary| to a MagnetismEdge so we can compare it to |edges|.
25 MagnetismEdge secondary_as_magnetism_edge = MAGNETISM_EDGE_TOP; 25 MagnetismEdge secondary_as_magnetism_edge = MAGNETISM_EDGE_TOP;
26 switch (primary) { 26 switch (primary) {
27 case MAGNETISM_EDGE_TOP: 27 case MAGNETISM_EDGE_TOP:
28 case MAGNETISM_EDGE_BOTTOM: 28 case MAGNETISM_EDGE_BOTTOM:
29 if (secondary == SECONDARY_MAGNETISM_EDGE_LEADING) 29 if (secondary == SECONDARY_MAGNETISM_EDGE_LEADING)
30 secondary_as_magnetism_edge = MAGNETISM_EDGE_LEFT; 30 secondary_as_magnetism_edge = MAGNETISM_EDGE_LEFT;
31 else if (secondary == SECONDARY_MAGNETISM_EDGE_TRAILING) 31 else if (secondary == SECONDARY_MAGNETISM_EDGE_TRAILING)
32 secondary_as_magnetism_edge = MAGNETISM_EDGE_RIGHT; 32 secondary_as_magnetism_edge = MAGNETISM_EDGE_RIGHT;
33 else 33 else
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 } 114 }
115 } 115 }
116 } 116 }
117 117
118 // MagnetismMatcher ------------------------------------------------------------ 118 // MagnetismMatcher ------------------------------------------------------------
119 119
120 // static 120 // static
121 const int MagnetismMatcher::kMagneticDistance = 8; 121 const int MagnetismMatcher::kMagneticDistance = 8;
122 122
123 MagnetismMatcher::MagnetismMatcher(const gfx::Rect& bounds, uint32 edges) 123 MagnetismMatcher::MagnetismMatcher(const gfx::Rect& bounds, uint32_t edges)
124 : edges_(edges) { 124 : edges_(edges) {
125 if (edges & MAGNETISM_EDGE_TOP) 125 if (edges & MAGNETISM_EDGE_TOP)
126 matchers_.push_back(new MagnetismEdgeMatcher(bounds, MAGNETISM_EDGE_TOP)); 126 matchers_.push_back(new MagnetismEdgeMatcher(bounds, MAGNETISM_EDGE_TOP));
127 if (edges & MAGNETISM_EDGE_LEFT) 127 if (edges & MAGNETISM_EDGE_LEFT)
128 matchers_.push_back(new MagnetismEdgeMatcher(bounds, MAGNETISM_EDGE_LEFT)); 128 matchers_.push_back(new MagnetismEdgeMatcher(bounds, MAGNETISM_EDGE_LEFT));
129 if (edges & MAGNETISM_EDGE_BOTTOM) { 129 if (edges & MAGNETISM_EDGE_BOTTOM) {
130 matchers_.push_back(new MagnetismEdgeMatcher(bounds, 130 matchers_.push_back(new MagnetismEdgeMatcher(bounds,
131 MAGNETISM_EDGE_BOTTOM)); 131 MAGNETISM_EDGE_BOTTOM));
132 } 132 }
133 if (edges & MAGNETISM_EDGE_RIGHT) 133 if (edges & MAGNETISM_EDGE_RIGHT)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 edges_) && 182 edges_) &&
183 IsCloseEnough(bounds.right(), src_bounds.right())) { 183 IsCloseEnough(bounds.right(), src_bounds.right())) {
184 *secondary_edge = SECONDARY_MAGNETISM_EDGE_TRAILING; 184 *secondary_edge = SECONDARY_MAGNETISM_EDGE_TRAILING;
185 } else { 185 } else {
186 *secondary_edge = SECONDARY_MAGNETISM_EDGE_NONE; 186 *secondary_edge = SECONDARY_MAGNETISM_EDGE_NONE;
187 } 187 }
188 } 188 }
189 } 189 }
190 190
191 } // namespace ash 191 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/magnetism_matcher.h ('k') | ash/wm/workspace/multi_window_resize_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698