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

Side by Side Diff: ui/events/gesture_detection/motion_event_generic.cc

Issue 1539583003: Convert Pass()→std::move() in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "ui/events/gesture_detection/motion_event_generic.h" 8 #include "ui/events/gesture_detection/motion_event_generic.h"
9 9
10 #include <cmath> 10 #include <cmath>
11 #include <utility>
11 12
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "ui/events/base_event_utils.h" 14 #include "ui/events/base_event_utils.h"
14 15
15 namespace ui { 16 namespace ui {
16 17
17 PointerProperties::PointerProperties() 18 PointerProperties::PointerProperties()
18 : PointerProperties(0, 0, 0) { 19 : PointerProperties(0, 0, 0) {
19 } 20 }
20 21
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 233 }
233 234
234 // static 235 // static
235 scoped_ptr<MotionEventGeneric> MotionEventGeneric::CancelEvent( 236 scoped_ptr<MotionEventGeneric> MotionEventGeneric::CancelEvent(
236 const MotionEvent& event) { 237 const MotionEvent& event) {
237 bool with_history = false; 238 bool with_history = false;
238 scoped_ptr<MotionEventGeneric> cancel_event( 239 scoped_ptr<MotionEventGeneric> cancel_event(
239 new MotionEventGeneric(event, with_history)); 240 new MotionEventGeneric(event, with_history));
240 cancel_event->set_action(ACTION_CANCEL); 241 cancel_event->set_action(ACTION_CANCEL);
241 cancel_event->set_unique_event_id(ui::GetNextTouchEventId()); 242 cancel_event->set_unique_event_id(ui::GetNextTouchEventId());
242 return cancel_event.Pass(); 243 return cancel_event;
243 } 244 }
244 245
245 size_t MotionEventGeneric::PushPointer(const PointerProperties& pointer) { 246 size_t MotionEventGeneric::PushPointer(const PointerProperties& pointer) {
246 DCHECK_EQ(0U, GetHistorySize()); 247 DCHECK_EQ(0U, GetHistorySize());
247 pointers_->push_back(pointer); 248 pointers_->push_back(pointer);
248 return pointers_->size() - 1; 249 return pointers_->size() - 1;
249 } 250 }
250 251
251 void MotionEventGeneric::RemovePointerAt(size_t index) { 252 void MotionEventGeneric::RemovePointerAt(size_t index) {
252 DCHECK_LT(index, pointers_->size()); 253 DCHECK_LT(index, pointers_->size());
253 pointers_->erase(pointers_->begin() + index); 254 pointers_->erase(pointers_->begin() + index);
254 } 255 }
255 256
256 void MotionEventGeneric::PushHistoricalEvent(scoped_ptr<MotionEvent> event) { 257 void MotionEventGeneric::PushHistoricalEvent(scoped_ptr<MotionEvent> event) {
257 DCHECK(event); 258 DCHECK(event);
258 DCHECK_EQ(event->GetAction(), ACTION_MOVE); 259 DCHECK_EQ(event->GetAction(), ACTION_MOVE);
259 DCHECK_EQ(event->GetPointerCount(), GetPointerCount()); 260 DCHECK_EQ(event->GetPointerCount(), GetPointerCount());
260 DCHECK_EQ(event->GetAction(), GetAction()); 261 DCHECK_EQ(event->GetAction(), GetAction());
261 DCHECK_LE(event->GetEventTime().ToInternalValue(), 262 DCHECK_LE(event->GetEventTime().ToInternalValue(),
262 GetEventTime().ToInternalValue()); 263 GetEventTime().ToInternalValue());
263 historical_events_.push_back(event.Pass()); 264 historical_events_.push_back(std::move(event));
264 } 265 }
265 266
266 MotionEventGeneric::MotionEventGeneric() 267 MotionEventGeneric::MotionEventGeneric()
267 : action_(ACTION_NONE), 268 : action_(ACTION_NONE),
268 unique_event_id_(ui::GetNextTouchEventId()), 269 unique_event_id_(ui::GetNextTouchEventId()),
269 action_index_(-1), 270 action_index_(-1),
270 button_state_(0) { 271 button_state_(0) {
271 } 272 }
272 273
273 MotionEventGeneric::MotionEventGeneric(const MotionEvent& event, 274 MotionEventGeneric::MotionEventGeneric(const MotionEvent& event,
(...skipping 18 matching lines...) Expand all
292 for (size_t h = 0; h < history_size; ++h) { 293 for (size_t h = 0; h < history_size; ++h) {
293 scoped_ptr<MotionEventGeneric> historical_event(new MotionEventGeneric()); 294 scoped_ptr<MotionEventGeneric> historical_event(new MotionEventGeneric());
294 historical_event->set_action(ACTION_MOVE); 295 historical_event->set_action(ACTION_MOVE);
295 historical_event->set_event_time(event.GetHistoricalEventTime(h)); 296 historical_event->set_event_time(event.GetHistoricalEventTime(h));
296 for (size_t i = 0; i < pointer_count; ++i) { 297 for (size_t i = 0; i < pointer_count; ++i) {
297 historical_event->PushPointer( 298 historical_event->PushPointer(
298 PointerProperties(event.GetHistoricalX(i, h), 299 PointerProperties(event.GetHistoricalX(i, h),
299 event.GetHistoricalY(i, h), 300 event.GetHistoricalY(i, h),
300 event.GetHistoricalTouchMajor(i, h))); 301 event.GetHistoricalTouchMajor(i, h)));
301 } 302 }
302 PushHistoricalEvent(historical_event.Pass()); 303 PushHistoricalEvent(std::move(historical_event));
303 } 304 }
304 } 305 }
305 306
306 MotionEventGeneric& MotionEventGeneric::operator=( 307 MotionEventGeneric& MotionEventGeneric::operator=(
307 const MotionEventGeneric& other) { 308 const MotionEventGeneric& other) {
308 action_ = other.action_; 309 action_ = other.action_;
309 event_time_ = other.event_time_; 310 event_time_ = other.event_time_;
310 unique_event_id_ = other.unique_event_id_; 311 unique_event_id_ = other.unique_event_id_;
311 action_index_ = other.action_index_; 312 action_index_ = other.action_index_;
312 button_state_ = other.button_state_; 313 button_state_ = other.button_state_;
313 flags_ = other.flags_; 314 flags_ = other.flags_;
314 pointers_ = other.pointers_; 315 pointers_ = other.pointers_;
315 const size_t history_size = other.GetHistorySize(); 316 const size_t history_size = other.GetHistorySize();
316 for (size_t h = 0; h < history_size; ++h) 317 for (size_t h = 0; h < history_size; ++h)
317 PushHistoricalEvent(other.historical_events_[h]->Clone()); 318 PushHistoricalEvent(other.historical_events_[h]->Clone());
318 return *this; 319 return *this;
319 } 320 }
320 321
321 void MotionEventGeneric::PopPointer() { 322 void MotionEventGeneric::PopPointer() {
322 DCHECK_GT(pointers_->size(), 0U); 323 DCHECK_GT(pointers_->size(), 0U);
323 pointers_->pop_back(); 324 pointers_->pop_back();
324 } 325 }
325 326
326 } // namespace ui 327 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698