OLD | NEW |
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 internal { | |
12 | |
13 namespace { | 11 namespace { |
14 | 12 |
15 // 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. |
16 bool IsCloseEnough(int a, int b) { | 14 bool IsCloseEnough(int a, int b) { |
17 return abs(a - b) <= MagnetismMatcher::kMagneticDistance; | 15 return abs(a - b) <= MagnetismMatcher::kMagneticDistance; |
18 } | 16 } |
19 | 17 |
20 // Returns true if the specified SecondaryMagnetismEdge can be matched with a | 18 // Returns true if the specified SecondaryMagnetismEdge can be matched with a |
21 // primary edge of |primary|. |edges| is a bitmask of the allowed | 19 // primary edge of |primary|. |edges| is a bitmask of the allowed |
22 // MagnetismEdges. | 20 // MagnetismEdges. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } else if (CanMatchSecondaryEdge(edge, SECONDARY_MAGNETISM_EDGE_TRAILING, | 181 } else if (CanMatchSecondaryEdge(edge, SECONDARY_MAGNETISM_EDGE_TRAILING, |
184 edges_) && | 182 edges_) && |
185 IsCloseEnough(bounds.right(), src_bounds.right())) { | 183 IsCloseEnough(bounds.right(), src_bounds.right())) { |
186 *secondary_edge = SECONDARY_MAGNETISM_EDGE_TRAILING; | 184 *secondary_edge = SECONDARY_MAGNETISM_EDGE_TRAILING; |
187 } else { | 185 } else { |
188 *secondary_edge = SECONDARY_MAGNETISM_EDGE_NONE; | 186 *secondary_edge = SECONDARY_MAGNETISM_EDGE_NONE; |
189 } | 187 } |
190 } | 188 } |
191 } | 189 } |
192 | 190 |
193 } // namespace internal | |
194 } // namespace ash | 191 } // namespace ash |
OLD | NEW |