Chromium Code Reviews| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 webViewImpl->updateAllLifecyclePhases(); | 128 webViewImpl->updateAllLifecyclePhases(); |
| 129 | 129 |
| 130 webViewImpl->setPageScaleFactor(2); | 130 webViewImpl->setPageScaleFactor(2); |
| 131 | 131 |
| 132 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 132 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| 133 | 133 |
| 134 { | 134 { |
| 135 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, | 135 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
| 136 WebInputEvent::NoModifiers, | 136 WebInputEvent::NoModifiers, |
| 137 WebInputEvent::TimeStampForTesting); | 137 WebInputEvent::TimeStampForTesting); |
| 138 webMouseEvent.x = 10; | 138 webMouseEvent.setPositionInWidget(10, 10); |
| 139 webMouseEvent.y = 10; | 139 webMouseEvent.setPositionInScreen(10, 10); |
| 140 webMouseEvent.globalX = 10; | |
| 141 webMouseEvent.globalY = 10; | |
| 142 webMouseEvent.movementX = 10; | 140 webMouseEvent.movementX = 10; |
| 143 webMouseEvent.movementY = 10; | 141 webMouseEvent.movementY = 10; |
| 144 | 142 |
| 145 WebMouseEvent transformedEvent = | 143 WebMouseEvent transformedEvent = |
| 146 TransformWebMouseEvent(view, webMouseEvent); | 144 TransformWebMouseEvent(view, webMouseEvent); |
| 147 IntPoint position = flooredIntPoint(transformedEvent.positionInRootFrame()); | 145 IntPoint position = flooredIntPoint(transformedEvent.positionInRootFrame()); |
| 148 EXPECT_EQ(5, position.x()); | 146 EXPECT_EQ(5, position.x()); |
| 149 EXPECT_EQ(5, position.y()); | 147 EXPECT_EQ(5, position.y()); |
| 150 EXPECT_EQ(10, transformedEvent.globalX); | 148 EXPECT_EQ(10, transformedEvent.positionInScreen().x); |
| 151 EXPECT_EQ(10, transformedEvent.globalY); | 149 EXPECT_EQ(10, transformedEvent.positionInScreen().y); |
| 152 | 150 |
| 153 IntPoint movement = flooredIntPoint(transformedEvent.movementInRootFrame()); | 151 IntPoint movement = flooredIntPoint(transformedEvent.movementInRootFrame()); |
| 154 EXPECT_EQ(5, movement.x()); | 152 EXPECT_EQ(5, movement.x()); |
| 155 EXPECT_EQ(5, movement.y()); | 153 EXPECT_EQ(5, movement.y()); |
| 156 } | 154 } |
| 157 | 155 |
| 158 { | 156 { |
| 159 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, | 157 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, |
| 160 WebInputEvent::NoModifiers, | 158 WebInputEvent::NoModifiers, |
| 161 WebInputEvent::TimeStampForTesting); | 159 WebInputEvent::TimeStampForTesting); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 webViewImpl->setPageScaleFactor(2); | 356 webViewImpl->setPageScaleFactor(2); |
| 359 webViewImpl->mainFrameImpl()->setInputEventsTransformForEmulation( | 357 webViewImpl->mainFrameImpl()->setInputEventsTransformForEmulation( |
| 360 IntSize(10, 20), 1.5); | 358 IntSize(10, 20), 1.5); |
| 361 | 359 |
| 362 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 360 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| 363 | 361 |
| 364 { | 362 { |
| 365 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, | 363 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
| 366 WebInputEvent::NoModifiers, | 364 WebInputEvent::NoModifiers, |
| 367 WebInputEvent::TimeStampForTesting); | 365 WebInputEvent::TimeStampForTesting); |
| 368 webMouseEvent.x = 100; | 366 webMouseEvent.setPositionInWidget(100, 110); |
| 369 webMouseEvent.y = 110; | 367 webMouseEvent.setPositionInScreen(100, 110); |
| 370 webMouseEvent.globalX = 100; | |
| 371 webMouseEvent.globalY = 110; | |
| 372 webMouseEvent.movementX = 60; | 368 webMouseEvent.movementX = 60; |
| 373 webMouseEvent.movementY = 60; | 369 webMouseEvent.movementY = 60; |
| 374 | 370 |
| 375 WebMouseEvent transformedEvent = | 371 WebMouseEvent transformedEvent = |
| 376 TransformWebMouseEvent(view, webMouseEvent); | 372 TransformWebMouseEvent(view, webMouseEvent); |
| 377 FloatPoint position = transformedEvent.positionInRootFrame(); | 373 FloatPoint position = transformedEvent.positionInRootFrame(); |
| 378 | 374 |
| 379 EXPECT_FLOAT_EQ(30, position.x()); | 375 EXPECT_FLOAT_EQ(30, position.x()); |
| 380 EXPECT_FLOAT_EQ(30, position.y()); | 376 EXPECT_FLOAT_EQ(30, position.y()); |
| 381 EXPECT_EQ(100, transformedEvent.globalX); | 377 EXPECT_EQ(100, transformedEvent.positionInScreen().x); |
| 382 EXPECT_EQ(110, transformedEvent.globalY); | 378 EXPECT_EQ(110, transformedEvent.positionInScreen().y); |
| 383 | 379 |
| 384 IntPoint movement = flooredIntPoint(transformedEvent.movementInRootFrame()); | 380 IntPoint movement = flooredIntPoint(transformedEvent.movementInRootFrame()); |
| 385 EXPECT_EQ(20, movement.x()); | 381 EXPECT_EQ(20, movement.x()); |
| 386 EXPECT_EQ(20, movement.y()); | 382 EXPECT_EQ(20, movement.y()); |
| 387 } | 383 } |
| 388 | 384 |
| 389 { | 385 { |
| 390 WebMouseEvent webMouseEvent1(WebInputEvent::MouseMove, | 386 WebMouseEvent webMouseEvent1(WebInputEvent::MouseMove, |
| 391 WebInputEvent::NoModifiers, | 387 WebInputEvent::NoModifiers, |
| 392 WebInputEvent::TimeStampForTesting); | 388 WebInputEvent::TimeStampForTesting); |
| 393 webMouseEvent1.x = 100; | 389 webMouseEvent1.setPositionInWidget(100, 110); |
| 394 webMouseEvent1.y = 110; | 390 webMouseEvent1.setPositionInScreen(100, 110); |
| 395 webMouseEvent1.globalX = 100; | |
| 396 webMouseEvent1.globalY = 110; | |
| 397 webMouseEvent1.movementX = 60; | 391 webMouseEvent1.movementX = 60; |
| 398 webMouseEvent1.movementY = 60; | 392 webMouseEvent1.movementY = 60; |
| 399 | 393 |
| 400 WebMouseEvent webMouseEvent2 = webMouseEvent1; | 394 WebMouseEvent webMouseEvent2 = webMouseEvent1; |
| 401 webMouseEvent2.y = 140; | 395 webMouseEvent2.setPositionInWidget(0, 140); |
|
dtapuska
2017/03/31 14:04:18
This looks wrong. Only the y is getting adjusted..
mustaq
2017/03/31 15:50:32
Done.
| |
| 402 webMouseEvent2.globalY = 140; | 396 webMouseEvent2.setPositionInScreen(0, 140); |
| 403 webMouseEvent2.movementY = 30; | 397 webMouseEvent2.movementY = 30; |
| 404 | 398 |
| 405 std::vector<const WebInputEvent*> events; | 399 std::vector<const WebInputEvent*> events; |
| 406 events.push_back(&webMouseEvent1); | 400 events.push_back(&webMouseEvent1); |
| 407 events.push_back(&webMouseEvent2); | 401 events.push_back(&webMouseEvent2); |
| 408 | 402 |
| 409 Vector<WebMouseEvent> coalescedevents = | 403 Vector<WebMouseEvent> coalescedevents = |
| 410 TransformWebMouseEventVector(view, events); | 404 TransformWebMouseEventVector(view, events); |
| 411 EXPECT_EQ(events.size(), coalescedevents.size()); | 405 EXPECT_EQ(events.size(), coalescedevents.size()); |
| 412 | 406 |
| 413 FloatPoint position = coalescedevents[0].positionInRootFrame(); | 407 FloatPoint position = coalescedevents[0].positionInRootFrame(); |
| 414 EXPECT_FLOAT_EQ(30, position.x()); | 408 EXPECT_FLOAT_EQ(30, position.x()); |
| 415 EXPECT_FLOAT_EQ(30, position.y()); | 409 EXPECT_FLOAT_EQ(30, position.y()); |
| 416 EXPECT_EQ(100, coalescedevents[0].globalX); | 410 EXPECT_EQ(100, coalescedevents[0].positionInScreen().x); |
| 417 EXPECT_EQ(110, coalescedevents[0].globalY); | 411 EXPECT_EQ(110, coalescedevents[0].positionInScreen().y); |
| 418 | 412 |
| 419 IntPoint movement = | 413 IntPoint movement = |
| 420 flooredIntPoint(coalescedevents[0].movementInRootFrame()); | 414 flooredIntPoint(coalescedevents[0].movementInRootFrame()); |
| 421 EXPECT_EQ(20, movement.x()); | 415 EXPECT_EQ(20, movement.x()); |
| 422 EXPECT_EQ(20, movement.y()); | 416 EXPECT_EQ(20, movement.y()); |
| 423 | 417 |
| 424 position = coalescedevents[1].positionInRootFrame(); | 418 position = coalescedevents[1].positionInRootFrame(); |
| 425 EXPECT_FLOAT_EQ(30, position.x()); | 419 EXPECT_FLOAT_EQ(30, position.x()); |
| 426 EXPECT_FLOAT_EQ(40, position.y()); | 420 EXPECT_FLOAT_EQ(40, position.y()); |
| 427 EXPECT_EQ(100, coalescedevents[1].globalX); | 421 EXPECT_EQ(100, coalescedevents[1].positionInScreen().x); |
| 428 EXPECT_EQ(140, coalescedevents[1].globalY); | 422 EXPECT_EQ(140, coalescedevents[1].positionInScreen().y); |
| 429 | 423 |
| 430 movement = flooredIntPoint(coalescedevents[1].movementInRootFrame()); | 424 movement = flooredIntPoint(coalescedevents[1].movementInRootFrame()); |
| 431 EXPECT_EQ(20, movement.x()); | 425 EXPECT_EQ(20, movement.x()); |
| 432 EXPECT_EQ(10, movement.y()); | 426 EXPECT_EQ(10, movement.y()); |
| 433 } | 427 } |
| 434 | 428 |
| 435 { | 429 { |
| 436 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, | 430 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, |
| 437 WebInputEvent::NoModifiers, | 431 WebInputEvent::NoModifiers, |
| 438 WebInputEvent::TimeStampForTesting); | 432 WebInputEvent::TimeStampForTesting); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 | 666 |
| 673 IntPoint visualOffset(35, 60); | 667 IntPoint visualOffset(35, 60); |
| 674 webViewImpl->page()->visualViewport().setLocation(visualOffset); | 668 webViewImpl->page()->visualViewport().setLocation(visualOffset); |
| 675 | 669 |
| 676 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 670 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| 677 | 671 |
| 678 { | 672 { |
| 679 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, | 673 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
| 680 WebInputEvent::NoModifiers, | 674 WebInputEvent::NoModifiers, |
| 681 WebInputEvent::TimeStampForTesting); | 675 WebInputEvent::TimeStampForTesting); |
| 682 webMouseEvent.x = 10; | 676 webMouseEvent.setPositionInWidget(10, 10); |
| 683 webMouseEvent.y = 10; | 677 webMouseEvent.setPositionInScreen(10, 10); |
| 684 webMouseEvent.globalX = 10; | |
| 685 webMouseEvent.globalY = 10; | |
| 686 | 678 |
| 687 WebMouseEvent transformedMouseEvent = | 679 WebMouseEvent transformedMouseEvent = |
| 688 TransformWebMouseEvent(view, webMouseEvent); | 680 TransformWebMouseEvent(view, webMouseEvent); |
| 689 IntPoint position = | 681 IntPoint position = |
| 690 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); | 682 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); |
| 691 EXPECT_EQ(5 + visualOffset.x(), position.x()); | 683 EXPECT_EQ(5 + visualOffset.x(), position.x()); |
| 692 EXPECT_EQ(5 + visualOffset.y(), position.y()); | 684 EXPECT_EQ(5 + visualOffset.y(), position.y()); |
| 693 EXPECT_EQ(10, transformedMouseEvent.globalX); | 685 EXPECT_EQ(10, transformedMouseEvent.positionInScreen().x); |
| 694 EXPECT_EQ(10, transformedMouseEvent.globalY); | 686 EXPECT_EQ(10, transformedMouseEvent.positionInScreen().y); |
| 695 } | 687 } |
| 696 | 688 |
| 697 { | 689 { |
| 698 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel, | 690 WebMouseWheelEvent webMouseWheelEvent(WebInputEvent::MouseWheel, |
| 699 WebInputEvent::NoModifiers, | 691 WebInputEvent::NoModifiers, |
| 700 WebInputEvent::TimeStampForTesting); | 692 WebInputEvent::TimeStampForTesting); |
| 701 webMouseWheelEvent.x = 10; | 693 webMouseWheelEvent.setPositionInWidget(10, 10); |
| 702 webMouseWheelEvent.y = 10; | 694 webMouseWheelEvent.setPositionInScreen(10, 10); |
| 703 webMouseWheelEvent.globalX = 10; | |
| 704 webMouseWheelEvent.globalY = 10; | |
| 705 | 695 |
| 706 WebMouseWheelEvent scaledMouseWheelEvent = | 696 WebMouseWheelEvent scaledMouseWheelEvent = |
| 707 TransformWebMouseWheelEvent(view, webMouseWheelEvent); | 697 TransformWebMouseWheelEvent(view, webMouseWheelEvent); |
| 708 IntPoint position = | 698 IntPoint position = |
| 709 flooredIntPoint(scaledMouseWheelEvent.positionInRootFrame()); | 699 flooredIntPoint(scaledMouseWheelEvent.positionInRootFrame()); |
| 710 EXPECT_EQ(5 + visualOffset.x(), position.x()); | 700 EXPECT_EQ(5 + visualOffset.x(), position.x()); |
| 711 EXPECT_EQ(5 + visualOffset.y(), position.y()); | 701 EXPECT_EQ(5 + visualOffset.y(), position.y()); |
| 712 EXPECT_EQ(10, scaledMouseWheelEvent.globalX); | 702 EXPECT_EQ(10, scaledMouseWheelEvent.positionInScreen().x); |
| 713 EXPECT_EQ(10, scaledMouseWheelEvent.globalY); | 703 EXPECT_EQ(10, scaledMouseWheelEvent.positionInScreen().y); |
| 714 } | 704 } |
| 715 | 705 |
| 716 { | 706 { |
| 717 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, | 707 WebGestureEvent webGestureEvent(WebInputEvent::GestureScrollUpdate, |
| 718 WebInputEvent::NoModifiers, | 708 WebInputEvent::NoModifiers, |
| 719 WebInputEvent::TimeStampForTesting); | 709 WebInputEvent::TimeStampForTesting); |
| 720 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; | 710 webGestureEvent.sourceDevice = WebGestureDeviceTouchscreen; |
| 721 webGestureEvent.x = 10; | 711 webGestureEvent.x = 10; |
| 722 webGestureEvent.y = 10; | 712 webGestureEvent.y = 10; |
| 723 webGestureEvent.globalX = 10; | 713 webGestureEvent.globalX = 10; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 | 767 |
| 778 FloatSize elasticOverscroll(10, -20); | 768 FloatSize elasticOverscroll(10, -20); |
| 779 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 769 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 780 elasticOverscroll, 1.0f, 0.0f); | 770 elasticOverscroll, 1.0f, 0.0f); |
| 781 | 771 |
| 782 // Just elastic overscroll. | 772 // Just elastic overscroll. |
| 783 { | 773 { |
| 784 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, | 774 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
| 785 WebInputEvent::NoModifiers, | 775 WebInputEvent::NoModifiers, |
| 786 WebInputEvent::TimeStampForTesting); | 776 WebInputEvent::TimeStampForTesting); |
| 787 webMouseEvent.x = 10; | 777 webMouseEvent.setPositionInWidget(10, 50); |
| 788 webMouseEvent.y = 50; | 778 webMouseEvent.setPositionInScreen(10, 50); |
| 789 webMouseEvent.globalX = 10; | |
| 790 webMouseEvent.globalY = 50; | |
| 791 | 779 |
| 792 WebMouseEvent transformedMouseEvent = | 780 WebMouseEvent transformedMouseEvent = |
| 793 TransformWebMouseEvent(view, webMouseEvent); | 781 TransformWebMouseEvent(view, webMouseEvent); |
| 794 IntPoint position = | 782 IntPoint position = |
| 795 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); | 783 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); |
| 796 | 784 |
| 797 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), position.x()); | 785 EXPECT_EQ(webMouseEvent.positionInWidget().x + elasticOverscroll.width(), |
| 798 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), position.y()); | 786 position.x()); |
| 799 EXPECT_EQ(webMouseEvent.globalX, transformedMouseEvent.globalX); | 787 EXPECT_EQ(webMouseEvent.positionInWidget().y + elasticOverscroll.height(), |
| 800 EXPECT_EQ(webMouseEvent.globalY, transformedMouseEvent.globalY); | 788 position.y()); |
| 789 EXPECT_EQ(webMouseEvent.positionInScreen().x, | |
| 790 transformedMouseEvent.positionInScreen().x); | |
| 791 EXPECT_EQ(webMouseEvent.positionInScreen().y, | |
| 792 transformedMouseEvent.positionInScreen().y); | |
| 801 } | 793 } |
| 802 | 794 |
| 803 // Elastic overscroll and pinch-zoom (this doesn't actually ever happen, | 795 // Elastic overscroll and pinch-zoom (this doesn't actually ever happen, |
| 804 // but ensure that if it were to, the overscroll would be applied after the | 796 // but ensure that if it were to, the overscroll would be applied after the |
| 805 // pinch-zoom). | 797 // pinch-zoom). |
| 806 float pageScale = 2; | 798 float pageScale = 2; |
| 807 webViewImpl->setPageScaleFactor(pageScale); | 799 webViewImpl->setPageScaleFactor(pageScale); |
| 808 IntPoint visualOffset(35, 60); | 800 IntPoint visualOffset(35, 60); |
| 809 webViewImpl->page()->visualViewport().setLocation(visualOffset); | 801 webViewImpl->page()->visualViewport().setLocation(visualOffset); |
| 810 { | 802 { |
| 811 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, | 803 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
| 812 WebInputEvent::NoModifiers, | 804 WebInputEvent::NoModifiers, |
| 813 WebInputEvent::TimeStampForTesting); | 805 WebInputEvent::TimeStampForTesting); |
| 814 webMouseEvent.x = 10; | 806 webMouseEvent.setPositionInWidget(10, 10); |
| 815 webMouseEvent.y = 10; | 807 webMouseEvent.setPositionInScreen(10, 10); |
| 816 webMouseEvent.globalX = 10; | |
| 817 webMouseEvent.globalY = 10; | |
| 818 | 808 |
| 819 WebMouseEvent transformedMouseEvent = | 809 WebMouseEvent transformedMouseEvent = |
| 820 TransformWebMouseEvent(view, webMouseEvent); | 810 TransformWebMouseEvent(view, webMouseEvent); |
| 821 IntPoint position = | 811 IntPoint position = |
| 822 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); | 812 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); |
| 823 | 813 |
| 824 EXPECT_EQ(webMouseEvent.x / pageScale + visualOffset.x() + | 814 EXPECT_EQ(webMouseEvent.positionInWidget().x / pageScale + |
| 825 elasticOverscroll.width(), | 815 visualOffset.x() + elasticOverscroll.width(), |
| 826 position.x()); | 816 position.x()); |
| 827 EXPECT_EQ(webMouseEvent.y / pageScale + visualOffset.y() + | 817 EXPECT_EQ(webMouseEvent.positionInWidget().y / pageScale + |
| 828 elasticOverscroll.height(), | 818 visualOffset.y() + elasticOverscroll.height(), |
| 829 position.y()); | 819 position.y()); |
| 830 EXPECT_EQ(webMouseEvent.globalX, transformedMouseEvent.globalX); | 820 EXPECT_EQ(webMouseEvent.positionInScreen().x, |
| 831 EXPECT_EQ(webMouseEvent.globalY, transformedMouseEvent.globalY); | 821 transformedMouseEvent.positionInScreen().x); |
| 822 EXPECT_EQ(webMouseEvent.positionInScreen().y, | |
| 823 transformedMouseEvent.positionInScreen().y); | |
| 832 } | 824 } |
| 833 } | 825 } |
| 834 | 826 |
| 835 // Page reload/navigation should not reset elastic overscroll. | 827 // Page reload/navigation should not reset elastic overscroll. |
| 836 TEST(WebInputEventConversionTest, ElasticOverscrollWithPageReload) { | 828 TEST(WebInputEventConversionTest, ElasticOverscrollWithPageReload) { |
| 837 const std::string baseURL("http://www.test6.com/"); | 829 const std::string baseURL("http://www.test6.com/"); |
| 838 const std::string fileName("fixed_layout.html"); | 830 const std::string fileName("fixed_layout.html"); |
| 839 | 831 |
| 840 registerMockedURL(baseURL, fileName); | 832 registerMockedURL(baseURL, fileName); |
| 841 FrameTestHelpers::WebViewHelper webViewHelper; | 833 FrameTestHelpers::WebViewHelper webViewHelper; |
| 842 WebViewImpl* webViewImpl = | 834 WebViewImpl* webViewImpl = |
| 843 webViewHelper.initializeAndLoad(baseURL + fileName, true); | 835 webViewHelper.initializeAndLoad(baseURL + fileName, true); |
| 844 int pageWidth = 640; | 836 int pageWidth = 640; |
| 845 int pageHeight = 480; | 837 int pageHeight = 480; |
| 846 webViewImpl->resize(WebSize(pageWidth, pageHeight)); | 838 webViewImpl->resize(WebSize(pageWidth, pageHeight)); |
| 847 webViewImpl->updateAllLifecyclePhases(); | 839 webViewImpl->updateAllLifecyclePhases(); |
| 848 | 840 |
| 849 FloatSize elasticOverscroll(10, -20); | 841 FloatSize elasticOverscroll(10, -20); |
| 850 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 842 webViewImpl->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 851 elasticOverscroll, 1.0f, 0.0f); | 843 elasticOverscroll, 1.0f, 0.0f); |
| 852 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); | 844 FrameTestHelpers::reloadFrame(webViewHelper.webView()->mainFrame()); |
| 853 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); | 845 FrameView* view = toLocalFrame(webViewImpl->page()->mainFrame())->view(); |
| 854 | 846 |
| 855 // Just elastic overscroll. | 847 // Just elastic overscroll. |
| 856 { | 848 { |
| 857 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, | 849 WebMouseEvent webMouseEvent(WebInputEvent::MouseMove, |
| 858 WebInputEvent::NoModifiers, | 850 WebInputEvent::NoModifiers, |
| 859 WebInputEvent::TimeStampForTesting); | 851 WebInputEvent::TimeStampForTesting); |
| 860 webMouseEvent.x = 10; | 852 webMouseEvent.setPositionInWidget(10, 50); |
| 861 webMouseEvent.y = 50; | 853 webMouseEvent.setPositionInScreen(10, 50); |
| 862 webMouseEvent.globalX = 10; | |
| 863 webMouseEvent.globalY = 50; | |
| 864 | 854 |
| 865 WebMouseEvent transformedMouseEvent = | 855 WebMouseEvent transformedMouseEvent = |
| 866 TransformWebMouseEvent(view, webMouseEvent); | 856 TransformWebMouseEvent(view, webMouseEvent); |
| 867 IntPoint position = | 857 IntPoint position = |
| 868 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); | 858 flooredIntPoint(transformedMouseEvent.positionInRootFrame()); |
| 869 | 859 |
| 870 EXPECT_EQ(webMouseEvent.x + elasticOverscroll.width(), position.x()); | 860 EXPECT_EQ(webMouseEvent.positionInWidget().x + elasticOverscroll.width(), |
| 871 EXPECT_EQ(webMouseEvent.y + elasticOverscroll.height(), position.y()); | 861 position.x()); |
| 872 EXPECT_EQ(webMouseEvent.globalX, transformedMouseEvent.globalX); | 862 EXPECT_EQ(webMouseEvent.positionInWidget().y + elasticOverscroll.height(), |
| 873 EXPECT_EQ(webMouseEvent.globalY, transformedMouseEvent.globalY); | 863 position.y()); |
| 864 EXPECT_EQ(webMouseEvent.positionInScreen().x, | |
| 865 transformedMouseEvent.positionInScreen().x); | |
| 866 EXPECT_EQ(webMouseEvent.positionInScreen().y, | |
| 867 transformedMouseEvent.positionInScreen().y); | |
| 874 } | 868 } |
| 875 } | 869 } |
| 876 | 870 |
| 877 } // namespace blink | 871 } // namespace blink |
| OLD | NEW |