| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 webGestureEvent.globalX = 20; | 343 webGestureEvent.globalX = 20; |
| 344 webGestureEvent.globalY = 22; | 344 webGestureEvent.globalY = 22; |
| 345 webGestureEvent.data.scrollUpdate.deltaX = 30; | 345 webGestureEvent.data.scrollUpdate.deltaX = 30; |
| 346 webGestureEvent.data.scrollUpdate.deltaY = 32; | 346 webGestureEvent.data.scrollUpdate.deltaY = 32; |
| 347 webGestureEvent.data.scrollUpdate.velocityX = 40; | 347 webGestureEvent.data.scrollUpdate.velocityX = 40; |
| 348 webGestureEvent.data.scrollUpdate.velocityY = 42; | 348 webGestureEvent.data.scrollUpdate.velocityY = 42; |
| 349 webGestureEvent.data.scrollUpdate.inertialPhase = | 349 webGestureEvent.data.scrollUpdate.inertialPhase = |
| 350 WebGestureEvent::MomentumPhase; | 350 WebGestureEvent::MomentumPhase; |
| 351 webGestureEvent.data.scrollUpdate.preventPropagation = true; | 351 webGestureEvent.data.scrollUpdate.preventPropagation = true; |
| 352 | 352 |
| 353 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 353 WebGestureEvent scaledGestureEvent = |
| 354 EXPECT_EQ(5, platformGestureBuilder.position().x()); | 354 ScaleWebGestureEvent(view, webGestureEvent); |
| 355 EXPECT_EQ(6, platformGestureBuilder.position().y()); | 355 IntPoint position = |
| 356 EXPECT_EQ(20, platformGestureBuilder.globalPosition().x()); | 356 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
| 357 EXPECT_EQ(22, platformGestureBuilder.globalPosition().y()); | 357 EXPECT_EQ(5, position.x()); |
| 358 EXPECT_EQ(15, platformGestureBuilder.deltaX()); | 358 EXPECT_EQ(6, position.y()); |
| 359 EXPECT_EQ(16, platformGestureBuilder.deltaY()); | 359 EXPECT_EQ(20, scaledGestureEvent.globalX); |
| 360 EXPECT_EQ(22, scaledGestureEvent.globalY); |
| 361 EXPECT_EQ(15, scaledGestureEvent.deltaXInRootFrame()); |
| 362 EXPECT_EQ(16, scaledGestureEvent.deltaYInRootFrame()); |
| 360 // TODO: The velocity values may need to be scaled to page scale in | 363 // TODO: The velocity values may need to be scaled to page scale in |
| 361 // order to remain consist with delta values. | 364 // order to remain consist with delta values. |
| 362 EXPECT_EQ(40, platformGestureBuilder.velocityX()); | 365 EXPECT_EQ(40, scaledGestureEvent.velocityX()); |
| 363 EXPECT_EQ(42, platformGestureBuilder.velocityY()); | 366 EXPECT_EQ(42, scaledGestureEvent.velocityY()); |
| 364 EXPECT_EQ(ScrollInertialPhaseMomentum, | 367 EXPECT_EQ(WebGestureEvent::MomentumPhase, |
| 365 platformGestureBuilder.inertialPhase()); | 368 scaledGestureEvent.inertialPhase()); |
| 366 EXPECT_TRUE(platformGestureBuilder.preventPropagation()); | 369 EXPECT_TRUE(scaledGestureEvent.preventPropagation()); |
| 367 } | 370 } |
| 368 | 371 |
| 369 { | 372 { |
| 370 WebGestureEvent webGestureEvent; | 373 WebGestureEvent webGestureEvent; |
| 371 webGestureEvent.type = WebInputEvent::GestureScrollEnd; | 374 webGestureEvent.type = WebInputEvent::GestureScrollEnd; |
| 372 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 375 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 373 webGestureEvent.x = 10; | 376 webGestureEvent.x = 10; |
| 374 webGestureEvent.y = 12; | 377 webGestureEvent.y = 12; |
| 375 webGestureEvent.globalX = 20; | 378 webGestureEvent.globalX = 20; |
| 376 webGestureEvent.globalY = 22; | 379 webGestureEvent.globalY = 22; |
| 377 | 380 |
| 378 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 381 WebGestureEvent scaledGestureEvent = |
| 379 EXPECT_EQ(5, platformGestureBuilder.position().x()); | 382 ScaleWebGestureEvent(view, webGestureEvent); |
| 380 EXPECT_EQ(6, platformGestureBuilder.position().y()); | 383 IntPoint position = |
| 381 EXPECT_EQ(20, platformGestureBuilder.globalPosition().x()); | 384 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
| 382 EXPECT_EQ(22, platformGestureBuilder.globalPosition().y()); | 385 EXPECT_EQ(5, position.x()); |
| 383 EXPECT_EQ(ScrollInertialPhaseUnknown, | 386 EXPECT_EQ(6, position.y()); |
| 384 platformGestureBuilder.inertialPhase()); | 387 EXPECT_EQ(20, scaledGestureEvent.globalX); |
| 388 EXPECT_EQ(22, scaledGestureEvent.globalY); |
| 389 EXPECT_EQ(WebGestureEvent::UnknownMomentumPhase, |
| 390 scaledGestureEvent.inertialPhase()); |
| 385 } | 391 } |
| 386 | 392 |
| 387 { | 393 { |
| 388 WebGestureEvent webGestureEvent; | 394 WebGestureEvent webGestureEvent; |
| 389 webGestureEvent.type = WebInputEvent::GestureTap; | 395 webGestureEvent.type = WebInputEvent::GestureTap; |
| 390 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 396 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 391 webGestureEvent.data.tap.width = 10; | 397 webGestureEvent.data.tap.width = 10; |
| 392 webGestureEvent.data.tap.height = 10; | 398 webGestureEvent.data.tap.height = 10; |
| 393 | 399 |
| 394 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 400 WebGestureEvent scaledGestureEvent = |
| 395 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 401 ScaleWebGestureEvent(view, webGestureEvent); |
| 396 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 402 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 403 EXPECT_EQ(5, area.width()); |
| 404 EXPECT_EQ(5, area.height()); |
| 397 } | 405 } |
| 398 | 406 |
| 399 { | 407 { |
| 400 WebGestureEvent webGestureEvent; | 408 WebGestureEvent webGestureEvent; |
| 401 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; | 409 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; |
| 402 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 410 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 403 webGestureEvent.data.tap.width = 10; | 411 webGestureEvent.data.tap.width = 10; |
| 404 webGestureEvent.data.tap.height = 10; | 412 webGestureEvent.data.tap.height = 10; |
| 405 | 413 |
| 406 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 414 WebGestureEvent scaledGestureEvent = |
| 407 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 415 ScaleWebGestureEvent(view, webGestureEvent); |
| 408 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 416 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 417 EXPECT_EQ(5, area.width()); |
| 418 EXPECT_EQ(5, area.height()); |
| 409 } | 419 } |
| 410 | 420 |
| 411 { | 421 { |
| 412 WebGestureEvent webGestureEvent; | 422 WebGestureEvent webGestureEvent; |
| 413 webGestureEvent.type = WebInputEvent::GestureTapDown; | 423 webGestureEvent.type = WebInputEvent::GestureTapDown; |
| 414 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 424 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 415 webGestureEvent.data.tapDown.width = 10; | 425 webGestureEvent.data.tapDown.width = 10; |
| 416 webGestureEvent.data.tapDown.height = 10; | 426 webGestureEvent.data.tapDown.height = 10; |
| 417 | 427 |
| 418 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 428 WebGestureEvent scaledGestureEvent = |
| 419 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 429 ScaleWebGestureEvent(view, webGestureEvent); |
| 420 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 430 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 431 EXPECT_EQ(5, area.width()); |
| 432 EXPECT_EQ(5, area.height()); |
| 421 } | 433 } |
| 422 | 434 |
| 423 { | 435 { |
| 424 WebGestureEvent webGestureEvent; | 436 WebGestureEvent webGestureEvent; |
| 425 webGestureEvent.type = WebInputEvent::GestureShowPress; | 437 webGestureEvent.type = WebInputEvent::GestureShowPress; |
| 426 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 438 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 427 webGestureEvent.data.showPress.width = 10; | 439 webGestureEvent.data.showPress.width = 10; |
| 428 webGestureEvent.data.showPress.height = 10; | 440 webGestureEvent.data.showPress.height = 10; |
| 429 | 441 |
| 430 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 442 WebGestureEvent scaledGestureEvent = |
| 431 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 443 ScaleWebGestureEvent(view, webGestureEvent); |
| 432 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 444 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 445 EXPECT_EQ(5, area.width()); |
| 446 EXPECT_EQ(5, area.height()); |
| 433 } | 447 } |
| 434 | 448 |
| 435 { | 449 { |
| 436 WebGestureEvent webGestureEvent; | 450 WebGestureEvent webGestureEvent; |
| 437 webGestureEvent.type = WebInputEvent::GestureLongPress; | 451 webGestureEvent.type = WebInputEvent::GestureLongPress; |
| 438 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 452 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 439 webGestureEvent.data.longPress.width = 10; | 453 webGestureEvent.data.longPress.width = 10; |
| 440 webGestureEvent.data.longPress.height = 10; | 454 webGestureEvent.data.longPress.height = 10; |
| 441 | 455 |
| 442 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 456 WebGestureEvent scaledGestureEvent = |
| 443 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 457 ScaleWebGestureEvent(view, webGestureEvent); |
| 444 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 458 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 459 EXPECT_EQ(5, area.width()); |
| 460 EXPECT_EQ(5, area.height()); |
| 445 } | 461 } |
| 446 | 462 |
| 447 { | 463 { |
| 448 WebGestureEvent webGestureEvent; | 464 WebGestureEvent webGestureEvent; |
| 449 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; | 465 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; |
| 450 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 466 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 451 webGestureEvent.data.twoFingerTap.firstFingerWidth = 10; | 467 webGestureEvent.data.twoFingerTap.firstFingerWidth = 10; |
| 452 webGestureEvent.data.twoFingerTap.firstFingerHeight = 10; | 468 webGestureEvent.data.twoFingerTap.firstFingerHeight = 10; |
| 453 | 469 |
| 454 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 470 WebGestureEvent scaledGestureEvent = |
| 455 EXPECT_EQ(5, platformGestureBuilder.area().width()); | 471 ScaleWebGestureEvent(view, webGestureEvent); |
| 456 EXPECT_EQ(5, platformGestureBuilder.area().height()); | 472 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 473 EXPECT_EQ(5, area.width()); |
| 474 EXPECT_EQ(5, area.height()); |
| 457 } | 475 } |
| 458 | 476 |
| 459 { | 477 { |
| 460 WebTouchEvent webTouchEvent; | 478 WebTouchEvent webTouchEvent; |
| 461 webTouchEvent.type = WebInputEvent::TouchMove; | 479 webTouchEvent.type = WebInputEvent::TouchMove; |
| 462 webTouchEvent.touchesLength = 1; | 480 webTouchEvent.touchesLength = 1; |
| 463 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 481 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
| 464 webTouchEvent.touches[0].screenPosition.x = 10.6f; | 482 webTouchEvent.touches[0].screenPosition.x = 10.6f; |
| 465 webTouchEvent.touches[0].screenPosition.y = 10.4f; | 483 webTouchEvent.touches[0].screenPosition.y = 10.4f; |
| 466 webTouchEvent.touches[0].position.x = 10.6f; | 484 webTouchEvent.touches[0].position.x = 10.6f; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1, | 531 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 1, |
| 514 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, | 532 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, |
| 515 0); | 533 0); |
| 516 MouseEvent* mouseEvent = MouseEvent::create( | 534 MouseEvent* mouseEvent = MouseEvent::create( |
| 517 EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); | 535 EventTypeNames::mousemove, domWindow, platformMouseEvent, 0, document); |
| 518 WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); | 536 WebMouseEventBuilder webMouseBuilder(view, documentLayoutView, *mouseEvent); |
| 519 EXPECT_EQ(WebMouseEvent::Button::NoButton, webMouseBuilder.button); | 537 EXPECT_EQ(WebMouseEvent::Button::NoButton, webMouseBuilder.button); |
| 520 } | 538 } |
| 521 | 539 |
| 522 { | 540 { |
| 523 PlatformGestureEvent platformGestureEvent( | |
| 524 PlatformEvent::GestureScrollUpdate, IntPoint(10, 12), IntPoint(20, 22), | |
| 525 IntSize(25, 27), 0, PlatformEvent::NoModifiers, | |
| 526 PlatformGestureSourceTouchscreen); | |
| 527 platformGestureEvent.setScrollGestureData(30, 32, ScrollByPrecisePixel, 40, | |
| 528 42, ScrollInertialPhaseMomentum, | |
| 529 true, -1 /* null plugin id */); | |
| 530 // FIXME: GestureEvent does not preserve velocityX, velocityY, | |
| 531 // or preventPropagation. It also fails to scale | |
| 532 // coordinates (x, y, deltaX, deltaY) to the page scale. This | |
| 533 // may lead to unexpected bugs if a PlatformGestureEvent is | |
| 534 // transformed into WebGestureEvent and back. | |
| 535 GestureEvent* gestureEvent = | |
| 536 GestureEvent::create(domWindow, platformGestureEvent); | |
| 537 WebGestureEventBuilder webGestureBuilder(documentLayoutView, *gestureEvent); | |
| 538 | |
| 539 EXPECT_EQ(10, webGestureBuilder.x); | |
| 540 EXPECT_EQ(12, webGestureBuilder.y); | |
| 541 EXPECT_EQ(20, webGestureBuilder.globalX); | |
| 542 EXPECT_EQ(22, webGestureBuilder.globalY); | |
| 543 EXPECT_EQ(30, webGestureBuilder.data.scrollUpdate.deltaX); | |
| 544 EXPECT_EQ(32, webGestureBuilder.data.scrollUpdate.deltaY); | |
| 545 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityX); | |
| 546 EXPECT_EQ(0, webGestureBuilder.data.scrollUpdate.velocityY); | |
| 547 EXPECT_EQ(WebGestureEvent::MomentumPhase, | |
| 548 webGestureBuilder.data.scrollUpdate.inertialPhase); | |
| 549 EXPECT_FALSE(webGestureBuilder.data.scrollUpdate.preventPropagation); | |
| 550 EXPECT_EQ(WebGestureDeviceTouchscreen, webGestureBuilder.sourceDevice); | |
| 551 } | |
| 552 | |
| 553 { | |
| 554 Touch* touch = | 541 Touch* touch = |
| 555 Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), document, | 542 Touch::create(toLocalFrame(webViewImpl->page()->mainFrame()), document, |
| 556 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2), | 543 0, FloatPoint(10, 9.5), FloatPoint(3.5, 2), |
| 557 FloatSize(4, 4.5), 0, 0, String()); | 544 FloatSize(4, 4.5), 0, 0, String()); |
| 558 TouchList* touchList = TouchList::create(); | 545 TouchList* touchList = TouchList::create(); |
| 559 touchList->append(touch); | 546 touchList->append(touch); |
| 560 TouchEvent* touchEvent = TouchEvent::create( | 547 TouchEvent* touchEvent = TouchEvent::create( |
| 561 touchList, touchList, touchList, EventTypeNames::touchmove, domWindow, | 548 touchList, touchList, touchList, EventTypeNames::touchmove, domWindow, |
| 562 PlatformEvent::NoModifiers, false, false, true, 0, TouchActionAuto); | 549 PlatformEvent::NoModifiers, false, false, true, 0, TouchActionAuto); |
| 563 | 550 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 WebGestureEvent webGestureEvent; | 648 WebGestureEvent webGestureEvent; |
| 662 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 649 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
| 663 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 650 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 664 webGestureEvent.x = 100; | 651 webGestureEvent.x = 100; |
| 665 webGestureEvent.y = 110; | 652 webGestureEvent.y = 110; |
| 666 webGestureEvent.globalX = 100; | 653 webGestureEvent.globalX = 100; |
| 667 webGestureEvent.globalY = 110; | 654 webGestureEvent.globalY = 110; |
| 668 webGestureEvent.data.scrollUpdate.deltaX = 60; | 655 webGestureEvent.data.scrollUpdate.deltaX = 60; |
| 669 webGestureEvent.data.scrollUpdate.deltaY = 60; | 656 webGestureEvent.data.scrollUpdate.deltaY = 60; |
| 670 | 657 |
| 671 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 658 WebGestureEvent scaledGestureEvent = |
| 672 EXPECT_EQ(30, platformGestureBuilder.position().x()); | 659 ScaleWebGestureEvent(view, webGestureEvent); |
| 673 EXPECT_EQ(30, platformGestureBuilder.position().y()); | 660 FloatPoint position = scaledGestureEvent.positionInRootFrame(); |
| 674 EXPECT_EQ(100, platformGestureBuilder.globalPosition().x()); | 661 |
| 675 EXPECT_EQ(110, platformGestureBuilder.globalPosition().y()); | 662 EXPECT_FLOAT_EQ(30, position.x()); |
| 676 EXPECT_EQ(20, platformGestureBuilder.deltaX()); | 663 EXPECT_FLOAT_EQ(30, position.y()); |
| 677 EXPECT_EQ(20, platformGestureBuilder.deltaY()); | 664 EXPECT_EQ(100, scaledGestureEvent.globalX); |
| 665 EXPECT_EQ(110, scaledGestureEvent.globalY); |
| 666 EXPECT_EQ(20, scaledGestureEvent.deltaXInRootFrame()); |
| 667 EXPECT_EQ(20, scaledGestureEvent.deltaYInRootFrame()); |
| 678 } | 668 } |
| 679 | 669 |
| 680 { | 670 { |
| 681 WebGestureEvent webGestureEvent; | 671 WebGestureEvent webGestureEvent; |
| 682 webGestureEvent.type = WebInputEvent::GestureTap; | 672 webGestureEvent.type = WebInputEvent::GestureTap; |
| 683 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 673 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 684 webGestureEvent.data.tap.width = 30; | 674 webGestureEvent.data.tap.width = 30; |
| 685 webGestureEvent.data.tap.height = 30; | 675 webGestureEvent.data.tap.height = 30; |
| 686 | 676 |
| 687 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 677 WebGestureEvent scaledGestureEvent = |
| 688 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 678 ScaleWebGestureEvent(view, webGestureEvent); |
| 689 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 679 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 680 EXPECT_EQ(10, area.width()); |
| 681 EXPECT_EQ(10, area.height()); |
| 690 } | 682 } |
| 691 | 683 |
| 692 { | 684 { |
| 693 WebGestureEvent webGestureEvent; | 685 WebGestureEvent webGestureEvent; |
| 694 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; | 686 webGestureEvent.type = WebInputEvent::GestureTapUnconfirmed; |
| 695 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 687 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 696 webGestureEvent.data.tap.width = 30; | 688 webGestureEvent.data.tap.width = 30; |
| 697 webGestureEvent.data.tap.height = 30; | 689 webGestureEvent.data.tap.height = 30; |
| 698 | 690 |
| 699 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 691 WebGestureEvent scaledGestureEvent = |
| 700 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 692 ScaleWebGestureEvent(view, webGestureEvent); |
| 701 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 693 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 694 EXPECT_EQ(10, area.width()); |
| 695 EXPECT_EQ(10, area.height()); |
| 702 } | 696 } |
| 703 | 697 |
| 704 { | 698 { |
| 705 WebGestureEvent webGestureEvent; | 699 WebGestureEvent webGestureEvent; |
| 706 webGestureEvent.type = WebInputEvent::GestureTapDown; | 700 webGestureEvent.type = WebInputEvent::GestureTapDown; |
| 707 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 701 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 708 webGestureEvent.data.tapDown.width = 30; | 702 webGestureEvent.data.tapDown.width = 30; |
| 709 webGestureEvent.data.tapDown.height = 30; | 703 webGestureEvent.data.tapDown.height = 30; |
| 710 | 704 |
| 711 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 705 WebGestureEvent scaledGestureEvent = |
| 712 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 706 ScaleWebGestureEvent(view, webGestureEvent); |
| 713 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 707 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 708 EXPECT_EQ(10, area.width()); |
| 709 EXPECT_EQ(10, area.height()); |
| 714 } | 710 } |
| 715 | 711 |
| 716 { | 712 { |
| 717 WebGestureEvent webGestureEvent; | 713 WebGestureEvent webGestureEvent; |
| 718 webGestureEvent.type = WebInputEvent::GestureShowPress; | 714 webGestureEvent.type = WebInputEvent::GestureShowPress; |
| 719 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 715 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 720 webGestureEvent.data.showPress.width = 30; | 716 webGestureEvent.data.showPress.width = 30; |
| 721 webGestureEvent.data.showPress.height = 30; | 717 webGestureEvent.data.showPress.height = 30; |
| 722 | 718 |
| 723 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 719 WebGestureEvent scaledGestureEvent = |
| 724 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 720 ScaleWebGestureEvent(view, webGestureEvent); |
| 725 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 721 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 722 EXPECT_EQ(10, area.width()); |
| 723 EXPECT_EQ(10, area.height()); |
| 726 } | 724 } |
| 727 | 725 |
| 728 { | 726 { |
| 729 WebGestureEvent webGestureEvent; | 727 WebGestureEvent webGestureEvent; |
| 730 webGestureEvent.type = WebInputEvent::GestureLongPress; | 728 webGestureEvent.type = WebInputEvent::GestureLongPress; |
| 731 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 729 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 732 webGestureEvent.data.longPress.width = 30; | 730 webGestureEvent.data.longPress.width = 30; |
| 733 webGestureEvent.data.longPress.height = 30; | 731 webGestureEvent.data.longPress.height = 30; |
| 734 | 732 |
| 735 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 733 WebGestureEvent scaledGestureEvent = |
| 736 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 734 ScaleWebGestureEvent(view, webGestureEvent); |
| 737 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 735 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 736 EXPECT_EQ(10, area.width()); |
| 737 EXPECT_EQ(10, area.height()); |
| 738 } | 738 } |
| 739 | 739 |
| 740 { | 740 { |
| 741 WebGestureEvent webGestureEvent; | 741 WebGestureEvent webGestureEvent; |
| 742 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; | 742 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; |
| 743 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 743 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 744 webGestureEvent.data.twoFingerTap.firstFingerWidth = 30; | 744 webGestureEvent.data.twoFingerTap.firstFingerWidth = 30; |
| 745 webGestureEvent.data.twoFingerTap.firstFingerHeight = 30; | 745 webGestureEvent.data.twoFingerTap.firstFingerHeight = 30; |
| 746 | 746 |
| 747 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 747 WebGestureEvent scaledGestureEvent = |
| 748 EXPECT_EQ(10, platformGestureBuilder.area().width()); | 748 ScaleWebGestureEvent(view, webGestureEvent); |
| 749 EXPECT_EQ(10, platformGestureBuilder.area().height()); | 749 IntSize area = flooredIntSize(scaledGestureEvent.tapAreaInRootFrame()); |
| 750 EXPECT_EQ(10, area.width()); |
| 751 EXPECT_EQ(10, area.height()); |
| 750 } | 752 } |
| 751 | 753 |
| 752 { | 754 { |
| 753 WebTouchEvent webTouchEvent; | 755 WebTouchEvent webTouchEvent; |
| 754 webTouchEvent.type = WebInputEvent::TouchMove; | 756 webTouchEvent.type = WebInputEvent::TouchMove; |
| 755 webTouchEvent.touchesLength = 1; | 757 webTouchEvent.touchesLength = 1; |
| 756 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 758 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
| 757 webTouchEvent.touches[0].screenPosition.x = 100; | 759 webTouchEvent.touches[0].screenPosition.x = 100; |
| 758 webTouchEvent.touches[0].screenPosition.y = 110; | 760 webTouchEvent.touches[0].screenPosition.y = 110; |
| 759 webTouchEvent.touches[0].position.x = 100; | 761 webTouchEvent.touches[0].position.x = 100; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 WebString::fromUTF8("fixed_layout.html")); | 823 WebString::fromUTF8("fixed_layout.html")); |
| 822 FrameTestHelpers::WebViewHelper webViewHelper; | 824 FrameTestHelpers::WebViewHelper webViewHelper; |
| 823 WebViewImpl* webViewImpl = | 825 WebViewImpl* webViewImpl = |
| 824 webViewHelper.initializeAndLoad(baseURL + fileName, true); | 826 webViewHelper.initializeAndLoad(baseURL + fileName, true); |
| 825 int pageWidth = 640; | 827 int pageWidth = 640; |
| 826 int pageHeight = 480; | 828 int pageHeight = 480; |
| 827 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 829 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 828 webViewImpl->updateAllLifecyclePhases(); | 830 webViewImpl->updateAllLifecyclePhases(); |
| 829 | 831 |
| 830 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 832 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| 831 Document* document = | |
| 832 toLocalFrame(webViewImpl->page()->mainFrame())->document(); | |
| 833 LocalDOMWindow* domWindow = document->domWindow(); | |
| 834 LayoutViewItem documentLayoutView = document->layoutViewItem(); | |
| 835 | |
| 836 { | 833 { |
| 837 WebGestureEvent webGestureEvent; | 834 WebGestureEvent webGestureEvent; |
| 838 webGestureEvent.type = WebInputEvent::GestureTap; | 835 webGestureEvent.type = WebInputEvent::GestureTap; |
| 839 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 836 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 840 webGestureEvent.x = 10; | 837 webGestureEvent.x = 10; |
| 841 webGestureEvent.y = 10; | 838 webGestureEvent.y = 10; |
| 842 webGestureEvent.globalX = 10; | 839 webGestureEvent.globalX = 10; |
| 843 webGestureEvent.globalY = 10; | 840 webGestureEvent.globalY = 10; |
| 844 webGestureEvent.data.tap.tapCount = 1; | 841 webGestureEvent.data.tap.tapCount = 1; |
| 845 webGestureEvent.data.tap.width = 10; | 842 webGestureEvent.data.tap.width = 10; |
| 846 webGestureEvent.data.tap.height = 10; | 843 webGestureEvent.data.tap.height = 10; |
| 847 | 844 |
| 848 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 845 WebGestureEvent scaledGestureEvent = |
| 849 EXPECT_EQ(10.f, platformGestureBuilder.position().x()); | 846 ScaleWebGestureEvent(view, webGestureEvent); |
| 850 EXPECT_EQ(10.f, platformGestureBuilder.position().y()); | 847 IntPoint position = |
| 851 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().x()); | 848 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
| 852 EXPECT_EQ(10.f, platformGestureBuilder.globalPosition().y()); | 849 EXPECT_EQ(10.f, position.x()); |
| 853 EXPECT_EQ(1, platformGestureBuilder.tapCount()); | 850 EXPECT_EQ(10.f, position.y()); |
| 854 | 851 EXPECT_EQ(10.f, scaledGestureEvent.globalX); |
| 855 GestureEvent* coreGestureEvent = | 852 EXPECT_EQ(10.f, scaledGestureEvent.globalY); |
| 856 GestureEvent::create(domWindow, platformGestureBuilder); | 853 EXPECT_EQ(1, scaledGestureEvent.tapCount()); |
| 857 WebGestureEventBuilder recreatedWebGestureEvent(documentLayoutView, | |
| 858 *coreGestureEvent); | |
| 859 EXPECT_EQ(webGestureEvent.type, recreatedWebGestureEvent.type); | |
| 860 EXPECT_EQ(webGestureEvent.x, recreatedWebGestureEvent.x); | |
| 861 EXPECT_EQ(webGestureEvent.y, recreatedWebGestureEvent.y); | |
| 862 EXPECT_EQ(webGestureEvent.globalX, recreatedWebGestureEvent.globalX); | |
| 863 EXPECT_EQ(webGestureEvent.globalY, recreatedWebGestureEvent.globalY); | |
| 864 EXPECT_EQ(webGestureEvent.data.tap.tapCount, | |
| 865 recreatedWebGestureEvent.data.tap.tapCount); | |
| 866 } | 854 } |
| 867 } | 855 } |
| 868 | 856 |
| 869 TEST(WebInputEventConversionTest, VisualViewportOffset) { | 857 TEST(WebInputEventConversionTest, VisualViewportOffset) { |
| 870 const std::string baseURL("http://www.test4.com/"); | 858 const std::string baseURL("http://www.test4.com/"); |
| 871 const std::string fileName("fixed_layout.html"); | 859 const std::string fileName("fixed_layout.html"); |
| 872 | 860 |
| 873 URLTestHelpers::registerMockedURLFromBaseURL( | 861 URLTestHelpers::registerMockedURLFromBaseURL( |
| 874 WebString::fromUTF8(baseURL.c_str()), | 862 WebString::fromUTF8(baseURL.c_str()), |
| 875 WebString::fromUTF8("fixed_layout.html")); | 863 WebString::fromUTF8("fixed_layout.html")); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 | 912 |
| 925 { | 913 { |
| 926 WebGestureEvent webGestureEvent; | 914 WebGestureEvent webGestureEvent; |
| 927 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; | 915 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; |
| 928 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 916 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 929 webGestureEvent.x = 10; | 917 webGestureEvent.x = 10; |
| 930 webGestureEvent.y = 10; | 918 webGestureEvent.y = 10; |
| 931 webGestureEvent.globalX = 10; | 919 webGestureEvent.globalX = 10; |
| 932 webGestureEvent.globalY = 10; | 920 webGestureEvent.globalY = 10; |
| 933 | 921 |
| 934 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | 922 WebGestureEvent scaledGestureEvent = |
| 935 EXPECT_EQ(5 + visualOffset.x(), platformGestureBuilder.position().x()); | 923 ScaleWebGestureEvent(view, webGestureEvent); |
| 936 EXPECT_EQ(5 + visualOffset.y(), platformGestureBuilder.position().y()); | 924 IntPoint position = |
| 937 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | 925 flooredIntPoint(scaledGestureEvent.positionInRootFrame()); |
| 938 EXPECT_EQ(10, platformGestureBuilder.globalPosition().y()); | 926 EXPECT_EQ(5 + visualOffset.x(), position.x()); |
| 927 EXPECT_EQ(5 + visualOffset.y(), position.y()); |
| 928 EXPECT_EQ(10, scaledGestureEvent.globalX); |
| 929 EXPECT_EQ(10, scaledGestureEvent.globalY); |
| 939 } | 930 } |
| 940 | 931 |
| 941 { | 932 { |
| 942 WebTouchEvent webTouchEvent; | 933 WebTouchEvent webTouchEvent; |
| 943 webTouchEvent.type = WebInputEvent::TouchMove; | 934 webTouchEvent.type = WebInputEvent::TouchMove; |
| 944 webTouchEvent.touchesLength = 1; | 935 webTouchEvent.touchesLength = 1; |
| 945 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; | 936 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; |
| 946 webTouchEvent.touches[0].screenPosition.x = 10.6f; | 937 webTouchEvent.touches[0].screenPosition.x = 10.6f; |
| 947 webTouchEvent.touches[0].screenPosition.y = 10.4f; | 938 webTouchEvent.touches[0].screenPosition.y = 10.4f; |
| 948 webTouchEvent.touches[0].position.x = 10.6f; | 939 webTouchEvent.touches[0].position.x = 10.6f; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 EXPECT_EQ(platformWheelBuilder.getRailsMode(), | 1236 EXPECT_EQ(platformWheelBuilder.getRailsMode(), |
| 1246 PlatformEvent::RailsModeVertical); | 1237 PlatformEvent::RailsModeVertical); |
| 1247 #if OS(MACOSX) | 1238 #if OS(MACOSX) |
| 1248 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); | 1239 EXPECT_EQ(PlatformWheelEventPhaseNone, platformWheelBuilder.phase()); |
| 1249 EXPECT_EQ(PlatformWheelEventPhaseNone, | 1240 EXPECT_EQ(PlatformWheelEventPhaseNone, |
| 1250 platformWheelBuilder.momentumPhase()); | 1241 platformWheelBuilder.momentumPhase()); |
| 1251 #endif | 1242 #endif |
| 1252 } | 1243 } |
| 1253 } | 1244 } |
| 1254 | 1245 |
| 1255 TEST(WebInputEventConversionTest, PlatformGestureEventBuilder) { | |
| 1256 const std::string baseURL("http://www.test9.com/"); | |
| 1257 const std::string fileName("fixed_layout.html"); | |
| 1258 | |
| 1259 URLTestHelpers::registerMockedURLFromBaseURL( | |
| 1260 WebString::fromUTF8(baseURL.c_str()), | |
| 1261 WebString::fromUTF8("fixed_layout.html")); | |
| 1262 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 1263 WebViewImpl* webViewImpl = | |
| 1264 webViewHelper.initializeAndLoad(baseURL + fileName, true); | |
| 1265 int pageWidth = 640; | |
| 1266 int pageHeight = 480; | |
| 1267 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | |
| 1268 webViewImpl->updateAllLifecyclePhases(); | |
| 1269 | |
| 1270 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | |
| 1271 | |
| 1272 { | |
| 1273 WebGestureEvent webGestureEvent; | |
| 1274 webGestureEvent.type = WebInputEvent::GestureScrollBegin; | |
| 1275 webGestureEvent.x = 0; | |
| 1276 webGestureEvent.y = 5; | |
| 1277 webGestureEvent.globalX = 10; | |
| 1278 webGestureEvent.globalY = 15; | |
| 1279 webGestureEvent.sourceDevice = WebGestureDeviceTouchpad; | |
| 1280 webGestureEvent.resendingPluginId = 2; | |
| 1281 webGestureEvent.data.scrollBegin.inertialPhase = | |
| 1282 WebGestureEvent::MomentumPhase; | |
| 1283 webGestureEvent.data.scrollBegin.synthetic = true; | |
| 1284 webGestureEvent.data.scrollBegin.deltaXHint = 100; | |
| 1285 webGestureEvent.data.scrollBegin.deltaYHint = 10; | |
| 1286 webGestureEvent.data.scrollBegin.deltaHintUnits = WebGestureEvent::Pixels; | |
| 1287 webGestureEvent.uniqueTouchEventId = 12345U; | |
| 1288 | |
| 1289 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | |
| 1290 EXPECT_EQ(PlatformGestureSourceTouchpad, platformGestureBuilder.source()); | |
| 1291 EXPECT_EQ(2, platformGestureBuilder.resendingPluginId()); | |
| 1292 EXPECT_EQ(0, platformGestureBuilder.position().x()); | |
| 1293 EXPECT_EQ(5, platformGestureBuilder.position().y()); | |
| 1294 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | |
| 1295 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | |
| 1296 EXPECT_EQ(ScrollInertialPhaseMomentum, | |
| 1297 platformGestureBuilder.inertialPhase()); | |
| 1298 EXPECT_TRUE(platformGestureBuilder.synthetic()); | |
| 1299 EXPECT_EQ(100, platformGestureBuilder.deltaX()); | |
| 1300 EXPECT_EQ(10, platformGestureBuilder.deltaY()); | |
| 1301 EXPECT_EQ(ScrollGranularity::ScrollByPixel, | |
| 1302 platformGestureBuilder.deltaUnits()); | |
| 1303 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); | |
| 1304 } | |
| 1305 | |
| 1306 { | |
| 1307 WebGestureEvent webGestureEvent; | |
| 1308 webGestureEvent.type = WebInputEvent::GestureScrollEnd; | |
| 1309 webGestureEvent.x = 0; | |
| 1310 webGestureEvent.y = 5; | |
| 1311 webGestureEvent.globalX = 10; | |
| 1312 webGestureEvent.globalY = 15; | |
| 1313 webGestureEvent.sourceDevice = WebGestureDeviceTouchpad; | |
| 1314 webGestureEvent.resendingPluginId = 2; | |
| 1315 webGestureEvent.data.scrollEnd.inertialPhase = | |
| 1316 WebGestureEvent::NonMomentumPhase; | |
| 1317 webGestureEvent.data.scrollEnd.synthetic = true; | |
| 1318 webGestureEvent.data.scrollEnd.deltaUnits = WebGestureEvent::Page; | |
| 1319 webGestureEvent.uniqueTouchEventId = 12345U; | |
| 1320 | |
| 1321 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); | |
| 1322 EXPECT_EQ(PlatformGestureSourceTouchpad, platformGestureBuilder.source()); | |
| 1323 EXPECT_EQ(2, platformGestureBuilder.resendingPluginId()); | |
| 1324 EXPECT_EQ(0, platformGestureBuilder.position().x()); | |
| 1325 EXPECT_EQ(5, platformGestureBuilder.position().y()); | |
| 1326 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); | |
| 1327 EXPECT_EQ(15, platformGestureBuilder.globalPosition().y()); | |
| 1328 EXPECT_EQ(ScrollInertialPhaseNonMomentum, | |
| 1329 platformGestureBuilder.inertialPhase()); | |
| 1330 EXPECT_TRUE(platformGestureBuilder.synthetic()); | |
| 1331 EXPECT_EQ(ScrollGranularity::ScrollByPage, | |
| 1332 platformGestureBuilder.deltaUnits()); | |
| 1333 EXPECT_EQ(12345U, platformGestureBuilder.uniqueTouchEventId()); | |
| 1334 } | |
| 1335 } | |
| 1336 | |
| 1337 } // namespace blink | 1246 } // namespace blink |
| OLD | NEW |