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

Side by Side Diff: ui/events/test/event_generator.cc

Issue 1421713002: Explicitly convert Point to PointF for event code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wip
Patch Set: pointfconvert-prod: . Created 5 years, 2 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 | « ui/aura/window_tree_host_x11.cc ('k') | ui/message_center/views/notifier_settings_view.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 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 "ui/events/test/event_generator.h" 5 #include "ui/events/test/event_generator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 auto location = gfx::PointF(GetLocationInCurrentRoot()); 167 auto location = gfx::PointF(GetLocationInCurrentRoot());
168 ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location, 168 ui::MouseEvent mouseev(ui::ET_MOUSEWHEEL, location, location,
169 ui::EventTimeForNow(), flags_, 0); 169 ui::EventTimeForNow(), flags_, 0);
170 ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y); 170 ui::MouseWheelEvent wheelev(mouseev, delta_x, delta_y);
171 Dispatch(&wheelev); 171 Dispatch(&wheelev);
172 } 172 }
173 173
174 void EventGenerator::SendMouseExit() { 174 void EventGenerator::SendMouseExit() {
175 gfx::Point exit_location(current_location_); 175 gfx::Point exit_location(current_location_);
176 delegate()->ConvertPointToTarget(current_target_, &exit_location); 176 delegate()->ConvertPointToTarget(current_target_, &exit_location);
177 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, exit_location, exit_location, 177 ui::MouseEvent mouseev(ui::ET_MOUSE_EXITED, gfx::PointF(exit_location),
178 ui::EventTimeForNow(), flags_, 0); 178 gfx::PointF(exit_location), ui::EventTimeForNow(),
179 flags_, 0);
179 Dispatch(&mouseev); 180 Dispatch(&mouseev);
180 } 181 }
181 182
182 void EventGenerator::MoveMouseToWithNative(const gfx::Point& point_in_host, 183 void EventGenerator::MoveMouseToWithNative(const gfx::Point& point_in_host,
183 const gfx::Point& point_for_native) { 184 const gfx::Point& point_for_native) {
184 #if defined(USE_X11) 185 #if defined(USE_X11)
185 ui::ScopedXI2Event xevent; 186 ui::ScopedXI2Event xevent;
186 xevent.InitMotionEvent(point_in_host, point_for_native, flags_); 187 xevent.InitMotionEvent(point_in_host, point_for_native, flags_);
187 static_cast<XEvent*>(xevent)->xmotion.time = Now().InMicroseconds(); 188 static_cast<XEvent*>(xevent)->xmotion.time = Now().InMicroseconds();
188 ui::MouseEvent mouseev(xevent); 189 ui::MouseEvent mouseev(xevent);
189 #elif defined(USE_OZONE) 190 #elif defined(USE_OZONE)
190 // Ozone uses the location in native event as a system location. 191 // Ozone uses the location in native event as a system location.
191 // Create a fake event with the point in host, which will be passed 192 // Create a fake event with the point in host, which will be passed
192 // to the non native event, then update the native event with the native 193 // to the non native event, then update the native event with the native
193 // (root) one. 194 // (root) one.
194 scoped_ptr<ui::MouseEvent> native_event(new ui::MouseEvent( 195 scoped_ptr<ui::MouseEvent> native_event(
195 ui::ET_MOUSE_MOVED, point_in_host, point_in_host, Now(), flags_, 0)); 196 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::PointF(point_in_host),
197 gfx::PointF(point_in_host), Now(), flags_, 0));
196 ui::MouseEvent mouseev(native_event.get()); 198 ui::MouseEvent mouseev(native_event.get());
197 native_event->set_location(point_for_native); 199 native_event->set_location(point_for_native);
198 #else 200 #else
199 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, point_in_host, point_for_native, 201 ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::PointF(point_in_host),
200 Now(), flags_, 0); 202 gfx::PointF(point_for_native), Now(), flags_, 0);
201 LOG(FATAL) 203 LOG(FATAL)
202 << "Generating a native motion event is not supported on this platform"; 204 << "Generating a native motion event is not supported on this platform";
203 #endif 205 #endif
204 Dispatch(&mouseev); 206 Dispatch(&mouseev);
205 207
206 current_location_ = point_in_host; 208 current_location_ = point_in_host;
207 delegate()->ConvertPointFromHost(current_target_, &current_location_); 209 delegate()->ConvertPointFromHost(current_target_, &current_location_);
208 } 210 }
209 211
210 void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) { 212 void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {
211 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? 213 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
212 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; 214 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
213 ui::MouseEvent mouseev(event_type, point_in_host, point_in_host, 215 ui::MouseEvent mouseev(event_type, gfx::PointF(point_in_host),
214 ui::EventTimeForNow(), flags_, 0); 216 gfx::PointF(point_in_host), ui::EventTimeForNow(),
217 flags_, 0);
215 Dispatch(&mouseev); 218 Dispatch(&mouseev);
216 219
217 current_location_ = point_in_host; 220 current_location_ = point_in_host;
218 delegate()->ConvertPointFromHost(current_target_, &current_location_); 221 delegate()->ConvertPointFromHost(current_target_, &current_location_);
219 } 222 }
220 223
221 void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen, 224 void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
222 int count) { 225 int count) {
223 DCHECK_GT(count, 0); 226 DCHECK_GT(count, 0);
224 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ? 227 const ui::EventType event_type = (flags_ & ui::EF_LEFT_MOUSE_BUTTON) ?
225 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED; 228 ui::ET_MOUSE_DRAGGED : ui::ET_MOUSE_MOVED;
226 229
227 gfx::Vector2dF diff(point_in_screen - current_location_); 230 gfx::Vector2dF diff(point_in_screen - current_location_);
228 for (float i = 1; i <= count; i++) { 231 for (float i = 1; i <= count; i++) {
229 gfx::Vector2dF step(diff); 232 gfx::Vector2dF step(diff);
230 step.Scale(i / count); 233 step.Scale(i / count);
231 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step); 234 gfx::Point move_point = current_location_ + gfx::ToRoundedVector2d(step);
232 if (!grab_) 235 if (!grab_)
233 UpdateCurrentDispatcher(move_point); 236 UpdateCurrentDispatcher(move_point);
234 delegate()->ConvertPointToTarget(current_target_, &move_point); 237 delegate()->ConvertPointToTarget(current_target_, &move_point);
235 ui::MouseEvent mouseev(event_type, move_point, move_point, 238 ui::MouseEvent mouseev(event_type, gfx::PointF(move_point),
236 ui::EventTimeForNow(), flags_, 0); 239 gfx::PointF(move_point), ui::EventTimeForNow(),
240 flags_, 0);
237 Dispatch(&mouseev); 241 Dispatch(&mouseev);
238 } 242 }
239 current_location_ = point_in_screen; 243 current_location_ = point_in_screen;
240 } 244 }
241 245
242 void EventGenerator::MoveMouseRelativeTo(const EventTarget* window, 246 void EventGenerator::MoveMouseRelativeTo(const EventTarget* window,
243 const gfx::Point& point_in_parent) { 247 const gfx::Point& point_in_parent) {
244 gfx::Point point(point_in_parent); 248 gfx::Point point(point_in_parent);
245 delegate()->ConvertPointFromTarget(window, &point); 249 delegate()->ConvertPointFromTarget(window, &point);
246 MoveMouseTo(point); 250 MoveMouseTo(point);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 308 }
305 309
306 void EventGenerator::GestureEdgeSwipe() { 310 void EventGenerator::GestureEdgeSwipe() {
307 ui::GestureEvent gesture( 311 ui::GestureEvent gesture(
308 0, 0, 0, Now(), ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE)); 312 0, 0, 0, Now(), ui::GestureEventDetails(ui::ET_GESTURE_WIN8_EDGE_SWIPE));
309 Dispatch(&gesture); 313 Dispatch(&gesture);
310 } 314 }
311 315
312 void EventGenerator::GestureTapAt(const gfx::Point& location) { 316 void EventGenerator::GestureTapAt(const gfx::Point& location) {
313 const int kTouchId = 2; 317 const int kTouchId = 2;
314 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 318 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), kTouchId,
315 location,
316 kTouchId,
317 Now()); 319 Now());
318 Dispatch(&press); 320 Dispatch(&press);
319 321
320 ui::TouchEvent release( 322 ui::TouchEvent release(
321 ui::ET_TOUCH_RELEASED, location, kTouchId, 323 ui::ET_TOUCH_RELEASED, gfx::PointF(location), kTouchId,
322 press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); 324 press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
323 Dispatch(&release); 325 Dispatch(&release);
324 } 326 }
325 327
326 void EventGenerator::GestureTapDownAndUp(const gfx::Point& location) { 328 void EventGenerator::GestureTapDownAndUp(const gfx::Point& location) {
327 const int kTouchId = 3; 329 const int kTouchId = 3;
328 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 330 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(location), kTouchId,
329 location,
330 kTouchId,
331 Now()); 331 Now());
332 Dispatch(&press); 332 Dispatch(&press);
333 333
334 ui::TouchEvent release( 334 ui::TouchEvent release(
335 ui::ET_TOUCH_RELEASED, location, kTouchId, 335 ui::ET_TOUCH_RELEASED, gfx::PointF(location), kTouchId,
336 press.time_stamp() + base::TimeDelta::FromMilliseconds(1000)); 336 press.time_stamp() + base::TimeDelta::FromMilliseconds(1000));
337 Dispatch(&release); 337 Dispatch(&release);
338 } 338 }
339 339
340 base::TimeDelta EventGenerator::CalculateScrollDurationForFlingVelocity( 340 base::TimeDelta EventGenerator::CalculateScrollDurationForFlingVelocity(
341 const gfx::Point& start, 341 const gfx::Point& start,
342 const gfx::Point& end, 342 const gfx::Point& end,
343 float velocity, 343 float velocity,
344 int steps) { 344 int steps) {
345 const float kGestureDistance = (start - end).Length(); 345 const float kGestureDistance = (start - end).Length();
346 const float kFlingStepDelay = (kGestureDistance / velocity) / steps * 1000000; 346 const float kFlingStepDelay = (kGestureDistance / velocity) / steps * 1000000;
347 return base::TimeDelta::FromMicroseconds(kFlingStepDelay); 347 return base::TimeDelta::FromMicroseconds(kFlingStepDelay);
348 } 348 }
349 349
350 void EventGenerator::GestureScrollSequence(const gfx::Point& start, 350 void EventGenerator::GestureScrollSequence(const gfx::Point& start,
351 const gfx::Point& end, 351 const gfx::Point& end,
352 const base::TimeDelta& step_delay, 352 const base::TimeDelta& step_delay,
353 int steps) { 353 int steps) {
354 GestureScrollSequenceWithCallback(start, end, step_delay, steps, 354 GestureScrollSequenceWithCallback(start, end, step_delay, steps,
355 base::Bind(&DummyCallback)); 355 base::Bind(&DummyCallback));
356 } 356 }
357 357
358 void EventGenerator::GestureScrollSequenceWithCallback( 358 void EventGenerator::GestureScrollSequenceWithCallback(
359 const gfx::Point& start, 359 const gfx::Point& start,
360 const gfx::Point& end, 360 const gfx::Point& end,
361 const base::TimeDelta& step_delay, 361 const base::TimeDelta& step_delay,
362 int steps, 362 int steps,
363 const ScrollStepCallback& callback) { 363 const ScrollStepCallback& callback) {
364 const int kTouchId = 5; 364 const int kTouchId = 5;
365 gfx::PointF location(start);
365 base::TimeDelta timestamp = Now(); 366 base::TimeDelta timestamp = Now();
366 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp); 367 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, kTouchId, timestamp);
367 Dispatch(&press); 368 Dispatch(&press);
368 369
369 callback.Run(ui::ET_GESTURE_SCROLL_BEGIN, gfx::Vector2dF()); 370 callback.Run(ui::ET_GESTURE_SCROLL_BEGIN, gfx::Vector2dF());
370 371
371 float dx = static_cast<float>(end.x() - start.x()) / steps; 372 float dx = static_cast<float>(end.x() - start.x()) / steps;
372 float dy = static_cast<float>(end.y() - start.y()) / steps; 373 float dy = static_cast<float>(end.y() - start.y()) / steps;
373 gfx::PointF location = start;
374 for (int i = 0; i < steps; ++i) { 374 for (int i = 0; i < steps; ++i) {
375 location.Offset(dx, dy); 375 location.Offset(dx, dy);
376 timestamp += step_delay; 376 timestamp += step_delay;
377 ui::TouchEvent move(ui::ET_TOUCH_MOVED, location, kTouchId, timestamp); 377 ui::TouchEvent move(ui::ET_TOUCH_MOVED, location, kTouchId, timestamp);
378 Dispatch(&move); 378 Dispatch(&move);
379 callback.Run(ui::ET_GESTURE_SCROLL_UPDATE, gfx::Vector2dF(dx, dy)); 379 callback.Run(ui::ET_GESTURE_SCROLL_UPDATE, gfx::Vector2dF(dx, dy));
380 } 380 }
381 381
382 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp); 382 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(end), kTouchId,
383 timestamp);
383 Dispatch(&release); 384 Dispatch(&release);
384 385
385 callback.Run(ui::ET_GESTURE_SCROLL_END, gfx::Vector2dF()); 386 callback.Run(ui::ET_GESTURE_SCROLL_END, gfx::Vector2dF());
386 } 387 }
387 388
388 void EventGenerator::GestureMultiFingerScroll(int count, 389 void EventGenerator::GestureMultiFingerScroll(int count,
389 const gfx::Point start[], 390 const gfx::Point start[],
390 int event_separation_time_ms, 391 int event_separation_time_ms,
391 int steps, 392 int steps,
392 int move_x, 393 int move_x,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 428 }
428 429
429 int last_id = 0; 430 int last_id = 0;
430 for (int step = 0; step < steps; ++step) { 431 for (int step = 0; step < steps; ++step) {
431 base::TimeDelta move_time = press_time_first + 432 base::TimeDelta move_time = press_time_first +
432 base::TimeDelta::FromMilliseconds(event_separation_time_ms * step); 433 base::TimeDelta::FromMilliseconds(event_separation_time_ms * step);
433 434
434 while (last_id < count && 435 while (last_id < count &&
435 !pressed[last_id] && 436 !pressed[last_id] &&
436 move_time >= press_time[last_id]) { 437 move_time >= press_time[last_id]) {
437 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 438 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::PointF(points[last_id]),
438 points[last_id], 439 last_id, press_time[last_id]);
439 last_id,
440 press_time[last_id]);
441 Dispatch(&press); 440 Dispatch(&press);
442 pressed[last_id] = true; 441 pressed[last_id] = true;
443 last_id++; 442 last_id++;
444 } 443 }
445 444
446 for (int i = 0; i < count; ++i) { 445 for (int i = 0; i < count; ++i) {
447 points[i].Offset(delta_x, delta_y); 446 points[i].Offset(delta_x, delta_y);
448 if (i >= last_id) 447 if (i >= last_id)
449 continue; 448 continue;
450 ui::TouchEvent move(ui::ET_TOUCH_MOVED, points[i], i, move_time); 449 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::PointF(points[i]), i,
450 move_time);
451 Dispatch(&move); 451 Dispatch(&move);
452 } 452 }
453 } 453 }
454 454
455 base::TimeDelta release_time = press_time_first + 455 base::TimeDelta release_time = press_time_first +
456 base::TimeDelta::FromMilliseconds(event_separation_time_ms * steps); 456 base::TimeDelta::FromMilliseconds(event_separation_time_ms * steps);
457 for (int i = 0; i < last_id; ++i) { 457 for (int i = 0; i < last_id; ++i) {
458 ui::TouchEvent release( 458 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::PointF(points[i]), i,
459 ui::ET_TOUCH_RELEASED, points[i], i, release_time); 459 release_time);
460 Dispatch(&release); 460 Dispatch(&release);
461 } 461 }
462 } 462 }
463 463
464 void EventGenerator::ScrollSequence(const gfx::Point& start, 464 void EventGenerator::ScrollSequence(const gfx::Point& start,
465 const base::TimeDelta& step_delay, 465 const base::TimeDelta& step_delay,
466 float x_offset, 466 float x_offset,
467 float y_offset, 467 float y_offset,
468 int steps, 468 int steps,
469 int num_fingers) { 469 int num_fingers) {
470 base::TimeDelta timestamp = Now(); 470 base::TimeDelta timestamp = Now();
471 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, 471 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, gfx::PointF(start),
472 start, 472 timestamp, 0, 0, 0, 0, 0, num_fingers);
473 timestamp,
474 0,
475 0, 0,
476 0, 0,
477 num_fingers);
478 Dispatch(&fling_cancel); 473 Dispatch(&fling_cancel);
479 474
480 float dx = x_offset / steps; 475 float dx = x_offset / steps;
481 float dy = y_offset / steps; 476 float dy = y_offset / steps;
482 for (int i = 0; i < steps; ++i) { 477 for (int i = 0; i < steps; ++i) {
483 timestamp += step_delay; 478 timestamp += step_delay;
484 ui::ScrollEvent move(ui::ET_SCROLL, 479 ui::ScrollEvent move(ui::ET_SCROLL, gfx::PointF(start), timestamp, 0, dx,
485 start, 480 dy, dx, dy, num_fingers);
486 timestamp,
487 0,
488 dx, dy,
489 dx, dy,
490 num_fingers);
491 Dispatch(&move); 481 Dispatch(&move);
492 } 482 }
493 483
494 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, 484 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, gfx::PointF(start),
495 start, 485 timestamp, 0, x_offset, y_offset, x_offset,
496 timestamp, 486 y_offset, num_fingers);
497 0,
498 x_offset, y_offset,
499 x_offset, y_offset,
500 num_fingers);
501 Dispatch(&fling_start); 487 Dispatch(&fling_start);
502 } 488 }
503 489
504 void EventGenerator::ScrollSequence(const gfx::Point& start, 490 void EventGenerator::ScrollSequence(const gfx::Point& start,
505 const base::TimeDelta& step_delay, 491 const base::TimeDelta& step_delay,
506 const std::vector<gfx::PointF>& offsets, 492 const std::vector<gfx::PointF>& offsets,
507 int num_fingers) { 493 int num_fingers) {
508 size_t steps = offsets.size(); 494 size_t steps = offsets.size();
509 base::TimeDelta timestamp = Now(); 495 base::TimeDelta timestamp = Now();
510 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, 496 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, gfx::PointF(start),
511 start, 497 timestamp, 0, 0, 0, 0, 0, num_fingers);
512 timestamp,
513 0,
514 0, 0,
515 0, 0,
516 num_fingers);
517 Dispatch(&fling_cancel); 498 Dispatch(&fling_cancel);
518 499
519 for (size_t i = 0; i < steps; ++i) { 500 for (size_t i = 0; i < steps; ++i) {
520 timestamp += step_delay; 501 timestamp += step_delay;
521 ui::ScrollEvent scroll(ui::ET_SCROLL, 502 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::PointF(start), timestamp, 0,
522 start, 503 offsets[i].x(), offsets[i].y(), offsets[i].x(),
523 timestamp, 504 offsets[i].y(), num_fingers);
524 0,
525 offsets[i].x(), offsets[i].y(),
526 offsets[i].x(), offsets[i].y(),
527 num_fingers);
528 Dispatch(&scroll); 505 Dispatch(&scroll);
529 } 506 }
530 507
531 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, 508 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, gfx::PointF(start),
532 start, 509 timestamp, 0, offsets[steps - 1].x(),
533 timestamp, 510 offsets[steps - 1].y(), offsets[steps - 1].x(),
534 0, 511 offsets[steps - 1].y(), num_fingers);
535 offsets[steps - 1].x(), offsets[steps - 1].y(),
536 offsets[steps - 1].x(), offsets[steps - 1].y(),
537 num_fingers);
538 Dispatch(&fling_start); 512 Dispatch(&fling_start);
539 } 513 }
540 514
541 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) { 515 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) {
542 DispatchKeyEvent(true, key_code, flags); 516 DispatchKeyEvent(true, key_code, flags);
543 } 517 }
544 518
545 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) { 519 void EventGenerator::ReleaseKey(ui::KeyboardCode key_code, int flags) {
546 DispatchKeyEvent(false, key_code, flags); 520 DispatchKeyEvent(false, key_code, flags);
547 } 521 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 579
606 void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) { 580 void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) {
607 current_target_ = delegate()->GetTargetAt(point); 581 current_target_ = delegate()->GetTargetAt(point);
608 } 582 }
609 583
610 void EventGenerator::PressButton(int flag) { 584 void EventGenerator::PressButton(int flag) {
611 if (!(flags_ & flag)) { 585 if (!(flags_ & flag)) {
612 flags_ |= flag; 586 flags_ |= flag;
613 grab_ = (flags_ & kAllButtonMask) != 0; 587 grab_ = (flags_ & kAllButtonMask) != 0;
614 gfx::Point location = GetLocationInCurrentRoot(); 588 gfx::Point location = GetLocationInCurrentRoot();
615 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, location, location, 589 ui::MouseEvent mouseev(ui::ET_MOUSE_PRESSED, gfx::PointF(location),
616 ui::EventTimeForNow(), flags_, flag); 590 gfx::PointF(location), ui::EventTimeForNow(), flags_,
591 flag);
617 Dispatch(&mouseev); 592 Dispatch(&mouseev);
618 } 593 }
619 } 594 }
620 595
621 void EventGenerator::ReleaseButton(int flag) { 596 void EventGenerator::ReleaseButton(int flag) {
622 if (flags_ & flag) { 597 if (flags_ & flag) {
623 gfx::Point location = GetLocationInCurrentRoot(); 598 gfx::Point location = GetLocationInCurrentRoot();
624 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, location, location, 599 ui::MouseEvent mouseev(ui::ET_MOUSE_RELEASED, gfx::PointF(location),
625 ui::EventTimeForNow(), flags_, flag); 600 gfx::PointF(location), ui::EventTimeForNow(), flags_,
601 flag);
626 Dispatch(&mouseev); 602 Dispatch(&mouseev);
627 flags_ ^= flag; 603 flags_ ^= flag;
628 } 604 }
629 grab_ = (flags_ & kAllButtonMask) != 0; 605 grab_ = (flags_ & kAllButtonMask) != 0;
630 } 606 }
631 607
632 gfx::Point EventGenerator::GetLocationInCurrentRoot() const { 608 gfx::Point EventGenerator::GetLocationInCurrentRoot() const {
633 gfx::Point p(current_location_); 609 gfx::Point p(current_location_);
634 delegate()->ConvertPointToTarget(current_target_, &p); 610 delegate()->ConvertPointToTarget(current_target_, &p);
635 return p; 611 return p;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 return default_delegate; 669 return default_delegate;
694 } 670 }
695 671
696 EventGeneratorDelegate* EventGenerator::delegate() { 672 EventGeneratorDelegate* EventGenerator::delegate() {
697 return const_cast<EventGeneratorDelegate*>( 673 return const_cast<EventGeneratorDelegate*>(
698 const_cast<const EventGenerator*>(this)->delegate()); 674 const_cast<const EventGenerator*>(this)->delegate());
699 } 675 }
700 676
701 } // namespace test 677 } // namespace test
702 } // namespace ui 678 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/window_tree_host_x11.cc ('k') | ui/message_center/views/notifier_settings_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698