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

Side by Side Diff: mash/wm/frame/move_loop.cc

Issue 1857623003: convert //mash to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « mash/wm/frame/move_loop.h ('k') | mash/wm/frame/move_loop_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mash/wm/frame/move_loop.h" 5 #include "mash/wm/frame/move_loop.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/ptr_util.h"
8 #include "components/mus/public/cpp/window.h" 9 #include "components/mus/public/cpp/window.h"
9 #include "components/mus/public/interfaces/input_event_constants.mojom.h" 10 #include "components/mus/public/interfaces/input_event_constants.mojom.h"
10 #include "mash/wm/property_util.h" 11 #include "mash/wm/property_util.h"
11 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
12 #include "ui/events/event.h" 13 #include "ui/events/event.h"
13 #include "ui/gfx/geometry/point_conversions.h" 14 #include "ui/gfx/geometry/point_conversions.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 16
16 namespace mash { 17 namespace mash {
17 namespace wm { 18 namespace wm {
18 19
19 namespace { 20 namespace {
20 21
21 int MouseOnlyEventFlags(int flags) { 22 int MouseOnlyEventFlags(int flags) {
22 return flags & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON | 23 return flags & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON |
23 ui::EF_RIGHT_MOUSE_BUTTON); 24 ui::EF_RIGHT_MOUSE_BUTTON);
24 } 25 }
25 26
26 } // namespace 27 } // namespace
27 28
28 MoveLoop::~MoveLoop() { 29 MoveLoop::~MoveLoop() {
29 if (target_) 30 if (target_)
30 target_->RemoveObserver(this); 31 target_->RemoveObserver(this);
31 } 32 }
32 33
33 // static 34 // static
34 scoped_ptr<MoveLoop> MoveLoop::Create(mus::Window* target, 35 std::unique_ptr<MoveLoop> MoveLoop::Create(mus::Window* target,
35 int ht_location, 36 int ht_location,
36 const ui::PointerEvent& event) { 37 const ui::PointerEvent& event) {
37 DCHECK_EQ(event.type(), ui::ET_POINTER_DOWN); 38 DCHECK_EQ(event.type(), ui::ET_POINTER_DOWN);
38 // Start a move on left mouse, or any other type of pointer. 39 // Start a move on left mouse, or any other type of pointer.
39 if (event.IsMousePointerEvent() && 40 if (event.IsMousePointerEvent() &&
40 MouseOnlyEventFlags(event.flags()) != ui::EF_LEFT_MOUSE_BUTTON) { 41 MouseOnlyEventFlags(event.flags()) != ui::EF_LEFT_MOUSE_BUTTON) {
41 return nullptr; 42 return nullptr;
42 } 43 }
43 44
44 Type type; 45 Type type;
45 HorizontalLocation h_loc; 46 HorizontalLocation h_loc;
46 VerticalLocation v_loc; 47 VerticalLocation v_loc;
47 if (!DetermineType(ht_location, &type, &h_loc, &v_loc)) 48 if (!DetermineType(ht_location, &type, &h_loc, &v_loc))
48 return nullptr; 49 return nullptr;
49 50
50 return make_scoped_ptr(new MoveLoop(target, event, type, h_loc, v_loc)); 51 return base::WrapUnique(new MoveLoop(target, event, type, h_loc, v_loc));
51 } 52 }
52 53
53 MoveLoop::MoveResult MoveLoop::Move(const ui::PointerEvent& event) { 54 MoveLoop::MoveResult MoveLoop::Move(const ui::PointerEvent& event) {
54 switch (event.type()) { 55 switch (event.type()) {
55 case ui::ET_POINTER_CANCELLED: 56 case ui::ET_POINTER_CANCELLED:
56 if (event.pointer_id() == pointer_id_) { 57 if (event.pointer_id() == pointer_id_) {
57 if (target_) 58 if (target_)
58 Revert(); 59 Revert();
59 return MoveResult::DONE; 60 return MoveResult::DONE;
60 } 61 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 Cancel(); 219 Cancel();
219 } 220 }
220 221
221 void MoveLoop::OnWindowVisibilityChanged(mus::Window* window) { 222 void MoveLoop::OnWindowVisibilityChanged(mus::Window* window) {
222 DCHECK_EQ(window, target_); 223 DCHECK_EQ(window, target_);
223 Cancel(); 224 Cancel();
224 } 225 }
225 226
226 } // namespace wm 227 } // namespace wm
227 } // namespace mash 228 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/frame/move_loop.h ('k') | mash/wm/frame/move_loop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698